Skip to content
1 change: 1 addition & 0 deletions doc/source/cli/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ documentation of these services:
obs
rds_v3
volume_backup
vpc
27 changes: 27 additions & 0 deletions doc/source/cli/vpc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Virtual Private Cloud (VPC)
===========================

The VPC client is the command-line interface (CLI) for
the Virtual Private Cloud (VPC) API and its extensions.

For help on a specific `vpc` command, enter:

.. code-block:: console

$ openstack vpc help SUBCOMMAND

.. _peering:

Vpc Peering Operations
----------------------

.. autoprogram-cliff:: openstack.vpc.v2
:command: vpc peering *

.. _route:

Vpc Route Operations
--------------------

.. autoprogram-cliff:: openstack.vpc.v2
:command: vpc route *
8 changes: 7 additions & 1 deletion doc/source/coverage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ under several service tags. This may change in future.
- X
-
* - vbs
- Volume Backup
- Volume Backup Service
- X
- X
- X
-
* - vpc_v2
- Virtual Private Cloud
- X
- X
- X
Expand Down
1 change: 1 addition & 0 deletions doc/source/sdk/guides/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Open Telekom Cloud related User Guides
kms
nat
rds
vpc
logging

.. _user_guides:
Expand Down
131 changes: 131 additions & 0 deletions doc/source/sdk/guides/vpc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
Virtual Private Cloud (VPC)
===========================

.. contents:: Table of Contents
:local:

VPC Peering Connection
----------------------

A VPC peering connection is a network connection between two VPCs that
enables you to route traffic between them using private IP addresses.
ECSs in either VPC can communicate with each other just as if they were in
the same VPC. You can create a VPC peering connection between your own VPCs,
or between your VPC and another account's VPC within the same region. A VPC
peering connection between VPCs in different regions will not take effect.

List VPC Peerings
^^^^^^^^^^^^^^^^^

This interface is used to query all VPC peering connections accessible to the
tenant submitting the request. The connections are filtered based on the
filtering condition.
:class:`~otcextensions.sdk.vpc.v2.peering.Peering`.

.. literalinclude:: ../examples/vpc/list_peerings.py
:lines: 16-23

Create VPC Peering
^^^^^^^^^^^^^^^^^^

This interface is used to create a VPC peering connection with
parameters.
:class:`~otcextensions.sdk.vpc.v2.peering.Peering`.

.. literalinclude:: ../examples/vpc/create_peering.py
:lines: 16-33

Get VPC Peering
^^^^^^^^^^^^^^^

This interface is used to get a VPC peering connection by ID
or an instance of class.
:class:`~otcextensions.sdk.vpc.v2.peering.Peering`.

.. literalinclude:: ../examples/vpc/get_peering.py
:lines: 16-26

Find VPC Peering
^^^^^^^^^^^^^^^^

This interface is used to find a VPC peering connection by id or name.
:class:`~otcextensions.sdk.vpc.v2.peering.Peering`.

.. literalinclude:: ../examples/vpc/find_peering.py
:lines: 16-26

Update VPC Peering
^^^^^^^^^^^^^^^^^^

This interface is used to update parameters of a VPC peering connection by
id or an instance of class.
:class:`~otcextensions.sdk.vpc.v2.peering.Peering`.

.. literalinclude:: ../examples/vpc/update_peering.py
:lines: 16-24

Delete VPC Peering
^^^^^^^^^^^^^^^^^^

This interface is used to delete a VPC peering connection by ID
or an instance of class.
:class:`~otcextensions.sdk.vpc.v2.peering.Peering`.

.. literalinclude:: ../examples/vpc/delete_peering.py
:lines: 16-23

Set VPC Peering
^^^^^^^^^^^^^^^

This interface is used to accept of reject a VPC peering connection
request by ID or an instance of class.
:class:`~otcextensions.sdk.vpc.v2.peering.Peering`.

.. literalinclude:: ../examples/vpc/set_peering.py
:lines: 16-32


VPC Route
---------

To enable communication between the two VPCs, you need to add local and
peer routes for the VPC peering connection.

List VPC Routes
^^^^^^^^^^^^^^^

This interface is used to query all routes of the tenant submitting the
request. The routes are filtered based on the filtering condition.
:class:`~otcextensions.sdk.vpc.v2.route.Route`.

.. literalinclude:: ../examples/vpc/list_routes.py
:lines: 16-23

Add VPC Route
^^^^^^^^^^^^^

This Interface is used to add a VPC route.
:class:`~otcextensions.sdk.vpc.v2.route.Route`.

.. literalinclude:: ../examples/vpc/add_route.py
:lines: 16-31

