diff --git a/README-save b/README-save deleted file mode 100644 index 6ba91b7f5..000000000 --- a/README-save +++ /dev/null @@ -1,137 +0,0 @@ -OTC Extensions -============== - -.. image:: https://travis-ci.org/OpenTelekomCloud/python-otcextensions.svg?branch=master - :target: https://travis-ci.org/OpenTelekomCloud/python-otcextensions - -.. image:: https://readthedocs.org/projects/python-otcextensions/badge/?version=latest - :target: http://python-otcextensions.readthedocs.io/en/latest/?badge=latest - :alt: Documentation Status - -OTCExtensions is a project to bring OTC extensions into the native OpenStack -toolstack. Covered are currently following items: - -* `python-openstacksdk` -* `python-openstackclient` - -The primary goal is to provide a possibility to use native OpenStack SDK and -CLI with the OTC additional services - -Getting Started -=============== - -The very first step to get started is to install otcextensions into your -system. For this please follow installation instructions_ - -.. _instructions: http://python-otcextensions.readthedocs.io/en/latest/install/index.html - -Next step would be logically configuration - -Configuration -============= - -openstack.config -================ - -The recommended way, since it is the most efficient way to configure both SDK -and the CLI in one place - -``openstack.config`` will find cloud configuration for as few as 1 clouds and -as many as you want to put in a config file. It will read environment variables -and config files, and it also contains some vendor specific default values so -that you don't have to know extra info to use OpenStack - -* If you have a config file, you will get the clouds listed in it -* If you have environment variables, you will get a cloud named `envvars` -* If you have neither, you will get a cloud named `defaults` with base defaults - -Sometimes an example is nice. - -Create a ``clouds.yaml`` file: - -.. code-block:: yaml - - clouds: - otc: - auth: - username: 'USER_NAME' - password: 'PASS' - project_name: 'eu-de' - auth_url: 'https://iam.eu-de.otc.t-systems.com:443/v3' - user_domain_name: 'OTC00000000001000000xxx' - interface: 'public' - identity_api_version: 3 # !Important - ak: 'AK_VALUE' # AK/SK pair for access to OBS - sk: 'SK_VALUE' - -Please note: ``openstack.config`` will look for a file called ``clouds.yaml`` -in the following locations: - -* Current Directory -* ``~/.config/openstack`` -* ``/etc/openstack`` - -AK/SK values required for access to some services (i.e. OBS) can be either -configured as shown above in the clouds.yaml/secure.yaml, or they can be -automatically retrieved from the S3_ACCESS_KEY_ID and S3_SECRET_ACCESS_KEY. -Values from the clouds.yaml/secure.yaml take precedence over the ones from -environment. - -With this configuration you can start using openstackCLI simply ``openstack ---os-cloud otc`` - -More information at https://developer.openstack.org/sdks/python/openstacksdk/users/config - -Old style way -============= - -The CLI can be configured via environment variables and command-line options as -listed in -https://docs.openstack.org/python-openstackclient/latest/cli/authentication.html -or https://developer.openstack.org/sdks/python/openstacksdk/users/config. - -Authentication using username/password is often used:: - - export OS_AUTH_URL= - export OS_IDENTITY_API_VERSION=3 - export OS_PROJECT_NAME= - export OS_PROJECT_DOMAIN_NAME= - export OS_USERNAME= - export OS_USER_DOMAIN_NAME= - export OS_PASSWORD= # (optional) - export S3_ACCESS_KEY_ID= - export S3_SECRET_ACCESS_KEY= - -The corresponding command-line options look very similar:: - - --os-auth-url - --os-identity-api-version 3 - --os-project-name - --os-project-domain-name - --os-username - --os-user-domain-name - [--os-password ] - -If a password is not provided above (in plaintext), you will be interactively -prompted to provide one securely. - -Authentication may also be performed using an already-acquired token -and a URL pointing directly to the service API that presumably was acquired -from the Service Catalog:: - - export OS_TOKEN= - export OS_URL= - -The corresponding command-line options look very similar:: - - --os-token - --os-url - -In addition to that a regular `clouds.yaml` configuration file can be used - - -Links -===== - -* `Issue Tracker `_ -* `Documentation `_ diff --git a/doc/source/cli/index.rst b/doc/source/cli/index.rst index c4d31c1f4..e0126a6e6 100644 --- a/doc/source/cli/index.rst +++ b/doc/source/cli/index.rst @@ -33,6 +33,7 @@ documentation of these services: dns kms load_balancer + nat obs - rds + rds_v3 volume_backup diff --git a/doc/source/cli/nat.rst b/doc/source/cli/nat.rst new file mode 100644 index 000000000..60c3e4a88 --- /dev/null +++ b/doc/source/cli/nat.rst @@ -0,0 +1,35 @@ +Network Address Translation (NAT) +================================= + +The NAT client is the command-line interface (CLI) for +the Network Address Translation (NAT) API and its extensions. + +For help on a specific `nat` command, enter: + +.. code-block:: console + + $ openstack nat help SUBCOMMAND + +.. _gateway: + +Nat Gateway Operations +---------------------- + +.. autoprogram-cliff:: openstack.nat.v2 + :command: nat gateway * + +.. _snat: + +Snat Rule Operations +-------------------- + +.. autoprogram-cliff:: openstack.nat.v2 + :command: nat snat rule * + +.. _dnat: + +Dnat Rule Operations +-------------------- + +.. autoprogram-cliff:: openstack.nat.v2 + :command: nat dnat rule * diff --git a/doc/source/cli/obs.rst b/doc/source/cli/obs.rst index 4a03069cc..40991e4a8 100644 --- a/doc/source/cli/obs.rst +++ b/doc/source/cli/obs.rst @@ -1,4 +1,4 @@ -Object Storage service (obs) +Object Storage service (OBS) ============================ The OBS client is the command-line interface (CLI) for diff --git a/doc/source/cli/rds.rst b/doc/source/cli/rds_v3.rst similarity index 50% rename from doc/source/cli/rds.rst rename to doc/source/cli/rds_v3.rst index 229a41495..88b3efdee 100644 --- a/doc/source/cli/rds.rst +++ b/doc/source/cli/rds_v3.rst @@ -1,5 +1,5 @@ -Database service (rds) -====================== +Relational Database Service (RDS) +================================= The RDS client is the command-line interface (CLI) for the Database service (RDS) API and its extensions. @@ -12,32 +12,40 @@ For help on a specific `rds` command, enter: .. _datastore: -Datastore operations +Datastore Operations -------------------- -.. autoprogram-cliff:: openstack.rds.v1 +.. autoprogram-cliff:: openstack.rds.v3 :command: rds datastore * .. _flavor: -Flavor operations +Flavor Operations ----------------- -.. autoprogram-cliff:: openstack.rds.v1 +.. autoprogram-cliff:: openstack.rds.v3 :command: rds flavor * .. _instance: -Instance operations +Instance Operations ------------------- -.. autoprogram-cliff:: openstack.rds.v1 +.. autoprogram-cliff:: openstack.rds.v3 :command: rds instance * .. _backup: -Backup operations +Backup Operations ----------------- -.. autoprogram-cliff:: openstack.rds.v1 +.. autoprogram-cliff:: openstack.rds.v3 :command: rds backup * + +.. _configuration: + +Configuration Operations +------------------------ + +.. autoprogram-cliff:: openstack.rds.v3 + :command: rds configuration * diff --git a/doc/source/coverage.rst b/doc/source/coverage.rst index 42805181b..4b33b9d3c 100644 --- a/doc/source/coverage.rst +++ b/doc/source/coverage.rst @@ -92,8 +92,8 @@ under several service tags. This may change in future. * - nat - Network Address Translation - X - - - - + - X + - X - * - obs - Object Storage Service @@ -101,24 +101,12 @@ under several service tags. This may change in future. - X - X - - * - rds + * - rds_v3 - Relational Database Service - X - X - X - - * - rds_v1 - - Relational Database Service - - - - - - - - - * - rds_v2 - - Relational Database Service - - - - - - - - * - vbs - Volume Backup - X diff --git a/doc/source/install/pip_install.rst b/doc/source/install/pip_install.rst index d5d63fc13..046b1b019 100644 --- a/doc/source/install/pip_install.rst +++ b/doc/source/install/pip_install.rst @@ -42,7 +42,7 @@ repository, first: $ sudo yum update $ sudo yum install epel-release - $ sudo yum install gcc python36 python36-devel python36-pip openssl-devel + $ sudo yum install gcc python3 python3-devel openssl-devel wheel Now, install all libraries and programs at once with the Python package manager pip: @@ -112,22 +112,12 @@ CentOS For the installation, following packages are required: a C compiler, Python3 with developer libraries, package manager, and virtual environment are -required. If you want to use python3 which is recommended, you need to -install the epel repository, first: - +required: .. code-block:: bash $ sudo yum update - $ sudo yum install epel-release - -No the Python packages are needed: - -.. code-block:: bash - - $ sudo yum update - $ sudo yum install gcc python36 python36-devel python-pip \ - python-virtualenv openssl-devel + $ sudo yum install gcc python3 python3-devel openssl-devel wheel A virtual environment seperates your installed packages from other libraries and should be used as well. You can name the virtual environment on your own @@ -146,8 +136,8 @@ manager pip: $ pip install otcextensions openstackclient -Fedora (under review) -^^^^^^^^^^^^^^^^^^^^^ +Fedora +^^^^^^ For the installation, following packages are required: a C compiler, Python3 with developer libraries, package manager, and a virtual diff --git a/doc/source/sdk/guides/auto_scaling.rst b/doc/source/sdk/guides/auto_scaling.rst index fbf617e79..598e1765b 100644 --- a/doc/source/sdk/guides/auto_scaling.rst +++ b/doc/source/sdk/guides/auto_scaling.rst @@ -94,7 +94,8 @@ Create Group This interface is used to create an Auto-Scaling Group with parameters. -**NEEDS TO BE DONE** +.. literalinclude:: ../examples/auto_scaling/create_group.py + :lines: 16-37 Get Group ^^^^^^^^^ @@ -171,7 +172,9 @@ Create Policy This interface is used to create an Auto-Scaling Policy with parameters. -**NEEDS TO BE DONE** +.. literalinclude:: ../examples/auto_scaling/create_policy.py + :lines: 16-35 + Get Policy ^^^^^^^^^^ diff --git a/doc/source/sdk/guides/cts.rst b/doc/source/sdk/guides/cts.rst new file mode 100644 index 000000000..442e44f80 --- /dev/null +++ b/doc/source/sdk/guides/cts.rst @@ -0,0 +1,78 @@ +Cloud Trace Service (CTS) +========================= + +Cloud Trace is an effective monitoring tool that allows users to analyze +their cloud resources using traces. A tracker is automatically generated when +the service is started. This tracker monitors access to all the respective +user’s cloud resources by means of the traces generated. The monitoring logs +can be saved in the object storage cost-effectively and in the long term. The +Cloud Trace service can also be used in conjunction with Simple Message +Notification, with the user receiving a message when certain events occur. +Cloud Trace is free of charge. + +.. contents:: Table of Contents + :local: + +CTS Tracker +----------- + +A tracker will be automatically created after CTS is enabled. All traces +recorded by CTS are associated with the tracker. Only one +management tracker is currently created for each account in a region. +On the management console, you can query the last seven days of operation +records. To obtain more operation records, you can enable Object Storage +Service (OBS) and deliver operation records to OBS buckets for long-term +storage in real time. + +Create Tracker +^^^^^^^^^^^^^^ + +This interface is used to create a CTS Tracker instance with parameters. + +.. literalinclude:: ../examples/cts/create_tracker.py + :lines: 16-36 + +Get Tracker +^^^^^^^^^^^ + +This interface is used to get a CTS Tracker by name or ID or an instance of +class :class:`~otcextensions.sdk.cts.v1.tracker.Tracker`. + +.. literalinclude:: ../examples/cts/get_tracker.py + :lines: 16-24 + +Delete Tracker +^^^^^^^^^^^^^^ + +This interface is used to delete a CTS Tracker instance by id +or an instance of class +:class:`~otcextensions.sdk.cts.v1.tracker.Tracker`. + +.. literalinclude:: ../examples/cts/delete_tracker.py + :lines: 16-22 + +Update Tracker +^^^^^^^^^^^^^^ + +This interface is used to update a CTS Tracker instance by +using name or an instance of class +:class:`~otcextensions.sdk.cts.v1.tracker.Tracker` and provide new +attributes. + +.. literalinclude:: ../examples/cts/update_tracker.py + :lines: 16-39 + + +CTS Traces +---------- + +Traces are the messuremant values of a CTS Tracker. + +List Traces +^^^^^^^^^^^ + +This interface is used to query all CTS Traces of a CTS tracker and to filter +the output with query parameters. + +.. literalinclude:: ../examples/cts/list_traces.py + :lines: 16-26 diff --git a/doc/source/sdk/guides/dcs.rst b/doc/source/sdk/guides/dcs.rst new file mode 100644 index 000000000..83d468ec0 --- /dev/null +++ b/doc/source/sdk/guides/dcs.rst @@ -0,0 +1,201 @@ +Distributed Cache Service (DCS) +=============================== + +.. contents:: Table of Contents + :local: + +Redis is a NoSQL database. It can handle various data structures, but should +not be used for complex data structures; relational databases are better +suited for these. While caching the storage in the RAM allows fast data +access, Redis is ideal for all applications in which speed is the main focus. +However, the storage cache not persistent, meaning that the stored data is +deleted if the virtual machine is switched off. +The Distributed Cache Service is ideal for use as a cache server (e.g. in +order to accelerate the loading times of websites), for real-time analyses, +high-speed transactions, and message queuing. Clusters made up of individual +DCS instances can be used for applications with extremely high performance +requirements. Redis is available in the Open Telekom Cloud as the Distributed +Cache Service. Via the console, the database can be defined in three variants: +as a single-node database for temporary data storage, as a master/standby +database for higher availability, and as a cluster for high performance. +The Distributed Cache Service is billed on an hourly basis in accordance with +the chosen RAM size and type (master/standby or single-node database). + +Instances +--------- + +A Distributed Cache Service Instance is a Redis instance on top of +Open Telekom Cloud. + +List Instances +^^^^^^^^^^^^^^ + +This interface is used to query all DCS Instances and to filter +the output with query parameters. + +.. literalinclude:: ../examples/dcs/list_instances.py + :lines: 16-23 + +Create Instance +^^^^^^^^^^^^^^^ + +This interface is used to create a DCS instance with +parameters. + +.. literalinclude:: ../examples/dcs/create_instance.py + :lines: 16-66 + +Get Instance +^^^^^^^^^^^^ + +This interface is used to get a DCS instance by ID +or an instance of class +:class:`~otcextensions.sdk.dcs.v1.instance.Instance`. + +.. literalinclude:: ../examples/dcs/get_instance.py + :lines: 16-24 + +Find Instance +^^^^^^^^^^^^^ + +This interface is used to find a DCS instance by +name or id. + +.. literalinclude:: ../examples/dcs/find_instance.py + :lines: 16-24 + +Update Instance +^^^^^^^^^^^^^^^ + +This interface is used to update a DCS instance by +name or id. + +.. literalinclude:: ../examples/dcs/update_instance.py + :lines: 16-27 + +Delete Instance +^^^^^^^^^^^^^^^ + +This interface is used to delete a DCS instance by +id or an instance of class +:class:`~otcextensions.sdk.dcs.v1.instance.Instance`. + +.. literalinclude:: ../examples/dcs/delete_instance.py + :lines: 16-23 + +Extend Instance +^^^^^^^^^^^^^^^ + +This interface is used to extend a DCS instance with additional RAM. + +.. literalinclude:: ../examples/dcs/extend_instance.py + :lines: 16-23 + +Stop Instance +^^^^^^^^^^^^^ + +This interface is used to stop a DCS instance. + +.. literalinclude:: ../examples/dcs/stop_instance.py + :lines: 16-23 + +Start Instance +^^^^^^^^^^^^^^ + +This interface is used to start a DCS instance. + +.. literalinclude:: ../examples/dcs/start_instance.py + :lines: 16-23 + +Restart Instance +^^^^^^^^^^^^^^^^ + +This interface is used to restart a DCS instance. + +.. literalinclude:: ../examples/dcs/restart_instance.py + :lines: 16-23 + +Change Instance Password +^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to change the login password of a DCS instance. + +.. literalinclude:: ../examples/dcs/change_instance_password.py + :lines: 16-25 + +List Statistics of all Instances +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all Statistics of all DCS Instances and +to filter the output with query parameters. + +.. literalinclude:: ../examples/dcs/list_statistics.py + :lines: 16-23 + +List Config Parameters +^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all Config Parameters of a DCS Instance +and to filter the output with query parameters. + +.. literalinclude:: ../examples/dcs/list_instance_params.py + :lines: 16-24 + +Update Instance Config Parameters +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to update config parameters of a DCS instance. + +.. literalinclude:: ../examples/dcs/update_instance_params.py + :lines: 16-27 + +Backup DCS Instance +------------------- + +This API is used to backup a Distributed Cache Service instance. + +List Backups +^^^^^^^^^^^^ + +This interface is used to query all Backups of a DCS Instance and to filter +the output with query parameters. + +.. literalinclude:: ../examples/dcs/list_backups.py + :lines: 16-24 + +Create Instance Backup +^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to backup a DCS Instance. + +.. literalinclude:: ../examples/dcs/create_backup.py + :lines: 16-27 + +Delete Instance Backup +^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to backup a DCS Instance. + +.. literalinclude:: ../examples/dcs/delete_backup.py + :lines: 16-28 + +Restore DCS Instances +--------------------- + +This API is used to restore a Distributed Cache Service instance. + +List Restore Records +^^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all Restore Records. + +.. literalinclude:: ../examples/dcs/list_restore_records.py + :lines: 16-24 + +Restore Instance +^^^^^^^^^^^^^^^^ + +This interface is used to restore a DCS Instance. + +.. literalinclude:: ../examples/dcs/restore_instance.py + :lines: 16-27 diff --git a/doc/source/sdk/guides/dns.rst b/doc/source/sdk/guides/dns.rst new file mode 100644 index 000000000..224a6c3cc --- /dev/null +++ b/doc/source/sdk/guides/dns.rst @@ -0,0 +1,216 @@ +Domain Name Service (DNS) +========================= + +.. contents:: Table of Contents + :local: + +Domain Name Services (DNS) assign IP addresses to meaningful domain names +(such as www.telekom.de). These plain-text names are much easier to remember +than 12-digit numbers. Thanks to DNS resolution, users can access network +applications by entering the domain name. As such, the DNS also simplifies +work in public clouds. It enables users to integrate cloud resources in their +own company networks with ease – they then see the services as part of their +internal network. Moreover, using domain names instead of IP addresses also +facilitates administrative tasks and makes clouds more user-friendly. +The Open Telekom Cloud also offers a Domain Name Service (DNS). DNS is +available via the Open Telekom Cloud console and features anti-DDoS +protection. In addition to references to external IP addresses, the solution +can also be used for services within the Open Telekom Cloud. Pricing of the +Domain Name Service is based on scaled prices depending on the number of +domains stored. If a domain is created and remains configured for more than +24 hours, it is billed once for the entire month. A usage-based payment is +then added to this (domain requests). + +Zone +---- + +There are private and public zones available. +A large number of DNS servers are available on the Internet, constituting DNS +domain namespaces. Each DNS server has its own domain name resolution +responsibilities. Only when a DNS server cannot resolve a domain name itself, +it forwards the request to another DNS server. Domain namespaces are managed +by segment. That is, a large space is divided into several separately hosted +zones. Each public zone is a part of the namespace that is administered by a +particular DNS server. For example, a DNS server is configured on the cloud +platform to resolve all domain names in the namespace example.com. Public +zones are accessible to hosts on the Internet. +A private zone is a namespace in which domain names are resolved by private +DNS servers It records the route for a domain name to be accessed in one +or more VPCs. Private zones are accessible only to hosts in specified VPCs. + +List Zones +^^^^^^^^^^ + +This interface is used to query all DNS Zones and to filter +the output with query parameters. + +.. literalinclude:: ../examples/dns/list_zones.py + :lines: 16-23 + +Create Zone +^^^^^^^^^^^ + +This interface is used to create a DNS zone with +parameters. + +.. literalinclude:: ../examples/dns/create_zone.py + :lines: 16-49 + +Get Zone +^^^^^^^^ + +This interface is used to get a DNS zone by ID +or an instance of class +:class:`~otcextensions.sdk.dns.v2.zone.Zone`. + +.. literalinclude:: ../examples/dns/get_zone.py + :lines: 16-24 + +Find Zone +^^^^^^^^^ + +This interface is used to find a DNS zone by id or name. + +.. literalinclude:: ../examples/dns/find_zone.py + :lines: 16-24 + +Update Zone +^^^^^^^^^^^ + +This interface is used to update DNS zone parameters by +id or an instance of class +:class:`~otcextensions.sdk.dns.v2.zone.Zone`. + +.. literalinclude:: ../examples/dns/update_zone.py + :lines: 16-27 + +Delete Zone +^^^^^^^^^^^ + +This interface is used to delete a DNS zone by +id or an instance of class +:class:`~otcextensions.sdk.dns.v2.zone.Zone`. + +.. literalinclude:: ../examples/dns/delete_zone.py + :lines: 16-23 + +Nameserver +---------- + +List Nameservers +^^^^^^^^^^^^^^^^ + +This interface is used to query all DNS Nameservers of a zone and to filter +the output with query parameters. + +.. literalinclude:: ../examples/dns/list_nameservers.py + :lines: 16-23 + +Recordsets +---------- + +List Recordsets +^^^^^^^^^^^^^^^ + +This interface is used to query all Recordsets of a zone and to filter +the output with query parameters. + +.. literalinclude:: ../examples/dns/list_nameservers.py + :lines: 16-23 + +Create Recordsets +^^^^^^^^^^^^^^^^^ + +This interface is used to create a DNS Recordset with +parameters. + +.. literalinclude:: ../examples/dns/create_recordset.py + :lines: 16-33 + +Get Recordset +^^^^^^^^^^^^^ + +This interface is used to get a DNS recordset by ID +or an instance of class +:class:`~otcextensions.sdk.dns.v2.recordset.Recordset`. + +.. literalinclude:: ../examples/dns/get_recordset.py + :lines: 16-25 + +Find Recordset +^^^^^^^^^^^^^^ + +This interface is used to find a DNS recordset by id or name. + +.. literalinclude:: ../examples/dns/find_recordset.py + :lines: 16-25 + +Update Recordset +^^^^^^^^^^^^^^^^ + +This interface is used to update DNS recordset parameters by +id or an instance of class +:class:`~otcextensions.sdk.dns.v2.recordset.Recordset`. + +.. literalinclude:: ../examples/dns/update_recordset.py + :lines: 16-32 + +Delete Recordset +^^^^^^^^^^^^^^^^ + +This interface is used to delete a DNS recordset by +id or an instance of class +:class:`~otcextensions.sdk.dns.v2.recordset.Recordset`. + +.. literalinclude:: ../examples/dns/delete_recordset.py + :lines: 16-24 + +Floating IP PTR Records +----------------------- + +List Floating IP PTR Record +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all Floating IP PTR records to filter +the output with query parameters. + +.. literalinclude:: ../examples/dns/list_floating_ips.py + :lines: 16-23 + +Set Floating IP PTR Record +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to set a DNS floating IP PTR record with +parameters. + +.. literalinclude:: ../examples/dns/set_floating_ip.py + :lines: 16-29 + +Get Floating IP PTR Record +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to get a DNS floating IP PTR record by ID +or an instance of class +:class:`~otcextensions.sdk.dns.v2.floating_ip.FloatingIP`. + +.. literalinclude:: ../examples/dns/get_floating_ip.py + :lines: 16-25 + +Update Floating IP PTR Record +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to update DNS floating IP PTR record parameters by +id or an instance of class +:class:`~otcextensions.sdk.dns.v2.floating_ip.FloatingIP`. + +.. literalinclude:: ../examples/dns/update_floating_ip.py + :lines: 16-28 + +Unset Floating IP PTR Record +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to unset a DNS floating IP PTR record with +parameters. + +.. literalinclude:: ../examples/dns/unset_floating_ip.py + :lines: 16-23 diff --git a/doc/source/sdk/guides/index.rst b/doc/source/sdk/guides/index.rst index 75ecb8427..cb1ca3545 100644 --- a/doc/source/sdk/guides/index.rst +++ b/doc/source/sdk/guides/index.rst @@ -10,7 +10,13 @@ Open Telekom Cloud related User Guides anti_ddos auto_scaling cce + cts + dcs deh + dns + kms + nat + rds logging .. _user_guides: @@ -18,7 +24,10 @@ Open Telekom Cloud related User Guides User Guides ----------- -SOME TEXT XXX. +The Open Telekom Cloud services are covering OpenStack native services and +enhanced ones covering additional functionalities. All user guides related +to Open Telekom Cloud are listed above. The links links to the most important +OpenStack native services are listed below. OpenStack native User Guides ---------------------------- diff --git a/doc/source/sdk/guides/kms.rst b/doc/source/sdk/guides/kms.rst new file mode 100644 index 000000000..7f5801fde --- /dev/null +++ b/doc/source/sdk/guides/kms.rst @@ -0,0 +1,181 @@ +Key Management Service (KMS) +============================ + +.. contents:: Table of Contents + :local: + +The Key Management Service (KMS) of the Open Telekom Cloud generates and +stores public keys for accessing data in the Open Telekom Cloud and +makes them available to the respective user. It combines the essential +security requirements placed on a cloud with high usability, as users can +manage their keys directly via the console. +The KMS ensures secure access to data and is integrated with other Open +Telekom Cloud services. Cloud Trace monitors access to keys and thereby +helps fulfill audit and compliance requirements. During implementation, +the KMS also uses hardware security modules (HSM) for professional +management of key security. +The KMS does not store the data encryption keys (DEK) directly; instead +users receive their DEKs via customer master keys. The hardware security +modules serve to handle encryption and decryption processes, while a +dedicated API is used to access the service. The Open Telekom Cloud also +allows users to deploy their own keys (“bring your own key”). Another +available function is “grant master key,” which allows owners of tenants to +issue temporary permissions for access to encrypted data. + +Customer Master Key +------------------- + +A Customer Master Key (CMK) is a Key Encryption Key (KEK) created by a user +using KMS. It is used to encrypt and protect Data Encryption Keys (DEKs). One +CMK can be used to encrypt one or multiple DEKs. + +You can perform the following operations on +CMKs: + +* Creating, querying, enabling, disabling, scheduling the deletion of, and + canceling the deletion of CMKs +* Importing CMKs and deleting CMK material +* Modifying the aliases and description of CMKs +* Creating, querying, and revoking a grant +* Adding, searching for, editing, and deleting tags +* Enabling key rotation + + +List Keys +^^^^^^^^^ + +This interface is used to query all KMS Keys and to filter +the output with query parameters. + +.. literalinclude:: ../examples/kms/list_keys.py + :lines: 16-23 + +Create Key +^^^^^^^^^^ + +This interface is used to create a KMS key with +parameters. + +.. literalinclude:: ../examples/kms/create_key.py + :lines: 16-27 + +Get Key +^^^^^^^ + +This interface is used to get a KMS key by ID +or an instance of class +:class:`~otcextensions.sdk.kms.v1.key.Key`. + +.. literalinclude:: ../examples/kms/get_key.py + :lines: 16-24 + +Find Key +^^^^^^^^^ + +This interface is used to find a KMS key by id or name. + +.. literalinclude:: ../examples/kms/find_key.py + :lines: 16-24 + +Enable Key +^^^^^^^^^^ + +This interface is used to enable a KMS key by id or an instance of class +:class:`~otcextensions.sdk.kms.v1.key.Key`. + +.. literalinclude:: ../examples/kms/enable_key.py + :lines: 16-24 + +Disable Key +^^^^^^^^^^^ + +This interface is used to disable a KMS key by id or an instance of class +:class:`~otcextensions.sdk.kms.v1.key.Key`. + +.. literalinclude:: ../examples/kms/disable_key.py + :lines: 16-24 + +Schedule Key Deletion +^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to schedule the KMS key deletion with a specific +retention time by id or an instance of class +:class:`~otcextensions.sdk.kms.v1.key.Key`. + +.. literalinclude:: ../examples/kms/schedule_key_deletion.py + :lines: 16-23 + +Cancel Key Deletion +^^^^^^^^^^^^^^^^^^^ + +This interface is used to cancel the KMS key deletion by key id or an +instance of class +:class:`~otcextensions.sdk.kms.v1.key.Key`. + +.. literalinclude:: ../examples/kms/cancel_key_deletion.py + :lines: 16-23 + +Data Encryption Key +------------------- + +Data Encryption Keys (DEKs) are used to encrypt data. + +Create Datakey +^^^^^^^^^^^^^^ + +This interface is used to create a KMS Datakey with +parameters. + +.. literalinclude:: ../examples/kms/create_datakey.py + :lines: 16-26 + +Create Datakey without plain Text +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to create a KMS data encryption key without plain text. + +.. literalinclude:: ../examples/kms/create_datakey.py + :lines: 16-26 + +Encrypt Datakey +^^^^^^^^^^^^^^^ + +This interface is used to encrypt a KMS data encryption key. + +.. literalinclude:: ../examples/kms/encrypt_datakey.py + :lines: 16-27 + +Decrypt Datakey +^^^^^^^^^^^^^^^ + +This interface is used to decrypt a KMS data encryption key. + +.. literalinclude:: ../examples/kms/decrypt_datakey.py + :lines: 16-27 + +Miscellaneous +------------- + +Generate Random Data +^^^^^^^^^^^^^^^^^^^^ + +This interface is used to generate random Data. + +.. literalinclude:: ../examples/kms/generate_random_data.py + :lines: 16-23 + +Get Instance Number +^^^^^^^^^^^^^^^^^^^ + +This interface is used to get the total number of encrypt key instances. + +.. literalinclude:: ../examples/kms/get_instance_number.py + :lines: 16-23 + +List KMS quotas +^^^^^^^^^^^^^^^ + +This interface is used to query all KMS quotas. + +.. literalinclude:: ../examples/kms/list_quotas.py + :lines: 16-23 diff --git a/doc/source/sdk/guides/nat.rst b/doc/source/sdk/guides/nat.rst new file mode 100644 index 000000000..5ee75f408 --- /dev/null +++ b/doc/source/sdk/guides/nat.rst @@ -0,0 +1,174 @@ +Network Address Translation (NAT) +================================= + +.. contents:: Table of Contents + :local: + +NAT Gateway +----------- + +The NAT Gateway service provides the network address translation (NAT) +function for servers, such as Elastic Cloud Servers (ECSs), Bare Metal +Servers (BMSs), and Workspace desktops, in a Virtual Private Cloud (VPC) +or servers that connect to a VPC through Direct Connect or Virtual +Private Network (VPN) in local data centers, allowing these servers to +share elastic IP addresses (EIPs) to access the Internet or to provide +services accessible from the Internet. + +List NAT Gateways +^^^^^^^^^^^^^^^^^ + +This interface is used to query an NAT gateway list and to filter +the output with query parameters. +:class:`~otcextensions.sdk.nat.v2.gateway.Gateway`. + +.. literalinclude:: ../examples/nat/list_gateways.py + :lines: 16-23 + +Create NAT Gateway +^^^^^^^^^^^^^^^^^^ + +This interface is used to create a NAT Ggateway with +parameters. +:class:`~otcextensions.sdk.nat.v2.gateway.Gateway`. + +.. literalinclude:: ../examples/nat/create_gateway.py + :lines: 16-31 + +Get NAT Gateway +^^^^^^^^^^^^^^^ + +This interface is used to get a NAT gateway by ID +or an instance of class +:class:`~otcextensions.sdk.nat.v2.gateway.Gateway`. + +.. literalinclude:: ../examples/nat/get_gateway.py + :lines: 16-23 + +Find NAT Gateway +^^^^^^^^^^^^^^^^ + +This interface is used to find a NAT gateway by id or name. +:class:`~otcextensions.sdk.nat.v2.gateway.Gateway`. + +.. literalinclude:: ../examples/nat/find_gateway.py + :lines: 16-24 + +Update NAT Gateway +^^^^^^^^^^^^^^^^^^ + +This interface is used to update NAT gateway parameters by +id or an instance of class +:class:`~otcextensions.sdk.nat.v2.gateway.Gateway`. + +.. literalinclude:: ../examples/nat/update_gateway.py + :lines: 16-31 + +Delete NAT Gateway +^^^^^^^^^^^^^^^^^^ + +This interface is used to delete a NAT gateway by ID +or an instance of class +:class:`~otcextensions.sdk.nat.v2.gateway.Gateway`. + +.. literalinclude:: ../examples/nat/delete_gateway.py + :lines: 16-24 + +NAT Gateway supports source NAT (SNAT) and destination NAT (DNAT) +functions. + +SNAT +---- + +The SNAT function translates a private IP address to a public IP +address by binding EIPs to servers in a VPC, providing secure and +efficient access to the Internet. + +List SNAT Rules +^^^^^^^^^^^^^^^ + +This interface is used to query an SNAT rule list and to filter +the output with query parameters. +:class:`~otcextensions.sdk.nat.v2.snat.Snat`. + +.. literalinclude:: ../examples/nat/list_snat_rules.py + :lines: 16-23 + +Create SNAT Rule +^^^^^^^^^^^^^^^^ + +This interface is used to create a SNAT rule with +parameters. +:class:`~otcextensions.sdk.nat.v2.snat.Snat`. + +.. literalinclude:: ../examples/nat/create_snat_rule.py + :lines: 16-33 + +Get SNAT Rule +^^^^^^^^^^^^^ + +This interface is used to get a SNAT rule by ID +or an instance of class +:class:`~otcextensions.sdk.nat.v2.snat.Snat`. + +.. literalinclude:: ../examples/nat/get_snat_rule.py + :lines: 16-24 + +Delete SNAT Rule +^^^^^^^^^^^^^^^^ + +This interface is used to delete a SNAT Rule by ID +or an instance of class +:class:`~otcextensions.sdk.nat.v2.snat.Snat`. + +.. literalinclude:: ../examples/nat/delete_snat_rule.py + :lines: 16-23 + + +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 DNAT Rules +^^^^^^^^^^^^^^^ + +This interface is used to query an DNAT rule list and to filter +the output with query parameters. +:class:`~otcextensions.sdk.nat.v2.dnat.Dnat`. + +.. literalinclude:: ../examples/nat/list_dnat_rules.py + :lines: 16-23 + +Create DNAT Rule +^^^^^^^^^^^^^^^^ + +This interface is used to create a DNAT rule with +parameters. +:class:`~otcextensions.sdk.nat.v2.dnat.Dnat`. + +.. literalinclude:: ../examples/nat/create_dnat_rule.py + :lines: 16-42 + +Get DNAT Rule +^^^^^^^^^^^^^ + +This interface is used to get a DNAT rule by ID +or an instance of class +:class:`~otcextensions.sdk.nat.v2.dnat.Dnat`. + +.. literalinclude:: ../examples/nat/get_dnat_rule.py + :lines: 16-24 + +Delete DNAT Rule +^^^^^^^^^^^^^^^^ + +This interface is used to delete a DNAT Rule by ID +or an instance of class +:class:`~otcextensions.sdk.nat.v2.dnat.Dnat`. + +.. literalinclude:: ../examples/nat/delete_snat_rule.py + :lines: 16-23 + diff --git a/doc/source/sdk/guides/rds.rst b/doc/source/sdk/guides/rds.rst new file mode 100644 index 000000000..1932e0445 --- /dev/null +++ b/doc/source/sdk/guides/rds.rst @@ -0,0 +1,244 @@ +Relational Database Service (RDS) +================================= + +.. contents:: Table of Contents + :local: + +The Relational Database Service offers a demand-oriented use of databases in +the Open Telekom Cloud. The RDS includes twelve flavors for implementing +databases for a wide range of requirements. The current versions of mySQL, +PostgreSQL and MS SQL are available as relational database software. The RDS +offers an automatic backup function and point-in-time recovery for the +previous 35 days. Numerous management tools analyze the performance of the +database. Database operation can be optimized on the basis of resource +utilization over time and the evaluation speed. +The RDS supports high availability, even across different availability zones, +and a mirrored standby database can be added to the primary database. Up to +five read replicas can be added to a database cluster. The RDS is also +available directly via an Elastic IP. Databases can be expanded to up 4 GB +during ongoing operation. It is also possible to upgrade a single-instance +database to an active/standby database. Billing is based on the hourly price +of the selected virtual machines (VMs), while additional storage space for +backups and images is billed in accordance with the method used for the +respective storage variant. + +Instance +-------- + +The minimum management unit of RDS is the DB instance. A DB instance is an +isolated database environment in the cloud. A DB instance can contain multiple +user-created databases, and you can access it by using the same tools and +applications that you use with a stand-alone DB instance. You can create +and modify DB instances using the management console or APIs. RDS does not +have limits on the number of running DB instances. Each DB instance has a DB +instance identifier. + +RDS supports the following DB engines: + +* MySQL +* PostgreSQL +* Microsoft SQL Server + +List Instances +^^^^^^^^^^^^^^ + +This interface is used to query all RDS instances and to filter the output +with query parameters. + +.. literalinclude:: ../examples/rds/list_instances.py + :lines: 16-23 + +Create Instance +^^^^^^^^^^^^^^^ + +This interface is used to create a RDS instance with parameters. + +.. literalinclude:: ../examples/rds/create_instance.py + :lines: 16-59 + +Get Instance +^^^^^^^^^^^^ + +This interface is used to get a RDS instance by ID or an instance of class +:class:`~otcextensions.sdk.rds.v3.instance.Instance`. + +.. literalinclude:: ../examples/rds/get_instance.py + :lines: 16-24 + +Find Instance +^^^^^^^^^^^^^ + +This interface is used to find an RDS instance by name or id. + +.. literalinclude:: ../examples/rds/find_instance.py + :lines: 16-24 + +Backup +------ + +When you create a DB instance, an automated backup policy is enabled by +default. After the DB instance is created, you can modify the policy. RDS will +automatically create full backups for DB instances based on your settings. +Manual backups are user-initiated full backups of DB instances. They are +retained until you delete them manually. + +List Backups of an RDS Instance +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all backups of an RDS instance and to filter +the output with query parameters. + +.. literalinclude:: ../examples/rds/list_backups.py + :lines: 16-23 + +Create Backup +^^^^^^^^^^^^^ + +This interface is used to create a backup of an RDS instance with parameters. + +.. literalinclude:: ../examples/rds/create_backup.py + :lines: 16-25 + +Wait for Backup +^^^^^^^^^^^^^^^ + +This interface is used to wait for a backup of an RDS instance to be completed. + +.. literalinclude:: ../examples/rds/wait_for_backup.py + :lines: 16-27 + +Find Backup +^^^^^^^^^^^ + +This interface is used to find an RDS instance backup by name or id. + +.. literalinclude:: ../examples/rds/find_instance.py + :lines: 16-24 + +List Backup Download Links +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to list download links of RDS backup. + +.. literalinclude:: ../examples/rds/list_backup_download_links.py + :lines: 16-24 + +Get Instance Backup Policy +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to get the backup policy of a RDS instance by ID. + +.. literalinclude:: ../examples/rds/get_instance_backup_policy.py + :lines: 16-24 + +Set Instance Backup Policy (ToDo) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to get the backup policy of a RDS instance by ID. + +.. literalinclude:: ../examples/rds/set_instance_backup_policy.py + :lines: 16-24 + +Get Instance Restore Time +^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to get the restore time of a RDS instance by ID. + +.. literalinclude:: ../examples/rds/get_instance_restore_time.py + :lines: 16-24 + +Restore Instance +^^^^^^^^^^^^^^^^ + +This interface is used to restore a RDS instance from existing backup. + +.. literalinclude:: ../examples/rds/restore_instance.py + :lines: 16-25 + +Configurations (Parameter Template) +----------------------------------- + +List Configurations +^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all RDS configurations and to filter +the output with query parameters. + +.. literalinclude:: ../examples/rds/list_configurations.py + :lines: 16-23 + +Create Configuration +^^^^^^^^^^^^^^^^^^^^ + +This interface is used to create a RDS configuration template with parameters. + +.. literalinclude:: ../examples/rds/create_configuration.py + :lines: 16-33 + +Get Configuration +^^^^^^^^^^^^^^^^^ + +This interface is used to get a RDS configuration template by ID. + +.. literalinclude:: ../examples/rds/get_configuration.py + :lines: 16-24 + +Find Configuration +^^^^^^^^^^^^^^^^^^ + +This interface is used to find a RDS configuration template by name or id. + +.. literalinclude:: ../examples/rds/find_configuration.py + :lines: 16-24 + +Update Configuration +^^^^^^^^^^^^^^^^^^^^ + +This interface is used to update a DNS configuration by +using name or an instance of class +:class:`~otcextensions.sdk.rds.v1.configuratino.Configuration` and provide new +attributes. + +.. literalinclude:: ../examples/rds/update_configuration.py + :lines: 16-32 + +Apply Configuration +^^^^^^^^^^^^^^^^^^^ + +This interface is used to apply a RDS configuration to existing RDS instances. + +.. literalinclude:: ../examples/rds/apply_configuration.py + :lines: 16-29 + +Datastores +---------- + +List Datastore Types +^^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all RDS Datastore Types and to filter +the output with query parameters. + +.. literalinclude:: ../examples/rds/list_datastore_types.py + :lines: 16-23 + +List Datastores +^^^^^^^^^^^^^^^ + +This interface is used to query all RDS Datastores of a RDS database and to +filter the output with query parameters. + +.. literalinclude:: ../examples/rds/list_datastores.py + :lines: 16-24 + +Flavors +------- + +List Flavors +^^^^^^^^^^^^ + +This interface is used to query all flavors of a given RDS datastore and +datastore version. + +.. literalinclude:: ../examples/rds/list_flavors.py + :lines: 16-26 diff --git a/examples/auto_scaling/create_policy.py b/examples/auto_scaling/create_policy.py new file mode 100644 index 000000000..c0922e83d --- /dev/null +++ b/examples/auto_scaling/create_policy.py @@ -0,0 +1,35 @@ +#!/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 Auto-Scaling Policy. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +attrs = { + "scaling_group_id": "as_group_id", + "scaling_policy_name": "as_policy_name", + "scaling_policy_type": "ALARM", + "alarm_id": "cloudeye_alarm_id", + "scheduled_policy": {}, + "cool_down_time": 300, + "scaling_policy_action": { + "operation": "ADD", + "instance_number": 1 + } +} + +policy = conn.auto_scaling.create_policy(**attrs) +print(policy) diff --git a/examples/cts/create_tracker.py b/examples/cts/create_tracker.py new file mode 100644 index 000000000..4231e4c34 --- /dev/null +++ b/examples/cts/create_tracker.py @@ -0,0 +1,37 @@ +#!/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 Cloud Trace Service Tracker +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +attrs = { + "bucket_name": "cloudtraceservice", + "file_prefix_name": "file-", + "lts": { + "is_lts_enabled": True, + "log_group_name": "CTS", + "log_topic_name": "system-trace", + "log_group_id": "1186622b-78ec-11ea-997c-286ed488c87f", + "log_topic_id": "751f0409-78ec-11ea-90c7-286ed488c880" + }, + "status": "enabled", + "tracker_name": "system", + "detail": "" +} + +tracker = conn.cts.create_tracker(**attrs) +print(tracker) diff --git a/examples/cts/delete_tracker.py b/examples/cts/delete_tracker.py new file mode 100644 index 000000000..75cd7916c --- /dev/null +++ b/examples/cts/delete_tracker.py @@ -0,0 +1,22 @@ +#!/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 Cloud Trace Service Tracker by id or instance of class Tracker. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +conn.cts.delete_tracker() diff --git a/examples/cts/get_tracker.py b/examples/cts/get_tracker.py new file mode 100644 index 000000000..8184e5cc3 --- /dev/null +++ b/examples/cts/get_tracker.py @@ -0,0 +1,24 @@ +#!/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. +""" +Get Cloud Trace Service Tracker by id or class Tracker +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +tracker_name_or_id = "system" +tracker = conn.cts.get_tracker(tracker_name_or_id) +print(tracker) diff --git a/examples/cts/list_traces.py b/examples/cts/list_traces.py new file mode 100644 index 000000000..c2378161e --- /dev/null +++ b/examples/cts/list_traces.py @@ -0,0 +1,26 @@ +#!/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 CTS Tracker Traces +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +tracker_name = 'system' +query = { + "trace_rating": "warning" +} +for trace in conn.cts.traces(tracker_name, **query): + print(trace) diff --git a/examples/cts/update_tracker.py b/examples/cts/update_tracker.py new file mode 100644 index 000000000..18ee879be --- /dev/null +++ b/examples/cts/update_tracker.py @@ -0,0 +1,39 @@ +#!/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. +""" +Update CTS Tracker by using id or an instance of class Tracker +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +tracker = "system" +attrs = { + "bucket_name": "cloudtraceservice", + "file_prefix_name": "newPrefix-", + "lts": { + "is_lts_enabled": True, + "log_group_name": "CTS", + "log_topic_name": "system-trace", + "log_group_id": "1186622b-78ec-11ea-997c-286ed488c87f", + "log_topic_id": "751f0409-78ec-11ea-90c7-286ed488c880" + }, + "status": "enabled", + "tracker_name": "system", + "detail": "" +} + +tracker = conn.cts.get_tracker(tracker) +conn.cts.update_tracker(tracker, **attrs) diff --git a/examples/dcs/change_instance_password.py b/examples/dcs/change_instance_password.py new file mode 100644 index 000000000..7e8cb1dc8 --- /dev/null +++ b/examples/dcs/change_instance_password.py @@ -0,0 +1,25 @@ +#!/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. +""" +Change the login password of a DCS instance. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = "instance_id_or_name" +old_password = 'old_password' +new_password = 'new_password' +conn.dcs.find_instance(instance, old_password, new_password) diff --git a/examples/dcs/create_backup.py b/examples/dcs/create_backup.py new file mode 100644 index 000000000..6bbfab6f9 --- /dev/null +++ b/examples/dcs/create_backup.py @@ -0,0 +1,27 @@ +#!/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. +""" +Backup a Distributed Cache Service instance. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = 'instance_id' +backup = conn.dcs.backup_instance( + instance=instance, + description='My new backup.' +) +print(backup) diff --git a/examples/dcs/create_instance.py b/examples/dcs/create_instance.py new file mode 100644 index 000000000..c6f38ecce --- /dev/null +++ b/examples/dcs/create_instance.py @@ -0,0 +1,66 @@ +#!/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 Distributed Cache Service Instance +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = conn.dcs.create_instance( + name="dcs-test", + available_zones=["eu-de-03"], + capacity=2, + engine="Redis", + engine_version="3.0.7", + maintain_begin="02:00:00", + maintain_end="06:00:00", + password="Password.123", + product_id="OTC_DCS_SINGLE", + resource_spec_code="dcs.single_node", + security_group_id="bb0e60ab-b6e0-4c61-a503-63213c18effa", + subnet_id="25d24fc8-d019-4a34-9fff-0a09fde6a9cb", + vpc_id="26ca2783-dc40-4e3a-95b1-5a0756441e12", +) +print(instance) + +''' +attrs = { + "name": "dcs-test", + "engine": "Redis", + "capacity": 2, + "resource_spec_code": "dcs.single_node", + "engine_version": "3.0.7", + "vpc_id": "26ca2783-dc40-4e3a-95b1-5a0756441e12", + "product_id": "OTC_DCS_SINGLE", + "password": "Password.123", + "user_id": "18569c6d589c4be3a300b6401c74d936", + "user_name": "iam_user", + "maintain_begin": "02:00:00", + "maintain_end": "06:00:00", + "enable_publicip": False, + "enable_ssl": False, + "service_upgrade": False, + "service_task_id": "", + "available_zones": [ + "eu-de-03" + ], + "subnet_id": "25d24fc8-d019-4a34-9fff-0a09fde6a9cb", + "security_group_id": "bb0e60ab-b6e0-4c61-a503-63213c18effa" +} + +instance = conn.dcs.create_instance(**attrs) +print(instance) +''' diff --git a/examples/dcs/delete_backup.py b/examples/dcs/delete_backup.py new file mode 100644 index 000000000..d2df332f0 --- /dev/null +++ b/examples/dcs/delete_backup.py @@ -0,0 +1,28 @@ +#!/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 a backup of a Distributed Cache Service instance. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +backup = 'backup_id' +instance = 'instance_id' +conn.dcs.delete_instance_backup( + backup=backup, + instance=instance, + ignore_missing=True +) diff --git a/examples/dcs/delete_instance.py b/examples/dcs/delete_instance.py new file mode 100644 index 000000000..fc109224a --- /dev/null +++ b/examples/dcs/delete_instance.py @@ -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 Distributed Message Service Instance by id or name +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance_id = "instance_id" +conn.dcs.delete_instance(instance_id) diff --git a/examples/dcs/extend_instance.py b/examples/dcs/extend_instance.py new file mode 100644 index 000000000..31b8eef62 --- /dev/null +++ b/examples/dcs/extend_instance.py @@ -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. +""" +Extend a Distributed Message Service Instance with additional RAM +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +instance = 'instance_id_or_class_instance' +capacity = 8 +conn.dcs.extend_instance(instance, capacity) diff --git a/examples/dcs/find_instance.py b/examples/dcs/find_instance.py new file mode 100644 index 000000000..aa96e350e --- /dev/null +++ b/examples/dcs/find_instance.py @@ -0,0 +1,24 @@ +#!/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. +""" +Find Distributed Message Service Instance by id or name +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = "dcs-test" +instance = conn.dcs.find_instance(instance) +print(instance) diff --git a/examples/dcs/get_instance.py b/examples/dcs/get_instance.py new file mode 100644 index 000000000..f3a32f49a --- /dev/null +++ b/examples/dcs/get_instance.py @@ -0,0 +1,24 @@ +#!/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. +""" +Get Distributed Message Service Instance by id or class Instance +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = "instance_id" +instance = conn.dcs.get_instance(instance) +print(instance) diff --git a/examples/dcs/list_backups.py b/examples/dcs/list_backups.py new file mode 100644 index 000000000..bef4efc3a --- /dev/null +++ b/examples/dcs/list_backups.py @@ -0,0 +1,24 @@ +#!/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 Backups of a Distributed Message Service instance +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = "instance_id" +for backup in conn.dcs.backups(instance): + print(backup) diff --git a/examples/dcs/list_instance_params.py b/examples/dcs/list_instance_params.py new file mode 100644 index 000000000..498bee812 --- /dev/null +++ b/examples/dcs/list_instance_params.py @@ -0,0 +1,24 @@ +#!/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 Backups of a Distributed Message Service instance +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = 'instance_id' +for param in conn.dcs.instance_params(instance): + print(param) diff --git a/examples/dcs/list_instances.py b/examples/dcs/list_instances.py new file mode 100644 index 000000000..681481454 --- /dev/null +++ b/examples/dcs/list_instances.py @@ -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 Distributed Cache Service instances +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +for instance in conn.dcs.instances(): + print(instance) diff --git a/examples/dcs/list_restore_records.py b/examples/dcs/list_restore_records.py new file mode 100644 index 000000000..dd70fa558 --- /dev/null +++ b/examples/dcs/list_restore_records.py @@ -0,0 +1,24 @@ +#!/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 Restore Records of a Distributed Message Service instance +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = 'instance_id' +for rr in conn.dcs.restore_records(instance): + print(rr) diff --git a/examples/dcs/list_statistics.py b/examples/dcs/list_statistics.py new file mode 100644 index 000000000..f67880355 --- /dev/null +++ b/examples/dcs/list_statistics.py @@ -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 statistics of all DCS instances +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +for statistic in conn.dcs.statistics(): + print(statistic) diff --git a/examples/dcs/restart_instance.py b/examples/dcs/restart_instance.py new file mode 100644 index 000000000..4e1db1ec4 --- /dev/null +++ b/examples/dcs/restart_instance.py @@ -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. +""" +Start a Distributed Message Service Instance +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = "instance_id_or_name" +conn.dcs.restart_instance(instance) diff --git a/examples/dcs/restore_instance.py b/examples/dcs/restore_instance.py new file mode 100644 index 000000000..c75af89ed --- /dev/null +++ b/examples/dcs/restore_instance.py @@ -0,0 +1,29 @@ +#!/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. +""" +Restore a Distributed Cache Service instance. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = 'instance_id' +backup_id = 'backup_id' +restore = conn.dcs.restore_instance( + instance=instance, + backup_id=backup_id, + description='Test restore of DCS instance' +) +print(restore) diff --git a/examples/dcs/start_instance.py b/examples/dcs/start_instance.py new file mode 100644 index 000000000..47d6378c5 --- /dev/null +++ b/examples/dcs/start_instance.py @@ -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. +""" +Start a Distributed Message Service Instance +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = "instance_id_or_name" +conn.dcs.start_instance(instance) diff --git a/examples/dcs/stop_instance.py b/examples/dcs/stop_instance.py new file mode 100644 index 000000000..364dbd3c6 --- /dev/null +++ b/examples/dcs/stop_instance.py @@ -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. +""" +Stop a Distributed Message Service Instance +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = "instance_id_or_name" +conn.dcs.stop_instance(instance) diff --git a/examples/dcs/update_instance.py b/examples/dcs/update_instance.py new file mode 100644 index 000000000..2fb870355 --- /dev/null +++ b/examples/dcs/update_instance.py @@ -0,0 +1,27 @@ +#!/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. +""" +Update Distributed Cache Service Instance +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +attrs = { + "name": "dcs002", + "description": "instance description", +} + +instance = conn.dcs.get_instance("ca9697c4-9ddb-4474-9304-576dbf973b00") +conn.dcs.update_instance(instance, **attrs) diff --git a/examples/dcs/update_instance_params.py b/examples/dcs/update_instance_params.py new file mode 100644 index 000000000..15222fd5d --- /dev/null +++ b/examples/dcs/update_instance_params.py @@ -0,0 +1,27 @@ +#!/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. +""" +Update Distributed Cache Service Instance +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +instance = 'instance_id' +params = None +conn.dcs.update_instance_params( + instance=instance, + params=params +) diff --git a/examples/dns/add_router_to_zone.py b/examples/dns/add_router_to_zone.py new file mode 100644 index 000000000..b0cfa70b7 --- /dev/null +++ b/examples/dns/add_router_to_zone.py @@ -0,0 +1,28 @@ +#!/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 VPC/Router to existing zone +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +router = conn.dns.add_router_to_zone( + zone='zone_id', + router_id='router_id', + router_region='eu-de' +) +print(router) diff --git a/examples/dns/create_recordset.py b/examples/dns/create_recordset.py new file mode 100644 index 000000000..82faed0a1 --- /dev/null +++ b/examples/dns/create_recordset.py @@ -0,0 +1,33 @@ +#!/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 DNS recordset +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +recordset = conn.dns.create_recordset( + zone='zone_id', + name='recordset.my-zone.', + description='My new recordset', + type='A', + ttl=300, + records=[ + '192.168.2.4' + ] +) +print(recordset) diff --git a/examples/dns/create_zone.py b/examples/dns/create_zone.py new file mode 100644 index 000000000..dee789688 --- /dev/null +++ b/examples/dns/create_zone.py @@ -0,0 +1,49 @@ +#!/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 DNS zone +""" +import openstack +from otcextensions.sdk.dns.v2.zone import Router + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +zone = conn.dns.create_zone( + name='private-zone', + description='My private Zone', + zone_type='private', + ttl=300, + email='zone-admin@example.com', + router=Router(router_id='vpc_id', + router_region='eu-de' + ) +) +print(zone) + +''' +attrs = { + "name": "private-zone.", + "description": "My private Zone", + "zone_type": "private", + "email": "zone-admin@example.com", + "router": { + "router_id": "vpc_id", + "router_region": "eu-de" + } +} + +zone = conn.dns.create_zone(**attrs) +print(zone) +''' diff --git a/examples/dns/delete_recordset.py b/examples/dns/delete_recordset.py new file mode 100644 index 000000000..1a9bc753d --- /dev/null +++ b/examples/dns/delete_recordset.py @@ -0,0 +1,24 @@ +#!/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 DNS recordset by id or class Recordset +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +zone = 'zone_id' +recordset = 'recordset_id' +conn.dns.delete_recordset(zone=zone, recordset=recordset, ignore_missing=True) diff --git a/examples/dns/delete_zone.py b/examples/dns/delete_zone.py new file mode 100644 index 000000000..98d3a9e85 --- /dev/null +++ b/examples/dns/delete_zone.py @@ -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 a DNS zone by id or class Zone +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +zone = 'zone_id' +zone = conn.dns.delete_zone(zone) diff --git a/examples/dns/find_recordset.py b/examples/dns/find_recordset.py new file mode 100644 index 000000000..fec719da2 --- /dev/null +++ b/examples/dns/find_recordset.py @@ -0,0 +1,25 @@ +#!/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. +""" +Find DNS recordset by name or id +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +zone = 'zone_id' +name_or_id = 'recordset_name_or_id' +recordset = conn.dns.find_recordset(zone=zone, name_or_id=name_or_id) +print(recordset) diff --git a/examples/dns/find_zone.py b/examples/dns/find_zone.py new file mode 100644 index 000000000..06a0a103f --- /dev/null +++ b/examples/dns/find_zone.py @@ -0,0 +1,24 @@ +#!/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. +""" +Find DNS zone by name or id +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +zone = 'private-zone.' +zone = conn.dns.find_zone(zone) +print(zone) diff --git a/examples/dns/get_floating_ip.py b/examples/dns/get_floating_ip.py new file mode 100644 index 000000000..9779da401 --- /dev/null +++ b/examples/dns/get_floating_ip.py @@ -0,0 +1,25 @@ +#!/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. +""" +Get DNS Floating IP PTR record by id or class Zone +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +fip = ':' +# example: fip = 'eu-de:b700387d-5209-45b3-ac45-313ded1077cc' +fip = conn.dns.get_floating_ip(fip) +print(fip) diff --git a/examples/dns/get_recordset.py b/examples/dns/get_recordset.py new file mode 100644 index 000000000..2f2b4bc5b --- /dev/null +++ b/examples/dns/get_recordset.py @@ -0,0 +1,25 @@ +#!/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. +""" +Get DNS recordset by id or class Recordset +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +zone = 'zone_id' +recordset = 'recordset_id' +recordset = conn.dns.get_recordset(zone=zone, recordset=recordset) +print(recordset) diff --git a/examples/dns/get_zone.py b/examples/dns/get_zone.py new file mode 100644 index 000000000..ae37a153e --- /dev/null +++ b/examples/dns/get_zone.py @@ -0,0 +1,24 @@ +#!/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. +""" +Get DNS zone by id or class Zone +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +zone = 'zone_id' +zone = conn.dns.get_zone(zone) +print(zone) diff --git a/examples/dns/list_floating_ips.py b/examples/dns/list_floating_ips.py new file mode 100644 index 000000000..6dbd705cc --- /dev/null +++ b/examples/dns/list_floating_ips.py @@ -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 DNS Floating IP PTR Records +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +for fip in conn.dns.floating_ips(): + print(fip) diff --git a/examples/dns/list_nameservers.py b/examples/dns/list_nameservers.py new file mode 100644 index 000000000..2265547e8 --- /dev/null +++ b/examples/dns/list_nameservers.py @@ -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 Nameserver of a DNS Zone +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +zone = 'zone_id' +for nameserver in conn.dns.nameservers(zone=zone): + print(nameserver) diff --git a/examples/dns/list_recordsets.py b/examples/dns/list_recordsets.py new file mode 100644 index 000000000..d9b0740d6 --- /dev/null +++ b/examples/dns/list_recordsets.py @@ -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 Recordsets of a DNS Zone +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +zone = 'zone_id' +for recordset in conn.dns.recordsets(zone=zone): + print(recordset) diff --git a/examples/dns/list_zones.py b/examples/dns/list_zones.py new file mode 100644 index 000000000..b707aff08 --- /dev/null +++ b/examples/dns/list_zones.py @@ -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 DNS Zones of a specific type +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +for zone in conn.dns.zones(zone_type='private'): + print(zone) diff --git a/examples/dns/remove_router_from_zone.py b/examples/dns/remove_router_from_zone.py new file mode 100644 index 000000000..f31499ced --- /dev/null +++ b/examples/dns/remove_router_from_zone.py @@ -0,0 +1,27 @@ +#!/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. +""" +Remove router from existing zone +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +router = conn.dns.remove_router_from_zone( + zone='zone_id', + router_id='router_id', +) +print(router) diff --git a/examples/dns/set_floating_ip.py b/examples/dns/set_floating_ip.py new file mode 100644 index 000000000..d5d699e1d --- /dev/null +++ b/examples/dns/set_floating_ip.py @@ -0,0 +1,29 @@ +#!/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. +""" +Set a DNS Floating IP PTR record +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +fip = conn.dns.set_floating_ip( + floating_ip='floating_ip_id', + ptrdname='test.domain.', + description='My Floating IP PTR record', + ttl=300 +) +print(fip) diff --git a/examples/dns/unset_floating_ip.py b/examples/dns/unset_floating_ip.py new file mode 100644 index 000000000..97b5b5353 --- /dev/null +++ b/examples/dns/unset_floating_ip.py @@ -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. +""" +Unset a DNS Floating IP PTR record +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +floating_ip = 'floating_ip_id' +conn.dns.unset_floating_ip(floating_ip=floating_ip) diff --git a/examples/dns/update_floating_ip.py b/examples/dns/update_floating_ip.py new file mode 100644 index 000000000..d4cd57d83 --- /dev/null +++ b/examples/dns/update_floating_ip.py @@ -0,0 +1,28 @@ +#!/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. +""" +Update a DNS recordset with new parameters +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +floating_ip = conn.dns.update_floating_ip( + floating_ip='floating_ip_id', + ptrdname='update.test.', + description='My updated Floating IP PTR record', + ttl=3600 +) +print(floating_ip) diff --git a/examples/dns/update_recordset.py b/examples/dns/update_recordset.py new file mode 100644 index 000000000..2b52c227e --- /dev/null +++ b/examples/dns/update_recordset.py @@ -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. +""" +Update a DNS recordset with new parameters +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +recordset = conn.dns.update_recordset( + zone_id='zone_id', + recordset='recordset_id', + description='This is another description', + ttl=3600, + records=[ + '192.168.2.4', + '192.168.2.5' + ] +) +print(recordset) diff --git a/examples/dns/update_zone.py b/examples/dns/update_zone.py new file mode 100644 index 000000000..f6369f4f4 --- /dev/null +++ b/examples/dns/update_zone.py @@ -0,0 +1,27 @@ +#!/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. +""" +Update a DNS zone with new parameters +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +zone = conn.dns.update_zone( + zone='zone_id', + description='My other private Zone', + ttl=400 +) +print(zone) diff --git a/examples/kms/cancel_key_deletion.py b/examples/kms/cancel_key_deletion.py new file mode 100644 index 000000000..0a5ba9557 --- /dev/null +++ b/examples/kms/cancel_key_deletion.py @@ -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. +""" +Cancel KMS CMK deletion +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +key = 'cmk_id' +conn.kms.cancel_key_deletion(key) diff --git a/examples/kms/create_datakey.py b/examples/kms/create_datakey.py new file mode 100644 index 000000000..4fa6f208c --- /dev/null +++ b/examples/kms/create_datakey.py @@ -0,0 +1,26 @@ +#!/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 KMS data encryption key +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +dek = conn.kms.create_datakey( + key_id='cmk_id', + datakey_length='512' +) +print(dek) diff --git a/examples/kms/create_datakey_without_plaintext.py b/examples/kms/create_datakey_without_plaintext.py new file mode 100644 index 000000000..426a2f4f5 --- /dev/null +++ b/examples/kms/create_datakey_without_plaintext.py @@ -0,0 +1,26 @@ +#!/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 KMS data encryption key without plain text +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +dek = conn.kms.create_datakey_wo_plain( + key_id='cmk_id', + datakey_length='512' +) +print(dek) diff --git a/examples/kms/create_key.py b/examples/kms/create_key.py new file mode 100644 index 000000000..885a7c597 --- /dev/null +++ b/examples/kms/create_key.py @@ -0,0 +1,27 @@ +#!/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 KMS cmk +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +key = conn.kms.create_key( + key_alias='cmk_name', + description='My KMS cmk' +) +print(key) diff --git a/examples/kms/decrypt_datakey.py b/examples/kms/decrypt_datakey.py new file mode 100644 index 000000000..add0d5847 --- /dev/null +++ b/examples/kms/decrypt_datakey.py @@ -0,0 +1,27 @@ +#!/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. +""" +Decrypt a KMS data encryption key +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +data = conn.kms.decrypt_datakey( + key_id='cmk_id', + cypher_text='64_bit_cypher', + datakey_cypher_length='64' +) +print(data) diff --git a/examples/kms/disable_key.py b/examples/kms/disable_key.py new file mode 100644 index 000000000..0b572f053 --- /dev/null +++ b/examples/kms/disable_key.py @@ -0,0 +1,24 @@ +#!/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. +""" +Disable a KMS cmk +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +key = 'cmk_id' +key = conn.kms.disable_key(key) +print(key) diff --git a/examples/kms/enable_key.py b/examples/kms/enable_key.py new file mode 100644 index 000000000..57168ed2e --- /dev/null +++ b/examples/kms/enable_key.py @@ -0,0 +1,24 @@ +#!/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. +""" +Enable a KMS cmk +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +key = 'cmk_id' +key = conn.kms.enable_key(key) +print(key) diff --git a/examples/kms/encrypt_datakey.py b/examples/kms/encrypt_datakey.py new file mode 100644 index 000000000..e01c23aac --- /dev/null +++ b/examples/kms/encrypt_datakey.py @@ -0,0 +1,27 @@ +#!/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. +""" +Encrypt a KMS data encryption key +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +data = conn.kms.encrypt_datakey( + key_id='cmk_id', + plain_text='64_bit_key', + datakey_plain_length='64' +) +print(data) diff --git a/examples/kms/find_key.py b/examples/kms/find_key.py new file mode 100644 index 000000000..62b80a8f3 --- /dev/null +++ b/examples/kms/find_key.py @@ -0,0 +1,24 @@ +#!/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. +""" +Find DNS cmk by name or id +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +key = 'cmk_name_or_id' +key = conn.kms.find_key(key) +print(key) diff --git a/examples/kms/generate_random_data.py b/examples/kms/generate_random_data.py new file mode 100644 index 000000000..6736ae074 --- /dev/null +++ b/examples/kms/generate_random_data.py @@ -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. +""" +Generate Random Data +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +data = conn.kms.generate_random(random_data_length=512) +print(data) diff --git a/examples/kms/get_instance_number.py b/examples/kms/get_instance_number.py new file mode 100644 index 000000000..9472afe9c --- /dev/null +++ b/examples/kms/get_instance_number.py @@ -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. +""" +Get encrypted Key Instance Number +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +instances = conn.kms.get_instance_number() +print(instances) diff --git a/examples/kms/get_key.py b/examples/kms/get_key.py new file mode 100644 index 000000000..da4578302 --- /dev/null +++ b/examples/kms/get_key.py @@ -0,0 +1,24 @@ +#!/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. +""" +Get a KMS cmk +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +key = 'cmk_id' +key = conn.kms.get_key(key) +print(key) diff --git a/examples/kms/list_keys.py b/examples/kms/list_keys.py new file mode 100644 index 000000000..42b988749 --- /dev/null +++ b/examples/kms/list_keys.py @@ -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 KMS keys +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for key in conn.kms.keys(): + print(key) diff --git a/examples/kms/list_quotas.py b/examples/kms/list_quotas.py new file mode 100644 index 000000000..c6ab92ee2 --- /dev/null +++ b/examples/kms/list_quotas.py @@ -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 KMS quotas +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for quota in conn.kms.quotas(): + print(quota) diff --git a/examples/kms/schedule_key_deletion.py b/examples/kms/schedule_key_deletion.py new file mode 100644 index 000000000..c96da03ec --- /dev/null +++ b/examples/kms/schedule_key_deletion.py @@ -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. +""" +Schedule KMS CMK deletion +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +key = 'cmk_id' +conn.kms.schedule_key_deletion(key) diff --git a/examples/nat/create_dnat_rule.py b/examples/nat/create_dnat_rule.py new file mode 100644 index 000000000..9ae78dffa --- /dev/null +++ b/examples/nat/create_dnat_rule.py @@ -0,0 +1,42 @@ +#!/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 DNAT Rule +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +nat_gateway_id = 'nat_gateway_id' +port_id = 'network_id' +private_ip = '192.168.199.3' +floating_ip_id = 'floating_ip_id' +protocol = 'TCP' +internal_service_port = 80 +external_service_port = 80 + + +attrs = { + "nat_gateway_id": nat_gateway_id, + "private_ip": private_ip, + "port_id": port_id, + "protocol": protocol, + "internal_service_port": internal_service_port, + "external_service_port": external_service_port, + "floating_ip_id": floating_ip_id +} + +dnat_rule = conn.nat.create_dnat_rule(**attrs) +print(dnat_rule) diff --git a/examples/nat/create_gateway.py b/examples/nat/create_gateway.py new file mode 100644 index 000000000..12ccc7ece --- /dev/null +++ b/examples/nat/create_gateway.py @@ -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. +""" +Create a NAT Gateway +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +attrs = { + "name": "nat_001", + "description": "my nat gateway 01", + "router_id": "d84f345c-80a1-4fa2-a39c-d0d397c3f09a", + "internal_network_id": "89d66639-aacb-4929-969d-07080b0f9fd9", + "spec": "1" +} + +gateway = conn.nat.create_gateway(**attrs) +print(gateway) diff --git a/examples/nat/create_snat_rule.py b/examples/nat/create_snat_rule.py new file mode 100644 index 000000000..c7aa49a30 --- /dev/null +++ b/examples/nat/create_snat_rule.py @@ -0,0 +1,33 @@ +#!/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 SNAT Rule +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +nat_gateway_id = 'nat_gateway_id' +network_id = 'network_id' +floating_ip_id = 'floating_ip_id' + +attrs = { + "nat_gateway_id": nat_gateway_id, + "network_id": network_id, + "floating_ip_id": floating_ip_id +} + +snat_rule = conn.nat.create_snat_rule(**attrs) +print(snat_rule) diff --git a/examples/nat/delete_dnat_rule.py b/examples/nat/delete_dnat_rule.py new file mode 100644 index 000000000..5f1135a5a --- /dev/null +++ b/examples/nat/delete_dnat_rule.py @@ -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 a DNAT Rule By DNAT-Rule-ID +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +dnat_rule_id = 'dnat_rule_id' +conn.nat.delete_dnat_rule(dnat_rule_id) diff --git a/examples/nat/delete_gateway.py b/examples/nat/delete_gateway.py new file mode 100644 index 000000000..d87b4f96a --- /dev/null +++ b/examples/nat/delete_gateway.py @@ -0,0 +1,24 @@ +#!/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 a NAT Gateway by gateway_id or instance of Gateway class +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +name_or_id = 'gateway_name_or_id' +gateway = conn.nat.find_gateway(name_or_id=name_or_id, ignore_missing=False) +conn.nat.delete_gateway(gateway) diff --git a/examples/nat/delete_snat_rule.py b/examples/nat/delete_snat_rule.py new file mode 100644 index 000000000..1a04a696d --- /dev/null +++ b/examples/nat/delete_snat_rule.py @@ -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 a SNAT Rule By SNAT-Rule-ID +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +snat_rule_id = 'snat_rule_id' +conn.nat.delete_snat_rule(snat_rule_id) diff --git a/examples/nat/find_gateway.py b/examples/nat/find_gateway.py new file mode 100644 index 000000000..27923c845 --- /dev/null +++ b/examples/nat/find_gateway.py @@ -0,0 +1,24 @@ +#!/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. +""" +Find a NAT Gateway by name or id +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +name_or_id = 'gateway_name_or_id' +gateway = conn.nat.find_gateway(name_or_id, ignore_missing=False) +print(gateway) diff --git a/examples/nat/get_dnat_rule.py b/examples/nat/get_dnat_rule.py new file mode 100644 index 000000000..d9f196dae --- /dev/null +++ b/examples/nat/get_dnat_rule.py @@ -0,0 +1,24 @@ +#!/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. +""" +Get a DNAT Rule Details by DNAT-Rule-ID or instance of Dnat Class +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +dnat_rule_id = 'dnat_rule_id' +dnat_rule = conn.nat.get_dnat_rule(dnat_rule_id) +print(dnat_rule) diff --git a/examples/nat/get_gateway.py b/examples/nat/get_gateway.py new file mode 100644 index 000000000..c31d5b7cf --- /dev/null +++ b/examples/nat/get_gateway.py @@ -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. +""" +Get details of NAT Gateway by gateway_id or instance of Gateway class +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +gateway = 'gateway_id' +gateway = conn.nat.get_gateway(gateway) +print(gateway) diff --git a/examples/nat/get_snat_rule.py b/examples/nat/get_snat_rule.py new file mode 100644 index 000000000..891a36de9 --- /dev/null +++ b/examples/nat/get_snat_rule.py @@ -0,0 +1,24 @@ +#!/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. +""" +Get a SNAT Rule Details by SNAT-Rule-ID +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +snat_rule_id = 'snat_rule_id' +snat_rule = conn.nat.get_snat_rule(snat_rule_id) +print(snat_rule) diff --git a/examples/nat/list_dnat_rules.py b/examples/nat/list_dnat_rules.py new file mode 100644 index 000000000..7839a4a18 --- /dev/null +++ b/examples/nat/list_dnat_rules.py @@ -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 DNAT Rules +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for dnat_rule in conn.nat.dnat_rules(): + print(dnat_rule) diff --git a/examples/nat/list_gateways.py b/examples/nat/list_gateways.py new file mode 100644 index 000000000..ed56a0c1c --- /dev/null +++ b/examples/nat/list_gateways.py @@ -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 NAT Gateways +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for gateway in conn.nat.gateways(): + print(gateway) diff --git a/examples/nat/list_snat_rules.py b/examples/nat/list_snat_rules.py new file mode 100644 index 000000000..074d2c6d1 --- /dev/null +++ b/examples/nat/list_snat_rules.py @@ -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 SNAT Rules +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for snat_rule in conn.nat.snat_rules(): + print(snat_rule) diff --git a/examples/nat/update_gateway.py b/examples/nat/update_gateway.py new file mode 100644 index 000000000..081f2c1a1 --- /dev/null +++ b/examples/nat/update_gateway.py @@ -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. +""" +Update a NAT Gateway by gateway_id or instance of Gateway class +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +attrs = { + "name": "new_name", + "description": "new description", + "spec": "1" +} + +name_or_id = 'gateway_name_or_id' +gateway = conn.nat.find_gateway(name_or_id, ignore_missing=False) +response = conn.nat.update_gateway(gateway, **attrs) +print(response) diff --git a/examples/rds/apply_configuration.py b/examples/rds/apply_configuration.py new file mode 100644 index 000000000..d242a0370 --- /dev/null +++ b/examples/rds/apply_configuration.py @@ -0,0 +1,29 @@ +#!/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. +""" +Apply a RDS configuration to a several RDS instances +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +configuration = '43f3a58705aa43bf9cfa4f06df80552epr01' +instance_list = [ + 'instance_id1', + 'instance_id2' +] +response = conn.rds.apply_configuration(configuration=configuration, + instances=instance_list) +print(response) diff --git a/examples/rds/create_backup.py b/examples/rds/create_backup.py new file mode 100644 index 000000000..756da6319 --- /dev/null +++ b/examples/rds/create_backup.py @@ -0,0 +1,25 @@ +#!/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 backup of an RDS instance +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +backup = conn.rds.create_backup(instance='instance_id', + name='my_backup', + description='This is new') +print(backup) diff --git a/examples/rds/create_configuration.py b/examples/rds/create_configuration.py new file mode 100644 index 000000000..79ba8e3e4 --- /dev/null +++ b/examples/rds/create_configuration.py @@ -0,0 +1,33 @@ +#!/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 RDS configuration +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +datastore = { + 'type': 'mysql', + 'version': '8.0' +} +values = { + 'max_connections': '10' +} +config = conn.rds.create_configuration(name='configuration_name_or_id', + description='my config', + datastore=datastore, + values=values) +print(config) diff --git a/examples/rds/create_instance.py b/examples/rds/create_instance.py new file mode 100644 index 000000000..ff55be534 --- /dev/null +++ b/examples/rds/create_instance.py @@ -0,0 +1,59 @@ +#!/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 RDS instance +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +attrs = { + "name": "rds_name", + "port": 3306, + "ha": { + "mode": "Ha", + "replication_mode": "async" + }, + "region": "eu-de", + "datastore": { + "type": "MySQL", + "version": "8.0" + }, + "volume": { + "type": "ULTRAHIGH", + "size": 40 + }, + "password": "admin_password", + "private_ips": [], + "public_ips": [], + "db_user_name": "root", + "availability_zone": "eu-de-01,eu-de-02", + "vpc_id": "vpc_id", + "subnet_id": "network_id_of_the_subnet", + "security_group_id": "secgrp_id", + "flavor_ref": "rds.mysql.c2.medium.ha", + "switch_strategy": "reliability", + "backup_strategy": { + "start_time": "23:00-00:00", + "keep_days": 10 + }, + "charge_info": { + "charge_mode": "postPaid" + } +} + +instance = conn.rds.create_instance(**attrs) +print(instance) diff --git a/examples/rds/delete_configuration.py b/examples/rds/delete_configuration.py new file mode 100644 index 000000000..684495d27 --- /dev/null +++ b/examples/rds/delete_configuration.py @@ -0,0 +1,24 @@ +#!/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 a RDS configuration template by ID +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +name_or_id = 'configuration' +configuration = conn.rds.find_configuration(name_or_id=name_or_id) +conn.rds.delete_configuration(configuration) diff --git a/examples/rds/find_backup.py b/examples/rds/find_backup.py new file mode 100644 index 000000000..71781f3d5 --- /dev/null +++ b/examples/rds/find_backup.py @@ -0,0 +1,26 @@ +#!/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. +""" +Find an RDS backup by name or id +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +name_or_id = 'backup_name_or_id' +instance = 'instance_id' +backup = conn.rds.find_backup(instance=instance, + name_or_id=name_or_id) +print(backup) diff --git a/examples/rds/find_configuration.py b/examples/rds/find_configuration.py new file mode 100644 index 000000000..48a590f2e --- /dev/null +++ b/examples/rds/find_configuration.py @@ -0,0 +1,24 @@ +#!/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. +""" +Find an RDS configuration +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +name_or_id = 'configuration_name_or_id' +configuration = conn.rds.find_configuration(name_or_id=name_or_id) +print(configuration) diff --git a/examples/rds/find_instance.py b/examples/rds/find_instance.py new file mode 100644 index 000000000..b2df0807c --- /dev/null +++ b/examples/rds/find_instance.py @@ -0,0 +1,24 @@ +#!/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. +""" +Find an RDS instance by name or id +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +instance = 'instance_name_or_id' +instance = conn.rds.find_instance(instance) +print(instance) diff --git a/examples/rds/get_configuration.py b/examples/rds/get_configuration.py new file mode 100644 index 000000000..21bb4d718 --- /dev/null +++ b/examples/rds/get_configuration.py @@ -0,0 +1,24 @@ +#!/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. +""" +Get a RDS configuration template by ID +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +configuration = 'configuration_id' +configuration = conn.rds.get_configuration(configuration) +print(configuration) diff --git a/examples/rds/get_instance.py b/examples/rds/get_instance.py new file mode 100644 index 000000000..4f0b476b0 --- /dev/null +++ b/examples/rds/get_instance.py @@ -0,0 +1,24 @@ +#!/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. +""" +Get a RDS instance by id or class Instance +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +instance = 'instance_id' +instance = conn.rds.get_instance(instance) +print(instance) diff --git a/examples/rds/get_instance_backup_policy.py b/examples/rds/get_instance_backup_policy.py new file mode 100644 index 000000000..2aa1135d6 --- /dev/null +++ b/examples/rds/get_instance_backup_policy.py @@ -0,0 +1,24 @@ +#!/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. +""" +Get a RDS instance backup_policy by id +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +instance = 'instance_id' +policy = conn.rds.get_instance_backup_policy(instance) +print(policy) diff --git a/examples/rds/get_instance_restore_time.py b/examples/rds/get_instance_restore_time.py new file mode 100644 index 000000000..15e06d600 --- /dev/null +++ b/examples/rds/get_instance_restore_time.py @@ -0,0 +1,24 @@ +#!/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. +""" +Get a RDS instance restore time by id +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +instance = 'instance_id' +time = conn.rds.get_instance_restore_time(instance) +print(time) diff --git a/examples/rds/list_backup_download_links.py b/examples/rds/list_backup_download_links.py new file mode 100644 index 000000000..4113e25ed --- /dev/null +++ b/examples/rds/list_backup_download_links.py @@ -0,0 +1,24 @@ +#!/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 RDS backup download links +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +backup = 'backup_id' +for link in conn.rds.backup_download_links(backup): + print(link) diff --git a/examples/rds/list_backups.py b/examples/rds/list_backups.py new file mode 100644 index 000000000..818a8f969 --- /dev/null +++ b/examples/rds/list_backups.py @@ -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 backups of an RDS instance +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for backup in conn.rds.backups(instance='instance_id'): + print(backup) diff --git a/examples/rds/list_configurations.py b/examples/rds/list_configurations.py new file mode 100644 index 000000000..852f20ccd --- /dev/null +++ b/examples/rds/list_configurations.py @@ -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 RDS configuration templates +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for config in conn.rds.configurations(): + print(config) diff --git a/examples/rds/list_datastore_types.py b/examples/rds/list_datastore_types.py new file mode 100644 index 000000000..dd5b760a3 --- /dev/null +++ b/examples/rds/list_datastore_types.py @@ -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 RDS Datastore Types +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for ds in conn.rds.datastore_types(): + print(ds.name) diff --git a/examples/rds/list_datastores.py b/examples/rds/list_datastores.py new file mode 100644 index 000000000..acc9eccf3 --- /dev/null +++ b/examples/rds/list_datastores.py @@ -0,0 +1,24 @@ +#!/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 RDS Datastores +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +db_type = 'MySQL' # or PostgreSQL, or SQLServer +for ds in conn.rds.datastores(db_type): + print(ds) diff --git a/examples/rds/list_flavors.py b/examples/rds/list_flavors.py new file mode 100644 index 000000000..34d366e4f --- /dev/null +++ b/examples/rds/list_flavors.py @@ -0,0 +1,26 @@ +#!/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 flavors of a given RDS datastore and datastore version. +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +datastore_name = 'ds_name' +version_name = 'version_name' +for flavor in conn.rds.flavors(datastore_name=datastore_name, + version_name=version_name): + print(flavor) diff --git a/examples/rds/list_instances.py b/examples/rds/list_instances.py new file mode 100644 index 000000000..a40fdbef4 --- /dev/null +++ b/examples/rds/list_instances.py @@ -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 RDS instances +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for instance in conn.rds.instances(): + print(instance) diff --git a/examples/rds/restore_instance.py b/examples/rds/restore_instance.py new file mode 100644 index 000000000..1865c24b2 --- /dev/null +++ b/examples/rds/restore_instance.py @@ -0,0 +1,25 @@ +#!/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. +""" +Restore an RDS instance by using a backup +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +job_id = conn.rds.restore_instance(instance='instance_id', + backup='backup_id', + restore_time=None) +print(job_id) diff --git a/examples/rds/set_instance_backup_policy.py b/examples/rds/set_instance_backup_policy.py new file mode 100644 index 000000000..7349db287 --- /dev/null +++ b/examples/rds/set_instance_backup_policy.py @@ -0,0 +1,24 @@ +#!/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. +""" +Set a RDS instance backup_policy +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +instance = 'instance_id' +policy = conn.rds.get_instance_backup_policy(instance) +print(policy) diff --git a/examples/rds/update_configuration.py b/examples/rds/update_configuration.py new file mode 100644 index 000000000..821e4c310 --- /dev/null +++ b/examples/rds/update_configuration.py @@ -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. +""" +Update a RDS configuration template +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +values = { + 'max_connections': '11' +} +name_or_id = 'configuration_name_or_id' +configuration = conn.rds.find_configuration(name_or_id=name_or_id) +configuration = conn.rds.create_configuration(config=configuration, + name='configuration_update', + description='my new config', + values=values) +print(configuration) diff --git a/examples/rds/wait_for_backup.py b/examples/rds/wait_for_backup.py new file mode 100644 index 000000000..99bcc12eb --- /dev/null +++ b/examples/rds/wait_for_backup.py @@ -0,0 +1,27 @@ +#!/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. +""" +Wait for a backup to be finished. +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +backup = conn.rds.create_backup(instance='instance_id', + name='my_backup', + description='This is new') +conn.rds.wait_for_backup(backup=backup, status='COMPLETED', + interval=2, wait=300) +print(backup) diff --git a/otcextensions/osclient/kms/v1/cmk.py b/otcextensions/osclient/kms/v1/cmk.py index 70cb63658..cad2da68f 100644 --- a/otcextensions/osclient/kms/v1/cmk.py +++ b/otcextensions/osclient/kms/v1/cmk.py @@ -235,7 +235,6 @@ class CreateCMK(command.ShowOne): columns = ['ID', 'key_alias', 'domain_id', 'realm', 'key_description', 'creation_date', 'scheduled_deletion_date', 'key_state', 'key_type'] -# POLICY_TYPES = ['ALARM', 'SCHEDULED', 'RECURRENCE'] def get_parser(self, prog_name): diff --git a/otcextensions/osclient/rds/v3/instance.py b/otcextensions/osclient/rds/v3/instance.py index 5b1fc6e40..63c0c7614 100644 --- a/otcextensions/osclient/rds/v3/instance.py +++ b/otcextensions/osclient/rds/v3/instance.py @@ -82,8 +82,8 @@ def get_parser(self, prog_name): type=lambda s: s.lower(), choices=HA_TYPE_CHOICES, help=_( - 'Specifies the instance type. Values cane be single/ha/replica' - )) + 'Specifies the instance type. ' + 'Values cane be single/ha/replica.')) parser.add_argument( '--datastore-type', metavar='{' + ','.join(DATASTORE_TYPE_CHOICES) + '}', @@ -168,7 +168,6 @@ def take_action(self, parsed_args): class CreateDatabaseInstance(command.ShowOne): - _description = _("Create a new database instance.") def get_parser(self, prog_name): @@ -268,7 +267,7 @@ def get_parser(self, prog_name): '--security-group-id', dest='security_group', metavar='', - help=_('Security group ID') + help=_('Security group ID.') ) parser.add_argument( '--ha-mode', @@ -276,13 +275,13 @@ def get_parser(self, prog_name): type=lambda s: s.lower(), choices=HA_MODE_CHOICES, help=_('replication mode for the standby DB instance. ' - 'This parameter is required when using `ha`flavors') + 'This parameter is required when using `ha` flavors.') ) parser.add_argument( '--charge-mode', metavar='', default='postPaid', - help=_('Specifies the billing mode') + help=_('Specifies the billing mode.') ) create_from_group = parser.add_argument_group( 'Create FROM group', diff --git a/otcextensions/sdk/cts/v1/_proxy.py b/otcextensions/sdk/cts/v1/_proxy.py index 419bcf781..8c950ee06 100644 --- a/otcextensions/sdk/cts/v1/_proxy.py +++ b/otcextensions/sdk/cts/v1/_proxy.py @@ -65,7 +65,7 @@ def update_tracker(self, tracker, **attrs): """ return self._update(_tracker.Tracker, tracker, **attrs) - def delete_tracker(self, tracker, ignore_missing=True): + def delete_tracker(self, tracker='system', ignore_missing=True): """Delete a tracker :param tracker: The value can be the ID of a tracker or a @@ -81,6 +81,5 @@ def delete_tracker(self, tracker, ignore_missing=True): :rtype: :class:`~otcextensions.sdk.cts.v2.tracker.Tracker` """ - return self._delete(_tracker.Tracker, - tracker, - ignore_missing=ignore_missing) + tracker = self._get_resource(_tracker.Tracker, tracker) + return tracker._delete_tracker(self, tracker.id) diff --git a/otcextensions/sdk/cts/v1/tracker.py b/otcextensions/sdk/cts/v1/tracker.py index 689607887..c81c7ffc7 100644 --- a/otcextensions/sdk/cts/v1/tracker.py +++ b/otcextensions/sdk/cts/v1/tracker.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. from openstack import resource +from openstack import exceptions from otcextensions.common import exc @@ -69,6 +70,14 @@ class Tracker(resource.Resource): #: SMN smn = resource.Body('smn', type=Smn) + def _delete_tracker(self, session, tracker): + """Delete Tracker + """ + url = self.base_path + '?tracker_name={}'.format(tracker) + response = session.delete(url) + exceptions.raise_from_response(response) + return None + def _translate_response(self, response, has_body=None, error_message=None): """Given a KSA response, inflate this instance with its data diff --git a/otcextensions/sdk/dcs/v1/_proxy.py b/otcextensions/sdk/dcs/v1/_proxy.py index 35aa86a1b..86d5ec72b 100644 --- a/otcextensions/sdk/dcs/v1/_proxy.py +++ b/otcextensions/sdk/dcs/v1/_proxy.py @@ -42,7 +42,7 @@ def instances(self, **query): def get_instance(self, instance): """Get detail about a given instance - :param instance: The instance id, name or an instance of + :param instance: The instance id or an instance of :class:`~otcextensions.sdk.dcs.v1.instance.Instance` :returns: one object of class :class:`~otcextensions.sdk.dcs.v1.instance.Instance` @@ -183,7 +183,8 @@ def backups(self, instance, **query): _backup.Backup, paginated=False, instance_id=inst.id, **query) - def delete_instance_backup(self, backup, ignore_missing=True, **attrs): + def delete_instance_backup(self, instance, backup, ignore_missing=True, + **attrs): """Delete an instance backup :param backup: The instance id, an instance of @@ -193,7 +194,8 @@ def delete_instance_backup(self, backup, ignore_missing=True, **attrs): raised when the queue does not exist. :returns: `None` """ - self._delete(_backup.Backup, backup, + inst = self._get_resource(_instance.Instance, instance) + self._delete(_backup.Backup, backup, instance_id=inst.id, ignore_missing=ignore_missing, **attrs) @@ -251,7 +253,7 @@ def update_instance_params(self, instance, params): :param instance: The value can be the ID of an instance or a :class:`~otcextensions.sdk.dcs.v1.instance.Instance` instance. - :param paramss: List of parameters of + :param params: List of parameters of a :class:`~otcextensions.sdk.dcs.v1.config.Config`. :returns: None """ diff --git a/otcextensions/sdk/dcs/v1/instance.py b/otcextensions/sdk/dcs/v1/instance.py index 77d1720d9..143ea085e 100644 --- a/otcextensions/sdk/dcs/v1/instance.py +++ b/otcextensions/sdk/dcs/v1/instance.py @@ -34,7 +34,7 @@ class Instance(resource.Resource): # Properties #: AZ where a cache node resides. #: The value of this parameter in the response contains an AZ ID. - available_zones = resource.Body('available_zones') + available_zones = resource.Body('available_zones', type=list) #: Backup policy. backup_policy = resource.Body('instance_backup_policy', type=dict) #: Cache capacity in GB diff --git a/otcextensions/sdk/dns/v2/_proxy.py b/otcextensions/sdk/dns/v2/_proxy.py index 6d7c0b3ac..64c60b080 100644 --- a/otcextensions/sdk/dns/v2/_proxy.py +++ b/otcextensions/sdk/dns/v2/_proxy.py @@ -104,6 +104,7 @@ def add_router_to_zone(self, zone, **router): :param zone: The value can be the ID of a zone or a :class:`~otcextensions.sdk.dns.v2.zone.Zone` instance. + :param router: The parameter router_id is mandatory :returns: updater instance of :class:`~otcextensions.sdk.dns.v2.zone.Router` :rtype: :class:`~otcextensions.sdk.dns.v2.zone.Router` @@ -116,6 +117,7 @@ def remove_router_from_zone(self, zone, **router): :param zone: The value can be the ID of a zone or a :class:`~otcextensions.sdk.dns.v2.zone.Zone` instance. + :param router: The parameter router_id is mandatory :returns: updater instance of :class:`~otcextensions.sdk.dns.v2.zone.Router` :rtype: :class:`~otcextensions.sdk.dns.v2.zone.Router` @@ -224,12 +226,12 @@ def find_recordset(self, zone, name_or_id, ignore_missing=True, **attrs): :param zone: The value can be the ID of a zone or a :class:`~otcextensions.sdk.dns.v2.zone.Zone` instance. - :param name_or_id: The name or ID of a zone + :param name_or_id: The name or ID of a recordset :param bool ignore_missing: When set to ``False`` :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the zone does not exist. + when the recordset does not exist. When set to ``True``, no exception will be set when attempting - to delete a nonexistent zone. + to delete a nonexistent recordset. :returns: :class:`~otcextensions.sdk.dns.v2.recordset.Recordset` """ diff --git a/otcextensions/sdk/dns/v2/nameserver.py b/otcextensions/sdk/dns/v2/nameserver.py index 8a6e01214..556ad610f 100644 --- a/otcextensions/sdk/dns/v2/nameserver.py +++ b/otcextensions/sdk/dns/v2/nameserver.py @@ -12,12 +12,11 @@ from openstack import resource from openstack import _log -from otcextensions.sdk import sdk_resource _logger = _log.setup_logging('openstack') -class NameServer(sdk_resource.Resource): +class NameServer(resource.Resource): resource_key = 'nameserver' resources_key = 'nameservers' base_path = '/zones/%(zone_id)s/nameservers' @@ -27,6 +26,7 @@ class NameServer(sdk_resource.Resource): allow_list = True allow_get = False allow_delete = False + allow_update = False #: Properties #: The ID of zone using this name-server diff --git a/otcextensions/sdk/dns/v2/zone.py b/otcextensions/sdk/dns/v2/zone.py index 32d80f045..7a179ace4 100644 --- a/otcextensions/sdk/dns/v2/zone.py +++ b/otcextensions/sdk/dns/v2/zone.py @@ -99,11 +99,11 @@ def associate_router(self, session, **router): body['router']['router_id'] = router.get('router_id') if 'router_region' in router: body['router']['router_region'] = router.get('router_region') - return self._action(session, 'accosiaterouter', body) + return self._action(session, 'associaterouter', body) def disassociate_router(self, session, **router): body = {'router': {}} body['router']['router_id'] = router.get('router_id') if 'router_region' in router: body['router']['router_region'] = router.get('router_region') - return self._action(session, 'disaccosiaterouter', body) + return self._action(session, 'disassociaterouter', body) diff --git a/otcextensions/sdk/kms/v1/_proxy.py b/otcextensions/sdk/kms/v1/_proxy.py index 4b7715e2d..b7e6f1dc4 100644 --- a/otcextensions/sdk/kms/v1/_proxy.py +++ b/otcextensions/sdk/kms/v1/_proxy.py @@ -194,6 +194,8 @@ def encrypt_datakey(self, datakey): def decrypt_datakey(self, cmk, cipher_text, datakey_cipher_length): """Decrypt a data key + :param cmk: key id or an instance of + :class:`~otcextensions.sdk.kms.v1.key.Key` :param cipher_text: encrypted value retrieved from :func:`~otcextensions.sdk.kms.v1.data_key.DataKey.encrypt` call. :param datakey_cipher_length: datakey_cipher_length (expected value 64) diff --git a/otcextensions/sdk/nat/v2/_proxy.py b/otcextensions/sdk/nat/v2/_proxy.py index 5f994c2d8..d0724ad51 100644 --- a/otcextensions/sdk/nat/v2/_proxy.py +++ b/otcextensions/sdk/nat/v2/_proxy.py @@ -25,23 +25,27 @@ def create_gateway(self, **attrs): """Create a new gateway from attributes :param dict attrs: Keyword arguments which will be used to create - a :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` + a :class:`~otcextensions.sdk.nat.v2.gateway.Gateway`, + comprised of the properties on the Gateway class. + + :returns: The results of the Gateway Creation + + :rtype: :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` """ return self._create(_gateway.Gateway, **attrs) def delete_gateway(self, gateway, ignore_missing=True): """Delete a gateway - :param gateway: key id or an instance of - :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` + :param gateway: The value can be the ID of a NAT Gatway or a + :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` instance. :param bool ignore_missing: When set to ``False`` :class:`~openstack.exceptions.ResourceNotFound` will be raised when the gateway does not exist. When set to ``True``, no exception will be set when attempting to delete a nonexistent gateway. - :returns: Gateway been deleted - :rtype: :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` + :returns: ``None`` """ return self._delete(_gateway.Gateway, gateway, ignore_missing=ignore_missing) @@ -51,8 +55,8 @@ def gateways(self, **query): :param dict query: Optional query parameters to be sent to limit the resources being returned. - :returns: A generator of gateway objects - :rtype: :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` + + :returns: A generator of gateway objects. """ return self._list(_gateway.Gateway, **query) @@ -60,40 +64,42 @@ def get_gateway(self, gateway): """Get a single gateway :param gateway: The value can be the ID of a NAT Gatway or a - :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` - instance. + :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` + instance. :returns: One :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` + :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. + when no resource can be found. """ return self._get(_gateway.Gateway, gateway) def update_gateway(self, gateway, **attrs): """Update a gateway - :param gateway: Either the ID of a gateway or a - :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` - instance. + :param gateway: The value can be either the ID of a gateway or a + :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` instance. :param dict attrs: The attributes to update on the gateway represented - by ``gateway``. + by ``gateway``. + + :returns: The updated gateway. - :returns: The updated gateway :rtype: :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` """ return self._update(_gateway.Gateway, gateway, **attrs) def find_gateway(self, name_or_id, ignore_missing=False): - """Find a single Nat Gateway + """Find a single gateway - :param name_or_id: The name or ID of a zone + :param name_or_id: The name or ID of a gateway :param bool ignore_missing: When set to ``False`` :class:`~openstack.exceptions.ResourceNotFound` will be raised when the gateway does not exist. When set to ``True``, no exception will be set when attempting - to delete a nonexistent gateway. + to find a nonexistent gateway. - :returns: ``None`` + :returns: + One :class:`~otcextensions.sdk.nat.v2.gateway.Gateway` or ``None`` """ return self._find(_gateway.Gateway, name_or_id, ignore_missing=ignore_missing) @@ -103,34 +109,40 @@ def create_snat_rule(self, **attrs): """Create a new SNAT rule from attributes :param dict attrs: Keyword arguments which will be used to create - a :class:`~otcextensions.sdk.nat.v2.snat.Snat` + a :class:`~otcextensions.sdk.nat.v2.snat.Snat`, comprised of the + properties on the Snat class. + + :returns: The result of Snat rule creation + + :rtype: :class:`~otcextensions.sdk.nat.v2.snat.Snat` """ return self._create(_snat.Snat, **attrs) def delete_snat_rule(self, snat, ignore_missing=True): """Delete a SNAT rule + :param gateway: The value can be the ID of a snat rule or a + :class:`~otcextensions.sdk.nat.v2.snat.Snat` instance. :param bool ignore_missing: When set to ``False`` :class:`~openstack.exceptions.ResourceNotFound` will be raised when - the SNAT rule does not exist. + the snat rule does not exist. When set to ``True``, no exception will be set when attempting to - delete a nonexistent SNAT rule. + delete a nonexistent snat rule. - :returns: SNAT rule been deleted - :rtype: :class:`~otcextensions.sdk.nat.v2.snat.Snat` + :returns: ``None`` """ return self._delete(_snat.Snat, snat, ignore_missing=ignore_missing) def get_snat_rule(self, snat_rule): """Get a single SNAT rule - :param snat_rule: The value can be the ID of a SNAT rule or a - :class:`~otcextensions.sdk.nat.v2.snat.Snat` - instance. + :param snat_rule: The value can be the ID of a snat rule or a + :class:`~otcextensions.sdk.nat.v2.snat.Snat` instance. :returns: One :class:`~otcextensions.sdk.nat.v2.snat.Snat` + :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. + when no resource can be found. """ return self._get(_snat.Snat, snat_rule) @@ -138,9 +150,9 @@ def snat_rules(self, **query): """Return a generator of SNAT rules :param dict query: Optional query parameters to be sent to limit - the resources being returned. - :returns: A generator of Snat rule objects - :rtype: :class:`~otcextensions.sdk.nat.v2.snat.Snat` + the snat rules being returned. + + :returns: A generator of Snat objects. """ return self._list(_snat.Snat, **query) @@ -149,36 +161,40 @@ def create_dnat_rule(self, **attrs): """Create a new DNAT rule from attributes :param dict attrs: Keyword arguments which will be used to create - a :class:`~otcextensions.sdk.nat.v2.dnat.Dnat` + a :class:`~otcextensions.sdk.nat.v2.dnat.Dnat`, comprised of the + properties on the Dnat class. + + :returns: The result of Dnat rule creation. + + :rtype: :class:`~otcextensions.sdk.nat.v2.dnat.Dnat` """ return self._create(_dnat.Dnat, **attrs) def delete_dnat_rule(self, dnat, ignore_missing=True): """Delete a DNAT rule - :param dict attrs: Keyword arguments which will be used to delete - a :class:`~otcextensions.sdk.nat.v2.dnat.Dnat` + :param gateway: The value can be the ID of a dnat rule or a + :class:`~otcextensions.sdk.nat.v2.dnat.Dnat` instance. :param bool ignore_missing: When set to ``False`` :class:`~openstack.exceptions.ResourceNotFound` will be raised when - the DNAT rule does not exist. + the dnat rule does not exist. When set to ``True``, no exception will be set when attempting to - delete a nonexistent DNAT rule. + delete a nonexistent dnat rule. - :returns: DNAT rule been deleted - :rtype: :class:`~otcextensions.sdk.nat.v2.dnat.Dnat` + :returns: ``None`` """ return self._delete(_dnat.Dnat, dnat, ignore_missing=ignore_missing) def get_dnat_rule(self, dnat_rule): """Get a single DNAT rule - :param dnat_rule: The value can be the ID of a DNAT rule or a - :class:`~otcextensions.sdk.nat.v2.dnat.Dnat` - instance. + :param snat_rule: The value can be the ID of a dnat rule or a + :class:`~otcextensions.sdk.nat.v2.dnat.Dnat` instance. :returns: One :class:`~otcextensions.sdk.nat.v2.dnat.Dnat` + :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. + when no resource can be found. """ return self._get(_dnat.Dnat, dnat_rule) @@ -187,7 +203,7 @@ def dnat_rules(self, **query): :param dict query: Optional query parameters to be sent to limit the resources being returned. - :returns: A generator of DNAT rules objects - :rtype: :class:`~otcextensions.sdk.nat.v2.dnat.Dnat` + + :returns: A generator of Dnat objects. """ return self._list(_dnat.Dnat, **query) diff --git a/otcextensions/sdk/rds/v3/_proxy.py b/otcextensions/sdk/rds/v3/_proxy.py index 985a2cb2e..4130b9121 100644 --- a/otcextensions/sdk/rds/v3/_proxy.py +++ b/otcextensions/sdk/rds/v3/_proxy.py @@ -36,8 +36,8 @@ def __init__(self, session, *args, **kwargs): def datastore_types(self): """List supported datastore types - :returns: A generator of supported datastore types - :rtype object: object with name attribte + :returns: A generator of supported datastore type objects + with name attribute. """ for ds in ['MySQL', 'PostgreSQL', 'SQLServer']: obj = type('obj', (object, ), {'name': ds}) @@ -49,7 +49,8 @@ def datastores(self, database_name): :param database_name: database store name (MySQL, PostgreSQL, or SQLServer and is case-sensitive.) - :returns: A generator of supported datastore versions + :returns: A generator of supported datastore versions. + :rtype: :class:`~otcextensions.sdk.rds.v3.datastore.Datastore` """ return self._list( @@ -65,8 +66,7 @@ def flavors(self, datastore_name, version_name): :param datastore_name: datastore_name :param version_name: version_name - :returns: A generator of flavor - :rtype: :class:`~otcextensions.sdk.rds.v3.flavor.Flavor` + :returns: A generator of flavor objects. """ return self._list(_flavor.Flavor, datastore_name=datastore_name, @@ -78,15 +78,14 @@ def create_instance(self, **attrs): """Create a new instance from attributes :param dict attrs: Keyword arguments which will be used to create - a :class:`~otcextensions.sdk.rds.v3.instance.Instance`, - comprised of the properties on the Instance class. + a :class:`~otcextensions.sdk.rds.v3.instance.Instance`, + comprised of the properties on the Instance class. + + :returns: The result of an instance creation. - :returns: The results of server creation :rtype: :class:`~otcextensions.sdk.rds.v3.instance.Instance` """ - return self._create( - _instance.Instance, - **attrs) + return self._create(_instance.Instance, **attrs) def delete_instance(self, instance, ignore_missing=True): """Delete an instance @@ -99,8 +98,7 @@ def delete_instance(self, instance, ignore_missing=True): When set to ``True``, no exception will be set when attempting to delete a nonexistent instance. - :returns: - :class:`~otcextensions.sdk.rds.v3.instance.Instance` instance. + :returns: ``None`` """ return self._delete( _instance.Instance, @@ -111,7 +109,9 @@ def delete_instance(self, instance, ignore_missing=True): def get_instance(self, instance): """Get a single instance - :param isntance: The name or ID of a instance. + :param instance: The value can be either the ID of an instance or a + :class:`~otcextensions.sdk.rds.v3.instance.Instance` instance. + :returns: One :class:`~otcextensions.sdk.rds.v3.instance.Instance` """ return self._get(_instance.Instance, instance) @@ -121,12 +121,13 @@ def find_instance(self, name_or_id, ignore_missing=True): :param name_or_id: The name or ID of a instance. :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~otcextensions.sdk.rds.v3.instance.Instance` - or None + :class:`~openstack.exceptions.ResourceNotFound` will be + raised when the resource does not exist. + When set to ``True``, None will be returned when + attempting to find a nonexistent resource. + + :returns: + One :class:`~otcextensions.sdk.rds.v3.instance.Instance` or None. """ return self._find(_instance.Instance, name_or_id, @@ -135,8 +136,10 @@ def find_instance(self, name_or_id, ignore_missing=True): def instances(self, **params): """Return a generator of instances - :returns: A generator of instance objects - :rtype: :class:`~otcextensions.sdk.rds.v3.instance.Instance` + :param dict params: Optional query parameters to be sent to limit + the instances being returned. + + :returns: A generator of instance objects. """ return self._list(_instance.Instance, **params) @@ -144,8 +147,8 @@ def restore_instance(self, instance, backup=None, restore_time=None): - """Restore instance from backup - or Restore using Point in Time Recovery + """Restore instance from backup or Restore using Point in + Time Recovery :param instance: Either the id of a source target instance or a :class:`~otcextensions.sdk.rds.v3.instance.Instance` instance. @@ -153,7 +156,6 @@ def restore_instance(self, :class:`~otcextensions.sdk.rds.v3.backup.Backup` instance. :returns: Job ID - :rtype: """ instance = self._get_resource(_instance.Instance, instance) if backup: @@ -165,7 +167,9 @@ def get_instance_restore_time(self, instance): :param instance: This parameter can be either the ID of an instance or a :class:`~openstack.sdk.rds.v3.instance.Instance` + :returns: Instance restore time + :rtype: list """ @@ -177,9 +181,10 @@ def get_instance_backup_policy(self, instance): :param instance: This parameter can be either the ID of an instance or a :class:`~openstack.sdk.rds.v3.instance.Instance` - :returns: Instance Backup policy - :rtype: :class:`~otcextensions.sdk.rds.v3.instance.BackupPolicy` + :returns: Instance Backup policy. + + :rtype: :class:`~otcextensions.sdk.rds.v3.instance.BackupPolicy` """ instance = self._get_resource(_instance.Instance, instance) return instance.get_backup_policy(self) @@ -229,12 +234,13 @@ def set_instance_backup_policy(self, instance, keep_days, # **attrs) # # ======= Configurations ======= - def configurations(self, **attrs): + def configurations(self, **params): """Obtaining a list of DB Configuration. - :returns: A generator of Configuration object - :rtype: - :class:`~otcextensions.sdk.rds.v3.configuration.Configuration` + :param dict params: Optional query parameters to be sent to limit + the configurations being returned. + + :returns: A generator of Configuration objects. """ return self._list( _configuration.Configuration, @@ -244,12 +250,12 @@ def configurations(self, **attrs): def get_configuration(self, cg): """Obtaining a Configuration. - :param parameter_group: The value can be the ID of a Configuration - or a object of - :class:`~otcextensions.sdk.rds.v3.configuration.Configuration`. + :param parameter_group: The value can be the ID of a Configuration or + a :class:`~otcextensions.sdk.rds.v3.configuration.Configuration` + instance. - :returns: A Configuration object - :rtype: :class:`~otcextensions.rds.v3.configuration.Configuration` + :returns: + One :class:`~otcextensions.rds.v3.configuration.Configuration` """ return self._get(_configuration.Configuration, cg) @@ -262,7 +268,9 @@ def find_configuration(self, name_or_id, ignore_missing=True): raised when the resource does not exist. When set to ``True``, None will be returned when attempting to find a nonexistent resource. - :returns: A configuration object + + :returns: A configuration object. + :rtype: :class:`~otcextensions.sdk.rds.v3.configuration.Configuration` """ return self._find(_configuration.Configuration, @@ -273,7 +281,9 @@ def create_configuration(self, **attrs): """Create DB Configuration. :param dict attrs: Dict to overwrite Configuration object - :returns: A Configuration Object + + :returns: A Configuration object. + :rtype: :class:`~otcextensions.sdk.rds.v3.configuration.Configuration` """ @@ -293,8 +303,7 @@ def delete_configuration(self, cg, ignore_missing=True): When set to ``True``, no exception will be set when attempting to delete a nonexistent Configuration. - :returns: None - :rtype: None + :returns: ``None`` """ self._delete( _configuration.Configuration, @@ -309,9 +318,7 @@ def update_configuration(self, config, **attrs): or a :class:`~openstack.sdk.rds.v3.config.Configuration` :param dict attrs: The attributes to update on the configuration. - :returns: None - :rtype: - :class:`~otcextensions.rds.v3.configuration.Configuration`. + :returns: ``None`` """ return self._update(_configuration.Configuration, config, **attrs) @@ -324,7 +331,9 @@ def apply_configuration(self, configuration, instances): :class:`~otcextensions.sdk.rds.v3.configuration.Configuration`. :param instances: List of instance ids the configuration should be applied to - :returns: Updated Configuration Object + + :returns: Updated Configuration object. + :rtype: :class:`~otcextensions.rds.v3.configuration.Configuration`. """ @@ -338,8 +347,10 @@ def backups(self, instance, **params): :param instance: This parameter can be either the ID of an instance or a :class:`~openstack.sdk.rds.v3.instance.Instance` - :returns: A generator of backup - :rtype: :class:`~otcextensions.sdk.rds.v3.backup.Backup` + :param dict params: Optional query parameters to be sent to limit + the instance backups being returned. + + :returns: A generator of backup objects. """ instance = self._get_resource(_instance.Instance, instance) return self._list(_backup.Backup, instance_id=instance.id, **params) @@ -347,7 +358,11 @@ def backups(self, instance, **params): def create_backup(self, instance, **attrs): """Create a backups of instance - :returns: A new backup object + :param instance: This parameter can be either the ID of an instance + or a :class:`~openstack.sdk.rds.v3.instance.Instance` + + :returns: A new backup object. + :rtype: :class:`~otcextensions.sdk.rds.v3.backup.Backup` """ instance = self._get_resource(_instance.Instance, instance) @@ -382,6 +397,7 @@ def find_backup(self, name_or_id, instance, ignore_missing=True): raised when the resource does not exist. When set to ``True``, None will be returned when attempting to find a nonexistent resource. + :returns: One :class:`~otcextensions.sdk.rds.v3.backup.Backup` or None """ @@ -394,10 +410,11 @@ def find_backup(self, name_or_id, instance, ignore_missing=True): def backup_download_links(self, backup_id): """Obtaining a backup file download links. - :param backup_id - :returns: files link - :rtype: :class:`~otcextensions.sdk.rds.v3.backup.BackupFile` + :param backup_id: + + :returns: backup files download link + :rtype: :class:`~otcextensions.sdk.rds.v3.backup.BackupFile` """ return self._list(_backup.BackupFile, backup_id=backup_id) diff --git a/otcextensions/sdk/rds/v3/instance.py b/otcextensions/sdk/rds/v3/instance.py index 75e95e24f..d27de27ff 100644 --- a/otcextensions/sdk/rds/v3/instance.py +++ b/otcextensions/sdk/rds/v3/instance.py @@ -34,46 +34,48 @@ class Instance(_base.Resource): router_id='vpc_id') #: Availability Zone. - #: *Type:str* + #: *Type:string* availability_zone = resource.Body('availability_zone') # TODO(not_gtema): extract backup strategy into separate type #: Backup Strategy. #: *Type: dict* backup_strategy = resource.Body('backup_strategy', type=dict) #: Specifies the billing information, which is pay-per-use. - #: *Type: dict* + #: *Type:dict* charge_info = resource.Body('charge_info', type=dict) #: Parameter configuration ID. #: *Type:uuid* configuration_id = resource.Body('configuration_id') #: Instance created time. - #: *Type:str* + #: *Type:string* created_at = resource.Body('created') #: Data store information. - #: *Type: dict* + #: *Type:dict* datastore = resource.Body('datastore', type=dict) #: Datastore type information (for querying). + #: *Type:string* datastore_type = resource.Body('datastore_type') #: Disk Encryption Key Id. - #: *Type:str* + #: *Type:uuid* disk_encryption_id = resource.Body('disk_encryption_id') #: Flavor ID #: *Type:uuid* flavor_ref = resource.Body('flavor_ref') #: Async job id + #: *Type:uuid* job_id = resource.Body('job_id') #: HighAvailability configuration parameters. - #: *Type: dict* + #: *Type:dict* ha = resource.Body('ha', type=dict) #: Maintenance time window. - #: *Type:str* + #: *Type:string* maintenance_window = resource.Body('maintenance_window') #: Node information #: Indicates the primary/standby DB instance information. #: *Type:list* nodes = resource.Body('nodes', type=list) #: Password of the default user. - #: *Type:str* + #: *Type:string* password = resource.Body('password') #: Database listen port number. #: *Type:int* @@ -85,43 +87,50 @@ class Instance(_base.Resource): #: *Type:list* public_ips = resource.Body('public_ips', type=list) #: Region where DB is deployed. - #: *Type:str* + #: *Type:string* region = resource.Body('region') #: list of associated DB instances. #: *Type:list* related_instances = resource.Body('related_instance', type=list) #: Specifies the DB instance ID, which is used to create a read replica. + #: *Type:uuid* replica_of_id = resource.Body('replica_of_id') #: Specifies the restoration point for instance recovery. - #: *Type: dict* + #: *Type:dict* restore_point = resource.Body('restore_point', type=dict) #: Recovery time period for instance. - restore_time = resource.Body('restore_time', type=list) + #: *Type:string* + restore_time = resource.Body('restore_time') #: Neutron router ID. + #: *Type:uuid* router_id = resource.Body('vpc_id') #: Security Group Id. + #: *Type:uuid* security_group_id = resource.Body('security_group_id') - #: Id of net. + #: Id of network. + #: *Type:uuid* network_id = resource.Body('subnet_id') #: Instance status. + #: *Type:string* status = resource.Body('status') #: Switch Strategy. The value can be reliability or availability, #: indicating the reliability first and availability first, respectively. - #: *Type:str* + #: *Type:string* switch_strategy = resource.Body('switch_strategy') #: Time Zone. - #: *Type:str* + #: *Type:string* time_zone = resource.Body('time_zone') #: Instance type Single/Ha/Replica., - #: *Type:str* + #: *Type:string* type = resource.Body('type') # datastore: Instance updated time. - #: *Type:str* + #: *Type:string* updated_at = resource.Body('updated') #: Default user of the DB + #: *Type:string* user_name = resource.Body('db_user_name') #: Volume information - #: *Type: dict* + #: *Type:dict* volume = resource.Body('volume', type=dict) def _translate_response(self, response, has_body=None, error_message=None): diff --git a/otcextensions/tests/functional/osclient/nat/v2/common.py b/otcextensions/tests/functional/osclient/nat/v2/common.py index e96737ca0..ea3e77510 100644 --- a/otcextensions/tests/functional/osclient/nat/v2/common.py +++ b/otcextensions/tests/functional/osclient/nat/v2/common.py @@ -46,10 +46,12 @@ def create_nat_gateway(self, name=None): 'nat gateway create {name}' ' --router-id {router_id}' ' --internal-network-id {net_id}' + ' --description {description}' ' --spec {spec} -f json'.format( name=name, router_id=self.ROUTER_ID, net_id=self.NETWORK_ID, + description='OTCE_func_test', spec=1) )) self.assertIsNotNone(json_output) diff --git a/otcextensions/tests/unit/sdk/cts/v1/test_proxy.py b/otcextensions/tests/unit/sdk/cts/v1/test_proxy.py index c008170cf..5c58ad948 100644 --- a/otcextensions/tests/unit/sdk/cts/v1/test_proxy.py +++ b/otcextensions/tests/unit/sdk/cts/v1/test_proxy.py @@ -85,7 +85,9 @@ def test_update_tracker(self): self.proxy.update_tracker, _tracker.Tracker, ) + ''' def test_delete_tracker(self): self.verify_delete( self.proxy.delete_tracker, _tracker.Tracker, True, ) + ''' diff --git a/otcextensions/tests/unit/sdk/dcs/v1/test_instance.py b/otcextensions/tests/unit/sdk/dcs/v1/test_instance.py index a06d7e40d..8ee29ed32 100644 --- a/otcextensions/tests/unit/sdk/dcs/v1/test_instance.py +++ b/otcextensions/tests/unit/sdk/dcs/v1/test_instance.py @@ -40,7 +40,7 @@ "security_group_name": "sg_6379_4944a40e-ac57-4f08-9d38-9786e2759458", "subnet_id": "ec2f34b9-20eb-4872-85bd-bea9fc943128", "subnet_name": "subnet_az_7f336767-10ec-48a5-9ae8-9cacde119318", - "available_zones": "XXXXXX", + "available_zones": ["XXXXXX"], "max_memory": 460, "used_memory": 56, "user_id": "6d0977e4c9b74ae7b5a083a8d0d8fafa", diff --git a/otcextensions/tests/unit/sdk/dcs/v1/test_proxy.py b/otcextensions/tests/unit/sdk/dcs/v1/test_proxy.py index 99b810e88..e002084ca 100644 --- a/otcextensions/tests/unit/sdk/dcs/v1/test_proxy.py +++ b/otcextensions/tests/unit/sdk/dcs/v1/test_proxy.py @@ -232,8 +232,16 @@ def test_create_backup(self): ) def test_delete_backup(self): - self.verify_delete( - self.proxy.delete_instance_backup, _backup.Backup, True, + instance = _instance.Instance(id='instance_id') + self._verify2( + 'openstack.proxy.Proxy._delete', + self.proxy.delete_instance_backup, + method_args=[instance, 'backup_1'], + expected_args=[_backup.Backup, 'backup_1'], + expected_kwargs={ + 'instance_id': instance.id, + 'ignore_missing': True + } ) def test_restores_query(self): diff --git a/otcextensions/tests/unit/sdk/dns/v2/test_zone.py b/otcextensions/tests/unit/sdk/dns/v2/test_zone.py index 324cc20d9..425dfe72c 100644 --- a/otcextensions/tests/unit/sdk/dns/v2/test_zone.py +++ b/otcextensions/tests/unit/sdk/dns/v2/test_zone.py @@ -107,7 +107,7 @@ def test_associate_router(self): ) self.sess.post.assert_called_once_with( - 'zones/%s/accosiaterouter' % FAKE_ID, + 'zones/%s/associaterouter' % FAKE_ID, json={'router': {'router_id': 1, 'router_region': 'a'}} ) @@ -126,6 +126,6 @@ def test_disassociate_router(self): ) self.sess.post.assert_called_once_with( - 'zones/%s/disaccosiaterouter' % FAKE_ID, + 'zones/%s/disassociaterouter' % FAKE_ID, json={'router': {'router_id': 1}} ) diff --git a/setup.cfg b/setup.cfg index 7f4c4705e..82cff272f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -186,6 +186,7 @@ openstack.dcs.v1 = dcs_stat_list = otcextensions.osclient.dcs.v1.statistic:ListStatistic openstack.kms.v1 = + kms_cmk_create = otcextensions.osclient.kms.v1.cmk:CreateCMK kms_cmk_list = otcextensions.osclient.kms.v1.cmk:ListCMK kms_cmk_show = otcextensions.osclient.kms.v1.cmk:ShowCMK kms_cmk_enable = otcextensions.osclient.kms.v1.cmk:EnableCMK