Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions doc/source/sdk/guides/privatenat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,29 @@ This interface is used to update a Private NAT gateway

.. literalinclude:: ../examples/natv3/update_private_gateway.py
:lines: 16-27

DNAT
----

The DNAT function enables servers that share the same EIPs in
a VPC to provide services accessible from the Internet through
the IP address mapping and port mapping.

List Private DNAT Rules
^^^^^^^^^^^^^^^^^^^^^^^

This interface is used to query a DNAT rule list and to filter
the output with query parameters.
:class:`~otcextensions.sdk.natv3.v3.dnat.PrivateDnat`.

.. literalinclude:: ../examples/natv3/list_private_dnat_rules.py
:lines: 16-23

Create Private DNAT Rules
^^^^^^^^^^^^^^^^^^^^^^^^^

This interface is used to create a DNAT rule.
:class:`~otcextensions.sdk.natv3.v3.dnat.PrivateDnat`.

.. literalinclude:: ../examples/natv3/create_private_dnat_rules.py
:lines: 16-32
1 change: 1 addition & 0 deletions doc/source/sdk/resources/privatenat/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Private NAT Resources
:maxdepth: 1

v3/private_gateway
v3/private_dnat
13 changes: 13 additions & 0 deletions doc/source/sdk/resources/privatenat/v3/private_dnat.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
otcextensions.sdk.natv3.v3.dnat
===============================

.. automodule:: otcextensions.sdk.natv3.v3.dnat

The Private DNAT Rule Class
---------------------------

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

.. autoclass:: otcextensions.sdk.natv3.v3.dnat.PrivateDnat
:members:
32 changes: 32 additions & 0 deletions examples/natv3/create_private_dnat_rules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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 a Private DNAT Rule
"""

import openstack

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

dnat_rule_attrs = {
"gateway_id": "0adefb29-a6c2-48a5-8637-2be67fa03fec",
"transit_ip_id": "3faa719d-6d18-4ccb-a5c7-33e65a09663e",
"network_interface_id": "dae9393a-b536-491c-a5a2-72edc1104707",
"protocol": "tcp",
"internal_service_port": 22,
"transit_service_port": 22,
}

dnat_rule = conn.natv3.create_private_dnat_rule(**dnat_rule_attrs)
print(dnat_rule)
23 changes: 23 additions & 0 deletions examples/natv3/list_private_dnat_rules.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.
"""
List all Private DNAT Rules
"""

import openstack

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

for dnat_rule in conn.natv3.private_dnat_rules():
print(dnat_rule)
Loading
Loading