Get VPC Route
^^^^^^^^^^^^^

This interface is used to get a VPC route by ID
or an instance of class.
:class:`~otcextensions.sdk.vpc.v2.route.Route`.

.. literalinclude:: ../examples/vpc/get_route.py
:lines: 16-26

Delete VPC Route
^^^^^^^^^^^^^^^^

This interface is used to delete a VPC route by ID
or an instance of class.
:class:`~otcextensions.sdk.vpc.v2.peering.Peering`.

.. literalinclude:: ../examples/vpc/delete_route.py
:lines: 16-23
1 change: 1 addition & 0 deletions doc/source/sdk/proxies/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Service Proxies
Relational Database Service RDS V1 (RDSv1) <rds_v1>
Relational Database Service RDS V3 (RDS) <rds_v3>
Volume Backup Service (VBS) <volume_backup>
Virtual Private Cloud (VPC) <vpc>

.. _service-proxies:

Expand Down
27 changes: 27 additions & 0 deletions doc/source/sdk/proxies/vpc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
VPC API
=======

.. automodule:: otcextensions.sdk.vpc.v2._proxy

The Virtual Private Cloud Class
-------------------------------

The nat high-level interface is available through the ``vpc``
member of a :class:`~openstack.connection.Connection` object. The
``vpc`` member will only be added if the
``otcextensions.sdk.register_otc_extensions(conn)`` method is called.

VPC Peering Operations
^^^^^^^^^^^^^^^^^^^^^^

.. autoclass:: otcextensions.sdk.vpc.v2._proxy.Proxy
:noindex:
:members: peerings, find_peering, create_peering,
update_peering, delete_peering, set_peering

VPC Route Operations
^^^^^^^^^^^^^^^^^^^^

.. autoclass:: otcextensions.sdk.vpc.v2._proxy.Proxy
:noindex:
:members: routes, get_route, add_route, delete_route
1 change: 1 addition & 0 deletions doc/source/sdk/resources/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Open Telekom Cloud Resources
Network Address Translation (NAT) <nat/index>
Object Block Storage (OBS) <obs/index>
Relational Database Service (RDS) <rds/index>
Virtual Private Cloud (VPC) <vpc/index>

Every resource which is used within the proxy methods have own attributes.
Those attributes define the behavior of the resource which can be a cluster
Expand Down
8 changes: 8 additions & 0 deletions doc/source/sdk/resources/vpc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
VPC Resources
=============

.. toctree::
:maxdepth: 1

v2/peering
v2/route
13 changes: 13 additions & 0 deletions doc/source/sdk/resources/vpc/v2/peering.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
otcextensions.sdk.vpc.v2.peering
================================

.. automodule:: otcextensions.sdk.vpc.v2.peering

The VPC Peering Class
----------------------

The ``Peering`` class inherits from
:class:`~otcextensions.sdk.sdk_resource.Resource`.

.. autoclass:: otcextensions.sdk.vpc.v2.peering.Peering
:members:
13 changes: 13 additions & 0 deletions doc/source/sdk/resources/vpc/v2/route.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
otcextensions.sdk.vpc.v2.route
================================

.. automodule:: otcextensions.sdk.vpc.v2.route

The VPC Route Class
-------------------

The ``Route`` class inherits from
:class:`~otcextensions.sdk.sdk_resource.Resource`.

.. autoclass:: otcextensions.sdk.vpc.v2.route.Route
:members:
31 changes: 31 additions & 0 deletions examples/vpc/add_route.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Add Route to VPC Peering Connection
"""
import openstack
from otcextensions import sdk

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
sdk.register_otc_extensions(conn)

attrs = {
"type": "peering",
"nexthop": "peering-uuid",
"destination": "192.168.100.0/24",
"vpc_id": "local-router-uuid"
}

route = conn.vpc.add_route(**attrs)
print(route)
34 changes: 34 additions & 0 deletions examples/vpc/create_peering.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Create VPC Peering Connection
"""
import openstack
from otcextensions import sdk

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
sdk.register_otc_extensions(conn)

attrs = {
"name": "test-peering",
"request_vpc_info": {
"vpc_id": "requester-router-uuid"
},
"accept_vpc_info": {
"vpc_id": "accepter-router-uuid"
}
}

peering = conn.vpc.create_peering(**attrs)
print(peering)
23 changes: 23 additions & 0 deletions examples/vpc/delete_peering.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Delete VPC Peering by id or name
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


peering = "peering_id"
conn.vpc.delete_peering(peering)
23 changes: 23 additions & 0 deletions examples/vpc/delete_route.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Delete VPC Route By ID
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


route_id = "route-uuid"
conn.vpc.delete_route(route_id)
Loading