diff --git a/.gitignore b/.gitignore index 919ef00d7..267e4101b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,12 +6,12 @@ *.swo *.swp *~ +otcextensions-*/ .coverage .idea .stestr/ .testrepository .tox -AUTHORS build ChangeLog dist diff --git a/.stestr.blacklist.functional b/.stestr.blacklist.functional new file mode 100644 index 000000000..099986f18 --- /dev/null +++ b/.stestr.blacklist.functional @@ -0,0 +1,12 @@ +otcextensions.tests.functional.osclient.obs* +otcextensions.tests.functional.osclient.rds.v3.test_instance* +otcextensions.tests.functional.osclient.volume_backup* +otcextensions.tests.functional.osclient.nat* +otcextensions.tests.functional.osclient.rds* +otcextensions.tests.functional.sdk.cce.v1* +otcextensions.tests.functional.sdk.kms* +otcextensions.tests.functional.sdk.volume_backup* +otcextensions.tests.functional.sdk.deh* +otcextensions.tests.functional.sdk.dds* +otcextensions.tests.functional.sdk.plas* +otcextensions.tests.functional.sdk.lts* diff --git a/.travis.yml b/.travis.yml index 0f8dd754f..8ba58a8b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,24 +3,21 @@ language: python cache: pip matrix: include: - - python: 2.7 - env: TOXENV=py27 - python: 3.6 env: TOXENV=py36 + - python: 3.7 + env: TOXENV=py37 - python: 3.6 env: TOXENV=pep8 install: pip install tox script: tox -deploy: - provider: pypi - edge: - branch: v1.8.45 - user: gtema - password: - secure: RME8zXB1ynBbmSHEx0kkFzViq56mYKleTuN/om+I+4uTxyTJQjbRkN3AJNKO9CX8V1l9KMeSQ/9a6c9Wmqwn7f+Mps1WwMwhAGqZpyV6ea16Z+G2GYR82lAGBqCIU0JWd2WOrwZ05PvPk0UMT8PkvJGPEl32BtIi7y3DTQa3U2Lpzvb2B3B15PMuFgGRDJgMtTfCtqpzJ9Afqa6X2x70HVXViJgCVKfk10NywNk0kqjFNOGnRXGH1w0oIkj7kSuDA2LRU9exNQZAdU5e2rre+BWae7H0/cYB0H58y5Ax5MA8Nga4o/wRy8MFaIB+9xG+fbo1PIRQtkdim2gwuR3ZkBjN5KHuMH1nnC6R5iMdNSmEaV63YST2YaVfWYA2HvSh6U5DI2ES+4FT8MtA3mFFVg2eOi8/r4c3V5EeLt7iR27R1pkWj83vcYCIXj20j/O6LkGkz+kOLgyfP7oGEgIZyXFDqoWk5pdW15eBHQ3hX5q+hT4oTYpF87i45/6SLfDZ/UWNRmASWBGelFRIEZCs69JvIxrbFHPf8kxzI+QIeouC2uV6MklyTq9iFUcZotUBL+WDOkUqO95VKsSlhIJYWBJiPBliXzBXM30XWexfZD49+b5tQqY1zJ0VCYn9YUkoAO08TQiNJbej8F6A9SOqI7FCB28RgW5D6XrfsXGHXzs= - # skip_cleanup: true - on: - tags: true - distributions: sdist bdist_wheel - repo: OpenTelekomCloud/python-otcextensions - condition: "$TOXENV = py36" +# deploy: +# provider: pypi +# user: __token__ +# password: +# secure: c/0z6avOAPLHWs0LBX9HJCfHexlHe/LDQU6ZQ4NBf9YpLLZON5CSchxU1LiLJMAB98NOpK48wewiC5jlWm8zXIV7t1wnOtKkR4X+HfRO4Lgii8ARlhTPyzF5I3fmgMa/WKyThZeiBl6xPA6G/slLGVDeCczUasUEZWS/jUAVEg0Ht81fDyu1SauRxyj5fXYbpjFFQ+jYyyHTm7FiroG0ylt0XOztpvd/5z7IvRvQ7f+OKg9BES+HHDbOmulY6wSnQrG5o+s3DPOkixiC0Hyh+bFuPfTidUDavKlkQFc4rv87WM+CnBGLoYztx31RFf4azv1SOn6yxsBfxA3zB82cjsWOQh7AWHLfQ19J2aZy5kysaBXnMs7FEo+8g1CdiUApLOqQ7b27B//ZifoKT7aRlwjkcX9g6lajy48MoQWy04xFV0z0/S2yxUrTGr4PcZucLO21YkcGP6Q/Pc4A/4qhz/p1Z1IrDVE8utvrD5jNraLtQzcRvbIqNKNOzpdSkiqsCjf+fzOH4bL0ej33BsVNWHSMn8ZK49d8ykhAsDNoLc7zXo4rJ0+49rRtAd5iDAZDOqBLexDG9x5EM6OMnSApv4km2Pk5Pt1PGFfMiTIuIiBtm8Xz0X7Aa98xiSlJ16IisA1PsXEVvh/QlPiGg1A0CTzzjMIjlpg5EJm55MFEcKc= +# on: +# tags: true +# distributions: sdist bdist_wheel +# repo: opentelekomcloud/python-otcextensions +# condition: "$TOXENV = py36" diff --git a/.zuul.yaml b/.zuul.yaml index 4e81e6f34..0909d8155 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,35 +1,26 @@ - job: - name: openstacksdk-functional - parent: otc-tox-functional - description: | - Run openstacksdk functional tests against a OTC - -- job: - name: openstacksdk-functional-otc - parent: openstacksdk-functional - description: | - Run openstacksdk functional tests using default python against OTC - -- job: - name: openstacksdk-functional-otc-python3 - parent: openstacksdk-functional - description: | - Run openstacksdk functional tests using python3 against OTC - vars: - tox_environment: - OPENSTACKSDK_TOX_PYTHON: python3 - OS_CLOUD: otc + name: tox-functional-master + parent: tox-functional + branches: master - project: + merge-mode: squash-merge + templates: + - publish-to-pypi check: jobs: - - tox-py36 - - tox-py27 + - tox-py37 + - tox-py38 - tox-pep8 - - openstacksdk-functional-otc-python3 + - tox-docs + - tox-functional gate: jobs: - - tox-py36 - - tox-py27 + - tox-py37 + - tox-py38 - tox-pep8 - - openstacksdk-functional-otc-python3 + - tox-docs + - tox-functional + periodic: + jobs: + - tox-functional-master diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 000000000..139c134f8 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,7 @@ +Artem Goncharov +György Hodi +Kristian Kucerak +Nils Magnus +Tino Schreiber +Vineet Pruthi <48789821+vineet-pruthi@users.noreply.github.com> +Zsolt Nagy diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 57b6bf563..84fe3a5dd 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,45 +1,30 @@ -.. _contributing: +Contributing to OTC Extensions +============================== -=================================== -Contributing to python-openstacksdk -=================================== +OTC Extension are developed as a community effort initiated by +T-Systems International GmbH for the Open Telekom Cloud under an Open +Source license. All code is licensed under the Apache 2.0 license. -If you're interested in contributing to the python-openstacksdk project, -the following will help get you started. +We are happily accepting pull requests. Please reach out to the +project to sort out legal code contribution. If you're interested in +contributing to the project, have a look in the `contributors +section`_ of our documentation. -Contributor License Agreement ------------------------------ +We follow the recommendation of the `OpenStack's workflow`_ for open +source contributions and value the four opens. -.. index:: - single: license; agreement - -In order to contribute to the python-openstacksdk project, you need to have -signed OpenStack's contributor's agreement. - -Please read `DeveloperWorkflow`_ before sending your first patch for review. -Pull requests submitted through GitHub will be ignored. - -.. seealso:: - - * http://wiki.openstack.org/HowToContribute - * http://wiki.openstack.org/CLA - -.. _DeveloperWorkflow: http://docs.openstack.org/infra/manual/developers.html#development-workflow Project Hosting Details -------------------------- +----------------------- Project Documentation - http://docs.openstack.org/sdks/python/openstacksdk/ + https://python-otcextensions.readthedocs.io/ Bug tracker - https://bugs.launchpad.net/python-openstacksdk - -Mailing list (prefix subjects with ``[sdk]`` for faster responses) - http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev + https://github.com/opentelekomcloud/python-otcextensions/issues Code Hosting - https://git.openstack.org/cgit/openstack/python-openstacksdk + https://github.com/opentelekomcloud/python-otcextensions/ -Code Review - https://review.openstack.org/#/q/status:open+project:openstack/python-openstacksdk,n,z +.. _contributors section: https://python-otcextensions.readthedocs.io/en/latest/contributor/ +.. _OpenStack's workflow: http://docs.openstack.org/infra/manual/developers.html#development-workflow diff --git a/HACKING.rst b/HACKING.rst deleted file mode 100644 index 61803e9a4..000000000 --- a/HACKING.rst +++ /dev/null @@ -1,108 +0,0 @@ -OpenStack Style Commandments -============================ - -- Step 1: Read the OpenStack Style Commandments - https://docs.openstack.org/hacking/latest/ -- Step 2: Read on - -General -------- -- thou shalt not violate causality in our time cone, or else - -Docstrings ----------- - -Docstrings should ONLY use triple-double-quotes (``"""``) - -Single-line docstrings should NEVER have extraneous whitespace -between enclosing triple-double-quotes. - -Deviation! Sentence fragments do not have punctuation. Specifically in the -command classes the one line docstring is also the help string for that -command and those do not have periods. - - """A one line docstring looks like this""" - -Calling Methods ---------------- - -Deviation! When breaking up method calls due to the 79 char line length limit, -use the alternate 4 space indent. With the first argument on the succeeding -line all arguments will then be vertically aligned. Use the same convention -used with other data structure literals and terminate the method call with -the last argument line ending with a comma and the closing paren on its own -line indented to the starting line level. - - unnecessarily_long_function_name( - 'string one', - 'string two', - kwarg1=constants.ACTIVE, - kwarg2=['a', 'b', 'c'], - ) - -Text encoding -------------- - -Note: this section clearly has not been implemented in this project yet, it is -the intention to do so. - -All text within python code should be of type 'unicode'. - - WRONG: - - >>> s = 'foo' - >>> s - 'foo' - >>> type(s) - - - RIGHT: - - >>> u = u'foo' - >>> u - u'foo' - >>> type(u) - - -Transitions between internal unicode and external strings should always -be immediately and explicitly encoded or decoded. - -All external text that is not explicitly encoded (database storage, -commandline arguments, etc.) should be presumed to be encoded as utf-8. - - WRONG: - - infile = open('testfile', 'r') - mystring = infile.readline() - myreturnstring = do_some_magic_with(mystring) - outfile.write(myreturnstring) - - RIGHT: - - infile = open('testfile', 'r') - mystring = infile.readline() - mytext = mystring.decode('utf-8') - returntext = do_some_magic_with(mytext) - returnstring = returntext.encode('utf-8') - outfile.write(returnstring) - -Python 3.x Compatibility ------------------------- - -OpenStackClient strives to be Python 3.3 compatible. Common guidelines: - -* Convert print statements to functions: print statements should be converted - to an appropriate log or other output mechanism. -* Use six where applicable: x.iteritems is converted to six.iteritems(x) - for example. - -Running Tests -------------- - -Note: Oh boy, are we behind on writing tests. But they are coming! - -The testing system is based on a combination of tox and testr. If you just -want to run the whole suite, run `tox` and all will be fine. However, if -you'd like to dig in a bit more, you might want to learn some things about -testr itself. A basic walkthrough for OpenStack can be found at -http://wiki.openstack.org/testr diff --git a/README.rst b/README.rst index 5310c6980..e23198627 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ -OpenTelekomCloud extensions -=========================== +OTC Extensions +============== .. image:: https://travis-ci.org/OpenTelekomCloud/python-otcextensions.svg?branch=master :target: https://travis-ci.org/OpenTelekomCloud/python-otcextensions @@ -8,89 +8,82 @@ OpenTelekomCloud extensions :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: +The OTC Extensions augment the OpenStack SDK of features and services +provided by the Open Telekom Cloud. If installed as a Python package, +they add several extra commands to the OpenStack Client CLI. Therefore +the project interacts closely with the * `python-openstacksdk` * `python-openstackclient` -The primary goal is to provide a possibility to use native OpenStack SDK and -CLI with the OTC additional services +packages. -Getting Started -=============== +Documentation +------------- -The very first step to get started is to install otcextensions into your -system. For this please follow installation instructions_ +`Documentation Overview `_ -.. _instructions: http://python-otcextensions.readthedocs.io/en/latest/install/index.html +Installation +------------ -Next step would be logically configuration +`Installation Page `_ -Configuration -============= +The OTC Extensions are hosted as the package `otcextensions` on PyPI +and can be installed by pip as + +.. code-block: console + + $ pip install otcextensions -openstack.config -================ +There are several options +to do that including but not limited to pip userland installation, system wide +installation as well as installation from operating system packets or directly +from source. Refer to the installation instructions_ in the projects +documentation. -The recommended way, since it is the most efficient way to configure both SDK -and the CLI in one place +Configuration +------------- -``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 +`Configuration Page `_ -* 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 +Acessing the Open Telekom Cloud APIs requires authentication and +authorization. For both there are several options available: -Sometimes an example is nice. +* **Configuration files** (recommended): A file called `clouds.yaml` + holds all necessary configuration parameters. The file can be placed + either in the local directory, below the user home directory in + `.config/openstack` or in the system-wide directory + `/etc/openstack`. You may use a second file `secure.yaml` in the + same directories to extra protect clear-text password + credentials. For more details see the section `configuration`_ in + the official documentation. -Create a ``clouds.yaml`` file: + Minimal sample ``clouds.yaml`` file: -.. code-block:: yaml + .. code-block:: yaml - clouds: + clouds: otc: + profile: otc auth: - username: 'USER_NAME' - password: 'PASS' - project_name: 'eu-de' - auth_url: 'https://iam.eu-de.otc.t-systems.com:443/v3' + username: '' + password: '' + project_name: '' + # or project_id: '<123456_PROJECT_ID>' user_domain_name: 'OTC00000000001000000xxx' + # or user_domain_id: '<123456_DOMAIN_ID>' + auth_url: 'https://iam.eu-de.otc.t-systems.com:443/v3' interface: 'public' identity_api_version: 3 # !Important - ak: 'AK_VALUE' # AK/SK pair for access to OBS - sk: 'SK_VALUE' + ak: '' # AK/SK pair for access to OBS + sk: '' -Please note: ``openstack.config`` will look for a file called ``clouds.yaml`` -in the following locations: + With this configuration you can start using the CLI with ``openstack + --os-cloud otc *command*`` or by ``export OS_CLOUD=otc; openstack + *command*``. -* 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:: +* **Environment variables:** Authentication using username/password is often + used:: export OS_AUTH_URL= export OS_IDENTITY_API_VERSION=3 @@ -102,7 +95,8 @@ Authentication using username/password is often used:: export S3_ACCESS_KEY_ID= export S3_SECRET_ACCESS_KEY= -The corresponding command-line options look very similar:: +* **Command-Line Options:** The corresponding command-line options look + very similar:: --os-auth-url --os-identity-api-version 3 @@ -112,26 +106,46 @@ The corresponding command-line options look very similar:: --os-user-domain-name [--os-password ] -If a password is not provided above (in plaintext), you will be interactively -prompted to provide one securely. + 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:: +* **Existing Token:** 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:: +* 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 +More information is available at +https://docs.openstack.org/python-openstackclient/latest/cli/authentication.html +or +https://developer.openstack.org/sdks/python/openstacksdk/users/config + +OTC Extensions CLI Usage +------------------------ + +`OTCE CLI Command Overview `_ -Links -===== +OTC Extensions SDK Guides +------------------------- + +`OTCE SDK Guides `_ + +Contributing +------------ + +* `Contribution Page `_ + +Further Links +------------- * `Issue Tracker `_ -* `Documentation `_ + +.. _instructions: http://python-otcextensions.readthedocs.io/en/latest/install/ diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 000000000..cf94d2a8c --- /dev/null +++ b/bindep.txt @@ -0,0 +1,11 @@ +# This is a cross-platform list tracking distribution packages needed by tests; +# see https://docs.openstack.org/infra/bindep/ for additional information. + +gcc [compile test] +libc6-dev [compile test platform:dpkg] +libffi-devel [platform:rpm] +libffi-dev [compile test platform:dpkg] +libffi6 [platform:dpkg] +libssl-dev [compile test platform:dpkg] +python3-dev [compile test platform:dpkg] +python3-devel [compile test platform:rpm] diff --git a/doc/requirements.txt b/doc/requirements.txt index 2256888a7..f829fa739 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -5,7 +5,7 @@ docutils>=0.11 # OSI-Approved Open Source, Public Domain beautifulsoup4>=4.6.0 # MIT reno>=2.5.0 # Apache-2.0 otcdocstheme # Apache-2.0 -sphinx!=1.6.6,!=1.6.7,>=1.6.5 # BSD +sphinx>=1.8.0,!=2.1.0 # BSD sphinxcontrib-apidoc>=0.2.0 # BSD cliff!=2.9.0,>=2.8.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 diff --git a/doc/source/glossary.rst b/doc/source/appendices/glossary.rst similarity index 74% rename from doc/source/glossary.rst rename to doc/source/appendices/glossary.rst index 3bdbde41d..2bf09d6ee 100644 --- a/doc/source/glossary.rst +++ b/doc/source/appendices/glossary.rst @@ -102,3 +102,33 @@ Glossary volume OpenStack Volume (Cinder). Also the attribute name of the virtual disks managed by the OpenStack Volume service. + + +Naming conventions +------------------ + +For consistency, a few naming conventions are defined for the name of +this project and adjacent identifiers. Let's start with the project +itself: + +`OTC Extensions`_ in exactly this spelling is the **name** of the +project. This term is used when the documentation references the +project as such. The three letters ``OTC`` are all uppercase. There is +a space and not dash between the two words. The second word is part of +the name and is thus capitalized. + +`otcextensions`_ is the name of the Python package hosted at +PyPI. Complying to the naming conventions of PyPI, the package name is +concatenated and consists only of lowercase letters. + +`python-otcextensions`_ is the name of the GitHub project where the +source code is hosted. It is the same name as the Python package, but +for compliance with many other OpenStack repositories, it is prepended +with ``python-`` as at least in theory there could also be a +``golang-otcextensions`` or even ``haskell-otcextensions`` project. + +.. _OTC Extensions: https://python-otcextensions.readthedocs.io/ + +.. _otcextensions: https://pypi.org/project/otcextensions/ + +.. _python-otcextensions: https://github.com/OpenTelekomCloud/python-otcextensions diff --git a/doc/source/appendices/history.rst b/doc/source/appendices/history.rst new file mode 100644 index 000000000..ba30948c1 --- /dev/null +++ b/doc/source/appendices/history.rst @@ -0,0 +1,75 @@ +History of the OTC Extensions +============================= + +This project may seem complicated as it has some dependencies and +obscure naming conventions. Sometimes understanding the OTC +Extensions's heritage helps to mitigate those pains. + +OpenStack itself started as a set of services, and developers very +early decided that having a (more or less) decoupled set of services +would be the best choice for such a huge, distributed +system. Distributed services need to talk to each other. That's why +each service provides an interface. As OpenStack uses RESTful +webservices as a communication fabric, this interface is called and +API. Most of the (quantitive) implementation effort of OpenStack is to +implement the services behind those API endpoints. + +However, there are also clients using and consuming those +services. Thus they need to talk to the APIs. Once a service was +implemented its developers tried to use the service. While using +generic HTTP tools like curl or wget might be a workaround for first +tests, dealing with authentication schemes, token handling, encoding, +encapsulation, and header and body handling made it not really +convenient to work with them. + +Now specific tools emerged implementing the client side of a +service. There have been novatools for the compute service, +glancetools for the image service, neutrontool for the network, and +many more. + +Once developers discovered that they needed to re-implement a lot of +duplicating code for each new service again, they started to factor +out common code pieces. That actually took place in several places +simulteanously: The **shade** library abstracted handling of +resources, that different services implemented with a similar +way. Many resource, for example, implement the so-called CRUD +operations for creating, reading, updating, and deleting them. + +A second major field for client application was authentication and +autorization against the cloud. While in the beginning environment +variables appeared to come in handy, having all runtime configuration +options in a single file simplified the overall management of your +cloud setup. This idea was introduced by **os-client-config**. It +centralized the environment variable handling, but even more +important, it introduced the **clouds.yaml** configuration file. + +In a major refactoring session, in 201X the developers combined both +libraries into a single one called **OpenStack SDK**. That in turn +would become the building block of one unified CLI tool that is +capable of adressing all OpenStack services from a single +command. This is the OpenStack Client. It has several subcommands that +work in a similar manner and share a common syntax. + +In a perfect world now all would have been fine. In reality, however, +not all clouds are the same. Some offer additional, vendor specific +services (or, which is worse) implement a subset of services +differently. To reflect these circumstances, 2018, Artem Goncharov +implemented a plugin mechanism into both OpenStack SDK and into the +OpenStack client. This way the SDK and CLI can be extended and +maintained without touching the generic code. One instance making use +of this plugin mechanism are the OTC Extensions, this very project. + +Wann gab es die ersten Clients für OpenStack? + +Wer hat wann erstmals die Notwendigkeit gesehen, etwas zu +vereinheitlichen? Wann? Haben wir da irgendwo einen Link drauf? + +Wer hat Shade begonnen und wann? + +Wer hat os-client-config beginnen und wann? + +Wann/warum wurden die Projekte aufgegeben? + +Wer maintaint was? + +https://docs.openstack.org/openstacksdk/latest/contributor/history.html diff --git a/doc/source/appendices/index.rst b/doc/source/appendices/index.rst new file mode 100644 index 000000000..c0e9836e7 --- /dev/null +++ b/doc/source/appendices/index.rst @@ -0,0 +1,10 @@ +Appendices +========== + +.. toctree:: + :maxdepth: 1 + + releasenotes + history + issues + glossary diff --git a/doc/source/appendices/issues.rst b/doc/source/appendices/issues.rst new file mode 100644 index 000000000..98c6b99c6 --- /dev/null +++ b/doc/source/appendices/issues.rst @@ -0,0 +1,200 @@ +Known Issues +============ + +Since providing services and writing client libraries is decoupled, +sometimes issues arise due to errors in the client or the server side, +or due to a service disruption or degration. This page collects +potential issues. They have been found during digging into the API. + +General +------- + +* Native service version discovery request to + https://as.eu-de.otc.t-systems.com/autoscaling-api/ caused + timeout. AS service is temporarily disabled +* Inconsistent naming between services (AS:create_time, + KMS:creation_date, CCE:createAt) +* Inconsistent error message structure between services (i.e. KMS vs + RDS). This prohibits code generalization +* No custom service supports proper version discovery. Leads to error + messages in the OSC tool and execution delays +* LB: while Neutron LBaaS is "strongly" considered as deprecated and + no bindings are present in Ansible/OSC it will likely not be + possible/challenge to upstream this support. +* EVS: volume type list --long returns changing results +* Subnet (in some APIs) is most likely net_id +* Without service discovery and multiple versions it is not possible + to get the proper service version in SDK. It falls back to first + entry in the VersionFilter +* Tags require different format ("key=value" vs "key*value") + +KMS +--- + +* service version discovery is broken. On + https://kms.eu-de.otc.t-systems.com/ it returns {"versions": + [{"status": "CURRENT", "id": "v1.0", "links": [{"href": + "https://rts.eu-de.otc.t-systems.com/v1/", "rel": "self"}]}]} In the + keystoneauth1 it results to + get_endpoint=https://kms.eu-de.otc.t-systems.com/v1 (instead of + V1.0). Detailed investigation is expensive, therefore aborted +* does not follow REST, everything is POST with different URLs and not + even json['action'] +* is conceptually far away from Barbican +* API Doc: This API allows you to create a plaintext-free DEK, that + is, the returned result of this API includes `only the plaintext` of + the DEK. +* purpose of KMS is not precise. Attributes change their names/meaning + depending on call +* encryption_context is described to be string, in reality dict is + expected +* max_length is always expected to be exactly max. Make no sense as a + param +* list CMK filter by key_state not working as documented +* format of the timestamp is unknown +* no way to get response in English + +CCE +--- + +* required header application/type also for GET +* cluster UUID is hidden in a inline metadata structure, making it + hard to address it without dirty hacks. Apis are jumping through + this structure in anti-rest pattern +* attribute naming: metadata.uuid vs metadata.uid +* undocumented properties of the cluster.spec field (i.e. `cidr`) +* far away from Magnum +* Cluster has both VPC and VPC_ID, in GET VPC is name, in POST it + should be ID +* Subnet is most likely net_id +* In AS sys disk has type "SYS", in CCE - "root" +* Node delete possible only by name, and not id +* service catalog configuration is broken v1 vs v2(v3) with no + corrupted discovery and new service type + +DCS +--- + +* In OS DCS is part of Trove. The API is same. In the DCS API is + similar to RDS, but not easy mappable +* Since Redis 3.0.7 (only available in DCS) lots of critical issues + (incl. security and possible data corruption), online memory defrag, + less mem usage were fixed + +MRS +--- + +* Inconsistent naming between services ( data_processing-mrs ) + +OBS +--- + +* Has storage class on Bucket level, but in AWS and all corresponding + tools (also s3cmd, s4cmd, Boto) it is on the Object level + +DNS (Designate) +--------------- + +* Nothing supports private zone (ansible, heat, ~terraform, + SDK/CLI). Very hard to cover that everywhere +* Zone transfer, slave zone are not present. Modern Designateclient is + not getting clear with response of designate +* API v2 is not implemented + +VBS +--- + +* Uses offset as a pagination, instead of marker (in docs, in reality + marker is supported) +* Backup creation takes too long. 1Gb empty volume takes >4 + minutes. Functional tests are not reasonable with that. +* Create policy requires frequency to be set +* Shift implemented stuff to osc + +CSS +--- + +* upon creation httpsEnable is str, upon read - bool +* flavors is not OpenStack compatible + +HEAT +---- + +* very old level, blocking many OpenSource projects, including + i.e. ansible-openshift, RedhatDNS. +* (to be doublechecked) template version check is likely not done, + since features of later templates with older version header are + passing validation (in the ranges of supported versions) +* validate return ok, doesn't mean create will pass (validation errors + i.e. template version doesn't match, condition on a resource level + was also added on newton) +* not all CLI calls return result +* Not possible to rely on mountpoint of the + OS::Cinder::VolumeAttachment - it's ignored +* usage of Server with block_device_mapping_v2, devicename="sdX" and > + 1 device fails. Port is not released leaving system in inconsistent + state (if router interface is deleted can be cleaned only manually) +* OS::Neutron::LBaaS::HealthMonitor does not support type HTTPS, but + GUI allows it +* update stack with existing template is missing + +Shade/Ansible +------------- + +* enabling SNAT through Ansible not possible, since upstream expects + default as true and sends only false if set + (shade:_build_external_gateway_info) +* only able to pass SYS volume size if boot_from_volume=True + (default=false) +* on a play retry port in the subnet changes if exists (change IP) and + corrupts connection +* No support for load balancer +* Ansible (Heat): https://github.com/ansible/ansible/issues/30786 - + small fix to see the failure message if stack create/update fails +* Private: yes helps to get public_v4 filled, but it hinders create + request with auto_ip:true +* add router interface + +VPC +--- + +* VPC uses network wrapped subnets. Simple net with multiple subnets + is not properly visible in OTC (in VPCs list subnet count includes + all subnets, but in VPC show subnets are missing) + +TMS +--- + +* How to assign tag to resource from API? + +BMS +--- + +* it is not Ironic, but ECS + +Network +------- + +* Security Group rule "Any" (value=0) is not working as designed. OSC + uses defaults, use of 0 results in really 0 as a value. Effect is + unknown yet + +DeH +--- + +* Tag support is not OS compatible + +OpenStack SDK +------------- + +* LBaaS: pool.healthmonitor_id according to ref api (and in OTC), but + in the SDK it is health_monitor_ids (list) (reported under + https://storyboard.openstack.org/#!/story/2001872). Some other + attributes missing. pool_member operating_status missing +* LBaaS HM: max_retries_down missing (optional and not present in OTC) + +DOC +--- + +* at least on example of ULB LIST allows filtering, but it is not + documented diff --git a/doc/source/appendices/releasenotes.rst b/doc/source/appendices/releasenotes.rst new file mode 100644 index 000000000..d9adcb965 --- /dev/null +++ b/doc/source/appendices/releasenotes.rst @@ -0,0 +1,4 @@ +Release Notes +============= + +Release notes for are currently not implemented for OTC Extensions. diff --git a/doc/source/cli/anti_ddos.rst b/doc/source/cli/anti_ddos.rst index 308ba8123..de663e60c 100644 --- a/doc/source/cli/anti_ddos.rst +++ b/doc/source/cli/anti_ddos.rst @@ -1,6 +1,5 @@ -================================================= -Anti DDoS Service (Anti_DDoS) command-line client -================================================= +Anti DDoS Service (Anti_DDoS) +============================= The Anti_DDoS client is the command-line interface (CLI) for the Anti DDoS Service (Anti_DDoS) API and its extensions. diff --git a/doc/source/cli/auto_scaling.rst b/doc/source/cli/auto_scaling.rst index e67398d01..1c75844ab 100644 --- a/doc/source/cli/auto_scaling.rst +++ b/doc/source/cli/auto_scaling.rst @@ -1,6 +1,5 @@ -============================================ -AutoScaling service (AS) command-line client -============================================ +AutoScaling service (AS) +======================== The AS client is the command-line interface (CLI) for the AutoScaling service (AS) API and its extensions. diff --git a/doc/source/cli/cce_v2.rst b/doc/source/cli/cce_v2.rst index b0ab6a044..17e17c4cc 100644 --- a/doc/source/cli/cce_v2.rst +++ b/doc/source/cli/cce_v2.rst @@ -1,6 +1,5 @@ -================================================ -Cloud Container Engine (CCE) command-line client -================================================ +Cloud Container Engine (CCE) +============================ The CCE client is the command-line interface (CLI) for the Cloud Container Engine (CCE) API and its extensions for the CCE v2. diff --git a/doc/source/cli/ces.rst b/doc/source/cli/ces.rst new file mode 100644 index 000000000..640e381b7 --- /dev/null +++ b/doc/source/cli/ces.rst @@ -0,0 +1,43 @@ +Cloud Eye Service (CES) +======================= + +The CES client is the command-line interface (CLI) for +the Cloud Eye Service (CES) API and its extensions. + +For help on a specific `ces` command, enter: + +.. code-block:: console + + $ openstack ces help SUBCOMMAND + +.. _alarm: + +Alarm Rule Operations +--------------------- + +.. autoprogram-cliff:: openstack.ces.v1 + :command: ces alarm * + +.. _metric: + +Metric Operations +----------------- + +.. autoprogram-cliff:: openstack.ces.v1 + :command: ces metric * + +.. _quota: + +Quota Operations +---------------- + +.. autoprogram-cliff:: openstack.ces.v1 + :command: ces quota * + +.. _event_data: + +Event Data Operations +--------------------- + +.. autoprogram-cliff:: openstack.ces.v1 + :command: ces event data * diff --git a/doc/source/cli/cts.rst b/doc/source/cli/cts.rst index 7a1132218..fa5bcb3c9 100644 --- a/doc/source/cli/cts.rst +++ b/doc/source/cli/cts.rst @@ -1,6 +1,5 @@ -============================================= -Cloud Trace Service (CTS) command-line client -============================================= +Cloud Trace Service (CTS) +========================= The CTS client is the command-line interface (CLI) for the Cloud Trace Service (CTS) API and its extensions. diff --git a/doc/source/cli/dcs.rst b/doc/source/cli/dcs.rst index 516e78ad2..6c9f3edd5 100644 --- a/doc/source/cli/dcs.rst +++ b/doc/source/cli/dcs.rst @@ -1,6 +1,5 @@ -=================================================== -Distributed Cache Service (DCS) command-line client -=================================================== +Distributed Cache Service (DCS) +=============================== The DCS client is the command-line interface (CLI) for the Distributed Cache Service (DMS) API and its extensions. diff --git a/doc/source/cli/deh.rst b/doc/source/cli/deh.rst index a19e5b3b1..5975b41f4 100644 --- a/doc/source/cli/deh.rst +++ b/doc/source/cli/deh.rst @@ -1,6 +1,5 @@ -================================================ -Dedicated Host Service (DeH) command-line client -================================================ +Dedicated Host Service (DeH) +============================ The DeH client is the command-line interface (CLI) for the Dedicated Host Service (DeH) API and its extensions. diff --git a/doc/source/cli/dms.rst b/doc/source/cli/dms.rst index f51d36712..e28453920 100644 --- a/doc/source/cli/dms.rst +++ b/doc/source/cli/dms.rst @@ -1,6 +1,5 @@ -===================================================== -Distributed Message Service (DMS) command-line client -===================================================== +Distributed Message Service (DMS) +================================= The DMS client is the command-line interface (CLI) for the Distributed Message Service (DMS) API and its extensions. @@ -27,10 +26,24 @@ Group operations .. autoprogram-cliff:: openstack.dms.v1 :command: dms group * -.. _dms_quota: +.. _dms_instance: -Quota operations ----------------- +Instance operations +------------------- + +.. autoprogram-cliff:: openstack.dms.v1 + :command: dms instance * + +.. _dms_misq: + +Misc operations +--------------- + +.. autoprogram-cliff:: openstack.dms.v1 + :command: dms az list + +.. autoprogram-cliff:: openstack.dms.v1 + :command: dms maintenance window list .. autoprogram-cliff:: openstack.dms.v1 - :command: dms quota * + :command: dms product list diff --git a/doc/source/cli/dns.rst b/doc/source/cli/dns.rst index b2e58c38f..e8db53d8d 100644 --- a/doc/source/cli/dns.rst +++ b/doc/source/cli/dns.rst @@ -1,6 +1,5 @@ -============================================= -Domain Name Service (DNS) command-line client -============================================= +Domain Name Service (DNS) +========================= The DNS client is the command-line interface (CLI) for the Domain Name Service (DNS) API and its extensions. diff --git a/doc/source/cli/identity.rst b/doc/source/cli/identity.rst new file mode 100644 index 000000000..f6c8af7ce --- /dev/null +++ b/doc/source/cli/identity.rst @@ -0,0 +1,12 @@ +Identity Service (IAM) +====================== + +The Identity client is the command-line interface (CLI) for +the Identity Service (IAM) API and its extensions. + +For help on a specific `identity` command, enter: + +.. code-block:: console + + $ openstack identity help SUBCOMMAND + diff --git a/doc/source/cli/index.rst b/doc/source/cli/index.rst index 524564ba6..7cd2bca7a 100644 --- a/doc/source/cli/index.rst +++ b/doc/source/cli/index.rst @@ -1,19 +1,42 @@ -OpenStackClient CLI Usage -========================= +OpenStack Client (CLI) +====================== + +The OpenStack Client is a self-contained OpenStack project providing a +command line interface to the most important cloud functions. For most +of the API calls an equivalent CLI command is available under a shared +command invoked as ``openstack``. An example is ``openstack server +list``. For reference see the documentation of the OpenStack Client +(OSC). + +The OTC Extensions don't re-implement the CLI tool, but augment it +automatically. If you have installed OTC Extensions and OpenStack +Client, the latter understands many extra commands: + +.. code-block:: bash + + openstack --help | grep -c otcextensions + 164 + +For details of the available commands, check the detailed CLI +documentation of these services: .. toctree:: - :maxdepth: 2 + :maxdepth: 1 - anti_ddos.rst - auto_scaling.rst - cce_v2.rst - cts.rst - dcs.rst - deh.rst - dms.rst - dns.rst - rds.rst - kms.rst - load_balancer.rst - obs.rst - volume_backup.rst + anti_ddos + auto_scaling + cce_v2 + ces + cts + dcs + deh + dms + dns + identity + kms + load_balancer + nat + obs + rds_v3 + volume_backup + vpc diff --git a/doc/source/cli/kms.rst b/doc/source/cli/kms.rst index 758421746..094bb1be3 100644 --- a/doc/source/cli/kms.rst +++ b/doc/source/cli/kms.rst @@ -1,6 +1,5 @@ -================================================ -Key Management Service (KMS) command-line client -================================================ +Key Management Service (KMS) +============================ The KMS client is the command-line interface (CLI) for the Key Management service (KMS) API and its extensions. diff --git a/doc/source/cli/load_balancer.rst b/doc/source/cli/load_balancer.rst index 5f37c93db..623caca06 100644 --- a/doc/source/cli/load_balancer.rst +++ b/doc/source/cli/load_balancer.rst @@ -1,6 +1,5 @@ -======================================== -LoadBalancer service command-line client -======================================== +Elastic LoadBalancer (ELB) +========================== The load_balancer client is the command-line interface (CLI) for the native Neutron/Octavia LoadBalancer service (load_balancer) API. 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 fae6f4bf4..40991e4a8 100644 --- a/doc/source/cli/obs.rst +++ b/doc/source/cli/obs.rst @@ -1,6 +1,5 @@ -================================================ -Object Storage service (obs) command-line client -================================================ +Object Storage service (OBS) +============================ The OBS client is the command-line interface (CLI) for the ObjectBlockStorage service (OBS) API and its extensions. 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 afa7e95cb..88b3efdee 100644 --- a/doc/source/cli/rds.rst +++ b/doc/source/cli/rds_v3.rst @@ -1,6 +1,5 @@ -========================================== -Database service (rds) command-line client -========================================== +Relational Database Service (RDS) +================================= The RDS client is the command-line interface (CLI) for the Database service (RDS) API and its extensions. @@ -13,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/cli/volume_backup.rst b/doc/source/cli/volume_backup.rst index c3243c8bd..fb2ddd4e5 100644 --- a/doc/source/cli/volume_backup.rst +++ b/doc/source/cli/volume_backup.rst @@ -1,6 +1,5 @@ -=============================================== -Volume Backup Service (VBS) command-line client -=============================================== +Volume Backup Service (VBS) +=========================== The VBS client is the command-line interface (CLI) for the Volume Backup service (vbs) API and its extensions. diff --git a/doc/source/cli/vpc.rst b/doc/source/cli/vpc.rst new file mode 100644 index 000000000..52aa93f5e --- /dev/null +++ b/doc/source/cli/vpc.rst @@ -0,0 +1,27 @@ +Virtual Private Cloud (VPC) +=========================== + +The VPC client is the command-line interface (CLI) for +the Virtual Private Cloud (VPC) API and its extensions. + +For help on a specific `vpc` command, enter: + +.. code-block:: console + + $ openstack vpc help SUBCOMMAND + +.. _peering: + +Vpc Peering Operations +---------------------- + +.. autoprogram-cliff:: openstack.vpc.v2 + :command: vpc peering * + +.. _route: + +Vpc Route Operations +-------------------- + +.. autoprogram-cliff:: openstack.vpc.v2 + :command: vpc route * diff --git a/doc/source/contributor/coding.rst b/doc/source/contributor/coding.rst index 14ab10ff8..2689807e5 100644 --- a/doc/source/contributor/coding.rst +++ b/doc/source/contributor/coding.rst @@ -1,114 +1,148 @@ -======================================== OpenStack SDK Developer Coding Standards ======================================== -In the beginning, there were no guidelines. And it was good. But that -didn't last long. As more and more people added more and more code, -we realized that we needed a set of coding standards to make sure that -the openstacksdk API at least *attempted* to display some form of consistency. +We follow the coding guidelines of +https://docs.openstack.org/hacking/latest/ of the OpenStack project in +general and the adopt the special rules of the OpenStack SDk in +specific where applicable unless otherwise stated. + +The SDK project which the OTC Extensions augment developed a set of +coding standards and guidelines were developed. Note that not all code +of OTC Extensions adheres to these standards just yet. All new code +has to adhere to these guidelines. -Thus, these coding standards/guidelines were developed. Note that not -all of openstacksdk adheres to these standards just yet. Some older code has -not been updated because we need to maintain backward compatibility. -Some of it just hasn't been changed yet. But be clear, all new code -*must* adhere to these guidelines. +Below are the patterns and principles that we expect developers to +follow. -Below are the patterns that we expect openstacksdk developers to follow. Release Notes -============= +------------- -openstacksdk uses `reno `_ for -managing its release notes. A new release note should be added to +OTC Extensions use `reno `_ +for managing its release notes. A new release note should be added to your contribution anytime you add new API calls, fix significant bugs, add new functionality or parameters to existing API calls, or make any -other significant changes to the code base that we should draw attention -to for the user base. +other significant changes to the code base that we should draw +attention to for the user base. + +It is not necessary to add release notes for minor fixes, such as +correction of documentation typos, minor code cleanup or +reorganization, or any other change that a user would not notice +through normal usage. -It is *not* necessary to add release notes for minor fixes, such as -correction of documentation typos, minor code cleanup or reorganization, -or any other change that a user would not notice through normal usage. Exceptions -========== +---------- -Exceptions should NEVER be wrapped and re-raised inside of a new exception. -This removes important debug information from the user. All of the exceptions -should be raised correctly the first time. +Exceptions should never be wrapped and re-raised inside of a new +exception. This removes important debug information from the +user. All of the exceptions should be raised correctly the first time. -openstack.cloud API Methods -=========================== + +API Methods of ``openstack.cloud`` +----------------------------------- The `openstack.cloud` layer has some specific rules: -- When an API call acts on a resource that has both a unique ID and a +* When an API call acts on a resource that has both a unique ID and a name, that API call should accept either identifier with a name_or_id parameter. -- All resources should adhere to the get/list/search interface that +* All resources should adhere to the get/list/search interface that control retrieval of those resources. E.g., `get_image()`, `list_images()`, `search_images()`. -- Resources should have `create_RESOURCE()`, `delete_RESOURCE()`, +* Resources should have `create_RESOURCE()`, `delete_RESOURCE()`, `update_RESOURCE()` API methods (as it makes sense). -- For those methods that should behave differently for omitted or None-valued +* For those methods that should behave differently for omitted or None-valued parameters, use the `_utils.valid_kwargs` decorator. Notably: all Neutron `update_*` functions. -- Deleting a resource should return True if the delete succeeded, or False +* Deleting a resource should return True if the delete succeeded, or False if the resource was not found. + Returned Resources ------------------ -Complex objects returned to the caller must be a `munch.Munch` type. The -`openstack._adapter.ShadeAdapter` class makes resources into `munch.Munch`. +Complex objects returned to the caller must be a `munch.Munch` +type. The `openstack._adapter.ShadeAdapter` class makes resources into +`munch.Munch`. -All objects should be normalized. It is shade's purpose in life to make -OpenStack consistent for end users, and this means not trusting the clouds -to return consistent objects. There should be a normalize function in -`openstack/cloud/_normalize.py` that is applied to objects before returning -them to the user. See :doc:`../user/model` for further details on object model -requirements. +All objects should be normalized. It is shade's purpose in life to +make OpenStack consistent for end users, and this means not trusting +the clouds to return consistent objects. There should be a normalize +function in `openstack/cloud/_normalize.py` that is applied to objects +before returning them to the user. -Fields should not be in the normalization contract if we cannot commit to -providing them to all users. +Fields should not be in the normalization contract if we cannot commit +to providing them to all users. -Fields should be renamed in normalization to be consistent with -the rest of `openstack.cloud`. For instance, nothing in `openstack.cloud` -exposes the legacy OpenStack concept of "tenant" to a user, but instead uses -"project" even if the cloud in question uses tenant. +Fields should be renamed in normalization to be consistent with the +rest of `openstack.cloud`. For instance, nothing in `openstack.cloud` +exposes the legacy OpenStack concept of "tenant" to a user, but +instead uses "project" even if the cloud in question uses tenant. -Nova vs. Neutron ----------------- - -- Recognize that not all cloud providers support Neutron, so never - assume it will be present. If a task can be handled by either - Neutron or Nova, code it to be handled by either. - -- For methods that accept either a Nova pool or Neutron network, the - parameter should just refer to the network, but documentation of it - should explain about the pool. See: `create_floating_ip()` and - `available_floating_ip()` methods. Tests -===== +----- -- New API methods *must* have unit tests! +* New API methods must have unit tests. -- New unit tests should only mock at the REST layer using `requests_mock`. +* New unit tests should only mock at the REST layer using `requests_mock`. Any mocking of openstacksdk itself should be considered legacy and to be avoided. Exceptions to this rule can be made when attempting to test the internals of a logical shim where the inputs and output of the method aren't actually impacted by remote content. -- Functional tests should be added, when possible. +* Functional tests should be added, when possible. -- In functional tests, always use unique names (for resources that have this +* In functional tests, always use unique names (for resources that have this attribute) and use it for clean up (see next point). -- In functional tests, always define cleanup functions to delete data added +* In functional tests, always define cleanup functions to delete data added by your test, should something go wrong. Data removal should be wrapped in a try except block and try to delete as many entries added by the test as possible. + + +Docstrings +---------- + +Docstrings should only use triple-double-quotes (``"""``). + +Single-line docstrings should never have extraneous whitespace +between enclosing triple-double-quotes. + +Sentence fragments do not have punctuation. Specifically in the +command classes the one line docstring is also the help string for +that command and those do not have periods. + + """A one line docstring looks like this""" + + +Calling Methods +--------------- + +When breaking up method calls due to the 79 char line length limit, +use the alternate four space indent. With the first argument on the +succeeding line all arguments will then be vertically aligned. Use the +same convention used with other data structure literals and terminate +the method call with the last argument line ending with a comma and +the closing paren on its own line indented to the starting line level. + +.. code-block: python + unnecessarily_long_function_name( + 'string one', + 'string two', + kwarg1=constants.ACTIVE, + kwarg2=['a', 'b', 'c'], + ) + + +Python 3 Compatibility +---------------------- + +The OTC Extensions are developed for Python 3. Compatibility for +Python 2.7 might be present, but would be so on accident. diff --git a/doc/source/contributor/contributing.rst b/doc/source/contributor/contributing.rst deleted file mode 100644 index b1cd2f37d..000000000 --- a/doc/source/contributor/contributing.rst +++ /dev/null @@ -1 +0,0 @@ -.. include:: ../../../CONTRIBUTING.rst diff --git a/doc/source/contributor/index.rst b/doc/source/contributor/index.rst index 9c48e2af3..f66736122 100644 --- a/doc/source/contributor/index.rst +++ b/doc/source/contributor/index.rst @@ -1,92 +1,86 @@ Contributing to the OTC Extensions ================================== -This section of documentation pertains to those who wish to contribute to the -development of this project. If you're looking for documentation on how to use -the SDK to build applications, please see the `user <../user>`_ section. +This section of the documentation is intended for those who want to +contribute to the development of the OTC Extensions. If you're looking +for documentation on how to use the SDK to build applications, please +see the `SDK <../sdk>`_ section. -Contribution Mechanics ----------------------- +Setting up an Development Environment +------------------------------------- + +The first step towards contributing code and documentation is to setup +your development environment. The project implements a pretty standard +setup. It is fully documented in the :doc:`setup ` section. .. toctree:: :maxdepth: 2 - contributing + setup -Contacting the Developers -------------------------- -GitHub -****** +Project Layout +-------------- -Currently no official communication other than GitHub is available +The project contains a top-level ``otcextensions`` package, which houses +several modules that form the foundation upon which each service's API is +built on. Under the ``otcextensions`` package are packages for the +``sdk``, the ``osclient`` (OpenStackClient / CLI) and the related ``tests`` +of each service implementation. Inside of those directories, the custom +created services such as ``Cloud Container Engine (CCE)`` are hosted. -Email -***** +.. toctree:: + + layout -??? Coding Standards ---------------- -We are a bit stricter than usual in the coding standards department. It's a -good idea to read through the :doc:`coding ` section. +We are a bit stricter than usual in the coding standards +department. It's a good idea to read through the :doc:`coding +` section. .. toctree:: :maxdepth: 2 coding -Development Environment ------------------------ - -The first step towards contributing code and documentation is to setup your -development environment. We use a pretty standard setup, but it is fully -documented in our :doc:`setup ` section. - -.. toctree:: - :maxdepth: 2 - - setup Testing ------- The project contains three test packages, one for unit tests, one for -functional tests and one for examples tests. The ``openstack.tests.unit`` -package tests the SDK's features in isolation. The -``openstack.tests.functional`` and ``openstack.tests.examples`` packages test -the SDK's features and examples against an OpenStack cloud. +functional tests and one for examples tests. The +``openstack.tests.unit`` package tests the SDK's features in +isolation. The ``openstack.tests.functional`` and +``openstack.tests.examples`` packages test the SDK's features and +examples against an OpenStack cloud. .. toctree:: testing -Project Layout --------------- -The project contains a top-level ``openstack`` package, which houses several -modules that form the foundation upon which each service's API is built on. -Under the ``openstack`` package are packages for each of those services, -such as ``openstack.compute``. +Example SDK Service and Resource Implementation +----------------------------------------------- -.. toctree:: - - layout - -Adding Features ---------------- - -Does this SDK not do what you need it to do? Is it missing a service? Are you -a developer on another project who wants to add their service? You're in the -right place. Below are examples of how to add new features to the -OpenStack SDK. +Do the OTC Extensions not do what you need them to do? Are they +missing a service? Are you a developer on another project who wants to +add a service? You're in the right place. Below are examples of how to +add new features to the project. .. toctree:: :maxdepth: 2 create/resource -.. TODO(briancurtin): document how to create a proxy -.. TODO(briancurtin): document how to create auth plugins + +Contacting the OTC Extensions Developers +---------------------------------------- + +Currently no official communication other than `GitHub +`_ is +available. Feel free to open new issues if you want to contact us +directly or have questions related to the existent packages. diff --git a/doc/source/coverage.rst b/doc/source/coverage.rst new file mode 100644 index 000000000..48fd4548b --- /dev/null +++ b/doc/source/coverage.rst @@ -0,0 +1,121 @@ +Service Coverage +================ + +Currently, the OTC Extensions cover 13 different services additionally +to the vanilla OpenStack services implemented in OpenStack SDK. Two +services (rds and cce) are currently covered in the documentation +under several service tags. This may change in future. + +.. list-table:: + :name: service-coverage + :widths: 50 120 30 30 30 30 + :header-rows: 1 + + * - Endpoint + - Service + - GUI + - CLI + - SDK + - Comment + * - anti_ddos + - Anti-DDoS + - X + - X + - X + - + * - auto_scaling + - Auto-auto_scaling + - X + - X + - X + - + * - cce_v1 + - Cloud Container Engine + - X + - X + - X + - + * - cce_v3 + - Cloud Container Engine V2 + - X + - X + - X + - + * - ces + - Cloudeye + - X + - X + - X + - + * - cts + - Clout Trace Service + - X + - X + - X + - + * - dts + - Distributed Cache Service + - X + - X + - X + - + * - deh + - Dedicated Host + - X + - X + - X + - + * - dms + - Document Management Service + - X + - X + - X + - + * - dns + - Domain Name Service + - X + - X + - X + - + * - kms + - Key Management Service + - X + - X + - X + - + * - load_balancer + - Load Balancer + - X + - X + - + - + * - nat + - Network Address Translation + - X + - X + - X + - + * - obs + - Object Storage Service + - X + - X + - X + - + * - rds_v3 + - Relational Database Service + - X + - X + - X + - + * - vbs + - Volume Backup Service + - X + - X + - X + - + * - vpc_v2 + - Virtual Private Cloud + - X + - X + - X + - diff --git a/doc/source/enforcer.py b/doc/source/enforcer.py index ca79b0311..9d17ff323 100644 --- a/doc/source/enforcer.py +++ b/doc/source/enforcer.py @@ -20,8 +20,14 @@ LOG = logging.getLogger(__name__) # NOTE: We do this because I can't find any way to pass "-v" -# into sphinx-build through pbr... -DEBUG = True if os.getenv("ENFORCER_DEBUG") else False +# into sphinx-build through pbr ... + +if os.getenv("ENFORCER_DEBUG"): + DEBUG = True + LOG.info("ENFORCER: Debugging is on.") +else: + DEBUG = False + WRITTEN_METHODS = set() @@ -36,6 +42,7 @@ def get_proxy_methods(): names = ["otcextensions.sdk.anti_ddos.v1._proxy", "otcextensions.sdk.auto_scaling.v1._proxy", "otcextensions.sdk.cce.v1._proxy", + "otcextensions.sdk.ces.v1._proxy", "otcextensions.sdk.cts.v1._proxy", "otcextensions.sdk.dcs.v1._proxy", "otcextensions.sdk.dms.v1._proxy", @@ -116,7 +123,8 @@ def build_finished(app, exception): # We also need to deal with Proxy subclassing keystoneauth.adapter.Adapter # now - some of the warnings come from Adapter elements. for name in sorted(missing): - LOG.info("ENFORCER: %s was not included in the output" % name) + if DEBUG: + LOG.info("ENFORCER: %s was not included in the output" % name) if app.config.enforcer_warnings_as_errors and missing_count > 0: raise EnforcementError( diff --git a/doc/source/index.rst b/doc/source/index.rst index c113cd71d..08b18c3d7 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -1,61 +1,96 @@ Welcome to the OTC Extensions of the OpenStack SDK and CLI! =========================================================== -**Note:** Currently documentation is a mostly a copy of OpenStackSDK -documentation (used version). -It will be soon extended with OTC services. Keep watching +There are several ways to access an OpenStack cloud. The ultimate way +is accessing the `OpenStack API`_ directly. But that can be very +tedious. The `OpenStack SDK`_ is a Python based client library that +simplifies building applications to work with OpenStack clouds. The +`OpenStack Client`_ is its equivalent on the command line. -This documentation is split into three sections: +**This project, OTC Extensions,** adds extra functionality to the SDK +and the CLI offered by the `Open Telekom Cloud`_. Technically, the OTC +Extensions provide Python classes and methods to attach your own code +to the cloud. They also integrate seamless into the OpenStack Client, +providing many extra commands. -* an :doc:`installation ` guide -* a section for :doc:`users ` looking to build applications - which make use of OpenStack -* a section for those looking to :doc:`contribute ` - to this project +Content +------- -Installation ------------- +This documentation is split into sections, adressing major use +cases. Additionally some auxiliary documentation is available: .. toctree:: - :maxdepth: 2 + :includehidden: + :numbered: 1 + :maxdepth: 1 install/index + install/configuration + cli/index + sdk/index + contributor/index + coverage + appendices/index -CLI Usage ---------- -This guides give you an overview of the CLI commands +Installation and Configuration +------------------------------ -.. toctree:: - :maxdepth: 2 +The :doc:`installation guide ` explains to system +administrators and developers how to setup the project from system +packages, from pip, and directly from sources. OTC Extensions are easy +to :doc:`configure `. All credentials can be +configured conveniently in a few files. - cli/index -For Users ---------- +Working with the CLI tool +------------------------- -.. toctree:: - :maxdepth: 2 +Users who want to access Open Telekom Cloud specific services with +:doc:`command line tools ` for a shell like Bash find +documentation of all of their operations and properties in this +section. - user/index -For Contributors ----------------- +Writing your own Scripts for the Cloud +-------------------------------------- -.. toctree:: - :maxdepth: 2 +Developers writing own Python code may access the API easily by using +the OTC Extensions' classes and methods. The :doc:`SDK interfaces +` are documented in this section. - contributor/index -.. include:: ../../README.rst +Contribute to the Project +------------------------- + +To :doc:`contribute ` to the project itself, +developers find helpful background information and architecture +specification of OTC Extensions it this section. + General Information ------------------- -General information about the SDK including a glossary and release history. +There is general background information about the OTC Extensions +available: -.. toctree:: - :maxdepth: 1 +* A :doc:`glossary ` describes important terms + and their naming conventions. + +* The :doc:`history ` explains the ancestry of + this project. This may or may not be insightful if you want to + understand the project's architecture. + +* The project keeps a :doc:`release history + `. + +* A list of :doc:`issues ` is maintained. + +* Currently 13 services are :doc:`covered ` by the OTC + extensions. - Glossary of Terms - Release Notes +.. _OpenStack API: https://docs.openstack.org/api-quick-start/ +.. _OpenStack SDK: https://docs.openstack.org/openstacksdk/ +.. _OpenStack Client: https://docs.openstack.org/python-openstackclient/ +.. _Ansible modules: https://github.com/OpenTelekomCloud/ansible-collections/ +.. _Open Telekom Cloud: https://open-telekom-cloud.com/ diff --git a/doc/source/install/configuration.rst b/doc/source/install/configuration.rst new file mode 100644 index 000000000..5b396ea9c --- /dev/null +++ b/doc/source/install/configuration.rst @@ -0,0 +1,213 @@ +Configuration +============= + +You can connect to the Open Telekom Cloud and OpenStack clouds in general +using two approaches. The first one uses a credential file called +``clouds.yaml`` and the other one is to use ``environment variables``. + +.. _clouds-yaml: + +Configuring a clouds.yaml file +------------------------------ + +The credential file ``clouds.yaml`` will be queried automatically in different +locations with increasing precedence: + +1. system-wide (/etc/openstack/{clouds,secure}.yaml) +2. Home directory / user space (~/.config/openstack/{clouds,secure}.yaml) +3. Current directory (./{clouds,secure}.yaml) + +A sample clouds.yaml file is listed below to connect with Open Telekom Cloud: + +**clouds.yaml** + +.. code-block:: yaml + + clouds: + otc: + profile: otc + auth: + username: '' + password: '' + project_name: '' + # or project_id: '<123456_PROJECT_ID>' + user_domain_name: 'OTC00000000001000000xxx' + # or user_domain_id: '<123456_DOMAIN_ID>' + auth_url: 'https://iam.eu-de.otc.t-systems.com:443/v3' + interface: 'public' + identity_api_version: 3 # !Important + ak: '' # AK/SK pair for access to OBS + sk: '' + +.. note:: + The name ``otc`` is self-defined and can be changed to any value. + +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. + +Test your connection +^^^^^^^^^^^^^^^^^^^^ + +If you followed the `installation advices `_ for your specific +operating system, you can use the following command to test the basic +functionality. + +.. code-block:: bash + + $ openstack --os-cloud otc flavor list + + +Configuration of a Second Project +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Additional connections to other Openstack-clouds or -projects can be added +to the file as shown below: + +**clouds.yaml** + +.. code-block:: yaml + + clouds: + otcfirstproject: + profile: otc + auth: + username: '' + password: '' + project_name: '' + # or project_id: '<123456_PROJECT_ID>' + user_domain_name: 'OTC00000000001000000xxx' + # or user_domain_id: '<123456_DOMAIN_ID>' + auth_url: 'https://iam.eu-de.otc.t-systems.com:443/v3' + interface: 'public' + identity_api_version: 3 # !Important + ak: '' # AK/SK pair for access to OBS + sk: '' + otcsecondproject: + profile: otc + auth: + username: '' + password: '' + project_name: '' + # or project_id: '<123456_PROJECT_ID2>' + user_domain_name: 'OTC00000000001000000xxx' + # or user_domain_id: '<123456_DOMAIN_ID2>' + auth_url: 'https://iam.eu-de.otc.t-systems.com:443/v3' + interface: 'public' + identity_api_version: 3 # !Important + ak: '' # AK/SK pair for access to OBS + sk: '' + +Splitting the credentials in clouds.yaml and secure.yaml +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In some scenarios a split of security credentials from the configuration file +is necessary. The optional file ``secure.yaml`` can be used to store the +secret which is left out from ``clouds.yaml``: + +**clouds.yaml** + +.. code-block:: yaml + + clouds: + otc: + profile: otc + auth: + username: '' + project_name: '' + # or project_id: '<123456_PROJECT_ID>' + user_domain_name: 'OTC00000000001000000xxx' + # or user_domain_id: '<123456_DOMAIN_ID>' + auth_url: 'https://iam.eu-de.otc.t-systems.com:443/v3' + interface: 'public' + identity_api_version: 3 # !Important + ak: '' # AK/SK pair for access to OBS + sk: '' + +**secure.yaml** + +.. code-block:: yaml + + clouds: + otc: + auth: + password: '' + +.. _environment-variables: + +Agency based authorization +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Open Telekom Cloud supports a concept of agencies. One domain delegates access +to resources to another domain. After trust relationship is established the +following configuration can be used in ``clouds.yaml``: + +.. code-block:: yaml + + clouds: + otc: + profile: otc + auth_type: agency + auth: + username: '' + project_name: '' + # or project_id: '<123456_PROJECT_ID>' + user_domain_name: 'OTC00000000001000000xxx' + # or user_domain_id: '<123456_DOMAIN_ID>' + auth_url: 'https://iam.eu-de.otc.t-systems.com:443/v3' + target_domain_id: '<123456_DOMAIN_ID>' # Domain where agency is created + # or target_domain_name: '<123456_DOMAIN_NAME' + target_agency_name: 'test_agency' # name of the agency + target_project_name: '<123456_PROJECT_NAME>' # project scoped operations + # or target_project_id: '<123456_PROJECT_ID>' + # When target_project_xx is not set - domain scope is selected + +Configuration of Environment Variables +-------------------------------------- + +Instead of using the clouds.yaml file, environmnt variables can be configured +to connect to the Open Telekom Cloud. Create a simple file like ``.ostackrc`` +in the home directory and source the file to make the variables available. On +Open Telekom Cloud servers this file exists on bootup and needs to be changed +according to your credentials. + +.. code-block:: bash + + # .ostackrc file + export OS_USERNAME="" + export OS_USER_DOMAIN_NAME= + export OS_PASSWORD= # optional + export OS_TENANT_NAME=eu-de + export OS_PROJECT_NAME= + export OS_AUTH_URL=https://iam.eu-de.otc.t-systems.com:443/v3 + export NOVA_ENDPOINT_TYPE=publicURL + export OS_ENDPOINT_TYPE=publicURL + export CINDER_ENDPOINT_TYPE=publicURL + export OS_VOLUME_API_VERSION=2 + export OS_IDENTITY_API_VERSION=3 + export OS_IMAGE_API_VERSION=2 + +Run the source command to make the ``environment variables`` available. + +.. code-block:: bash + + $ source .ostackrc + +The ``environment variables`` are now available for usage. For testing your +connection run the following command. + +Test your connection +^^^^^^^^^^^^^^^^^^^^ + +If you followed the `installation advices `_ for your specific +operating system, you can use the following command to test the basic +functionality. + +.. code-block:: bash + + $ openstack flavor list + +.. note:: + You don't need to specify the `--os-cloud` parameter when environment + variables are used. diff --git a/doc/source/install/index.rst b/doc/source/install/index.rst index 42dba52c7..50eac4e40 100644 --- a/doc/source/install/index.rst +++ b/doc/source/install/index.rst @@ -1,393 +1,87 @@ -============ Installation ============ -There are several ways to install python-otcextensions to enhance the native -``openstack`` CLI client and to extend the OpenStack SDK to cover the -additional Open Telekom Cloud services providing a larger functionality -on top of OpenStack. +There are several install options for OTC Extensions to enhance the +native `OpenStack Client`_ and to extend the `OpenStack SDK`_. Once +installed, they cover additional `Open Telekom Cloud`_ services and +provide extra functionality on top of the stock OpenStack SDK and CLI. -The easiest way is to use the Python pip installer which is working -distribution independent and can be used in an isolated virtual environment -as described below. Ansible can be used to install python-otcextensions on -various operating systems, too by using the following Ansible Role: -https://github.com/OpenTelekomCloud/ansible-role-otcextensions . -There are also ready-made installation packages for various operating -systems which have their own versions, package names and sometimes bugs. -A repository based on openSUSE's build services tries to cover these issues -which is available under: -https://build.opensuse.org/project/show/Cloud:OTC:Tools:OpenStack. +.. toctree:: + :maxdepth: 3 + + pip_install + source_install Overview of Related Packages ---------------------------- -**OpenStackSDK:** -A library on the client side that translates Python function calls into -API calls to an OpenStack cloud. - -**OpenStackClient:** -An application that turns the Python interface of OpenStackSDK and -python-otcextensions into a CLI tool. - -**python-otcextensions:** -An addition to OpenStackSD with enhanced functionality that is specific for the -Open Telekom Cloud. - -Installation with pip installer -------------------------------- - -All three packages are written in Python and stored as Python libraries in the -PyPi repository. The following section describes the installation of -``OpenStackSDK``, ``otcextensions`` and ``OpenStackClient``. Please remember, -it is not the latest development state. For this purpose the latest sources -needs to be installed. - -Installation under Ubuntu or Debian -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For the installation, following packages are required: a C compiler, Python3 -with developer libraries, and package manager pip are required: - -.. code-block:: bash - - $ sudo apt update - $ sudo apt install gcc python3 python3-dev python3-pip libssl-dev - -Now, install all libraries and programs at once with the Python package -manager pip. The --user flag provides user wide installation instead of a -global installation. - -.. code-block:: bash - - $ pip3 install otcextensions python-openstackclient --user - - -Installation under CentOS -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For the installation, following packages are required: a C compiler, Python3 -with developer libraries, and package manager pip are required. If you want to -use python3 which is recommended, you need to install the epel -repository, first: - - -.. code-block:: bash - - $ sudo yum update - $ sudo yum install epel-release - $ sudo yum install gcc python36 python36-devel python36-pip openssl-devel - - -Now, install all libraries and programs at once with the Python package -manager pip: - -.. code-block:: bash - - $ pip3 install otcextensions python-openstackclient --user - -Installation under Fedora -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For the installation, following packages are required: a C compiler, Python3 -with developer libraries, and package manager pip are required: - - -.. code-block:: bash - - $ sudo dnf upgrade - $ sudo dnf install gcc python3 python3-devel python3-pip openssl-devel - -Now, install all libraries and programs at once with the Python package -manager pip: - -.. code-block:: bash - - $ pip3 install otcextensions python-openstackclient --user - - -Installation in a virtual environment with pip installer --------------------------------------------------------------- - -A virtual environment seperates your installed packages from other -libraries and should be used as well. - -Installation under Ubuntu or Debian -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For the installation, following packages are required: a C compiler, Python3 -with developer libraries, package manager, and virtual environment -are required: - -.. code-block:: bash - - $ sudo apt update - $ sudo apt install gcc python3 python3-dev python3-pip python3-venv libssl-dev - -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 -desires, in our example it is: "venv". The second command will switch -on "venv": - -.. code-block:: bash - - $ python3 -m venv venv - $ source venv/bin/activate - (venv) $ - -Now, install all libraries and programs at once with the Python package -manager pip: - -.. code-block:: bash - - $ pip install otcextensions openstackclient - - -Installation under 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: - - -.. 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 - -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 -desires, in our example it is: "venv". The second command will switch -on "venv": - -.. code-block:: bash - - $ python3 -m venv venv - $ source venv/bin/activate - -Now, install all libraries and programs at once with the Python package -manager pip: - -.. code-block:: bash - - $ pip install otcextensions openstackclient - -Installation under Fedora (under review) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The OTC Extensions are, as most software in OpenStack, written in +Python and are eventually a Python package. These packages come with +dependencies to other packages. Usually a package manager such as pip +is used to resolve those dependencies or all requirements are bundled +in a single packet. These are the main packages and their relations to +each other: + +**OpenStack SDK:** A library on the client side that translates Python +function calls into API calls to an OpenStack cloud. It depends only +on other, internal Python packages. + +**OpenStack Client:** An application that turns the Python interface +of OpenStack SDK and OTC Extensions into a CLI tool. If installed, it +requires the SDK. + +**OTC Extensions:** An addition to OpenStack SDK with enhanced +functionality that is specific for the Open Telekom Cloud. This is the +package you are currently looking at. It requires the SDK since it +extends its interfaces. If it is installed as a Python package it is +detected and integrated automatically by the other two packages +without further installation or configuration. + +So effectively, using a package manager like pip it is sufficient to +install the packages like this: + +.. code-block: console + $ pip install openstackclcient otcextensions + +Other packaging methods may or may not have these dependencies built +in already. + + +Installation Options +-------------------- + +There are a number of alternatives available to install OTC Extensions +(including the SDK and CLI): + +* **Installing from operating system packages (deb, rpm, yum, dnf):** + This is a very easy way that is also easy to revert. The downside of + this aproach is that operating system packages for the major + distributions are often quite outdated, as many of the internal + dependencies are also often outdated. You often experience a backlog + of several months up to years behind the latest development. + +* **Installing with a Python package manager (pip):** Python comes + with its own package manager `pip` for the `Python Package Index + (PyPI)`_. That is today the standard way to install Python + packages. All other described options use this method under the + hood. This way is operating system independent. Installing with + `pip` comes with three sub-options: Installing system-wide, for a + single user, or inside a virtual environemt. **This is the + recommended way to install OTC Extensions.** + +* **Installing from sources:** All related projects are hosted on + public source code repositories. So if you need a bleeding edge + feature or want to contribute directly to the project yourself, + installation from sources is for you. It requires some extra steps, + though. -For the installation, following packages are required: a C compiler, -Python3 with developer libraries, package manager, and a virtual -environment are required: - - -.. code-block:: bash - - $ sudo dnf upgrade - $ sudo dnf install gcc python3 python3-devel python3-pip \ - python3-virtualenv openssl-devel - -The virtual environment will be created and activated. You can name the -virtual environment on your own desires, in our example it is "venv": - -.. code-block:: bash - - $ python3 -m venv venv - $ source venv/bin/activate - -Now, install all libraries and programs at once with the Python package -manager pip: - -.. code-block:: bash - - (venv) $ pip install otcextensions openstackclient - - -Installation from Github sources --------------------------------- - -The latest state of the packages can be installed with the following approach. - -Cloning the Github repository: - -.. code-block:: bash - - $ git clone https://github.com/OpenTelekomCloud/python-otcextensions.git - -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 -desires, in our example it is: "venv". The second command will switch -on "venv": - -.. code-block:: bash - - $ python3 -m venv venv - $ source venv/bin/activate - (venv) $ - -Switch into the new folder which is created by cloning the repository and -install install the project dependencies into the virtual environment: - -.. code-block:: bash - - (venv) $ cd ./python-otcextensions - -Register the CLI plugin using: - -.. code-block:: bash - - (venv) ~/python-otcextensions$ python setup.py install - -Install Openstack-Client binary from pip-Repository: - -.. code-block:: bash - - (venv) ~/python-otcextensions$ pip install openstackclient - -Configuration for the Cloud Connection --------------------------------------- - -You can connect to the Open Telekom Cloud and OpenStack clouds in general -using two approaches. The first one uses a credential file called -``clouds.yaml`` and the other one is to use environment variables. - -Configuring a clouds.yaml file -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The credential file clouds.yaml will be queried automatically in different -locations with increasing precedence: - -1. system-wide (/etc/openstack/{clouds,secure}.yaml) -2. Home directory / user space (~/.config/openstack/{clouds,secure}.yaml) -3. Current directory (./{clouds,secure}.yaml) - -A sample clouds.yaml file is listed below to connect with Open Telekom Cloud: - -**clouds.yaml** - -.. 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' - -The name otc is self-defined and can be changed. 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. - -Additional connections to other Openstack-clouds or -projects can be added -to the file as shown below: - -**clouds.yaml** - -.. 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' - otcsecondproject: - region_name: eu-de - auth: - username: '' - password: '' - project_id: '' - user_domain_id: '' - auth_url: 'https://iam.eu-de.otc.t-systems.com:443/v3' - -Test your connection -^^^^^^^^^^^^^^^^^^^^ - -Use the following command to test the basic functionality. - -.. code-block:: bash - - $ openstack --os-cloud otc flavor list - -Splitting the credentials in clouds.yaml and secure.yaml -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -In some scenarios a split of security credentials from the configuration file -is necessary. The optional file ``secure.yaml`` can be used to store the -secret which is left out from ``clouds.yaml``: - -**clouds.yaml** - -.. code-block:: yaml - - clouds: - otc: - auth: - username: 'USER_NAME' - 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' - -**secure.yaml** - -.. code-block:: yaml - - clouds: - otc: - auth: - password: '' - -Configuration of Environment Variables --------------------------------------- - -Instead of using the clouds.yaml file, environmnt variables can be configured -to connect to the Open Telekom Cloud. Create a simple file like ``.ostackrc`` -in the home directory and source the file to make the variables available. On -Open Telekom Cloud servers this file exists on bootup and needs to be changed -according to your credentials. - -.. code-block:: bash - - 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= - -Test your connection -^^^^^^^^^^^^^^^^^^^^ - -Use the following command to test the basic functionality. - -.. code-block:: bash +There are also ready-made installation packages for various operating +systems which have their own versions, package names and sometimes +bugs. A repository based on openSUSE's build services tries to cover +these issues which is available under: +https://build.opensuse.org/project/show/Cloud:OTC:Tools:OpenStack. - $ openstack flavor list +.. _OpenStack SDK: https://docs.openstack.org/openstacksdk/ +.. _OpenStack Client: https://docs.openstack.org/python-openstackclient/ +.. _Open Telekom Cloud: https://open-telekom-cloud.com/ +.. _Python Package Index (PyPI): https://pypi.org/ diff --git a/doc/source/install/pip_install.rst b/doc/source/install/pip_install.rst new file mode 100644 index 000000000..046b1b019 --- /dev/null +++ b/doc/source/install/pip_install.rst @@ -0,0 +1,165 @@ +Installation with PiP Installer +=============================== + +All three packages are written in Python and stored as Python packages in the +PyPi repository. The following section describes the installation of +``OpenStackSDK``, ``otcextensions`` and ``OpenStackClient``. Please remember, +it is not the latest development state. For this purpose the latest sources +needs to be installed. + +PiP Installation in User Space +------------------------------ + +Ubuntu or Debian +^^^^^^^^^^^^^^^^ + +For the installation, following packages are required: a C compiler, Python3 +with developer libraries, and package manager pip are required: + +.. code-block:: bash + + $ sudo apt update + $ sudo apt install gcc python3 python3-dev python3-pip libssl-dev + +Now, install all libraries and programs at once with the Python package +manager pip. The --user flag provides user wide installation instead of a +global installation. + +.. code-block:: bash + + $ pip3 install otcextensions python-openstackclient --user + + +CentOS +^^^^^^ + +For the installation, following packages are required: a C compiler, Python3 +with developer libraries, and package manager pip are required. If you want to +use python3 which is recommended, you need to install the epel +repository, first: + +.. code-block:: bash + + $ sudo yum update + $ sudo yum install epel-release + $ sudo yum install gcc python3 python3-devel openssl-devel wheel + +Now, install all libraries and programs at once with the Python package +manager pip: + +.. code-block:: bash + + $ pip3 install otcextensions python-openstackclient --user + +Fedora +^^^^^^ + +For the installation, following packages are required: a C compiler, Python3 +with developer libraries, and package manager pip are required: + + +.. code-block:: bash + + $ sudo dnf upgrade + $ sudo dnf install gcc python3 python3-devel python3-pip openssl-devel + +Now, install all libraries and programs at once with the Python package +manager pip: + +.. code-block:: bash + + $ pip3 install otcextensions python-openstackclient --user + +PiP Installation within a Virtual Environment +--------------------------------------------- + +A virtual environment seperates your installed packages from other +libraries and should be used as well. + +Ubuntu or Debian +^^^^^^^^^^^^^^^^ + +For the installation, following packages are required: a C compiler, Python3 +with developer libraries, package manager, and virtual environment +are required: + +.. code-block:: bash + + $ sudo apt update + $ sudo apt install gcc python3 python3-dev python3-pip python3-venv libssl-dev + +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 +desires, in our example it is: "venv". The second command will switch +on "venv": + +.. code-block:: bash + + $ python3 -m venv venv + $ source venv/bin/activate + (venv) $ + +Now, install all libraries and programs at once with the Python package +manager pip: + +.. code-block:: bash + + $ pip install otcextensions openstackclient + + +CentOS +^^^^^^ + +For the installation, following packages are required: a C compiler, Python3 +with developer libraries, package manager, and virtual environment are +required: + +.. code-block:: bash + + $ sudo yum update + $ 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 +desires, in our example it is: "venv". The second command will switch +on "venv": + +.. code-block:: bash + + $ python3 -m venv venv + $ source venv/bin/activate + +Now, install all libraries and programs at once with the Python package +manager pip: + +.. code-block:: bash + + $ pip install otcextensions openstackclient + +Fedora +^^^^^^ + +For the installation, following packages are required: a C compiler, +Python3 with developer libraries, package manager, and a virtual +environment are required: + +.. code-block:: bash + + $ sudo dnf upgrade + $ sudo dnf install gcc python3 python3-devel python3-pip \ + python3-virtualenv openssl-devel + +The virtual environment will be created and activated. You can name the +virtual environment on your own desires, in our example it is "venv": + +.. code-block:: bash + + $ python3 -m venv venv + $ source venv/bin/activate + +Now, install all libraries and programs at once with the Python package +manager pip: + +.. code-block:: bash + + (venv) $ pip install otcextensions openstackclient diff --git a/doc/source/install/source_install.rst b/doc/source/install/source_install.rst new file mode 100644 index 000000000..eaa4fb9df --- /dev/null +++ b/doc/source/install/source_install.rst @@ -0,0 +1,41 @@ +Installation from GitHub sources +================================ + +The latest state of the packages can be installed with the following +source installation approach. + +Cloning the Github repository: + +.. code-block:: bash + + $ git clone https://github.com/OpenTelekomCloud/python-otcextensions.git + +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 +desires, in our example it is: "venv". The second command will switch +on "venv": + +.. code-block:: bash + + $ python3 -m venv venv + $ source venv/bin/activate + (venv) $ + +Switch into the new folder which is created by cloning the repository and +install install the project dependencies into the virtual environment: + +.. code-block:: bash + + (venv) $ cd ./python-otcextensions + +Register the CLI plugin using: + +.. code-block:: bash + + (venv) ~/python-otcextensions$ python setup.py install + +Install Openstack-Client binary from pip-Repository: + +.. code-block:: bash + + (venv) ~/python-otcextensions$ pip install openstackclient diff --git a/doc/source/releasenotes.rst b/doc/source/releasenotes.rst deleted file mode 100644 index 74fa320f0..000000000 --- a/doc/source/releasenotes.rst +++ /dev/null @@ -1,5 +0,0 @@ -============= -Release Notes -============= - -Release notes for `python-otcextensions` are currently not implemented diff --git a/doc/source/sdk/architecture.rst b/doc/source/sdk/architecture.rst new file mode 100644 index 000000000..897f0a22c --- /dev/null +++ b/doc/source/sdk/architecture.rst @@ -0,0 +1,17 @@ +Architecture Overview and Important Terms +========================================= + +The OTC Extensions contain an abstraction interface layer. Clouds can +do many things, but there are probably only about ten of them that +most people care frequently. + +If you want to do complicated things, the per-service oriented +portions of the SDK are for you. However, if what you want is to be +able to write an application that talks to clouds no matter what crazy +choices the deployer has made in an attempt to be more hipster than +their self-entitled narcissist peers, then the Cloud Abstraction layer +is for you. + +The OTC Extensions provide an extension to the OpenStack SDK. Refer to +its documentation for the details: +. diff --git a/doc/source/sdk/examples b/doc/source/sdk/examples new file mode 120000 index 000000000..d4cb9b9c8 --- /dev/null +++ b/doc/source/sdk/examples @@ -0,0 +1 @@ +../../../examples/ \ No newline at end of file diff --git a/doc/source/sdk/getting_started.rst b/doc/source/sdk/getting_started.rst new file mode 100644 index 000000000..1588cec8e --- /dev/null +++ b/doc/source/sdk/getting_started.rst @@ -0,0 +1,101 @@ +Getting Started +=============== + +Verify Installation +------------------- + +``OTC Extensions`` needs to be installed correctly. Please check +:doc:`../install/index` for further instructions. The +``otcextensions`` Python package pulls the ``openstacksdk`` package +automatically as dependency which is needed to create own OpenStack scripts. + +Configure Connection Credentials +-------------------------------- + +In order to work with an OpenStack cloud you first need to create a +:class:`~openstack.connection.Connection` using your credentials. A +:class:`~openstack.connection.Connection` can be created in three +ways, using the class itself, :ref:`clouds-yaml`, or +:ref:`environment-variables`. It is recommended use +:ref:`clouds-yaml` as the same config can be used across tools +and languages. Examples are: + +- OpenStack Client +- Gophercloud (library for golang) +- Terraform (based on Gophercloud) + +.. note:: Please be also aware that environment variables carrying + credentials can be a security risk. + + +Creating a Minimal Python Script +-------------------------------- + +At first we need to import `openstack` to get access to all available +:doc:`Proxy ` functions. Enable Logging is an optional +step in the script and can be left out in productive usage. +For communication purposes a :class:`~openstack.connection.Connection` +instance is created to communicate with the Cloud environment. The +`cloud=` represents the :class:`~openstack.connection.Connection` +name defined while creating the ``clouds.yaml`` file in :ref:`clouds-yaml`. +The ``cloud``-variable can be left out if environment variables are +used or only ``one`` Cloud-connection is defined. + +.. code-block:: python + + #!/usr/bin/env python3 + + import openstack + + # optional, enable Logging on + openstack.enable_logging(True) + + # Creates cloud connection + # Parameter cloud='otc' is optional for env variables or single + # clouds.yaml entry. + conn = openstack.connect(cloud='otc') + + for server in conn.compute.servers(): + print(server) + +.. note:: For further examples, see `Examples `_. + +.. note:: For further information about logging, please see + :doc:`Logging User Guide `. + +Run the Script +-------------- + +After saving the script as `list_server.py`. You can simply run it by using +the following command. + +.. code-block:: bash + + python list_server.py + +The output represents all existent OpenStack servers in your Cloud +environment. + +OTC Extensions specific Example for Open Telekom Cloud +------------------------------------------------------ + +The following script uses the OTC Extensions to list all existent CCE Clusters +in your account. + +.. code-block:: python + + #!/usr/bin/env python3 + + import openstack + + # openstack.enable_logging(True) + conn = openstack.connect() + + for cluster in conn.cce.clusters(): + print(cluster) + +Save the file as `list_cce_clusters.py` and run it with: + +.. code-block:: bash + + python list_cce_clusters.py diff --git a/doc/source/sdk/guides/anti_ddos.rst b/doc/source/sdk/guides/anti_ddos.rst new file mode 100644 index 000000000..28a82624a --- /dev/null +++ b/doc/source/sdk/guides/anti_ddos.rst @@ -0,0 +1,109 @@ +Anti-DDoS (AS) +============== + +.. contents:: Table of Contents + :local: + +Floating-IP Operations +---------------------- + +Floating IP operations lists all methods which are used to query and modify +Floating IPs settings related to Anti-DDoS. + +List Anti-DDoS Floating IPs +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all Floating IPs protected by Anti-DDoS and +limit the output with parameters. + +.. literalinclude:: ../examples/anti_ddos/list_floating_ips.py + :lines: 16-23 + +Protect an Floating IP (not working) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to enable Anti-DDoS on a Floating IP by using IP id or +an instance of class +:class:`~otcextensions.sdk.anti_ddos.v1.floating_ip.FloatingIP`. + +.. literalinclude:: ../examples/anti_ddos/protect_floating_ip.py + :lines: 17-23 + +Unprotect an Floating IP (not working) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to disable Anti-DDoS on a Floating IP by using IP id or +an instance of class +:class:`~otcextensions.sdk.anti_ddos.v1.floating_ip.FloatingIP`. + +.. literalinclude:: ../examples/anti_ddos/unprotect_floating_ip.py + :lines: 17-23 + +Get Floating IP Policies +^^^^^^^^^^^^^^^^^^^^^^^^ + +This Interface is used to query the Anti-DDoS Policy for a specific Floating +IP by using Floating IP id or an instance of class +:class:`~otcextensions.sdk.anti_ddos.v1.floating_ip.FloatingIP`. Anti-DDoS +must be enabled for the specific Floating IP otherwise an error occures. + +.. literalinclude:: ../examples/anti_ddos/get_floating_ip_policies.py + :lines: 18-25 + +Update Floating IP Policies +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This Interface is used to update Anti-DDoS Policy attributes. + +.. literalinclude:: ../examples/anti_ddos/update_floating_ip_policies.py + :lines: 16-30 + +Get Floating IP Status +^^^^^^^^^^^^^^^^^^^^^^ + +This Interface is used to query Anti-DDoS status of a Floating IP by using +id. + +.. literalinclude:: ../examples/anti_ddos/get_floating_ip_status.py + :lines: 16-25 + +List Floating IP Events +^^^^^^^^^^^^^^^^^^^^^^^ + +This Interface is used to query all Anti-DDoS events of a Floating IP by using +id. + +.. literalinclude:: ../examples/anti_ddos/list_floating_ip_events.py + :lines: 16-25 + +List Floating IP Day Statistics +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This Interface is used to query all Anti-DDoS events per day of a Floating IP +by using id. + +.. literalinclude:: ../examples/anti_ddos/list_floating_ip_stat_day.py + :lines: 16-25 + +List Week Statistics of all Floating IPs +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This Interface is used to query all Anti-DDoS events per week of all Floating +IPs. + +.. literalinclude:: ../examples/anti_ddos/list_floating_ip_stat_week.py + :lines: 16-23 + +Alarm Configuration +------------------- + +Anti-DDoS alerts can be sent in various ways and notifies in case of defense. + +List Alarm Configurations +^^^^^^^^^^^^^^^^^^^^^^^^^ + +This Interface is used to query Anti-DDoS alarm configurations. + +.. literalinclude:: ../examples/anti_ddos/list_configs.py + :lines: 16-23 + diff --git a/doc/source/sdk/guides/auto_scaling.rst b/doc/source/sdk/guides/auto_scaling.rst new file mode 100644 index 000000000..598e1765b --- /dev/null +++ b/doc/source/sdk/guides/auto_scaling.rst @@ -0,0 +1,300 @@ +Auto-Scaling (AS) +================= + +.. contents:: Table of Contents + :local: + +Auto-Scaling Configuration +-------------------------- + +An Auto-Scaling (AS) configuration is a template of Elastic Cloud Servers in +an AS group. It defines the specifications of the instances to be added to +the AS group. The AS configuration is decoupled from the AS group and can +be used several times in different groups. Up to 100 AS configurations can +be created for each user. + +List Configurations +^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all Auto-Scaling configurations and to filter +the output with query parameters. + +.. literalinclude:: ../examples/auto_scaling/list_configs.py + :lines: 16-22 + +Create Configuration +^^^^^^^^^^^^^^^^^^^^ + +This interface is used to create an Auto-Scaling Configuration instance with +parameters. + +.. literalinclude:: ../examples/auto_scaling/create_config.py + :lines: 16-36 + +Get Configuration +^^^^^^^^^^^^^^^^^ + +This interface is used to get an Auto-Scaling Configuration by ID +or an instance of class +:class:`~otcextensions.sdk.auto_scaling.v1.config.Config`. + +.. literalinclude:: ../examples/auto_scaling/get_config.py + :lines: 16-24 + +Find Configuration +^^^^^^^^^^^^^^^^^^ + +This interface is used to find an Auto-Scaling Configuration instance by +name or id. + +.. literalinclude:: ../examples/auto_scaling/find_config.py + :lines: 16-24 + +Delete Configuration +^^^^^^^^^^^^^^^^^^^^ + +This interface is used to delete an Auto-Scaling Configuration instance by id +or an instance of class +:class:`~otcextensions.sdk.auto_scaling.v1.config.Config`. + +.. literalinclude:: ../examples/auto_scaling/delete_config.py + :lines: 16-23 + +Batch Delete Configurations +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to delete multiple Auto-Scaling Configuration instances +by id or an instance of +class :class:`~otcextensions.sdk.auto_scaling.v1.config.Config`. + +.. literalinclude:: ../examples/auto_scaling/batch_delete_config.py + :lines: 16-26 + + +Auto-Scaling Group +------------------ + +An Auto-Scaling (AS) group consists of a collection of instances that apply +to the same scaling scenario. An AS group specifies parameters, such as the +maximum number of instances, expected number of instances, minimum number +of instances, VPC, subnet, and load balancing. Each user can create a maximum +of 25 AS groups by default. + +List Groups +^^^^^^^^^^^ + +This interface is used to query all Auto-Scaling Groups and to filter +the output with query parameters. + +.. literalinclude:: ../examples/auto_scaling/list_groups.py + :lines: 16-22 + +Create Group +^^^^^^^^^^^^ + +This interface is used to create an Auto-Scaling Group with parameters. + +.. literalinclude:: ../examples/auto_scaling/create_group.py + :lines: 16-37 + +Get Group +^^^^^^^^^ + +This interface is used to get an Auto-Scaling Group by ID +or an instance of class +:class:`~otcextensions.sdk.auto_scaling.v1.group.Group`. + +.. literalinclude:: ../examples/auto_scaling/get_group.py + :lines: 16-24 + +Find Group +^^^^^^^^^^ + +This interface is used to find an Auto-Scaling Group instance by +name or id. + +.. literalinclude:: ../examples/auto_scaling/find_group.py + :lines: 16-24 + +Delete Group +^^^^^^^^^^^^ + +This interface is used to delete an Auto-Scaling Group instance by id or +an instance of class :class:`~otcextensions.sdk.auto_scaling.v1.group.Group`. + +.. literalinclude:: ../examples/auto_scaling/delete_group.py + :lines: 16-23 + +Pause Group +^^^^^^^^^^^ + +This interface is used to pause an Auto-Scaling Group instance in +passive state by using id or an instance of +class :class:`~otcextensions.sdk.auto_scaling.v1.group.Group`. + +.. literalinclude:: ../examples/auto_scaling/pause_group.py + :lines: 16-25 + +Resume Group +^^^^^^^^^^^^ + +This interface is used to resume an Auto-Scaling Group instance in +active state by using id or an instance of +class :class:`~otcextensions.sdk.auto_scaling.v1.group.Group`. + +.. literalinclude:: ../examples/auto_scaling/resume_group.py + :lines: 16-24 + +Auto-Scaling Policy +------------------- + +An Auto-Scaling (AS) policy defines whether to increase or decrease the number +of instances in an AS group. If the number and the expected number of +instances in an AS group are different due to the execution of the AS policy, +AS automatically adjusts the number of instances to the expected. AS supports +the following policy variants: + +* alarm-triggered policy +* periodic policy +* scheduled policy + +List Policy +^^^^^^^^^^^ + +This interface is used to query all Auto-Scaling Policies of an AS group +and to filter the output with query parameters. + +.. literalinclude:: ../examples/auto_scaling/list_policies.py + :lines: 16-25 + +Create Policy +^^^^^^^^^^^^^ + +This interface is used to create an Auto-Scaling Policy with parameters. + +.. literalinclude:: ../examples/auto_scaling/create_policy.py + :lines: 16-35 + + +Get Policy +^^^^^^^^^^ + +This interface is used to get an Auto-Scaling Policy by ID +or an instance of class +:class:`~otcextensions.sdk.auto_scaling.v1.policy.Policy`. + +.. literalinclude:: ../examples/auto_scaling/get_policy.py + :lines: 16-24 + +Find Policy +^^^^^^^^^^^ + +This interface is used to find an Auto-Scaling Policy instance by +name or id. + +.. literalinclude:: ../examples/auto_scaling/find_policy.py + :lines: 16-24 + +Delete Policy +^^^^^^^^^^^^^ + +This interface is used to delete an Auto-Scaling Policy instance by id +or an instance of class +:class:`~otcextensions.sdk.auto_scaling.v1.policy.Policy`. + +.. literalinclude:: ../examples/auto_scaling/delete_policy.py + :lines: 16-23 + +Update Policy +^^^^^^^^^^^^^ + +This interface is used to update an Auto-Scaling Policy instance by +using policy's id or an instance of class +:class:`~otcextensions.sdk.auto_scaling.v1.policy.Policy` and provide new +attributes. + +.. literalinclude:: ../examples/auto_scaling/update_policy.py + :lines: 16-39 + +Pause Policy +^^^^^^^^^^^^ + +This interface is used to pause an Auto-Scaling Policy instance in +passive state by using id or an instance of +class :class:`~otcextensions.sdk.auto_scaling.v1.policy.Policy`. + +.. literalinclude:: ../examples/auto_scaling/pause_policy.py + :lines: 16-25 + +Resume Policy +^^^^^^^^^^^^^ + +This interface is used to resume an Auto-Scaling Policy instance in +active state by using id or an instance of +class :class:`~otcextensions.sdk.auto_scaling.v1.policy.Policy`. + +.. literalinclude:: ../examples/auto_scaling/resume_policy.py + :lines: 16-25 + +Execute Policy +^^^^^^^^^^^^^^ + +This interface is used to execute an Auto-Scaling Policy instance and +run the defined actions. + +.. literalinclude:: ../examples/auto_scaling/execute_policy.py + :lines: 16-25 + +Auto-Scaling Instance +--------------------- + +An Auto-Scaling (AS) Instance is the executive unit of an Auto-Scaling group. + +List Instances +^^^^^^^^^^^^^^ + +This interface is used to query all Auto-Scaling Instances of an AS group +and to filter the output with query parameters. + +.. literalinclude:: ../examples/auto_scaling/list_instances.py + :lines: 16-25 + +Remove Instance +^^^^^^^^^^^^^^^ + +This interface is used to remove an Auto-Scaling Instances of an AS group. + +.. literalinclude:: ../examples/auto_scaling/remove_instance.py + :lines: 16-26 + +Batch Action Instance +^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to run actions on an Auto-Scaling group by adding +or deleting instance. + +.. literalinclude:: ../examples/auto_scaling/batch_instance_action.py + :lines: 16-37 + +Auto-Scaling Actions and Quotas +------------------------------- + +Auto-Scaling quotas and query scaling action logs can be querried. + +List Scaling Actions +^^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all Auto-Scaling scaling action logs +of an AS group and to filter the output with query parameters. + +.. literalinclude:: ../examples/auto_scaling/list_activities.py + :lines: 16-27 + +List User or Group Quota for Auto-Scaling +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all Auto-Scaling quotas of an AS group +or a user and to filter the output with query parameters. + +.. literalinclude:: ../examples/auto_scaling/list_quotas.py + :lines: 16-27 diff --git a/doc/source/sdk/guides/cce.rst b/doc/source/sdk/guides/cce.rst new file mode 100644 index 000000000..a5925356b --- /dev/null +++ b/doc/source/sdk/guides/cce.rst @@ -0,0 +1,145 @@ +Cloud Container Engine (CCE) +============================ + +.. contents:: Table of Contents + :local: + +CCE Cluster +----------- + +Cloud Container Engine (CCE) is a highly reliable and high-performance service +that allows enterprises to manage containerized applications. With support +for Kubernetes-native applications and tools, CCE makes it simple to set up +an environment for running containers in the cloud. CCE Clusters are the +environment where cluster nodes are administrated. The core component +is a Kubernetes Cluster with advanced features. + +List CCE Clusters +^^^^^^^^^^^^^^^^^ + +This interface is used to query all CCE clusters and to filter +the output with query parameters. + +.. literalinclude:: ../examples/cce/list_clusters.py + :lines: 16-22 + +Create CCE Cluster +^^^^^^^^^^^^^^^^^^ + +This interface is used to create a CCE cluster instance with +parameters. + +.. literalinclude:: ../examples/cce/create_cluster.py + :lines: 16-53 + +Get CCE Cluster +^^^^^^^^^^^^^^^ + +This interface is used to get a CCE cluster by ID +or an instance of class +:class:`~otcextensions.sdk.cce.v3.cluster.Cluster`. + +.. literalinclude:: ../examples/cce/get_cluster.py + :lines: 16-24 + +Find CCE Cluster +^^^^^^^^^^^^^^^^ + +This interface is used to find a CCE cluster by ID +or name. + +.. literalinclude:: ../examples/cce/find_cluster.py + :lines: 16-24 + +Delete CCE Cluster +^^^^^^^^^^^^^^^^^^ + +This interface is used to get a CCE cluster by ID +or an instance of class +:class:`~otcextensions.sdk.cce.v3.cluster.Cluster`. + +.. literalinclude:: ../examples/cce/delete_cluster.py + :lines: 16-25 + +CCE Node +-------- + +A CCE cluster node is the computing instance of a CCE cluster where +containers are hosted. One cluster can manage several nodes which +can be distributed over different availability zones to increase +reliability. + +List CCE Cluster Nodes +^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to query all nodes of a CCE cluster +and to filter the output with query parameters. + +.. literalinclude:: ../examples/cce/list_cluster_nodes.py + :lines: 16-25 + +Create CCE Cluster Node +^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to create a CCE cluster node instance with +parameters. + +.. literalinclude:: ../examples/cce/create_cluster_node.py + :lines: 16-53 + +Get CCE Cluster Node +^^^^^^^^^^^^^^^^^^^^ + +This interface is used to get a CCE cluster by ID +or an instance of class +:class:`~otcextensions.sdk.cce.v3.cluster_node.ClusterNode`. + +.. literalinclude:: ../examples/cce/get_cluster_node.py + :lines: 16-26 + +Find CCE Cluster Node +^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to find a node of a CCE cluster by ID +or name. + +.. literalinclude:: ../examples/cce/find_cluster_node.py + :lines: 16-26 + +Delete CCE Cluster Node +^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to delete a CCE cluster node by ID +or an instance of class +:class:`~otcextensions.sdk.cce.v3.cluster_node.ClusterNode`. + +.. literalinclude:: ../examples/cce/delete_cluster_node.py + :lines: 16-25 + +Job Operations +-------------- + +Jobs are created while cluster creation and other similar operations +have been started. Jobs have different phases and can be triggered by +the following methods. + +Get Job +^^^^^^^ + +This interface is used to get a CCE Job by ID +or an instance of class +:class:`~otcextensions.sdk.cce.v3.job.Job`. + +.. literalinclude:: ../examples/cce/get_job.py + :lines: 16-24 + +Wait for a Job +^^^^^^^^^^^^^^ + +This interface is used to wait for a CCE Job until reaches a specific state +by using ID or an instance of class +:class:`~otcextensions.sdk.cce.v3.job.Job`. + +.. literalinclude:: ../examples/cce/wait_for_job.py + :lines: 16-24 + diff --git a/doc/source/sdk/guides/ces.rst b/doc/source/sdk/guides/ces.rst new file mode 100644 index 000000000..f4916caea --- /dev/null +++ b/doc/source/sdk/guides/ces.rst @@ -0,0 +1,115 @@ +Cloud Eye Service (CES) +========================= + +Cloud Eye (CES) is a high-performance monitoring service with integrated +alarm functions. Open Telekom Cloud users benefit from a dashboard with +a basic overview of resources and their current status. Users can +configure the alarm function in such a way that they receive +notifications via SMS or email. Monitoring with the Cloud Eye Service +is activated by default; the free service does not need to be booked +or activated. + +.. contents:: Table of Contents + :local: + +CES Alarm Rule +-------------- + +The alarm function is based on collected metrics. You can set alarm rules for +key metrics of cloud services. When the metric data triggers the conditions +set in the alarm rule, Cloud Eye sends emails, or text messages, to you, or +sends HTTP/HTTPS requests to the servers. In this way, you are immediately +informed of cloud service exceptions and can quickly handle the faults to +avoid service losses. + +Cloud Eye uses the SMN service to notify users. This +requires you to create a topic and add subscriptions to this topic on the +SMN console first. Then when you create alarm rules, you can enable the +Alarm Notification function and select the created topic. When an error +occurs, Cloud Eye can broadcast alarm information to those subscriptions in +real time. + + +Create Alarm Rule +^^^^^^^^^^^^^^^^^ + +This interface is used to create a CES alarm with parameters. + +.. literalinclude:: ../examples/ces/create_alarm.py + :lines: 16-89 + +Get Alarm Rule +^^^^^^^^^^^^^^ + +This interface is used to get a CES alarm rule by name or ID or an instance of +class :class:`~otcextensions.sdk.ces.v1.alarm.Alarm`. + +.. literalinclude:: ../examples/ces/get_alarm.py + :lines: 16-24 + +Delete Alarm Rule +^^^^^^^^^^^^^^^^^ + +This interface is used to delete a CES Alarm Rule instance by id +or an instance of class +:class:`~otcextensions.sdk.cts.v1.tracker.Tracker`. + +.. literalinclude:: ../examples/ces/delete_alarm.py + :lines: 16-25 + +Switch Alarm Rule State +^^^^^^^^^^^^^^^^^^^^^^^^ + +This interface is used to switch the Alarm Rule State by using name or id. + +.. literalinclude:: ../examples/ces/switch_alarm_state.py + :lines: 16-25 + + +Monitoring Data Management +-------------------------- + +Monitoring / Metric data is used to generate and query custom monitoring +data. + +List Metric Data +^^^^^^^^^^^^^^^^ + +This interface is used to query all CES metric data and to filter +the output with query parameters. + +.. literalinclude:: ../examples/ces/list_metric_data.py + :lines: 16-34 + + +Miscellaneous +------------- + +List Metrics +^^^^^^^^^^^^ + +This API is used to query the metric list. You can specify the namespace, +metric, dimension, sorting order, start records, and the maximum number of +records when using this API to query metrics. + +.. literalinclude:: ../examples/ces/list_metrics.py + :lines: 16-23 + +List Quotas +^^^^^^^^^^^ + +This API is used to query a resource quota and the used amount. The current +resource refers to alarm rules only. + +.. literalinclude:: ../examples/ces/list_quotas.py + :lines: 16-23 + +List Host Configuration / Event Data +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This API is used to query the host configuration for a specified event type +in a specified period of time. You can specify the dimension of data to be +queried. + +.. literalinclude:: ../examples/ces/list_event_data.py + :lines: 16-32 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/user/guides/deh.rst b/doc/source/sdk/guides/deh.rst similarity index 88% rename from doc/source/user/guides/deh.rst rename to doc/source/sdk/guides/deh.rst index 81ce7493e..8e0f49bfd 100644 --- a/doc/source/user/guides/deh.rst +++ b/doc/source/sdk/guides/deh.rst @@ -1,10 +1,5 @@ -Using OTC DeH -============= - -Before working with the Dedicated Host service, you'll need to create a -connection to your OTC cloud account by following the :doc:`connect_otc` user -guide. This will provide you with the ``conn`` variable used in the examples -below. +Dedicated Hosts (DeH) +===================== .. contents:: Table of Contents :local: 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 new file mode 100644 index 000000000..9aab4c3cc --- /dev/null +++ b/doc/source/sdk/guides/index.rst @@ -0,0 +1,49 @@ +Guides for SDK +============== + +Open Telekom Cloud related User Guides +-------------------------------------- + +.. toctree:: + :maxdepth: 1 + + anti_ddos + auto_scaling + cce + ces + cts + dcs + deh + dns + kms + nat + rds + vpc + logging + +.. _user_guides: + +User Guides +----------- + +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 +---------------------------- + +.. toctree:: + :maxdepth: 1 + + Block Storage + Compute + Identity + Image + Key Manager + Message + Microversions + Network + Object Store + Using Cloud Abstration Layer 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/user/guides/logging.rst b/doc/source/sdk/guides/logging.rst similarity index 100% rename from doc/source/user/guides/logging.rst rename to doc/source/sdk/guides/logging.rst 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/doc/source/sdk/guides/vpc.rst b/doc/source/sdk/guides/vpc.rst new file mode 100644 index 000000000..cb15c6cb6 --- /dev/null +++ b/doc/source/sdk/guides/vpc.rst @@ -0,0 +1,131 @@ +Virtual Private Cloud (VPC) +=========================== + +.. contents:: Table of Contents + :local: + +VPC Peering Connection +---------------------- + +A VPC peering connection is a network connection between two VPCs that +enables you to route traffic between them using private IP addresses. +ECSs in either VPC can communicate with each other just as if they were in +the same VPC. You can create a VPC peering connection between your own VPCs, +or between your VPC and another account's VPC within the same region. A VPC +peering connection between VPCs in different regions will not take effect. + +List VPC Peerings +^^^^^^^^^^^^^^^^^ + +This interface is used to query all VPC peering connections accessible to the +tenant submitting the request. The connections are filtered based on the +filtering condition. +:class:`~otcextensions.sdk.vpc.v2.peering.Peering`. + +.. literalinclude:: ../examples/vpc/list_peerings.py + :lines: 16-23 + +Create VPC Peering +^^^^^^^^^^^^^^^^^^ + +This interface is used to create a VPC peering connection with +parameters. +:class:`~otcextensions.sdk.vpc.v2.peering.Peering`. + +.. literalinclude:: ../examples/vpc/create_peering.py + :lines: 16-33 + +Get VPC Peering +^^^^^^^^^^^^^^^ + +This interface is used to get a VPC peering connection by ID +or an instance of class. +:class:`~otcextensions.sdk.vpc.v2.peering.Peering`. + +.. literalinclude:: ../examples/vpc/get_peering.py + :lines: 16-26 + +Find VPC Peering +^^^^^^^^^^^^^^^^ + +This interface is used to find a VPC peering connection by id or name. +:class:`~otcextensions.sdk.vpc.v2.peering.Peering`. + +.. literalinclude:: ../examples/vpc/find_peering.py + :lines: 16-26 + +Update VPC Peering +^^^^^^^^^^^^^^^^^^ + +This interface is used to update parameters of a VPC peering connection by +id or an instance of class. +:class:`~otcextensions.sdk.vpc.v2.peering.Peering`. + +.. literalinclude:: ../examples/vpc/update_peering.py + :lines: 16-24 + +Delete VPC Peering +^^^^^^^^^^^^^^^^^^ + +This interface is used to delete a VPC peering connection by ID +or an instance of class. +:class:`~otcextensions.sdk.vpc.v2.peering.Peering`. + +.. literalinclude:: ../examples/vpc/delete_peering.py + :lines: 16-23 + +Set VPC Peering +^^^^^^^^^^^^^^^ + +This interface is used to accept of reject a VPC peering connection +request by ID or an instance of class. +:class:`~otcextensions.sdk.vpc.v2.peering.Peering`. + +.. literalinclude:: ../examples/vpc/set_peering.py + :lines: 16-32 + + +VPC Route +--------- + +To enable communication between the two VPCs, you need to add local and +peer routes for the VPC peering connection. + +List VPC Routes +^^^^^^^^^^^^^^^ + +This interface is used to query all routes of the tenant submitting the +request. The routes are filtered based on the filtering condition. +:class:`~otcextensions.sdk.vpc.v2.route.Route`. + +.. literalinclude:: ../examples/vpc/list_routes.py + :lines: 16-23 + +Add VPC Route +^^^^^^^^^^^^^ + +This Interface is used to add a VPC route. +:class:`~otcextensions.sdk.vpc.v2.route.Route`. + +.. literalinclude:: ../examples/vpc/add_route.py + :lines: 16-31 + +Get VPC Route +^^^^^^^^^^^^^ + +This interface is used to get a VPC route by ID +or an instance of class. +:class:`~otcextensions.sdk.vpc.v2.route.Route`. + +.. literalinclude:: ../examples/vpc/get_route.py + :lines: 16-26 + +Delete VPC Route +^^^^^^^^^^^^^^^^ + +This interface is used to delete a VPC route by ID +or an instance of class. +:class:`~otcextensions.sdk.vpc.v2.peering.Peering`. + +.. literalinclude:: ../examples/vpc/delete_route.py + :lines: 16-23 diff --git a/doc/source/sdk/index.rst b/doc/source/sdk/index.rst new file mode 100644 index 000000000..beedb8d89 --- /dev/null +++ b/doc/source/sdk/index.rst @@ -0,0 +1,27 @@ +Using the OpenStack SDK +======================= + +.. toctree:: + :maxdepth: 1 + + architecture + getting_started + guides/index + proxies/index + resources/index + +The OTC Extensions contain an abstraction interface layer. Clouds can +do many things, but there are probably only about 10 of them that most +people care about with any regularity. + +If you want to do complicated things, the per-service oriented +portions of the SDK are for you. + +However, if what you want is to be able to write an application that +talks to clouds no matter what crazy choices the deployer has made in +an attempt to be more hipster than their self-entitled narcissist +peers, then the Cloud Abstraction layer is for you. + +OTC Extensions provide an extension to the OpenStackSDK. Refer to its +documentation for the details: +. diff --git a/doc/source/sdk/proxies/anti_ddos.rst b/doc/source/sdk/proxies/anti_ddos.rst new file mode 100644 index 000000000..e6ba15dbc --- /dev/null +++ b/doc/source/sdk/proxies/anti_ddos.rst @@ -0,0 +1,29 @@ +Anti_DDoS API +============= + +.. automodule:: otcextensions.sdk.anti_ddos.v1._proxy + +The Anti DDoS Service Class +--------------------------- + +The anti_ddos high-level interface is available through the ``anti_ddos`` +member of a :class:`~openstack.connection.Connection` object. The +``anti_ddos`` member will only be added if the +``otcextensions.sdk.register_otc_extensions(conn)`` method is called. + +Floating IP Operations +^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy + :noindex: + :members: floating_ips, protect_floating_ip, unprotect_floating_ip, + get_floating_ip_policies, update_floating_ip_policies, + get_floating_ip_status, floating_ip_events, floating_ip_stat_day, + floating_ip_stat_week + +Misc Operations +^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy + :noindex: + :members: configs diff --git a/doc/source/sdk/proxies/auto_scaling.rst b/doc/source/sdk/proxies/auto_scaling.rst new file mode 100644 index 000000000..cc94209f0 --- /dev/null +++ b/doc/source/sdk/proxies/auto_scaling.rst @@ -0,0 +1,55 @@ +AutoScaling API +=============== + +For details on how to use auto scaling, see /sdk/guides/auto_scaling +(NEEDS TO BE DONE). + +.. automodule:: otcextensions.sdk.auto_scaling.v1._proxy + +The AutoScaling Class +--------------------- + +The AS high-level interface is available through the ``auto_scaling`` +member of a :class:`~openstack.connection.Connection` object. The +``auto_scaling`` member will only be added if the +``otcextensions.sdk.register_otc_extensions(conn)`` method is called. + +Group Operations +^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy + :noindex: + :members: groups, get_group, find_group, create_group, delete_group, + resume_group, pause_group + +Config Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy + :noindex: + :members: configs, get_config, find_config, create_config, delete_config, + batch_delete_configs + + +Policy Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy + :noindex: + :members: policies, get_policy, find_policy, create_policy, + delete_policy, update_policy, resume_policy, + pause_policy, execute_policy + +Instance Operations +^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy + :noindex: + :members: instances, remove_instance, batch_instance_action + +Actions and Quotas +^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy + :noindex: + :members: activities, quotas diff --git a/doc/source/sdk/proxies/cce_v1.rst b/doc/source/sdk/proxies/cce_v1.rst new file mode 100644 index 000000000..684a8bc6e --- /dev/null +++ b/doc/source/sdk/proxies/cce_v1.rst @@ -0,0 +1,27 @@ +CCE API +======= + +.. automodule:: otcextensions.sdk.cce.v1._proxy + +The Cloud Container Engine Class +-------------------------------- + +The cce high-level interface is available through the ``cce`` member of a +:class:`~openstack.connection.Connection` object. The ``cce`` member will only +be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is +called. + +Cluster Operations +^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.cce.v1._proxy.Proxy + :noindex: + :members: clusters, get_cluster, find_cluster, delete_cluster + +Cluster Nodes Operations +^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.cce.v1._proxy.Proxy + :noindex: + :members: cluster_nodes, get_cluster_node, find_cluster_node, + delete_cluster_nodes, add_node diff --git a/doc/source/sdk/proxies/cce_v3.rst b/doc/source/sdk/proxies/cce_v3.rst new file mode 100644 index 000000000..f8f1f5740 --- /dev/null +++ b/doc/source/sdk/proxies/cce_v3.rst @@ -0,0 +1,34 @@ +CCE API +======= + +.. automodule:: otcextensions.sdk.cce.v3._proxy + +The Cloud Container Engine Class +-------------------------------- + +The cce high-level interface is available through the ``cce`` member of a +:class:`~openstack.connection.Connection` object. The ``cce`` member will only +be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is +called. + +Cluster Operations +^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.cce.v3._proxy.Proxy + :members: clusters, get_cluster, find_cluster, delete_cluster + + +Cluster Nodes Operations +^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.cce.v3._proxy.Proxy + :noindex: + :members: cluster_nodes, get_cluster_node, find_cluster_node, + delete_cluster_node, create_cluster_node + +Job Operations +^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.cce.v3._proxy.Proxy + :noindex: + :members: get_job, wait_for_job diff --git a/doc/source/sdk/proxies/ces.rst b/doc/source/sdk/proxies/ces.rst new file mode 100644 index 000000000..d3e71f29f --- /dev/null +++ b/doc/source/sdk/proxies/ces.rst @@ -0,0 +1,34 @@ +CES API +======= + +.. automodule:: otcextensions.sdk.ces.v1._proxy + +The Cloud Eye Service Class +--------------------------- + +The CES high-level interface is available through the ``ces`` +member of a :class:`~openstack.connection.Connection` object. The +``ces`` member will only be added if the +``otcextensions.sdk.register_otc_extensions(conn)`` method is called. + +Alarm Rule Operations +^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.ces.v1._proxy.Proxy + :noindex: + :members: alarms, get_alarm, create_alarm, delete_alarm, find_alarm, + switch_alarm_state + +Monitoring Data Operations +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.ces.v1._proxy.Proxy + :noindex: + :members: metric_data + +Miscellaneous Operations +^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.ces.v1._proxy.Proxy + :noindex: + :members: metrics, quotas, event_data diff --git a/doc/source/user/proxies/cts.rst b/doc/source/sdk/proxies/cts.rst similarity index 53% rename from doc/source/user/proxies/cts.rst rename to doc/source/sdk/proxies/cts.rst index 4d4683ad1..77a70f6e7 100644 --- a/doc/source/user/proxies/cts.rst +++ b/doc/source/sdk/proxies/cts.rst @@ -3,8 +3,8 @@ CTS API .. automodule:: otcextensions.sdk.cts.v1._proxy -The Distributed Message Service Class -------------------------------------- +The Cloud Trace Service Class +----------------------------- The CTS high-level interface is available through the ``cts`` member of a :class:`~openstack.connection.Connection` object. The @@ -15,15 +15,12 @@ Trace Operations ^^^^^^^^^^^^^^^^ .. autoclass:: otcextensions.sdk.cts.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.cts.v1._proxy.Proxy.traces + :noindex: + :members: traces Trackers Operations ^^^^^^^^^^^^^^^^^^^ .. autoclass:: otcextensions.sdk.cts.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.cts.v1._proxy.Proxy.get_tracker - .. automethod:: otcextensions.sdk.cts.v1._proxy.Proxy.create_tracker - .. automethod:: otcextensions.sdk.cts.v1._proxy.Proxy.update_tracker - .. automethod:: otcextensions.sdk.cts.v1._proxy.Proxy.delete_tracker + :noindex: + :members: get_tracker, create_tracker, update_tracker, delete_tracker diff --git a/doc/source/sdk/proxies/dcs.rst b/doc/source/sdk/proxies/dcs.rst new file mode 100644 index 000000000..6291b03fe --- /dev/null +++ b/doc/source/sdk/proxies/dcs.rst @@ -0,0 +1,43 @@ +DCS API +======= + +.. automodule:: otcextensions.sdk.dcs.v1._proxy + +The Distributed Message Service Class +------------------------------------- + +The dcs high-level interface is available through the ``dcs`` +member of a :class:`~openstack.connection.Connection` object. The +``dcs`` member will only be added if the +``otcextensions.sdk.register_otc_extensions(conn)`` method is called. + +Instance Operations +^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy + :noindex: + :members: instances, get_instance, find_instance, create_instance, + delete_instance, update_instance, extend_instance, + start_instance, restart_instance, stop_instance + +Statistics Operations +^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy + :noindex: + :members: statistics + +Backup Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy + :noindex: + :members: backups, backup_instance, delete_instance_backup, + restore_instance, restore_records + +Instance Configuration Operations +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy + :noindex: + :members: instance_params, update_instance_params diff --git a/doc/source/sdk/proxies/deh.rst b/doc/source/sdk/proxies/deh.rst new file mode 100644 index 000000000..593a51cae --- /dev/null +++ b/doc/source/sdk/proxies/deh.rst @@ -0,0 +1,20 @@ +DeH API +======= + +.. automodule:: otcextensions.sdk.deh.v1._proxy + +The Dedicated Host Service Class +-------------------------------- + +The dehs high-level interface is available through the ``deh`` member of a +:class:`~openstack.connection.Connection` object. The ``deh`` member will only +be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is +called. + +Host Operations +^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.deh.v1._proxy.Proxy + :noindex: + :members: hosts, get_host, find_host, create_host, + update_host, delete_host, servers, host_types diff --git a/doc/source/user/proxies/dms.rst b/doc/source/sdk/proxies/dms.rst similarity index 52% rename from doc/source/user/proxies/dms.rst rename to doc/source/sdk/proxies/dms.rst index 741876687..a4d301f06 100644 --- a/doc/source/user/proxies/dms.rst +++ b/doc/source/sdk/proxies/dms.rst @@ -15,25 +15,23 @@ Queue Operations ^^^^^^^^^^^^^^^^ .. autoclass:: otcextensions.sdk.dms.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.dms.v1._proxy.Proxy.queues - .. automethod:: otcextensions.sdk.dms.v1._proxy.Proxy.create_queue - .. automethod:: otcextensions.sdk.dms.v1._proxy.Proxy.get_queue - .. automethod:: otcextensions.sdk.dms.v1._proxy.Proxy.delete_queue - + :noindex: + :members: queues, create_queue, get_queue, delete_queue Message Group Operations ^^^^^^^^^^^^^^^^^^^^^^^^ .. autoclass:: otcextensions.sdk.dms.v1._proxy.Proxy + :noindex: + :members: groups, create_group, delete_group - .. automethod:: otcextensions.sdk.dms.v1._proxy.Proxy.groups - .. automethod:: otcextensions.sdk.dms.v1._proxy.Proxy.create_group - .. automethod:: otcextensions.sdk.dms.v1._proxy.Proxy.delete_group - -DMS Quota Operations -^^^^^^^^^^^^^^^^^^^^ +Instance Operations +^^^^^^^^^^^^^^^^^^^ .. autoclass:: otcextensions.sdk.dms.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.dms.v1._proxy.Proxy.quotas + :noindex: + :members: instances, find_instance, get_instance, + create_instance, update_instance, delete_instance, + delete_batch, restart_instance, delete_failed, + topics, create_topic, delete_topic, + availability_zones, products, maintenance_windows diff --git a/doc/source/sdk/proxies/dns.rst b/doc/source/sdk/proxies/dns.rst new file mode 100644 index 000000000..4f1fea557 --- /dev/null +++ b/doc/source/sdk/proxies/dns.rst @@ -0,0 +1,37 @@ +DNS API +======= + +.. automodule:: otcextensions.sdk.dns.v2._proxy + +The DNS Service Class +--------------------- + +The dns high-level interface is available through the ``dns`` +member of a :class:`~openstack.connection.Connection` object. The +``dns`` member will only be added if the +``otcextensions.sdk.register_otc_extensions(conn)`` method is called. + +Zone Operations +^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.dns.v2._proxy.Proxy + :noindex: + :members: zones, create_zone, get_zone, delete_zone, + update_zone, find_zone, add_router_to_zone, + remove_router_from_zone, nameservers + +Recordset Operations +^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.dns.v2._proxy.Proxy + :noindex: + :members: recordsets, create_recordset, get_recordset, update_recordset, + delete_recordset + + +PTR Records Operations +^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.dns.v2._proxy.Proxy + :noindex: + :members: floating_ips, set_floating_ip, get_floating_ip, unset_floating_ip diff --git a/doc/source/sdk/proxies/identity_v3.rst b/doc/source/sdk/proxies/identity_v3.rst new file mode 100644 index 000000000..fcf91053b --- /dev/null +++ b/doc/source/sdk/proxies/identity_v3.rst @@ -0,0 +1,112 @@ +Identity API v3 +=============== + +.. automodule:: otcextensions.sdk.identity.v3._proxy + +The Identity v3 Class +--------------------- + +The identity high-level interface is available through the ``identity`` +member of a :class:`~openstack.connection.Connection` object. The +``identity`` member will only be added if the service is detected. + +Agency Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: create_agency, update_agency, delete_agency, + get_agency, find_agency, agencies, + agency_project_roles, check_agency_project_role, + grant_agency_project_role, revoke_agency_project_role, + agency_domain_roles, check_agency_domain_role, + grant_agency_domain_role, revoke_agency_domain_role, + +Credential Operations +^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: create_credential, update_credential, delete_credential, + get_credential, find_credential, credentials + +Domain Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: create_domain, update_domain, delete_domain, get_domain, + find_domain, domains + +Endpoint Operations +^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: create_endpoint, update_endpoint, delete_endpoint, get_endpoint, + find_endpoint, endpoints + +Group Operations +^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: create_group, update_group, delete_group, get_group, find_group, + groups + +Policy Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: create_policy, update_policy, delete_policy, get_policy, + find_policy, policies + +Project Operations +^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: create_project, update_project, delete_project, get_project, + find_project, projects + +Region Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: create_region, update_region, delete_region, get_region, + find_region, regions + +Role Operations +^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: create_role, update_role, delete_role, get_role, find_role, roles + +Role Assignment Operations +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: role_assignments, role_assignments_filter, + assign_project_role_to_user, unassign_project_role_from_user, + validate_user_has_role, assign_project_role_to_group, + unassign_project_role_from_group, validate_group_has_role + +Service Operations +^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: create_service, update_service, delete_service, get_service, + find_service, services + +User Operations +^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.identity.v3._proxy.Proxy + :noindex: + :members: create_user, update_user, delete_user, get_user, find_user, users, + user_projects diff --git a/doc/source/sdk/proxies/index.rst b/doc/source/sdk/proxies/index.rst new file mode 100644 index 000000000..65ad58c75 --- /dev/null +++ b/doc/source/sdk/proxies/index.rst @@ -0,0 +1,51 @@ +Service Proxies +=============== + +.. toctree:: + :maxdepth: 1 + + Anti DDoS Service (Anti-DDoS) + AutoScaling Service (AS) + Cloud Container Engine v1 (CCEv1) + Cloud Container Engine v2 (CCE) + Cloud Eye Service (CES) + Cloud Trace Service (CTS) + Distributed Cache Service (DCS) + Dedicated Host Service (DeH) + Distributed Message Service (DMS) + Domain Name Server Service (DNS) + Identity Service (IAM) + Key Management Service (KMS) + Network Address Translation (NAT) + Object Block Storage (OBS) + Relational Database Service RDS V1 (RDSv1) + Relational Database Service RDS V3 (RDS) + Volume Backup Service (VBS) + Virtual Private Cloud (VPC) + Web Application Firewall (WAF) + +.. _service-proxies: + +Service Proxies +--------------- + +The following service proxies exist on the +:class:`~openstack.connection.Connection`. The service proxies are all always +present on the :class:`~openstack.connection.Connection` object, but the +combination of your ``CloudRegion`` and the catalog of the cloud in question +control which services can be used. + +Links to Native OpenStack Service Proxies +----------------------------------------- + +.. toctree:: + :maxdepth: 1 + + Block Storage + Compute + Database + Identity v3 + Image v2 + Network + Object Store + Orchestration diff --git a/doc/source/sdk/proxies/kms.rst b/doc/source/sdk/proxies/kms.rst new file mode 100644 index 000000000..9cb575143 --- /dev/null +++ b/doc/source/sdk/proxies/kms.rst @@ -0,0 +1,35 @@ +KMS API +======= + +.. automodule:: otcextensions.sdk.kms.v1._proxy + +The KeyManagementService Class +------------------------------ + +The kms high-level interface is available through the ``kms`` member of a +:class:`~openstack.connection.Connection` object. The ``kms`` member will only +be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is +called. + +CMK (Customer Master Key) Operations +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.kms.v1._proxy.Proxy + :noindex: + :members: keys, get_key, find_key, create_key, enable_key, disable_key, + schedule_key_deletion, cancel_key_deletion + +DEK (Data Encryption Key) Operations +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.kms.v1._proxy.Proxy + :noindex: + :members: create_datakey, create_datakey_wo_plain, encrypt_datakey, + decrypt_datakey + +Other Operations +^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.kms.v1._proxy.Proxy + :noindex: + :members: generate_random, get_instance_number, quotas diff --git a/doc/source/sdk/proxies/nat.rst b/doc/source/sdk/proxies/nat.rst new file mode 100644 index 000000000..824b1d0b5 --- /dev/null +++ b/doc/source/sdk/proxies/nat.rst @@ -0,0 +1,34 @@ +NAT API +======= + +.. automodule:: otcextensions.sdk.nat.v2._proxy + +The Network Address Translation Class +------------------------------------- + +The nat high-level interface is available through the ``nat`` +member of a :class:`~openstack.connection.Connection` object. The +``nat`` member will only be added if the +``otcextensions.sdk.register_otc_extensions(conn)`` method is called. + +Gateway Operations +^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.nat.v2._proxy.Proxy + :noindex: + :members: gateways, find_gateway, + create_gateway, update_gateway, delete_gateway + +SNAT Rule Operations +^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.nat.v2._proxy.Proxy + :noindex: + :members: snat_rules, get_snat_rule, create_snat_rule, delete_snat_rule + +DNAT Rule Operations +^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.nat.v2._proxy.Proxy + :noindex: + :members: dnat_rules, get_dnat_rule, create_dnat_rule, delete_dnat_rule diff --git a/doc/source/sdk/proxies/obs.rst b/doc/source/sdk/proxies/obs.rst new file mode 100644 index 000000000..f26725843 --- /dev/null +++ b/doc/source/sdk/proxies/obs.rst @@ -0,0 +1,28 @@ +ObjectBlockStorage OBS API +========================== + +For details on how to use database, see /user/guides/obs (NEEDS TO BE DONE) + +.. automodule:: otcextensions.sdk.obs.v1._proxy + +The OBS Class +------------- + +The obs high-level interface is available through the ``obs`` member of a +:class:`~openstack.connection.Connection` object. The ``obs`` member will only +be added if the ``otcextensions.sdk.register_otc_Extensions(conn)`` method is +called. + +Container Operations +^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.obs.v1._proxy.Proxy + :noindex: + :members: containers, get_container, create_container, delete_container + +Object Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.obs.v1._proxy.Proxy + :noindex: + :members: objects, get_object, create_object, delete_object, download_object diff --git a/doc/source/sdk/proxies/rds_v1.rst b/doc/source/sdk/proxies/rds_v1.rst new file mode 100644 index 000000000..ade0d9116 --- /dev/null +++ b/doc/source/sdk/proxies/rds_v1.rst @@ -0,0 +1,44 @@ +Database RDS API +================ + +For details on how to use database, see /user/guides/rds (NEEDS TO BE DONE) + +.. automodule:: otcextensions.sdk.rds.v1._proxy + +The Database Class +------------------ + +The database high-level interface is available through the ``rds`` member of a +:class:`~openstack.connection.Connection` object. The ``rds`` member will only +be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is +called. + +Datastore Operations +^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.rds.v1._proxy.Proxy + :noindex: + :members: datastore_versions, get_datastore_version, datastore_types + +Flavor Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.rds.v1._proxy.Proxy + :noindex: + :members: flavors, get_flavor + +Instance Operations +^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.rds.v1._proxy.Proxy + :noindex: + :members: instances, get_instance, find_instance, + create_instance, delete_instance, update_instance + +Backup Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.rds.v1._proxy.Proxy + :noindex: + :members: backups, create_backup, delete_backup, + get_backup_policy, set_backup_policy diff --git a/doc/source/sdk/proxies/rds_v3.rst b/doc/source/sdk/proxies/rds_v3.rst new file mode 100644 index 000000000..e88e3dd7e --- /dev/null +++ b/doc/source/sdk/proxies/rds_v3.rst @@ -0,0 +1,55 @@ +Database RDS API +================ + +For details on how to use database, see /sdk/guides/rds (NEEDS TO BE DONE) + +.. automodule:: otcextensions.sdk.rds.v3._proxy + +The Database Class +------------------ + +The database high-level interface is available through the ``rds`` member of a +:class:`~openstack.connection.Connection` object. The ``rds`` member will only +be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is +called. + +Datastore Operations +^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.rds.v3._proxy.Proxy + :noindex: + :members: datastores, datastore_types + +Flavor Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.rds.v3._proxy.Proxy + :noindex: + :members: flavors + +Instance Operations +^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.rds.v3._proxy.Proxy + :noindex: + :members: instances, get_instance, find_instance, + create_instance, delete_instance, restore_instance, + get_instance_restore_time + +Backup Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.rds.v3._proxy.Proxy + :noindex: + :members: backups, find_backup, create_backup, delete_backup, + backup_download_links, get_instance_backup_policy, + set_instance_backup_policy, wait_for_backup + +Configuration Operations +^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.rds.v3._proxy.Proxy + :noindex: + :members: configurations, get_configuration, find_configuration, + create_configuration, delete_configuration, update_configuration, + apply_configuration diff --git a/doc/source/sdk/proxies/volume_backup.rst b/doc/source/sdk/proxies/volume_backup.rst new file mode 100644 index 000000000..cb97a9cdf --- /dev/null +++ b/doc/source/sdk/proxies/volume_backup.rst @@ -0,0 +1,30 @@ +VolumeBackup API +================ + +For details on how to use auto scaling, see /sdk/guides/volume_backup +(NEEDS TO BE DONE). + +.. automodule:: otcextensions.sdk.volume_backup.v2._proxy + +The VolumeBackup Class +---------------------- + +The VBS high-level interface is available through the +``volume_backup`` member of a +:class:`~openstack.connection.Connection` object. The +``volume_backup`` member will only be added if the +``otcextensions.sdk.register_otc_extensions(conn)`` method is called. + +The Backup itself is an OpenStack entity and supported natively as +block_storage.Backup. + + +Backup Policy Operations +^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.volume_backup.v2._proxy.Proxy + :noindex: + :members: backup_policies, find_backup_policy, create_backup_policy, + update_backup_policy, delete_backup_policy, execute_policy, + enable_policy, disable_policy, link_resources_to_policy, + unlink_resources_of_policy diff --git a/doc/source/sdk/proxies/vpc.rst b/doc/source/sdk/proxies/vpc.rst new file mode 100644 index 000000000..18cd53c74 --- /dev/null +++ b/doc/source/sdk/proxies/vpc.rst @@ -0,0 +1,27 @@ +VPC API +======= + +.. automodule:: otcextensions.sdk.vpc.v2._proxy + +The Virtual Private Cloud Class +------------------------------- + +The nat high-level interface is available through the ``vpc`` +member of a :class:`~openstack.connection.Connection` object. The +``vpc`` member will only be added if the +``otcextensions.sdk.register_otc_extensions(conn)`` method is called. + +VPC Peering Operations +^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.vpc.v2._proxy.Proxy + :noindex: + :members: peerings, find_peering, create_peering, + update_peering, delete_peering, set_peering + +VPC Route Operations +^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.vpc.v2._proxy.Proxy + :noindex: + :members: routes, get_route, add_route, delete_route diff --git a/doc/source/sdk/proxies/waf.rst b/doc/source/sdk/proxies/waf.rst new file mode 100644 index 000000000..2b2da8187 --- /dev/null +++ b/doc/source/sdk/proxies/waf.rst @@ -0,0 +1,28 @@ +Web Application Firewall API +============================ + +.. automodule:: otcextensions.sdk.waf.v1._proxy + +The WAF Service Class +--------------------- + +The waf high-level interface is available through the ``waf`` +member of a :class:`~openstack.connection.Connection` object. The +``waf`` member will only be added if the +``otcextensions.sdk.register_otc_extensions(conn)`` method is called. + +Certificate Operations +^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.waf.v1._proxy.Proxy + :noindex: + :members: certificates, create_certificate, get_certificate, + delete_certificate, update_certificate, find_certificate + +Domain Operations +^^^^^^^^^^^^^^^^^ + +.. autoclass:: otcextensions.sdk.waf.v1._proxy.Proxy + :noindex: + :members: domains, create_domain, get_domain, find_domain, + delete_domain, update_domain, find_domain diff --git a/doc/source/user/resources/anti_ddos/index.rst b/doc/source/sdk/resources/anti_ddos/index.rst similarity index 100% rename from doc/source/user/resources/anti_ddos/index.rst rename to doc/source/sdk/resources/anti_ddos/index.rst diff --git a/doc/source/user/resources/anti_ddos/v1/config.rst b/doc/source/sdk/resources/anti_ddos/v1/config.rst similarity index 100% rename from doc/source/user/resources/anti_ddos/v1/config.rst rename to doc/source/sdk/resources/anti_ddos/v1/config.rst diff --git a/doc/source/user/resources/anti_ddos/v1/floating_ip.rst b/doc/source/sdk/resources/anti_ddos/v1/floating_ip.rst similarity index 100% rename from doc/source/user/resources/anti_ddos/v1/floating_ip.rst rename to doc/source/sdk/resources/anti_ddos/v1/floating_ip.rst diff --git a/doc/source/user/resources/anti_ddos/v1/status.rst b/doc/source/sdk/resources/anti_ddos/v1/status.rst similarity index 100% rename from doc/source/user/resources/anti_ddos/v1/status.rst rename to doc/source/sdk/resources/anti_ddos/v1/status.rst diff --git a/doc/source/user/resources/auto_scaling/index.rst b/doc/source/sdk/resources/auto_scaling/index.rst similarity index 100% rename from doc/source/user/resources/auto_scaling/index.rst rename to doc/source/sdk/resources/auto_scaling/index.rst diff --git a/doc/source/user/resources/auto_scaling/v1/activity.rst b/doc/source/sdk/resources/auto_scaling/v1/activity.rst similarity index 100% rename from doc/source/user/resources/auto_scaling/v1/activity.rst rename to doc/source/sdk/resources/auto_scaling/v1/activity.rst diff --git a/doc/source/user/resources/auto_scaling/v1/config.rst b/doc/source/sdk/resources/auto_scaling/v1/config.rst similarity index 100% rename from doc/source/user/resources/auto_scaling/v1/config.rst rename to doc/source/sdk/resources/auto_scaling/v1/config.rst diff --git a/doc/source/user/resources/auto_scaling/v1/group.rst b/doc/source/sdk/resources/auto_scaling/v1/group.rst similarity index 100% rename from doc/source/user/resources/auto_scaling/v1/group.rst rename to doc/source/sdk/resources/auto_scaling/v1/group.rst diff --git a/doc/source/user/resources/auto_scaling/v1/instance.rst b/doc/source/sdk/resources/auto_scaling/v1/instance.rst similarity index 100% rename from doc/source/user/resources/auto_scaling/v1/instance.rst rename to doc/source/sdk/resources/auto_scaling/v1/instance.rst diff --git a/doc/source/user/resources/auto_scaling/v1/policy.rst b/doc/source/sdk/resources/auto_scaling/v1/policy.rst similarity index 100% rename from doc/source/user/resources/auto_scaling/v1/policy.rst rename to doc/source/sdk/resources/auto_scaling/v1/policy.rst diff --git a/doc/source/user/resources/auto_scaling/v1/quota.rst b/doc/source/sdk/resources/auto_scaling/v1/quota.rst similarity index 100% rename from doc/source/user/resources/auto_scaling/v1/quota.rst rename to doc/source/sdk/resources/auto_scaling/v1/quota.rst diff --git a/doc/source/user/resources/cce/index.rst b/doc/source/sdk/resources/cce/index.rst similarity index 100% rename from doc/source/user/resources/cce/index.rst rename to doc/source/sdk/resources/cce/index.rst diff --git a/doc/source/user/resources/cce/v1/cluster.rst b/doc/source/sdk/resources/cce/v1/cluster.rst similarity index 100% rename from doc/source/user/resources/cce/v1/cluster.rst rename to doc/source/sdk/resources/cce/v1/cluster.rst diff --git a/doc/source/user/resources/cce/v1/cluster_node.rst b/doc/source/sdk/resources/cce/v1/cluster_node.rst similarity index 100% rename from doc/source/user/resources/cce/v1/cluster_node.rst rename to doc/source/sdk/resources/cce/v1/cluster_node.rst diff --git a/doc/source/user/resources/cce/v3/cluster.rst b/doc/source/sdk/resources/cce/v3/cluster.rst similarity index 58% rename from doc/source/user/resources/cce/v3/cluster.rst rename to doc/source/sdk/resources/cce/v3/cluster.rst index 8b4cd7f60..431f448b8 100644 --- a/doc/source/user/resources/cce/v3/cluster.rst +++ b/doc/source/sdk/resources/cce/v3/cluster.rst @@ -11,3 +11,12 @@ The ``Cluster`` class inherits from .. autoclass:: otcextensions.sdk.cce.v3.cluster.Cluster :members: + +.. autoclass:: otcextensions.sdk.cce.v3.cluster.ClusterSpec + :members: + +.. autoclass:: otcextensions.sdk.cce.v3.cluster.HostNetworkSpec + :members: + +.. autoclass:: otcextensions.sdk.cce.v3.cluster.StatusSpec + :members: diff --git a/doc/source/user/resources/cce/v3/cluster_node.rst b/doc/source/sdk/resources/cce/v3/cluster_node.rst similarity index 100% rename from doc/source/user/resources/cce/v3/cluster_node.rst rename to doc/source/sdk/resources/cce/v3/cluster_node.rst diff --git a/doc/source/sdk/resources/ces/index.rst b/doc/source/sdk/resources/ces/index.rst new file mode 100644 index 000000000..ddd5b338e --- /dev/null +++ b/doc/source/sdk/resources/ces/index.rst @@ -0,0 +1,11 @@ +CES Resources +============= + +.. toctree:: + :maxdepth: 1 + + v1/alarm + v1/event_data + v1/metric + v1/metric_data + v1/quota diff --git a/doc/source/sdk/resources/ces/v1/alarm.rst b/doc/source/sdk/resources/ces/v1/alarm.rst new file mode 100644 index 000000000..99d858100 --- /dev/null +++ b/doc/source/sdk/resources/ces/v1/alarm.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.ces.v1.alarm +============================== + +.. automodule:: otcextensions.sdk.ces.v1.alarm + +The CES Alarm Rule Class +------------------------ + +The ``Alarm`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.ces.v1.alarm.Alarm + :members: diff --git a/doc/source/sdk/resources/ces/v1/event_data.rst b/doc/source/sdk/resources/ces/v1/event_data.rst new file mode 100644 index 000000000..d53ff12f3 --- /dev/null +++ b/doc/source/sdk/resources/ces/v1/event_data.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.ces.v1.event_data +=================================== + +.. automodule:: otcextensions.sdk.ces.v1.event_data + +The CES Event Data Class +------------------------ + +The ``Event Data`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.ces.v1.event_data.EventData + :members: diff --git a/doc/source/sdk/resources/ces/v1/metric.rst b/doc/source/sdk/resources/ces/v1/metric.rst new file mode 100644 index 000000000..859d6ed28 --- /dev/null +++ b/doc/source/sdk/resources/ces/v1/metric.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.ces.v1.metric +=============================== + +.. automodule:: otcextensions.sdk.ces.v1.metric + +The CES Metric Class +-------------------- + +The ``Metric`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.ces.v1.metric.Metric + :members: diff --git a/doc/source/sdk/resources/ces/v1/metric_data.rst b/doc/source/sdk/resources/ces/v1/metric_data.rst new file mode 100644 index 000000000..247fe19fc --- /dev/null +++ b/doc/source/sdk/resources/ces/v1/metric_data.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.ces.v1.metric_data +==================================== + +.. automodule:: otcextensions.sdk.ces.v1.metric_data + +The CES Metric Data Class +------------------------- + +The ``Metric Data`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.ces.v1.metric_data.MetricData + :members: diff --git a/doc/source/user/resources/dms/v1/quota.rst b/doc/source/sdk/resources/ces/v1/quota.rst similarity index 50% rename from doc/source/user/resources/dms/v1/quota.rst rename to doc/source/sdk/resources/ces/v1/quota.rst index 5faa27fd5..9b777988b 100644 --- a/doc/source/user/resources/dms/v1/quota.rst +++ b/doc/source/sdk/resources/ces/v1/quota.rst @@ -1,13 +1,13 @@ -otcextensions.sdk.dcs.v1.quota +otcextensions.sdk.ces.v1.quota ============================== -.. automodule:: otcextensions.sdk.dms.v1.quota +.. automodule:: otcextensions.sdk.ces.v1.quota -The DMS Quota Class +The CES Quota Class ------------------- The ``Quota`` class inherits from :class:`~otcextensions.sdk.sdk_resource.Resource`. -.. autoclass:: otcextensions.sdk.dms.v1.quota.Quota +.. autoclass:: otcextensions.sdk.ces.v1.quota.Quota :members: diff --git a/doc/source/user/resources/cts/index.rst b/doc/source/sdk/resources/cts/index.rst similarity index 100% rename from doc/source/user/resources/cts/index.rst rename to doc/source/sdk/resources/cts/index.rst diff --git a/doc/source/user/resources/cts/v1/trace.rst b/doc/source/sdk/resources/cts/v1/trace.rst similarity index 100% rename from doc/source/user/resources/cts/v1/trace.rst rename to doc/source/sdk/resources/cts/v1/trace.rst diff --git a/doc/source/user/resources/cts/v1/tracker.rst b/doc/source/sdk/resources/cts/v1/tracker.rst similarity index 100% rename from doc/source/user/resources/cts/v1/tracker.rst rename to doc/source/sdk/resources/cts/v1/tracker.rst diff --git a/doc/source/user/resources/dcs/index.rst b/doc/source/sdk/resources/dcs/index.rst similarity index 100% rename from doc/source/user/resources/dcs/index.rst rename to doc/source/sdk/resources/dcs/index.rst diff --git a/doc/source/user/resources/dcs/v1/backup.rst b/doc/source/sdk/resources/dcs/v1/backup.rst similarity index 100% rename from doc/source/user/resources/dcs/v1/backup.rst rename to doc/source/sdk/resources/dcs/v1/backup.rst diff --git a/doc/source/user/resources/dcs/v1/config.rst b/doc/source/sdk/resources/dcs/v1/config.rst similarity index 100% rename from doc/source/user/resources/dcs/v1/config.rst rename to doc/source/sdk/resources/dcs/v1/config.rst diff --git a/doc/source/user/resources/dcs/v1/instance.rst b/doc/source/sdk/resources/dcs/v1/instance.rst similarity index 100% rename from doc/source/user/resources/dcs/v1/instance.rst rename to doc/source/sdk/resources/dcs/v1/instance.rst diff --git a/doc/source/user/resources/dcs/v1/restore.rst b/doc/source/sdk/resources/dcs/v1/restore.rst similarity index 100% rename from doc/source/user/resources/dcs/v1/restore.rst rename to doc/source/sdk/resources/dcs/v1/restore.rst diff --git a/doc/source/user/resources/dcs/v1/statistic.rst b/doc/source/sdk/resources/dcs/v1/statistic.rst similarity index 100% rename from doc/source/user/resources/dcs/v1/statistic.rst rename to doc/source/sdk/resources/dcs/v1/statistic.rst diff --git a/doc/source/user/resources/deh/index.rst b/doc/source/sdk/resources/deh/index.rst similarity index 100% rename from doc/source/user/resources/deh/index.rst rename to doc/source/sdk/resources/deh/index.rst diff --git a/doc/source/user/resources/deh/v1/host.rst b/doc/source/sdk/resources/deh/v1/host.rst similarity index 100% rename from doc/source/user/resources/deh/v1/host.rst rename to doc/source/sdk/resources/deh/v1/host.rst diff --git a/doc/source/user/resources/deh/v1/host_type.rst b/doc/source/sdk/resources/deh/v1/host_type.rst similarity index 100% rename from doc/source/user/resources/deh/v1/host_type.rst rename to doc/source/sdk/resources/deh/v1/host_type.rst diff --git a/doc/source/user/resources/deh/v1/server.rst b/doc/source/sdk/resources/deh/v1/server.rst similarity index 100% rename from doc/source/user/resources/deh/v1/server.rst rename to doc/source/sdk/resources/deh/v1/server.rst diff --git a/doc/source/user/resources/dms/index.rst b/doc/source/sdk/resources/dms/index.rst similarity index 71% rename from doc/source/user/resources/dms/index.rst rename to doc/source/sdk/resources/dms/index.rst index 210555c88..3837c3064 100644 --- a/doc/source/user/resources/dms/index.rst +++ b/doc/source/sdk/resources/dms/index.rst @@ -5,7 +5,8 @@ DMS Resources :maxdepth: 1 v1/group - v1/group_message v1/message v1/queue - v1/quota + v1/instance + v1/topic + v1/misc diff --git a/doc/source/user/resources/dms/v1/group.rst b/doc/source/sdk/resources/dms/v1/group.rst similarity index 100% rename from doc/source/user/resources/dms/v1/group.rst rename to doc/source/sdk/resources/dms/v1/group.rst diff --git a/doc/source/sdk/resources/dms/v1/instance.rst b/doc/source/sdk/resources/dms/v1/instance.rst new file mode 100644 index 000000000..fad2b31fe --- /dev/null +++ b/doc/source/sdk/resources/dms/v1/instance.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.dcs.v1.instance +================================= + +.. automodule:: otcextensions.sdk.dms.v1.instance + +The DMS Instance Class +---------------------- + +The ``Instance`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.dms.v1.instance.Instance + :members: diff --git a/doc/source/user/resources/dms/v1/message.rst b/doc/source/sdk/resources/dms/v1/message.rst similarity index 100% rename from doc/source/user/resources/dms/v1/message.rst rename to doc/source/sdk/resources/dms/v1/message.rst diff --git a/doc/source/sdk/resources/dms/v1/misc b/doc/source/sdk/resources/dms/v1/misc new file mode 100644 index 000000000..027026683 --- /dev/null +++ b/doc/source/sdk/resources/dms/v1/misc @@ -0,0 +1,41 @@ +otcextensions.sdk.dcs.v1.az +=========================== + +.. automodule:: otcextensions.sdk.dms.v1.az + +The DMS Availability Zone Class +------------------------------- + +The ``AvailabilityZone`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.dms.v1.az.AvailabilityZone + :members: + +otcextensions.sdk.dcs.v1.product +================================ + +.. automodule:: otcextensions.sdk.dms.v1.product + +The DMS Product Spec Class +-------------------------- + +The ``Product`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.dms.v1.product.Product + :members: + +otcextensions.sdk.dcs.v1.maintenance_window +=========================================== + +.. automodule:: otcextensions.sdk.dms.v1.maintenance_window + +The DMS Maintenance window Class +-------------------------------- + +The ``MaintenanceWindow`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.dms.v1.maintenance_window.MaintenanceWindow + :members: diff --git a/doc/source/sdk/resources/dms/v1/misc.rst b/doc/source/sdk/resources/dms/v1/misc.rst new file mode 100644 index 000000000..027026683 --- /dev/null +++ b/doc/source/sdk/resources/dms/v1/misc.rst @@ -0,0 +1,41 @@ +otcextensions.sdk.dcs.v1.az +=========================== + +.. automodule:: otcextensions.sdk.dms.v1.az + +The DMS Availability Zone Class +------------------------------- + +The ``AvailabilityZone`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.dms.v1.az.AvailabilityZone + :members: + +otcextensions.sdk.dcs.v1.product +================================ + +.. automodule:: otcextensions.sdk.dms.v1.product + +The DMS Product Spec Class +-------------------------- + +The ``Product`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.dms.v1.product.Product + :members: + +otcextensions.sdk.dcs.v1.maintenance_window +=========================================== + +.. automodule:: otcextensions.sdk.dms.v1.maintenance_window + +The DMS Maintenance window Class +-------------------------------- + +The ``MaintenanceWindow`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.dms.v1.maintenance_window.MaintenanceWindow + :members: diff --git a/doc/source/user/resources/dms/v1/queue.rst b/doc/source/sdk/resources/dms/v1/queue.rst similarity index 100% rename from doc/source/user/resources/dms/v1/queue.rst rename to doc/source/sdk/resources/dms/v1/queue.rst diff --git a/doc/source/sdk/resources/dms/v1/topic.rst b/doc/source/sdk/resources/dms/v1/topic.rst new file mode 100644 index 000000000..46a04e733 --- /dev/null +++ b/doc/source/sdk/resources/dms/v1/topic.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.dcs.v1.topic +============================== + +.. automodule:: otcextensions.sdk.dms.v1.topic + +The DMS Instance topic Class +---------------------------- + +The ``Topic`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.dms.v1.topic.Topic + :members: diff --git a/doc/source/user/resources/dns/index.rst b/doc/source/sdk/resources/dns/index.rst similarity index 100% rename from doc/source/user/resources/dns/index.rst rename to doc/source/sdk/resources/dns/index.rst diff --git a/doc/source/user/resources/dns/v2/floating_ip.rst b/doc/source/sdk/resources/dns/v2/floating_ip.rst similarity index 100% rename from doc/source/user/resources/dns/v2/floating_ip.rst rename to doc/source/sdk/resources/dns/v2/floating_ip.rst diff --git a/doc/source/user/resources/dns/v2/nameserver.rst b/doc/source/sdk/resources/dns/v2/nameserver.rst similarity index 100% rename from doc/source/user/resources/dns/v2/nameserver.rst rename to doc/source/sdk/resources/dns/v2/nameserver.rst diff --git a/doc/source/user/resources/dns/v2/recordset.rst b/doc/source/sdk/resources/dns/v2/recordset.rst similarity index 100% rename from doc/source/user/resources/dns/v2/recordset.rst rename to doc/source/sdk/resources/dns/v2/recordset.rst diff --git a/doc/source/user/resources/dns/v2/zone.rst b/doc/source/sdk/resources/dns/v2/zone.rst similarity index 100% rename from doc/source/user/resources/dns/v2/zone.rst rename to doc/source/sdk/resources/dns/v2/zone.rst diff --git a/doc/source/sdk/resources/identity/index.rst b/doc/source/sdk/resources/identity/index.rst new file mode 100644 index 000000000..76f1b8aa7 --- /dev/null +++ b/doc/source/sdk/resources/identity/index.rst @@ -0,0 +1,16 @@ +Identity v3 Resources +===================== + +.. toctree:: + :maxdepth: 1 + + v3/agency + v3/agency_role + v3/credential + v3/domain + v3/endpoint + v3/group + v3/policy + v3/project + v3/service + v3/user diff --git a/doc/source/sdk/resources/identity/v3/agency.rst b/doc/source/sdk/resources/identity/v3/agency.rst new file mode 100644 index 000000000..33e010fe2 --- /dev/null +++ b/doc/source/sdk/resources/identity/v3/agency.rst @@ -0,0 +1,12 @@ +otcextensions.sdk.identity.v3.agency +==================================== + +.. automodule:: otcextensions.sdk.identity.v3.agency + +The Agency Class +---------------- + +The ``Agency`` class inherits from :class:`~openstack.resource.Resource`. + +.. autoclass:: otcextensions.sdk.identity.v3.agency.Agency + :members: diff --git a/doc/source/sdk/resources/identity/v3/agency_role.rst b/doc/source/sdk/resources/identity/v3/agency_role.rst new file mode 100644 index 000000000..b055f5df7 --- /dev/null +++ b/doc/source/sdk/resources/identity/v3/agency_role.rst @@ -0,0 +1,12 @@ +otcextensions.sdk.identity.v3.agency_role +========================================= + +.. automodule:: otcextensions.sdk.identity.v3.agency_role + +The AgencyRole Class +-------------------- + +The ``AgencyRole`` class inherits from :class:`~openstack.resource.Resource`. + +.. autoclass:: otcextensions.sdk.identity.v3.agency_role.AgencyRole + :members: diff --git a/doc/source/sdk/resources/identity/v3/credential.rst b/doc/source/sdk/resources/identity/v3/credential.rst new file mode 100644 index 000000000..e00a19fc8 --- /dev/null +++ b/doc/source/sdk/resources/identity/v3/credential.rst @@ -0,0 +1,12 @@ +otcextensions.sdk.identity.v3.credential +======================================== + +.. automodule:: otcextensions.sdk.identity.v3.credential + +The Credential Class +-------------------- + +The ``Credential`` class inherits from :class:`~openstack.resource.Resource`. + +.. autoclass:: otcextensions.sdk.identity.v3.credential.Credential + :members: diff --git a/doc/source/sdk/resources/identity/v3/domain.rst b/doc/source/sdk/resources/identity/v3/domain.rst new file mode 100644 index 000000000..bf7d109f3 --- /dev/null +++ b/doc/source/sdk/resources/identity/v3/domain.rst @@ -0,0 +1,12 @@ +openstack.identity.v3.domain +============================ + +.. automodule:: openstack.identity.v3.domain + +The Domain Class +---------------- + +The ``Domain`` class inherits from :class:`~openstack.resource.Resource`. + +.. autoclass:: openstack.identity.v3.domain.Domain + :members: diff --git a/doc/source/sdk/resources/identity/v3/endpoint.rst b/doc/source/sdk/resources/identity/v3/endpoint.rst new file mode 100644 index 000000000..366113d86 --- /dev/null +++ b/doc/source/sdk/resources/identity/v3/endpoint.rst @@ -0,0 +1,12 @@ +openstack.identity.v3.endpoint +============================== + +.. automodule:: openstack.identity.v3.endpoint + +The Endpoint Class +------------------ + +The ``Endpoint`` class inherits from :class:`~openstack.resource.Resource`. + +.. autoclass:: openstack.identity.v3.endpoint.Endpoint + :members: diff --git a/doc/source/sdk/resources/identity/v3/group.rst b/doc/source/sdk/resources/identity/v3/group.rst new file mode 100644 index 000000000..fe6c4462a --- /dev/null +++ b/doc/source/sdk/resources/identity/v3/group.rst @@ -0,0 +1,12 @@ +openstack.identity.v3.group +=========================== + +.. automodule:: openstack.identity.v3.group + +The Group Class +--------------- + +The ``Group`` class inherits from :class:`~openstack.resource.Resource`. + +.. autoclass:: openstack.identity.v3.group.Group + :members: diff --git a/doc/source/sdk/resources/identity/v3/policy.rst b/doc/source/sdk/resources/identity/v3/policy.rst new file mode 100644 index 000000000..2506b1123 --- /dev/null +++ b/doc/source/sdk/resources/identity/v3/policy.rst @@ -0,0 +1,12 @@ +openstack.identity.v3.policy +============================ + +.. automodule:: openstack.identity.v3.policy + +The Policy Class +---------------- + +The ``Policy`` class inherits from :class:`~openstack.resource.Resource`. + +.. autoclass:: openstack.identity.v3.policy.Policy + :members: diff --git a/doc/source/sdk/resources/identity/v3/project.rst b/doc/source/sdk/resources/identity/v3/project.rst new file mode 100644 index 000000000..db8c8546b --- /dev/null +++ b/doc/source/sdk/resources/identity/v3/project.rst @@ -0,0 +1,12 @@ +openstack.identity.v3.project +============================= + +.. automodule:: openstack.identity.v3.project + +The Project Class +----------------- + +The ``Project`` class inherits from :class:`~openstack.resource.Resource`. + +.. autoclass:: openstack.identity.v3.project.Project + :members: diff --git a/doc/source/sdk/resources/identity/v3/service.rst b/doc/source/sdk/resources/identity/v3/service.rst new file mode 100644 index 000000000..02585f5f5 --- /dev/null +++ b/doc/source/sdk/resources/identity/v3/service.rst @@ -0,0 +1,12 @@ +openstack.identity.v3.service +============================= + +.. automodule:: openstack.identity.v3.service + +The Service Class +----------------- + +The ``Service`` class inherits from :class:`~openstack.resource.Resource`. + +.. autoclass:: openstack.identity.v3.service.Service + :members: diff --git a/doc/source/sdk/resources/identity/v3/user.rst b/doc/source/sdk/resources/identity/v3/user.rst new file mode 100644 index 000000000..6ba7ae3f3 --- /dev/null +++ b/doc/source/sdk/resources/identity/v3/user.rst @@ -0,0 +1,12 @@ +openstack.identity.v3.user +========================== + +.. automodule:: openstack.identity.v3.user + +The User Class +-------------- + +The ``User`` class inherits from :class:`~openstack.resource.Resource`. + +.. autoclass:: openstack.identity.v3.user.User + :members: diff --git a/doc/source/sdk/resources/index.rst b/doc/source/sdk/resources/index.rst new file mode 100644 index 000000000..982188c84 --- /dev/null +++ b/doc/source/sdk/resources/index.rst @@ -0,0 +1,39 @@ +Resources and Attributes +======================== + +Open Telekom Cloud Resources +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. toctree:: + :maxdepth: 1 + + Anti DDoS Service (Anti-DDoS) + AutoScaling Service (AS) + Cloud Container Engine (CCE) + Cloud Eye Service (CES) + Cloud Trace Service (CTS) + Distributed Cache Service (DCS) + Dedicated Host Service (DeH) + Distributed Message Service (DMS) + Domain Name Service (DNS) + Identity Service (IAM) + Key Management Service (KMS) + Network Address Translation (NAT) + Object Block Storage (OBS) + Relational Database Service (RDS) + Virtual Private Cloud (VPC) + Web Application Firewall (WAF) + +Every resource which is used within the proxy methods have own attributes. +Those attributes define the behavior of the resource which can be a cluster +or a node or anything different logical unit in an OpenStack Cloud. The +*Resource* layer is a lower-level interface to communicate with OpenStack +services. While the classes exposed by the :ref:`service-proxies` build a +convenience layer on top of this, :class:`~openstack.resource.Resource` +objects can be used directly. However, the most common usage of this layer is +in receiving an object from a class in the `Connection Interface_`, +modifying it, and sending it back to the :ref:`service-proxies` layer, +such as to update a resource on the server. + +The following services have exposed :class:`~openstack.resource.Resource` +classes. diff --git a/doc/source/user/resources/kms/index.rst b/doc/source/sdk/resources/kms/index.rst similarity index 100% rename from doc/source/user/resources/kms/index.rst rename to doc/source/sdk/resources/kms/index.rst diff --git a/doc/source/user/resources/kms/v1/data_key.rst b/doc/source/sdk/resources/kms/v1/data_key.rst similarity index 100% rename from doc/source/user/resources/kms/v1/data_key.rst rename to doc/source/sdk/resources/kms/v1/data_key.rst diff --git a/doc/source/user/resources/kms/v1/key.rst b/doc/source/sdk/resources/kms/v1/key.rst similarity index 100% rename from doc/source/user/resources/kms/v1/key.rst rename to doc/source/sdk/resources/kms/v1/key.rst diff --git a/doc/source/sdk/resources/nat/index.rst b/doc/source/sdk/resources/nat/index.rst new file mode 100644 index 000000000..712e949da --- /dev/null +++ b/doc/source/sdk/resources/nat/index.rst @@ -0,0 +1,9 @@ +NAT Resources +============= + +.. toctree:: + :maxdepth: 1 + + v2/gateway + v2/snat + v2/dnat diff --git a/doc/source/sdk/resources/nat/v2/dnat.rst b/doc/source/sdk/resources/nat/v2/dnat.rst new file mode 100644 index 000000000..8fcb3cf4f --- /dev/null +++ b/doc/source/sdk/resources/nat/v2/dnat.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.nat.v2.dnat +============================= + +.. automodule:: otcextensions.sdk.nat.v2.dnat + +The DNAT Rule Class +-------------------- + +The ``Dnat`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.nat.v2.dnat.Dnat + :members: diff --git a/doc/source/sdk/resources/nat/v2/gateway.rst b/doc/source/sdk/resources/nat/v2/gateway.rst new file mode 100644 index 000000000..1fea7908d --- /dev/null +++ b/doc/source/sdk/resources/nat/v2/gateway.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.nat.v2.gateway +================================ + +.. automodule:: otcextensions.sdk.nat.v2.gateway + +The NAT Gateway Class +---------------------- + +The ``Gateway`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.nat.v2.gateway.Gateway + :members: diff --git a/doc/source/sdk/resources/nat/v2/snat.rst b/doc/source/sdk/resources/nat/v2/snat.rst new file mode 100644 index 000000000..6dd62e650 --- /dev/null +++ b/doc/source/sdk/resources/nat/v2/snat.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.nat.v2.snat +============================= + +.. automodule:: otcextensions.sdk.nat.v2.snat + +The SNAT Rule Class +-------------------- + +The ``Snat`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.nat.v2.snat.Snat + :members: diff --git a/doc/source/user/resources/obs/index.rst b/doc/source/sdk/resources/obs/index.rst similarity index 100% rename from doc/source/user/resources/obs/index.rst rename to doc/source/sdk/resources/obs/index.rst diff --git a/doc/source/user/resources/obs/v1/container.rst b/doc/source/sdk/resources/obs/v1/container.rst similarity index 100% rename from doc/source/user/resources/obs/v1/container.rst rename to doc/source/sdk/resources/obs/v1/container.rst diff --git a/doc/source/user/resources/obs/v1/obj.rst b/doc/source/sdk/resources/obs/v1/obj.rst similarity index 100% rename from doc/source/user/resources/obs/v1/obj.rst rename to doc/source/sdk/resources/obs/v1/obj.rst diff --git a/doc/source/user/resources/rds/index.rst b/doc/source/sdk/resources/rds/index.rst similarity index 71% rename from doc/source/user/resources/rds/index.rst rename to doc/source/sdk/resources/rds/index.rst index 935c168e6..a4acba66e 100644 --- a/doc/source/user/resources/rds/index.rst +++ b/doc/source/sdk/resources/rds/index.rst @@ -1,12 +1,22 @@ RDS Resources ============= +RDS v1 +^^^^^^ + .. toctree:: :maxdepth: 1 v1/configuration v1/flavor v1/instance + +RDS v3 +^^^^^^ + +.. toctree:: + :maxdepth: 1 + v3/configuration v3/flavor v3/instance diff --git a/doc/source/user/resources/rds/v1/configuration.rst b/doc/source/sdk/resources/rds/v1/configuration.rst similarity index 100% rename from doc/source/user/resources/rds/v1/configuration.rst rename to doc/source/sdk/resources/rds/v1/configuration.rst diff --git a/doc/source/user/resources/rds/v1/flavor.rst b/doc/source/sdk/resources/rds/v1/flavor.rst similarity index 100% rename from doc/source/user/resources/rds/v1/flavor.rst rename to doc/source/sdk/resources/rds/v1/flavor.rst diff --git a/doc/source/user/resources/rds/v1/instance.rst b/doc/source/sdk/resources/rds/v1/instance.rst similarity index 100% rename from doc/source/user/resources/rds/v1/instance.rst rename to doc/source/sdk/resources/rds/v1/instance.rst diff --git a/doc/source/user/resources/rds/v3/configuration.rst b/doc/source/sdk/resources/rds/v3/configuration.rst similarity index 97% rename from doc/source/user/resources/rds/v3/configuration.rst rename to doc/source/sdk/resources/rds/v3/configuration.rst index 2952778eb..a6b436702 100644 --- a/doc/source/user/resources/rds/v3/configuration.rst +++ b/doc/source/sdk/resources/rds/v3/configuration.rst @@ -9,5 +9,5 @@ The Configuration Class The ``Configuration`` class inherits from :class:`~otcextensions.sdk.sdk_resource.Resource`. -.. autoclass:: otcextensions.sdk.rds.v3.configuration.ConfigurationGroup +.. autoclass:: otcextensions.sdk.rds.v3.configuration.Configuration :members: diff --git a/doc/source/user/resources/rds/v3/flavor.rst b/doc/source/sdk/resources/rds/v3/flavor.rst similarity index 100% rename from doc/source/user/resources/rds/v3/flavor.rst rename to doc/source/sdk/resources/rds/v3/flavor.rst diff --git a/doc/source/user/resources/rds/v3/instance.rst b/doc/source/sdk/resources/rds/v3/instance.rst similarity index 100% rename from doc/source/user/resources/rds/v3/instance.rst rename to doc/source/sdk/resources/rds/v3/instance.rst diff --git a/doc/source/sdk/resources/vpc/index.rst b/doc/source/sdk/resources/vpc/index.rst new file mode 100644 index 000000000..9c255873c --- /dev/null +++ b/doc/source/sdk/resources/vpc/index.rst @@ -0,0 +1,8 @@ +VPC Resources +============= + +.. toctree:: + :maxdepth: 1 + + v2/peering + v2/route diff --git a/doc/source/sdk/resources/vpc/v2/peering.rst b/doc/source/sdk/resources/vpc/v2/peering.rst new file mode 100644 index 000000000..12b8dcc8b --- /dev/null +++ b/doc/source/sdk/resources/vpc/v2/peering.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.vpc.v2.peering +================================ + +.. automodule:: otcextensions.sdk.vpc.v2.peering + +The VPC Peering Class +---------------------- + +The ``Peering`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.vpc.v2.peering.Peering + :members: diff --git a/doc/source/sdk/resources/vpc/v2/route.rst b/doc/source/sdk/resources/vpc/v2/route.rst new file mode 100644 index 000000000..d2f3cb467 --- /dev/null +++ b/doc/source/sdk/resources/vpc/v2/route.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.vpc.v2.route +================================ + +.. automodule:: otcextensions.sdk.vpc.v2.route + +The VPC Route Class +------------------- + +The ``Route`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.vpc.v2.route.Route + :members: diff --git a/doc/source/sdk/resources/waf/index.rst b/doc/source/sdk/resources/waf/index.rst new file mode 100644 index 000000000..7f6aec6a8 --- /dev/null +++ b/doc/source/sdk/resources/waf/index.rst @@ -0,0 +1,8 @@ +WAF Resources +============= + +.. toctree:: + :maxdepth: 1 + + v1/certificate + v1/domain diff --git a/doc/source/sdk/resources/waf/v1/certificate.rst b/doc/source/sdk/resources/waf/v1/certificate.rst new file mode 100644 index 000000000..35a222c85 --- /dev/null +++ b/doc/source/sdk/resources/waf/v1/certificate.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.waf.v1.certificate +==================================== + +.. automodule:: otcextensions.sdk.waf.v1.certificate + +The WAF Certificate Class +------------------------- + +The ``Certificate`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.waf.v1.certificate.Certificate + :members: diff --git a/doc/source/sdk/resources/waf/v1/domain.rst b/doc/source/sdk/resources/waf/v1/domain.rst new file mode 100644 index 000000000..4c9ebadc4 --- /dev/null +++ b/doc/source/sdk/resources/waf/v1/domain.rst @@ -0,0 +1,13 @@ +otcextensions.sdk.waf.v1.domain +=============================== + +.. automodule:: otcextensions.sdk.waf.v1.domain + +The WAF Domain Class +-------------------- + +The ``Domain`` class inherits from +:class:`~otcextensions.sdk.sdk_resource.Resource`. + +.. autoclass:: otcextensions.sdk.waf.v1.domain.Domain + :members: diff --git a/doc/source/user/config/configuration.rst b/doc/source/user/config/configuration.rst deleted file mode 100644 index 1cdd0ec10..000000000 --- a/doc/source/user/config/configuration.rst +++ /dev/null @@ -1,322 +0,0 @@ -.. _openstack-config: - -====================================== -Configuring OpenStack SDK Applications -====================================== - -.. _config-environment-variables: - -Environment Variables ---------------------- - -`openstacksdk` honors all of the normal `OS_*` variables. It does not -provide backwards compatibility to service-specific variables such as -`NOVA_USERNAME`. - -If you have OpenStack environment variables set, `openstacksdk` will -produce a cloud config object named `envvars` containing your values from the -environment. If you don't like the name `envvars`, that's ok, you can override -it by setting `OS_CLOUD_NAME`. - -Service specific settings, like the nova service type, are set with the -default service type as a prefix. For instance, to set a special service_type -for trove set - -.. code-block:: bash - - export OS_DATABASE_SERVICE_TYPE=rax:database - -.. _config-clouds-yaml: - -Config Files ------------- - -`openstacksdk` will look for a file called `clouds.yaml` in the following -locations: - -* Current Directory -* ~/.config/openstack -* /etc/openstack - -The first file found wins. - -You can also set the environment variable `OS_CLIENT_CONFIG_FILE` to an -absolute path of a file to look for and that location will be inserted at the -front of the file search list. - -The keys are all of the keys you'd expect from `OS_*` - except lower case -and without the OS prefix. So, region name is set with `region_name`. - -Service specific settings, like the nova service type, are set with the -default service type as a prefix. For instance, to set a special service_type -for trove (because you're using Rackspace) set: - -.. code-block:: yaml - - database_service_type: 'rax:database' - - -Site Specific File Locations -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In addition to `~/.config/openstack` and `/etc/openstack` - some platforms -have other locations they like to put things. `openstacksdk` will also -look in an OS specific config dir - -* `USER_CONFIG_DIR` -* `SITE_CONFIG_DIR` - -`USER_CONFIG_DIR` is different on Linux, OSX and Windows. - -* Linux: `~/.config/openstack` -* OSX: `~/Library/Application Support/openstack` -* Windows: `C:\\Users\\USERNAME\\AppData\\Local\\OpenStack\\openstack` - -`SITE_CONFIG_DIR` is different on Linux, OSX and Windows. - -* Linux: `/etc/openstack` -* OSX: `/Library/Application Support/openstack` -* Windows: `C:\\ProgramData\\OpenStack\\openstack` - -An example config file is probably helpful: - -.. code-block:: yaml - - clouds: - mtvexx: - profile: vexxhost - auth: - username: mordred@inaugust.com - password: XXXXXXXXX - project_name: mordred@inaugust.com - region_name: ca-ymq-1 - dns_api_version: 1 - mordred: - region_name: RegionOne - auth: - username: 'mordred' - password: XXXXXXX - project_name: 'shade' - auth_url: 'https://montytaylor-sjc.openstack.blueboxgrid.com:5001/v2.0' - infra: - profile: rackspace - auth: - username: openstackci - password: XXXXXXXX - project_id: 610275 - regions: - - DFW - - ORD - - IAD - -You may note a few things. First, since `auth_url` settings are silly -and embarrassingly ugly, known cloud vendor profile information is included and -may be referenced by name. One of the benefits of that is that `auth_url` -isn't the only thing the vendor defaults contain. For instance, since -Rackspace lists `rax:database` as the service type for trove, `openstacksdk` -knows that so that you don't have to. In case the cloud vendor profile is not -available, you can provide one called `clouds-public.yaml`, following the same -location rules previously mentioned for the config files. - -`regions` can be a list of regions. When you call `get_all_clouds`, -you'll get a cloud config object for each cloud/region combo. - -As seen with `dns_service_type`, any setting that makes sense to be -per-service, like `service_type` or `endpoint` or `api_version` can be set -by prefixing the setting with the default service type. That might strike you -funny when setting `service_type` and it does me too - but that's just the -world we live in. - -Auth Settings -------------- - -Keystone has auth plugins - which means it's not possible to know ahead of time -which auth settings are needed. `openstacksdk` sets the default plugin type -to `password`, which is what things all were before plugins came about. In -order to facilitate validation of values, all of the parameters that exist -as a result of a chosen plugin need to go into the auth dict. For password -auth, this includes `auth_url`, `username` and `password` as well as anything -related to domains, projects and trusts. - -Splitting Secrets ------------------ - -In some scenarios, such as configuration management controlled environments, -it might be easier to have secrets in one file and non-secrets in another. -This is fully supported via an optional file `secure.yaml` which follows all -the same location rules as `clouds.yaml`. It can contain anything you put -in `clouds.yaml` and will take precedence over anything in the `clouds.yaml` -file. - -.. code-block:: yaml - - # clouds.yaml - clouds: - internap: - profile: internap - auth: - username: api-55f9a00fb2619 - project_name: inap-17037 - regions: - - ams01 - - nyj01 - # secure.yaml - clouds: - internap: - auth: - password: XXXXXXXXXXXXXXXXX - -SSL Settings ------------- - -When the access to a cloud is done via a secure connection, `openstacksdk` -will always verify the SSL cert by default. This can be disabled by setting -`verify` to `False`. In case the cert is signed by an unknown CA, a specific -cacert can be provided via `cacert`. **WARNING:** `verify` will always have -precedence over `cacert`, so when setting a CA cert but disabling `verify`, the -cloud cert will never be validated. - -Client certs are also configurable. `cert` will be the client cert file -location. In case the cert key is not included within the client cert file, -its file location needs to be set via `key`. - -.. code-block:: yaml - - # clouds.yaml - clouds: - regular-secure-cloud: - auth: - auth_url: https://signed.cert.domain:5000 - ... - unknown-ca-with-client-cert-secure-cloud: - auth: - auth_url: https://unknown.ca.but.secure.domain:5000 - ... - key: /home/myhome/client-cert.key - cert: /home/myhome/client-cert.crt - cacert: /home/myhome/ca.crt - self-signed-insecure-cloud: - auth: - auth_url: https://self.signed.cert.domain:5000 - ... - verify: False - -Note for parity with ``openstack`` command-line options the `insecure` -boolean is also recognised (with the opposite semantics to `verify`; -i.e. `True` ignores certificate failures). This should be considered -deprecated for `verify`. - -Cache Settings --------------- - -Accessing a cloud is often expensive, so it's quite common to want to do some -client-side caching of those operations. To facilitate that, `openstacksdk` -understands passing through cache settings to dogpile.cache, with the following -behaviors: - -* Listing no config settings means you get a null cache. -* `cache.expiration_time` and nothing else gets you memory cache. -* Otherwise, `cache.class` and `cache.arguments` are passed in - -Different cloud behaviors are also differently expensive to deal with. If you -want to get really crazy and tweak stuff, you can specify different expiration -times on a per-resource basis by passing values, in seconds to an expiration -mapping keyed on the singular name of the resource. A value of `-1` indicates -that the resource should never expire. - -`openstacksdk` does not actually cache anything itself, but it collects -and presents the cache information so that your various applications that -are connecting to OpenStack can share a cache should you desire. - -.. code-block:: yaml - - cache: - class: dogpile.cache.pylibmc - expiration_time: 3600 - arguments: - url: - - 127.0.0.1 - expiration: - server: 5 - flavor: -1 - clouds: - mtvexx: - profile: vexxhost - auth: - username: mordred@inaugust.com - password: XXXXXXXXX - project_name: mordred@inaugust.com - region_name: ca-ymq-1 - dns_api_version: 1 - - -IPv6 ----- - -IPv6 is the future, and you should always use it if your cloud supports it and -if your local network supports it. Both of those are easily detectable and all -friendly software should do the right thing. However, sometimes you might -exist in a location where you have an IPv6 stack, but something evil has -caused it to not actually function. In that case, there is a config option -you can set to unbreak you `force_ipv4`, or `OS_FORCE_IPV4` boolean -environment variable. - -.. code-block:: yaml - - client: - force_ipv4: true - clouds: - mtvexx: - profile: vexxhost - auth: - username: mordred@inaugust.com - password: XXXXXXXXX - project_name: mordred@inaugust.com - region_name: ca-ymq-1 - dns_api_version: 1 - monty: - profile: rax - auth: - username: mordred@inaugust.com - password: XXXXXXXXX - project_name: mordred@inaugust.com - region_name: DFW - -The above snippet will tell client programs to prefer returning an IPv4 -address. - -Per-region settings -------------------- - -Sometimes you have a cloud provider that has config that is common to the -cloud, but also with some things you might want to express on a per-region -basis. For instance, Internap provides a public and private network specific -to the user in each region, and putting the values of those networks into -config can make consuming programs more efficient. - -To support this, the region list can actually be a list of dicts, and any -setting that can be set at the cloud level can be overridden for that -region. - -.. code-block:: yaml - - clouds: - internap: - profile: internap - auth: - password: XXXXXXXXXXXXXXXXX - username: api-55f9a00fb2619 - project_name: inap-17037 - regions: - - name: ams01 - values: - networks: - - name: inap-17037-WAN1654 - routes_externally: true - - name: inap-17037-LAN6745 - - name: nyj01 - values: - networks: - - name: inap-17037-WAN1654 - routes_externally: true - - name: inap-17037-LAN6745 diff --git a/doc/source/user/config/index.rst b/doc/source/user/config/index.rst deleted file mode 100644 index 11637239d..000000000 --- a/doc/source/user/config/index.rst +++ /dev/null @@ -1,12 +0,0 @@ -====================== -Using os-client-config -====================== - -.. toctree:: - :maxdepth: 2 - - configuration - using - vendor-support - network-config - reference diff --git a/doc/source/user/config/network-config.rst b/doc/source/user/config/network-config.rst deleted file mode 100644 index ea8541478..000000000 --- a/doc/source/user/config/network-config.rst +++ /dev/null @@ -1,67 +0,0 @@ -============== -Network Config -============== - -There are several different qualities that networks in OpenStack might have -that might not be able to be automatically inferred from the available -metadata. To help users navigate more complex setups, `os-client-config` -allows configuring a list of network metadata. - -.. code-block:: yaml - - clouds: - amazing: - networks: - - name: blue - routes_externally: true - - name: purple - routes_externally: true - default_interface: true - - name: green - routes_externally: false - - name: yellow - routes_externally: false - nat_destination: true - - name: chartreuse - routes_externally: false - routes_ipv6_externally: true - - name: aubergine - routes_ipv4_externally: false - routes_ipv6_externally: true - -Every entry must have a name field, which can hold either the name or the id -of the network. - -`routes_externally` is a boolean field that labels the network as handling -north/south traffic off of the cloud. In a public cloud this might be thought -of as the "public" network, but in private clouds it's possible it might -be an RFC1918 address. In either case, it's provides IPs to servers that -things not on the cloud can use. This value defaults to `false`, which -indicates only servers on the same network can talk to it. - -`routes_ipv4_externally` and `routes_ipv6_externally` are boolean fields to -help handle `routes_externally` in the case where a network has a split stack -with different values for IPv4 and IPv6. Either entry, if not given, defaults -to the value of `routes_externally`. - -`default_interface` is a boolean field that indicates that the network is the -one that programs should use. It defaults to false. An example of needing to -use this value is a cloud with two private networks, and where a user is -running ansible in one of the servers to talk to other servers on the private -network. Because both networks are private, there would otherwise be no way -to determine which one should be used for the traffic. There can only be one -`default_interface` per cloud. - -`nat_destination` is a boolean field that indicates which network floating -ips should be attached to. It defaults to false. Normally this can be inferred -by looking for a network that has subnets that have a gateway_ip. But it's -possible to have more than one network that satisfies that condition, so the -user might want to tell programs which one to pick. There can be only one -`nat_destination` per cloud. - -`nat_source` is a boolean field that indicates which network floating -ips should be requested from. It defaults to false. Normally this can be -inferred by looking for a network that is attached to a router. But it's -possible to have more than one network that satisfies that condition, so the -user might want to tell programs which one to pick. There can be only one -`nat_source` per cloud. diff --git a/doc/source/user/config/reference.rst b/doc/source/user/config/reference.rst deleted file mode 100644 index b4909ad32..000000000 --- a/doc/source/user/config/reference.rst +++ /dev/null @@ -1,14 +0,0 @@ -============= -API Reference -============= - -.. module:: openstack.config - :synopsis: OpenStack client configuration - -.. autoclass:: openstack.config.OpenStackConfig - :members: - :inherited-members: - -.. autoclass:: openstack.config.cloud_region.CloudRegion - :members: - :inherited-members: diff --git a/doc/source/user/config/using.rst b/doc/source/user/config/using.rst deleted file mode 100644 index 7792989cf..000000000 --- a/doc/source/user/config/using.rst +++ /dev/null @@ -1,58 +0,0 @@ -======================================== -Using openstack.config in an Application -======================================== - -Usage ------ - -The simplest and least useful thing you can do is: - -.. code-block:: python - - python -m openstack.config.loader - -Which will print out whatever if finds for your config. If you want to use -it from python, which is much more likely what you want to do, things like: - -Get a named cloud. - -.. code-block:: python - - import openstack.config - - cloud_region = openstack.config.OpenStackConfig().get_one( - 'internap', region_name='ams01') - print(cloud_region.name, cloud_region.region, cloud_region.config) - -Or, get all of the clouds. - -.. code-block:: python - - import openstack.config - - cloud_regions = openstack.config.OpenStackConfig().get_all() - for cloud_region in cloud_regions: - print(cloud_region.name, cloud_region.region, cloud_region.config) - -argparse --------- - -If you're using `openstack.config` from a program that wants to process -command line options, there is a registration function to register the -arguments that both `openstack.config` and keystoneauth know how to deal -with - as well as a consumption argument. - -.. code-block:: python - - import argparse - import sys - - import openstack.config - - config = openstack.config.OpenStackConfig() - parser = argparse.ArgumentParser() - config.register_argparse_arguments(parser, sys.argv) - - options = parser.parse_args() - - cloud_region = config.get_one(argparse=options) diff --git a/doc/source/user/config/vendor-support.rst b/doc/source/user/config/vendor-support.rst deleted file mode 100644 index 4143da248..000000000 --- a/doc/source/user/config/vendor-support.rst +++ /dev/null @@ -1,343 +0,0 @@ -============== -Vendor Support -============== - -OpenStack presents deployers with many options, some of which can expose -differences to end users. `os-client-config` tries its best to collect -information about various things a user would need to know. The following -is a text representation of the vendor related defaults `os-client-config` -knows about. - -Default Values --------------- - -These are the default behaviors unless a cloud is configured differently. - -* Identity uses `password` authentication -* Identity API Version is 2 -* Image API Version is 2 -* Volume API Version is 2 -* Compute API Version is 2.1 -* Images must be in `qcow2` format -* Images are uploaded using PUT interface -* Public IPv4 is directly routable via DHCP from Neutron -* IPv6 is not provided -* Floating IPs are not required -* Floating IPs are provided by Neutron -* Security groups are provided by Neutron -* Vendor specific agents are not used - -AURO ----- - -https://api.auro.io:5000/v2.0 - -============== ================ -Region Name Location -============== ================ -van1 Vancouver, BC -============== ================ - -* Public IPv4 is provided via NAT with Neutron Floating IP - -Betacloud ---------- - -https://api-1.betacloud.io:5000 - -============== ================== -Region Name Location -============== ================== -betacloud-1 Nuremberg, Germany -============== ================== - -* Identity API Version is 3 -* Images must be in `raw` format -* Public IPv4 is provided via NAT with Neutron Floating IP -* Volume API Version is 3 - -Catalyst --------- - -https://api.cloud.catalyst.net.nz:5000/v2.0 - -============== ================ -Region Name Location -============== ================ -nz-por-1 Porirua, NZ -nz_wlg_2 Wellington, NZ -============== ================ - -* Identity API Version is 3 -* Compute API Version is 2 -* Images must be in `raw` format -* Volume API Version is 3 - -City Cloud ----------- - -https://identity1.citycloud.com:5000/v3/ - -============== ================ -Region Name Location -============== ================ -Buf1 Buffalo, NY -Fra1 Frankfurt, DE -Kna1 Karlskrona, SE -La1 Los Angeles, CA -Lon1 London, UK -Sto2 Stockholm, SE -============== ================ - -* Identity API Version is 3 -* Public IPv4 is provided via NAT with Neutron Floating IP -* Volume API Version is 1 - -ConoHa ------- - -https://identity.%(region_name)s.conoha.io - -============== ================ -Region Name Location -============== ================ -tyo1 Tokyo, JP -sin1 Singapore -sjc1 San Jose, CA -============== ================ - -* Image upload is not supported - -DreamCompute ------------- - -https://iad2.dream.io:5000 - -============== ================ -Region Name Location -============== ================ -RegionOne Ashburn, VA -============== ================ - -* Identity API Version is 3 -* Images must be in `raw` format -* IPv6 is provided to every server - -Open Telekom Cloud ------------------- - -https://iam.%(region_name)s.otc.t-systems.com/v3 - -============== ================ -Region Name Location -============== ================ -eu-de Germany -============== ================ - -* Identity API Version is 3 -* Images must be in `vhd` format -* Public IPv4 is provided via NAT with Neutron Floating IP - -ELASTX ------- - -https://ops.elastx.net:5000/v2.0 - -============== ================ -Region Name Location -============== ================ -regionOne Stockholm, SE -============== ================ - -* Public IPv4 is provided via NAT with Neutron Floating IP - -Enter Cloud Suite ------------------ - -https://api.entercloudsuite.com/v2.0 - -============== ================ -Region Name Location -============== ================ -nl-ams1 Amsterdam, NL -it-mil1 Milan, IT -de-fra1 Frankfurt, DE -============== ================ - -* Compute API Version is 2 - -Fuga ----- - -https://identity.api.fuga.io:5000 - -============== ================ -Region Name Location -============== ================ -cystack Netherlands -============== ================ - -* Identity API Version is 3 -* Volume API Version is 3 - -Internap --------- - -https://identity.api.cloud.iweb.com/v2.0 - -============== ================ -Region Name Location -============== ================ -ams01 Amsterdam, NL -da01 Dallas, TX -nyj01 New York, NY -sin01 Singapore -sjc01 San Jose, CA -============== ================ - -* Floating IPs are not supported - -Limestone Networks ------------------- - -https://auth.cloud.lstn.net:5000/v3 - -============== ================== -Region Name Location -============== ================== -us-dfw-1 Dallas, TX -us-slc Salt Lake City, UT -============== ================== - -* Identity API Version is 3 -* Images must be in `raw` format -* IPv6 is provided to every server connected to the `Public Internet` network - -OVH ---- - -https://auth.cloud.ovh.net/v2.0 - -============== ================ -Region Name Location -============== ================ -BHS1 Beauharnois, QC -SBG1 Strassbourg, FR -GRA1 Gravelines, FR -============== ================ - -* Images may be in `raw` format. The `qcow2` default is also supported -* Floating IPs are not supported - -Rackspace ---------- - -https://identity.api.rackspacecloud.com/v2.0/ - -============== ================ -Region Name Location -============== ================ -DFW Dallas, TX -HKG Hong Kong -IAD Washington, D.C. -LON London, UK -ORD Chicago, IL -SYD Sydney, NSW -============== ================ - -* Database Service Type is `rax:database` -* Compute Service Name is `cloudServersOpenStack` -* Images must be in `vhd` format -* Images must be uploaded using the Glance Task Interface -* Floating IPs are not supported -* Public IPv4 is directly routable via static config by Nova -* IPv6 is provided to every server -* Security groups are not supported -* Uploaded Images need properties to not use vendor agent:: - :vm_mode: hvm - :xenapi_use_agent: False -* Volume API Version is 1 -* While passwords are recommended for use, API keys do work as well. - The `rackspaceauth` python package must be installed, and then the following - can be added to clouds.yaml:: - - auth: - username: myusername - api_key: myapikey - auth_type: rackspace_apikey - -SWITCHengines -------------- - -https://keystone.cloud.switch.ch:5000/v2.0 - -============== ================ -Region Name Location -============== ================ -LS Lausanne, CH -ZH Zurich, CH -============== ================ - -* Identity API Version is 3 -* Compute API Version is 2 -* Images must be in `raw` format -* Volume API Version is 3 - -Ultimum -------- - -https://console.ultimum-cloud.com:5000/v2.0 - -============== ================ -Region Name Location -============== ================ -RegionOne Prague, CZ -============== ================ - -* Volume API Version is 1 - -UnitedStack ------------ - -https://identity.api.ustack.com/v3 - -============== ================ -Region Name Location -============== ================ -bj1 Beijing, CN -gd1 Guangdong, CN -============== ================ - -* Identity API Version is 3 -* Images must be in `raw` format -* Volume API Version is 1 - -VEXXHOST --------- - -http://auth.vexxhost.net - -============== ================ -Region Name Location -============== ================ -ca-ymq-1 Montreal, QC -sjc1 Santa Clara, CA -============== ================ - -* DNS API Version is 1 -* Identity API Version is 3 -* Volume API Version is 3 - -Zetta ------ - -https://identity.api.zetta.io/v3 - -============== ================ -Region Name Location -============== ================ -no-osl1 Oslo, NO -============== ================ - -* DNS API Version is 2 -* Identity API Version is 3 diff --git a/doc/source/user/connection.rst b/doc/source/user/connection.rst deleted file mode 100644 index 9ce3452f5..000000000 --- a/doc/source/user/connection.rst +++ /dev/null @@ -1,31 +0,0 @@ -Connection -========== -.. automodule:: openstack.connection - - from_config - ----------- - .. autofunction:: openstack.connection.from_config - -Registering OTC extensions -========================== - -.. autofunction:: otcextensions.sdk.register_otc_extensions - -Connection Object ------------------ - -.. autoclass:: openstack.connection.Connection - :members: - :inherited-members: - - -Transitioning from Profile --------------------------- - -Support exists for users coming from older releases of OpenStack SDK who have -been using the :class:`~openstack.profile.Profile` interface. - -.. toctree:: - :maxdepth: 1 - - transition_from_profile diff --git a/doc/source/user/examples b/doc/source/user/examples deleted file mode 120000 index 9f9d1de88..000000000 --- a/doc/source/user/examples +++ /dev/null @@ -1 +0,0 @@ -../../../examples \ No newline at end of file diff --git a/doc/source/user/guides/auto_scaling.rst b/doc/source/user/guides/auto_scaling.rst deleted file mode 100644 index 10c805c9d..000000000 --- a/doc/source/user/guides/auto_scaling.rst +++ /dev/null @@ -1,4 +0,0 @@ -Using OTC AS -============ - -.. TODO(agoncharov): Implement this guide diff --git a/doc/source/user/guides/connect_otc.rst b/doc/source/user/guides/connect_otc.rst deleted file mode 100644 index d0e27ac67..000000000 --- a/doc/source/user/guides/connect_otc.rst +++ /dev/null @@ -1,39 +0,0 @@ -Connect OTC -=========== - -In order to work with an OpenStack cloud you first need to create a -:class:`~openstack.connection.Connection` to it using your credentials. A -:class:`~openstack.connection.Connection` can be -created in 3 ways, using the class itself, :ref:`config-clouds-yaml`, or -:ref:`config-environment-variables`. It is recommended to always use -:ref:`config-clouds-yaml` as the same config can be used across tools and -languages. - -Create Connection ------------------ - -To create a :class:`~openstack.connection.Connection` instance, use the -:func:`~openstack.connect` factory function. - -As a next step inject the OTC extensions into the retrieved connection - -.. code-block:: python - - # An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml - conn = openstack.connect(cloud='otc') - - # Register OTC Extensions - sdk.register_otc_extensions(conn) - -Full example at `connect_otc.py `_ - -.. note:: To enable logging, see the :doc:`logging` user guide. - -Next ----- -Now that you can create a connection, continue with the :ref:`user_guides` -to work with an OpenStack service. - -.. TODO(shade) Update the text here and consolidate with the old - os-client-config docs so that we have a single and consistent explanation - of the envvars cloud, etc. diff --git a/doc/source/user/guides/obs.rst b/doc/source/user/guides/obs.rst deleted file mode 100644 index 89ffc0f71..000000000 --- a/doc/source/user/guides/obs.rst +++ /dev/null @@ -1,4 +0,0 @@ -Using OTC OBS -============= - -.. TODO(agoncharov): Implement this guide diff --git a/doc/source/user/guides/rds.rst b/doc/source/user/guides/rds.rst deleted file mode 100644 index c7512a459..000000000 --- a/doc/source/user/guides/rds.rst +++ /dev/null @@ -1,4 +0,0 @@ -Using OTC RDS -============= - -.. TODO(agoncharov): Implement this guide diff --git a/doc/source/user/guides/volume_backup.rst b/doc/source/user/guides/volume_backup.rst deleted file mode 100644 index d2a5be6f8..000000000 --- a/doc/source/user/guides/volume_backup.rst +++ /dev/null @@ -1,4 +0,0 @@ -Using OTC VBS -============= - -.. TODO(agoncharov): Implement this guide diff --git a/doc/source/user/index.rst b/doc/source/user/index.rst deleted file mode 100644 index 3d9c2d0fe..000000000 --- a/doc/source/user/index.rst +++ /dev/null @@ -1,195 +0,0 @@ -Getting started with the OTCExtensions SDK -========================================== - -Please note that OTCExtensions provides an extension to the OpenStackSDK. -Please refer to it's documentation for the details - - -Installation ------------- - -The OTCExtensions SDK is available on -`GitHub `_. -To install it, use ``pip``:: - - $ pip install otcextensions - -.. _user_guides: - -User Guides ------------ - -These guides walk you through how to make use of the libraries we provide -to work with each OpenStack service. If you're looking for a cookbook -approach, this is where you'll want to begin. - -.. toctree:: - :maxdepth: 1 - - Plain-simple connect to OTC - Configuration - Connect to an OpenStack Cloud Using a Config File - Using Cloud Abstration Layer - Logging - Microversions - Block Storage - Compute - Identity - Image - Key Manager - Message - Network - Object Store - Orchestration - RDS - OBS - AutoScaling - Volume Backup - Dedicated Host - -API Documentation ------------------ - -OpenStackSDK documentation is available under - - -Service APIs are exposed through a two-layered approach. The classes -exposed through our `Connection Interface`_ are -the place to start if you're an application developer consuming an OpenStack -cloud. The `Resource Interface`_ is the layer upon which the -`Connection Interface`_ is built, with methods on `Service Proxies`_ accepting -and returning :class:`~openstack.resource.Resource` objects. - -The Cloud Abstraction layer has a data model. - -.. toctree:: - :maxdepth: 1 - - model - -Connection Interface -~~~~~~~~~~~~~~~~~~~~ - -A :class:`~openstack.connection.Connection` instance maintains your cloud -config, session and authentication information providing you with a set of -higher-level interfaces to work with OpenStack services. - -.. toctree:: - :maxdepth: 1 - - connection - -Once you have a :class:`~openstack.connection.Connection` instance, services -are accessed through instances of :class:`~openstack.proxy.Proxy` or -subclasses of it that exist as attributes on the -:class:`~openstack.connection.Connection`. - -.. autoclass:: openstack.proxy.Proxy - :members: - -.. _service-proxies: - -Service Proxies -~~~~~~~~~~~~~~~ - -The following service proxies exist on the -:class:`~openstack.connection.Connection`. The service proxies are all always -present on the :class:`~openstack.connection.Connection` object, but the -combination of your ``CloudRegion`` and the catalog of the cloud in question -control which services can be used. - -.. toctree:: - :maxdepth: 1 - - Block Storage - Compute - Database - Identity v2 - Identity v3 - Image v1 - Image v2 - Key Manager - Load Balancer - Message v2 - Network - Object Store - Orchestration - Workflow - Anti DDoS Service - AutoScaling Service - Cloud Container Engine v1 - Cloud Container Engine v2 - Cloud Trace Service - Distributed Cache Service - Dedicated Host Service - Distributed Message Service - DNS Service - Key Management Service - Object Block Storage - Volume Backup Service - RDS - -Resource Interface -~~~~~~~~~~~~~~~~~~ - -The *Resource* layer is a lower-level interface to -communicate with OpenStack services. While the classes exposed by the -`Service Proxies`_ build a convenience layer on top of -this, :class:`~openstack.resource.Resource` objects can be -used directly. However, the most common usage of this layer is in receiving -an object from a class in the `Connection Interface_`, modifying it, and -sending it back to the `Service Proxies`_ layer, such as to update a resource -on the server. - -The following services have exposed :class:`~openstack.resource.Resource` -classes. - -.. toctree:: - :maxdepth: 1 - - Baremetal - Block Storage - Clustering - Compute - Database - Identity - Image - Key Management - Load Balancer - Network - Orchestration - Object Store - Workflow - Anti DDoS Service - AutoScaling Service - DNS Service - Cloud Container Engine - Cloud Trace Service - Distributed Cache Service - Dedicated Host Service - Distributed Message Service - Key Management Service - Object Block Storage - RDS - -Low-Level Classes -~~~~~~~~~~~~~~~~~ - -The following classes are not commonly used by application developers, -but are used to construct applications to talk to OpenStack APIs. Typically -these parts are managed through the `Connection Interface`_, but their use -can be customized. - -.. toctree:: - :maxdepth: 1 - - resource - utils - -Presentations -============= - -.. toctree:: - :maxdepth: 1 - - multi-cloud-demo diff --git a/doc/source/user/model.rst b/doc/source/user/model.rst deleted file mode 100644 index 62fa748ef..000000000 --- a/doc/source/user/model.rst +++ /dev/null @@ -1,533 +0,0 @@ -========== -Data Model -========== - -shade has a very strict policy on not breaking backwards compatability ever. -However, with the data structures returned from OpenStack, there are places -where the resource structures from OpenStack are returned to the user somewhat -directly, leaving a shade user open to changes/differences in result content. - -To combat that, shade 'normalizes' the return structure from OpenStack in many -places, and the results of that normalization are listed below. Where shade -performs normalization, a user can count on any fields declared in the docs -as being completely safe to use - they are as much a part of shade's API -contract as any other Python method. - -Some OpenStack objects allow for arbitrary attributes at -the root of the object. shade will pass those through so as not to break anyone -who may be counting on them, but as they are arbitrary shade can make no -guarantees as to their existence. As part of normalization, shade will put any -attribute from an OpenStack resource that is not in its data model contract -into an attribute called 'properties'. The contents of properties are -defined to be an arbitrary collection of key value pairs with no promises as -to any particular key ever existing. - -If a user passes `strict=True` to the shade constructor, shade will not pass -through arbitrary objects to the root of the resource, and will instead only -put them in the properties dict. If a user is worried about accidentally -writing code that depends on an attribute that is not part of the API contract, -this can be a useful tool. Keep in mind all data can still be accessed via -the properties dict, but any code touching anything in the properties dict -should be aware that the keys found there are highly user/cloud specific. -Any key that is transformed as part of the shade data model contract will -not wind up with an entry in properties - only keys that are unknown. - -Location --------- - -A Location defines where a resource lives. It includes a cloud name and a -region name, an availability zone as well as information about the project -that owns the resource. - -The project information may contain a project id, or a combination of one or -more of a project name with a domain name or id. If a project id is present, -it should be considered correct. - -Some resources do not carry ownership information with them. For those, the -project information will be filled in from the project the user currently -has a token for. - -Some resources do not have information about availability zones, or may exist -region wide. Those resources will have None as their availability zone. - -If all of the project information is None, then - -.. code-block:: python - - Location = dict( - cloud=str(), - region_name=str(), - zone=str() or None, - project=dict( - id=str() or None, - name=str() or None, - domain_id=str() or None, - domain_name=str() or None)) - - -Resources -========= - -Flavor ------- - -A flavor for a Nova Server. - -.. code-block:: python - - Flavor = dict( - location=Location(), - id=str(), - name=str(), - is_public=bool(), - is_disabled=bool(), - ram=int(), - vcpus=int(), - disk=int(), - ephemeral=int(), - swap=int(), - rxtx_factor=float(), - extra_specs=dict(), - properties=dict()) - - -Flavor Access -------------- - -An access entry for a Nova Flavor. - -.. code-block:: python - - FlavorAccess = dict( - flavor_id=str(), - project_id=str()) - - -Image ------ - -A Glance Image. - -.. code-block:: python - - Image = dict( - location=Location(), - id=str(), - name=str(), - min_ram=int(), - min_disk=int(), - size=int(), - virtual_size=int(), - container_format=str(), - disk_format=str(), - checksum=str(), - created_at=str(), - updated_at=str(), - owner=str(), - is_public=bool(), - is_protected=bool(), - visibility=str(), - status=str(), - locations=list(), - direct_url=str() or None, - tags=list(), - properties=dict()) - - -Keypair -------- - -A keypair for a Nova Server. - -.. code-block:: python - - Keypair = dict( - location=Location(), - name=str(), - id=str(), - public_key=str(), - fingerprint=str(), - type=str(), - user_id=str(), - private_key=str() or None - properties=dict()) - - -Security Group --------------- - -A Security Group from either Nova or Neutron - -.. code-block:: python - - SecurityGroup = dict( - location=Location(), - id=str(), - name=str(), - description=str(), - security_group_rules=list(), - properties=dict()) - -Security Group Rule -------------------- - -A Security Group Rule from either Nova or Neutron - -.. code-block:: python - - SecurityGroupRule = dict( - location=Location(), - id=str(), - direction=str(), # oneof('ingress', 'egress') - ethertype=str(), - port_range_min=int() or None, - port_range_max=int() or None, - protocol=str() or None, - remote_ip_prefix=str() or None, - security_group_id=str() or None, - remote_group_id=str() or None - properties=dict()) - -Server ------- - -A Server from Nova - -.. code-block:: python - - Server = dict( - location=Location(), - id=str(), - name=str(), - image=dict() or str(), - flavor=dict(), - volumes=list(), # Volume - interface_ip=str(), - has_config_drive=bool(), - accessIPv4=str(), - accessIPv6=str(), - addresses=dict(), # string, list(Address) - created=str(), - created_at=str(), - key_name=str(), - metadata=dict(), # string, string - private_v4=str(), - progress=int(), - public_v4=str(), - public_v6=str(), - security_groups=list(), # SecurityGroup - status=str(), - updated=str(), - user_id=str(), - host_id=str() or None, - power_state=str() or None, - task_state=str() or None, - vm_state=str() or None, - launched_at=str() or None, - terminated_at=str() or None, - task_state=str() or None, - properties=dict()) - -ComputeLimits -------------- - -Limits and current usage for a project in Nova - -.. code-block:: python - - ComputeLimits = dict( - location=Location(), - max_personality=int(), - max_personality_size=int(), - max_server_group_members=int(), - max_server_groups=int(), - max_server_meta=int(), - max_total_cores=int(), - max_total_instances=int(), - max_total_keypairs=int(), - max_total_ram_size=int(), - total_cores_used=int(), - total_instances_used=int(), - total_ram_used=int(), - total_server_groups_used=int(), - properties=dict()) - -ComputeUsage ------------- - -Current usage for a project in Nova - -.. code-block:: python - - ComputeUsage = dict( - location=Location(), - started_at=str(), - stopped_at=str(), - server_usages=list(), - max_personality=int(), - max_personality_size=int(), - max_server_group_members=int(), - max_server_groups=int(), - max_server_meta=int(), - max_total_cores=int(), - max_total_instances=int(), - max_total_keypairs=int(), - max_total_ram_size=int(), - total_cores_used=int(), - total_hours=int(), - total_instances_used=int(), - total_local_gb_usage=int(), - total_memory_mb_usage=int(), - total_ram_used=int(), - total_server_groups_used=int(), - total_vcpus_usage=int(), - properties=dict()) - -ServerUsage ------------ - -Current usage for a server in Nova - -.. code-block:: python - - ComputeUsage = dict( - started_at=str(), - ended_at=str(), - flavor=str(), - hours=int(), - instance_id=str(), - local_gb=int(), - memory_mb=int(), - name=str(), - state=str(), - uptime=int(), - vcpus=int(), - properties=dict()) - -Floating IP ------------ - -A Floating IP from Neutron or Nova - - -.. code-block:: python - - FloatingIP = dict( - location=Location(), - id=str(), - description=str(), - attached=bool(), - fixed_ip_address=str() or None, - floating_ip_address=str() or None, - network=str() or None, - port=str() or None, - router=str(), - status=str(), - created_at=str() or None, - updated_at=str() or None, - revision_number=int() or None, - properties=dict()) - -Volume ------- - -A volume from cinder. - -.. code-block:: python - - Volume = dict( - location=Location(), - id=str(), - name=str(), - description=str(), - size=int(), - attachments=list(), - status=str(), - migration_status=str() or None, - host=str() or None, - replication_driver=str() or None, - replication_status=str() or None, - replication_extended_status=str() or None, - snapshot_id=str() or None, - created_at=str(), - updated_at=str() or None, - source_volume_id=str() or None, - consistencygroup_id=str() or None, - volume_type=str() or None, - metadata=dict(), - is_bootable=bool(), - is_encrypted=bool(), - can_multiattach=bool(), - properties=dict()) - - -VolumeType ----------- - -A volume type from cinder. - -.. code-block:: python - - VolumeType = dict( - location=Location(), - id=str(), - name=str(), - description=str() or None, - is_public=bool(), - qos_specs_id=str() or None, - extra_specs=dict(), - properties=dict()) - - -VolumeTypeAccess ----------------- - -A volume type access from cinder. - -.. code-block:: python - - VolumeTypeAccess = dict( - location=Location(), - volume_type_id=str(), - project_id=str(), - properties=dict()) - - -ClusterTemplate ---------------- - -A Cluster Template from magnum. - -.. code-block:: python - - ClusterTemplate = dict( - location=Location(), - apiserver_port=int(), - cluster_distro=str(), - coe=str(), - created_at=str(), - dns_nameserver=str(), - docker_volume_size=int(), - external_network_id=str(), - fixed_network=str() or None, - flavor_id=str(), - http_proxy=str() or None, - https_proxy=str() or None, - id=str(), - image_id=str(), - insecure_registry=str(), - is_public=bool(), - is_registry_enabled=bool(), - is_tls_disabled=bool(), - keypair_id=str(), - labels=dict(), - master_flavor_id=str() or None, - name=str(), - network_driver=str(), - no_proxy=str() or None, - server_type=str(), - updated_at=str() or None, - volume_driver=str(), - properties=dict()) - -MagnumService -------------- - -A Magnum Service from magnum - -.. code-block:: python - - MagnumService = dict( - location=Location(), - binary=str(), - created_at=str(), - disabled_reason=str() or None, - host=str(), - id=str(), - report_count=int(), - state=str(), - properties=dict()) - -Stack ------ - -A Stack from Heat - -.. code-block:: python - - Stack = dict( - location=Location(), - id=str(), - name=str(), - created_at=str(), - deleted_at=str(), - updated_at=str(), - description=str(), - action=str(), - identifier=str(), - is_rollback_enabled=bool(), - notification_topics=list(), - outputs=list(), - owner=str(), - parameters=dict(), - parent=str(), - stack_user_project_id=str(), - status=str(), - status_reason=str(), - tags=dict(), - tempate_description=str(), - timeout_mins=int(), - properties=dict()) - -Identity Resources -================== - -Identity Resources are slightly different. - -They are global to a cloud, so location.availability_zone and -location.region_name and will always be None. If a deployer happens to deploy -OpenStack in such a way that users and projects are not shared amongst regions, -that necessitates treating each of those regions as separate clouds from -shade's POV. - -The Identity Resources that are not Project do not exist within a Project, -so all of the values in ``location.project`` will be None. - -Project -------- - -A Project from Keystone (or a tenant if Keystone v2) - -Location information for Project has some additional specific semantics. -If the project has a parent project, that will be in ``location.project.id``, -and if it doesn't that should be ``None``. - -If the Project is associated with a domain that will be in -``location.project.domain_id`` in addition to the normal ``domain_id`` -regardless of the current user's token scope. - -.. code-block:: python - - Project = dict( - location=Location(), - id=str(), - name=str(), - description=str(), - is_enabled=bool(), - is_domain=bool(), - domain_id=str(), - properties=dict()) - -Role ----- - -A Role from Keystone - -.. code-block:: python - - Project = dict( - location=Location(), - id=str(), - name=str(), - domain_id=str(), - properties=dict()) diff --git a/doc/source/user/multi-cloud-demo.rst b/doc/source/user/multi-cloud-demo.rst deleted file mode 100644 index de529d598..000000000 --- a/doc/source/user/multi-cloud-demo.rst +++ /dev/null @@ -1,809 +0,0 @@ -================ -Multi-Cloud Demo -================ - -This document contains a presentation in `presentty`_ format. If you want to -walk through it like a presentation, install `presentty` and run: - -.. code:: bash - - presentty doc/source/user/multi-cloud-demo.rst - -The content is hopefully helpful even if it's not being narrated, so it's being -included in the `shade` docs. - -.. _presentty: https://pypi.org/project/presentty - -Using Multiple OpenStack Clouds Easily with Shade -================================================= - -Who am I? -========= - -Monty Taylor - -* OpenStack Infra Core -* irc: mordred -* twitter: @e_monty - -What are we going to talk about? -================================ - -`shade` - -* a task and end-user oriented Python library -* abstracts deployment differences -* designed for multi-cloud -* simple to use -* massive scale - - * optional advanced features to handle 20k servers a day - -* Initial logic/design extracted from nodepool -* Librified to re-use in Ansible - -shade is Free Software -====================== - -* https://git.openstack.org/cgit/openstack-infra/shade -* openstack-dev@lists.openstack.org -* #openstack-shade on freenode - -This talk is Free Software, too -=============================== - -* Written for presentty (https://pypi.org/project/presentty) -* doc/source/multi-cloud-demo.rst -* examples in doc/source/examples -* Paths subject to change- this is the first presentation in tree! - -Complete Example -================ - -.. code:: python - - from openstack import cloud as openstack - - # Initialize and turn on debug logging - openstack.enable_logging(debug=True) - - for cloud_name, region_name in [ - ('my-vexxhost', 'ca-ymq-1'), - ('my-citycloud', 'Buf1'), - ('my-internap', 'ams01')]: - # Initialize cloud - cloud = openstack.connect(cloud=cloud_name, region_name=region_name) - - # Upload an image to the cloud - image = cloud.create_image( - 'devuan-jessie', filename='devuan-jessie.qcow2', wait=True) - - # Find a flavor with at least 512M of RAM - flavor = cloud.get_flavor_by_ram(512) - - # Boot a server, wait for it to boot, and then do whatever is needed - # to get a public ip for it. - cloud.create_server( - 'my-server', image=image, flavor=flavor, wait=True, auto_ip=True) - -Let's Take a Few Steps Back -=========================== - -Multi-cloud is easy, but you need to know a few things. - -* Terminology -* Config -* Shade API - -Cloud Terminology -================= - -Let's define a few terms, so that we can use them with ease: - -* `cloud` - logically related collection of services -* `region` - completely independent subset of a given cloud -* `patron` - human who has an account -* `user` - account on a cloud -* `project` - logical collection of cloud resources -* `domain` - collection of users and projects - -Cloud Terminology Relationships -=============================== - -* A `cloud` has one or more `regions` -* A `patron` has one or more `users` -* A `patron` has one or more `projects` -* A `cloud` has one or more `domains` -* In a `cloud` with one `domain` it is named "default" -* Each `patron` may have their own `domain` -* Each `user` is in one `domain` -* Each `project` is in one `domain` -* A `user` has one or more `roles` on one or more `projects` - -HTTP Sessions -============= - -* HTTP interactions are authenticated via keystone -* Authenticating returns a `token` -* An authenticated HTTP Session is shared across a `region` - -Cloud Regions -============= - -A `cloud region` is the basic unit of REST interaction. - -* A `cloud` has a `service catalog` -* The `service catalog` is returned in the `token` -* The `service catalog` lists `endpoint` for each `service` in each `region` -* A `region` is completely autonomous - -Users, Projects and Domains -=========================== - -In clouds with multiple domains, project and user names are -only unique within a region. - -* Names require `domain` information for uniqueness. IDs do not. -* Providing `domain` information when not needed is fine. -* `project_name` requires `project_domain_name` or `project_domain_id` -* `project_id` does not -* `username` requires `user_domain_name` or `user_domain_id` -* `user_id` does not - -Confused Yet? -============= - -Don't worry - you don't have to deal with most of that. - -Auth per cloud, select per region -================================= - -In general, the thing you need to know is: - -* Configure authentication per `cloud` -* Select config to use by `cloud` and `region` - -clouds.yaml -=========== - -Information about the clouds you want to connect to is stored in a file -called `clouds.yaml`. - -`clouds.yaml` can be in your homedir: `~/.config/openstack/clouds.yaml` -or system-wide: `/etc/openstack/clouds.yaml`. - -Information in your homedir, if it exists, takes precedence. - -Full docs on `clouds.yaml` are at -https://docs.openstack.org/os-client-config/latest/ - -What about Mac and Windows? -=========================== - -`USER_CONFIG_DIR` is different on Linux, OSX and Windows. - -* Linux: `~/.config/openstack` -* OSX: `~/Library/Application Support/openstack` -* Windows: `C:\\Users\\USERNAME\\AppData\\Local\\OpenStack\\openstack` - -`SITE_CONFIG_DIR` is different on Linux, OSX and Windows. - -* Linux: `/etc/openstack` -* OSX: `/Library/Application Support/openstack` -* Windows: `C:\\ProgramData\\OpenStack\\openstack` - -Config Terminology -================== - -For multi-cloud, think of two types: - -* `profile` - Facts about the `cloud` that are true for everyone -* `cloud` - Information specific to a given `user` - -Apologies for the use of `cloud` twice. - -Environment Variables and Simple Usage -====================================== - -* Environment variables starting with `OS_` go into a cloud called `envvars` -* If you only have one cloud, you don't have to specify it -* `OS_CLOUD` and `OS_REGION_NAME` are default values for - `cloud` and `region_name` - -TOO MUCH TALKING - NOT ENOUGH CODE -================================== - -basic clouds.yaml for the example code -====================================== - -Simple example of a clouds.yaml - -* Config for a named `cloud` "my-citycloud" -* Reference a well-known "named" profile: `citycloud` -* `os-client-config` has a built-in list of profiles at - https://docs.openstack.org/os-client-config/latest/user/vendor-support.html -* Vendor profiles contain various advanced config -* `cloud` name can match `profile` name (using different names for clarity) - -.. code:: yaml - - clouds: - my-citycloud: - profile: citycloud - auth: - username: mordred - project_id: 65222a4d09ea4c68934fa1028c77f394 - user_domain_id: d0919bd5e8d74e49adf0e145807ffc38 - project_domain_id: d0919bd5e8d74e49adf0e145807ffc38 - -Where's the password? - -secure.yaml -=========== - -* Optional additional file just like `clouds.yaml` -* Values overlaid on `clouds.yaml` -* Useful if you want to protect secrets more stringently - -Example secure.yaml -=================== - -* No, my password isn't XXXXXXXX -* `cloud` name should match `clouds.yaml` -* Optional - I actually keep mine in my `clouds.yaml` - -.. code:: yaml - - clouds: - my-citycloud: - auth: - password: XXXXXXXX - -more clouds.yaml -================ - -More information can be provided. - -* Use v3 of the `identity` API - even if others are present -* Use `https://image-ca-ymq-1.vexxhost.net/v2` for `image` API - instead of what's in the catalog - -.. code:: yaml - - my-vexxhost: - identity_api_version: 3 - image_endpoint_override: https://image-ca-ymq-1.vexxhost.net/v2 - profile: vexxhost - auth: - user_domain_id: default - project_domain_id: default - project_name: d8af8a8f-a573-48e6-898a-af333b970a2d - username: 0b8c435b-cc4d-4e05-8a47-a2ada0539af1 - -Much more complex clouds.yaml example -===================================== - -* Not using a profile - all settings included -* In the `ams01` `region` there are two networks with undiscoverable qualities -* Each one are labeled here so choices can be made -* Any of the settings can be specific to a `region` if needed -* `region` settings override `cloud` settings -* `cloud` does not support `floating-ips` - -.. code:: yaml - - my-internap: - auth: - auth_url: https://identity.api.cloud.iweb.com - username: api-55f9a00fb2619 - project_name: inap-17037 - identity_api_version: 3 - floating_ip_source: None - regions: - - name: ams01 - values: - networks: - - name: inap-17037-WAN1654 - routes_externally: true - default_interface: true - - name: inap-17037-LAN3631 - routes_externally: false - -Complete Example Again -====================== - -.. code:: python - - from openstack import cloud as openstack - - # Initialize and turn on debug logging - openstack.enable_logging(debug=True) - - for cloud_name, region_name in [ - ('my-vexxhost', 'ca-ymq-1'), - ('my-citycloud', 'Buf1'), - ('my-internap', 'ams01')]: - # Initialize cloud - cloud = openstack.connect(cloud=cloud_name, region_name=region_name) - - # Upload an image to the cloud - image = cloud.create_image( - 'devuan-jessie', filename='devuan-jessie.qcow2', wait=True) - - # Find a flavor with at least 512M of RAM - flavor = cloud.get_flavor_by_ram(512) - - # Boot a server, wait for it to boot, and then do whatever is needed - # to get a public ip for it. - cloud.create_server( - 'my-server', image=image, flavor=flavor, wait=True, auto_ip=True) - -Step By Step -============ - -Import the library -================== - -.. code:: python - - from openstack import cloud as openstack - -Logging -======= - -* `openstacksdk` uses standard python logging -* ``openstack.enable_logging`` does easy defaults -* Squelches some meaningless warnings - - * `debug` - - * Logs shade loggers at debug level - - * `http_debug` Implies `debug`, turns on HTTP tracing - -.. code:: python - - # Initialize and turn on debug logging - openstack.enable_logging(debug=True) - -Example with Debug Logging -========================== - -* doc/source/examples/debug-logging.py - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging(debug=True) - - cloud = openstack.connect( - cloud='my-vexxhost', region_name='ca-ymq-1') - cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]') - -Example with HTTP Debug Logging -=============================== - -* doc/source/examples/http-debug-logging.py - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging(http_debug=True) - - cloud = openstack.connect( - cloud='my-vexxhost', region_name='ca-ymq-1') - cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]') - -Cloud Regions -============= - -* `cloud` constructor needs `cloud` and `region_name` -* `openstack.connect` is a helper factory function - -.. code:: python - - for cloud_name, region_name in [ - ('my-vexxhost', 'ca-ymq-1'), - ('my-citycloud', 'Buf1'), - ('my-internap', 'ams01')]: - # Initialize cloud - cloud = openstack.connect(cloud=cloud_name, region_name=region_name) - -Upload an Image -=============== - -* Picks the correct upload mechanism -* **SUGGESTION** Always upload your own base images - -.. code:: python - - # Upload an image to the cloud - image = cloud.create_image( - 'devuan-jessie', filename='devuan-jessie.qcow2', wait=True) - -Always Upload an Image -====================== - -Ok. You don't have to. But, for multi-cloud... - -* Images with same content are named different on different clouds -* Images with same name on different clouds can have different content -* Upload your own to all clouds, both problems go away -* Download from OS vendor or build with `diskimage-builder` - -Find a flavor -============= - -* Flavors are all named differently on clouds -* Flavors can be found via RAM -* `get_flavor_by_ram` finds the smallest matching flavor - -.. code:: python - - # Find a flavor with at least 512M of RAM - flavor = cloud.get_flavor_by_ram(512) - -Create a server -=============== - -* my-vexxhost - - * Boot server - * Wait for `status==ACTIVE` - -* my-internap - - * Boot server on network `inap-17037-WAN1654` - * Wait for `status==ACTIVE` - -* my-citycloud - - * Boot server - * Wait for `status==ACTIVE` - * Find the `port` for the `fixed_ip` for `server` - * Create `floating-ip` on that `port` - * Wait for `floating-ip` to attach - -.. code:: python - - # Boot a server, wait for it to boot, and then do whatever is needed - # to get a public ip for it. - cloud.create_server( - 'my-server', image=image, flavor=flavor, wait=True, auto_ip=True) - -Wow. We didn't even deploy Wordpress! -===================================== - -Image and Flavor by Name or ID -============================== - -* Pass string to image/flavor -* Image/Flavor will be found by name or ID -* Common pattern -* doc/source/examples/create-server-name-or-id.py - -.. code:: python - - from openstack import cloud as openstack - - # Initialize and turn on debug logging - openstack.enable_logging(debug=True) - - for cloud_name, region_name, image, flavor in [ - ('my-vexxhost', 'ca-ymq-1', - 'Ubuntu 16.04.1 LTS [2017-03-03]', 'v1-standard-4'), - ('my-citycloud', 'Buf1', - 'Ubuntu 16.04 Xenial Xerus', '4C-4GB-100GB'), - ('my-internap', 'ams01', - 'Ubuntu 16.04 LTS (Xenial Xerus)', 'A1.4')]: - # Initialize cloud - cloud = openstack.connect(cloud=cloud_name, region_name=region_name) - - # Boot a server, wait for it to boot, and then do whatever is needed - # to get a public ip for it. - server = cloud.create_server( - 'my-server', image=image, flavor=flavor, wait=True, auto_ip=True) - print(server.name) - print(server['name']) - cloud.pprint(server) - # Delete it - this is a demo - cloud.delete_server(server, wait=True, delete_ips=True) - -cloud.pprint method was just added this morning -=============================================== - -Delete Servers -============== - -* `delete_ips` Delete any `floating_ips` the server may have - -.. code:: python - - cloud.delete_server('my-server', wait=True, delete_ips=True) - -Image and Flavor by Dict -======================== - -* Pass dict to image/flavor -* If you know if the value is Name or ID -* Common pattern -* doc/source/examples/create-server-dict.py - -.. code:: python - - from openstack import cloud as openstack - - # Initialize and turn on debug logging - openstack.enable_logging(debug=True) - - for cloud_name, region_name, image, flavor_id in [ - ('my-vexxhost', 'ca-ymq-1', 'Ubuntu 16.04.1 LTS [2017-03-03]', - '5cf64088-893b-46b5-9bb1-ee020277635d'), - ('my-citycloud', 'Buf1', 'Ubuntu 16.04 Xenial Xerus', - '0dab10b5-42a2-438e-be7b-505741a7ffcc'), - ('my-internap', 'ams01', 'Ubuntu 16.04 LTS (Xenial Xerus)', - 'A1.4')]: - # Initialize cloud - cloud = openstack.connect(cloud=cloud_name, region_name=region_name) - - # Boot a server, wait for it to boot, and then do whatever is needed - # to get a public ip for it. - server = cloud.create_server( - 'my-server', image=image, flavor=dict(id=flavor_id), - wait=True, auto_ip=True) - # Delete it - this is a demo - cloud.delete_server(server, wait=True, delete_ips=True) - -Munch Objects -============= - -* Behave like a dict and an object -* doc/source/examples/munch-dict-object.py - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging(debug=True) - - cloud = openstack.connect(cloud='zetta', region_name='no-osl1') - image = cloud.get_image('Ubuntu 14.04 (AMD64) [Local Storage]') - print(image.name) - print(image['name']) - -API Organized by Logical Resource -================================= - -* list_servers -* search_servers -* get_server -* create_server -* delete_server -* update_server - -For other things, it's still {verb}_{noun} - -* attach_volume -* wait_for_server -* add_auto_ip - -Cleanup Script -============== - -* Sometimes my examples had bugs -* doc/source/examples/cleanup-servers.py - -.. code:: python - - from openstack import cloud as openstack - - # Initialize and turn on debug logging - openstack.enable_logging(debug=True) - - for cloud_name, region_name in [ - ('my-vexxhost', 'ca-ymq-1'), - ('my-citycloud', 'Buf1'), - ('my-internap', 'ams01')]: - # Initialize cloud - cloud = openstack.connect(cloud=cloud_name, region_name=region_name) - for server in cloud.search_servers('my-server'): - cloud.delete_server(server, wait=True, delete_ips=True) - -Normalization -============= - -* https://docs.openstack.org/shade/latest/user/model.html#image -* doc/source/examples/normalization.py - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging() - - cloud = openstack.connect(cloud='fuga', region_name='cystack') - image = cloud.get_image( - 'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image') - cloud.pprint(image) - -Strict Normalized Results -========================= - -* Return only the declared model -* doc/source/examples/strict-mode.py - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging() - - cloud = openstack.connect( - cloud='fuga', region_name='cystack', strict=True) - image = cloud.get_image( - 'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image') - cloud.pprint(image) - -How Did I Find the Image Name for the Last Example? -=================================================== - -* I often make stupid little utility scripts -* doc/source/examples/find-an-image.py - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging() - - cloud = openstack.connect(cloud='fuga', region_name='cystack') - cloud.pprint([ - image for image in cloud.list_images() - if 'ubuntu' in image.name.lower()]) - -Added / Modified Information -============================ - -* Servers need more extra help -* Fetch addresses dict from neutron -* Figure out which IPs are good -* `detailed` - defaults to True, add everything -* `bare` - no extra calls - don't even fix broken things -* `bare` is still normalized -* doc/source/examples/server-information.py - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging(debug=True) - - cloud = openstack.connect(cloud='my-citycloud', region_name='Buf1') - try: - server = cloud.create_server( - 'my-server', image='Ubuntu 16.04 Xenial Xerus', - flavor=dict(id='0dab10b5-42a2-438e-be7b-505741a7ffcc'), - wait=True, auto_ip=True) - - print("\n\nFull Server\n\n") - cloud.pprint(server) - - print("\n\nTurn Detailed Off\n\n") - cloud.pprint(cloud.get_server('my-server', detailed=False)) - - print("\n\nBare Server\n\n") - cloud.pprint(cloud.get_server('my-server', bare=True)) - - finally: - # Delete it - this is a demo - cloud.delete_server(server, wait=True, delete_ips=True) - -Exceptions -========== - -* All shade exceptions are subclasses of `OpenStackCloudException` -* Direct REST calls throw `OpenStackCloudHTTPError` -* `OpenStackCloudHTTPError` subclasses `OpenStackCloudException` - and `requests.exceptions.HTTPError` -* `OpenStackCloudURINotFound` for 404 -* `OpenStackCloudBadRequest` for 400 - -User Agent Info -=============== - -* Set `app_name` and `app_version` for User Agents -* (sssh ... `region_name` is optional if the cloud has one region) -* doc/source/examples/user-agent.py - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging(http_debug=True) - - cloud = openstack.connect( - cloud='datacentred', app_name='AmazingApp', app_version='1.0') - cloud.list_networks() - -Uploading Large Objects -======================= - -* swift has a maximum object size -* Large Objects are uploaded specially -* shade figures this out and does it -* multi-threaded -* doc/source/examples/upload-object.py - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging(debug=True) - - cloud = openstack.connect(cloud='ovh', region_name='SBG1') - cloud.create_object( - container='my-container', name='my-object', - filename='/home/mordred/briarcliff.sh3d') - cloud.delete_object('my-container', 'my-object') - cloud.delete_container('my-container') - -Uploading Large Objects -======================= - -* Default max_file_size is 5G -* This is a conference demo -* Let's force a segment_size -* One MILLION bytes -* doc/source/examples/upload-object.py - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging(debug=True) - - cloud = openstack.connect(cloud='ovh', region_name='SBG1') - cloud.create_object( - container='my-container', name='my-object', - filename='/home/mordred/briarcliff.sh3d', - segment_size=1000000) - cloud.delete_object('my-container', 'my-object') - cloud.delete_container('my-container') - -Service Conditionals -==================== - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging(debug=True) - - cloud = openstack.connect(cloud='kiss', region_name='region1') - print(cloud.has_service('network')) - print(cloud.has_service('container-orchestration')) - -Service Conditional Overrides -============================= - -* Sometimes clouds are weird and figuring that out won't work - -.. code:: python - - from openstack import cloud as openstack - openstack.enable_logging(debug=True) - - cloud = openstack.connect(cloud='rax', region_name='DFW') - print(cloud.has_service('network')) - -.. code:: yaml - - clouds: - rax: - profile: rackspace - auth: - username: mordred - project_id: 245018 - # This is already in profile: rackspace - has_network: false - -Coming Soon -=========== - -* Completion of RESTification -* Full version discovery support -* Multi-cloud facade layer -* Microversion support (talk tomorrow) -* Completion of caching tier (talk tomorrow) -* All of you helping hacking on shade!!! (we're friendly) diff --git a/doc/source/user/proxies/anti_ddos.rst b/doc/source/user/proxies/anti_ddos.rst deleted file mode 100644 index 348e08a7b..000000000 --- a/doc/source/user/proxies/anti_ddos.rst +++ /dev/null @@ -1,35 +0,0 @@ -Anti_DDoS API -============= - -.. automodule:: otcextensions.sdk.anti_ddos.v1._proxy - -The Anti DDoS Service Class ---------------------------- - -The anti_ddos high-level interface is available through the ``anti_ddos`` -member of a :class:`~openstack.connection.Connection` object. The -``anti_ddos`` member will only be added if the -``otcextensions.sdk.register_otc_extensions(conn)`` method is called. - -Floating IP Operations -^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy.floating_ips - .. automethod:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy.protect_floating_ip - .. automethod:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy.unprotect_floating_ip - .. automethod:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy.get_floating_ip_policies - .. automethod:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy.update_floating_ip_policies - .. automethod:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy.get_floating_ip_status - .. automethod:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy.floating_ip_events - .. automethod:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy.floating_ip_stat_day - .. automethod:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy.floating_ip_stat_week - .. automethod:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy.update_floating_ip_policies - -Misc Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.anti_ddos.v1._proxy.Proxy.configs diff --git a/doc/source/user/proxies/auto_scaling.rst b/doc/source/user/proxies/auto_scaling.rst deleted file mode 100644 index c28d501e4..000000000 --- a/doc/source/user/proxies/auto_scaling.rst +++ /dev/null @@ -1,73 +0,0 @@ -AutoScaling API -=============== - -For details on how to use auto scaling, see :doc:`/user/guides/auto_scaling` - -.. automodule:: otcextensions.sdk.auto_scaling.v1._proxy - -The AutoScaling Class ---------------------- - -The AS high-level interface is available through the ``auto_scaling`` member of -a :class:`~openstack.connection.Connection` object. The ``auto_scaling`` -member will only be added if the -``otcextensions.sdk.register_otc_extensions(conn)`` method is called. - -Group Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.groups - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.get_group - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.find_group - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.create_group - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.delete_group - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.resume_group - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.pause_group - - -Config Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.configs - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.get_config - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.find_config - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.create_config - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.delete_config - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.batch_delete_configs - - -Policy Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.policies - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.get_policy - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.find_policy - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.create_policy - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.delete_policy - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.update_policy - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.resume_policy - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.pause_policy - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.execute_policy - -Instance Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.instances - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.remove_instance - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.batch_instance_action - -Actions and Quotas -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.activities - .. automethod:: otcextensions.sdk.auto_scaling.v1._proxy.Proxy.quotas diff --git a/doc/source/user/proxies/cce_v1.rst b/doc/source/user/proxies/cce_v1.rst deleted file mode 100644 index 26299e89d..000000000 --- a/doc/source/user/proxies/cce_v1.rst +++ /dev/null @@ -1,34 +0,0 @@ -CCE API -======= - -.. automodule:: otcextensions.sdk.cce.v1._proxy - -The Cloud Container Engine Class --------------------------------- - -The cce high-level interface is available through the ``cce`` member of a -:class:`~openstack.connection.Connection` object. The ``cce`` member will only -be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is -called. - -Cluster Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.cce.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.cce.v1._proxy.Proxy.clusters - .. automethod:: otcextensions.sdk.cce.v1._proxy.Proxy.get_cluster - .. automethod:: otcextensions.sdk.cce.v1._proxy.Proxy.find_cluster - .. automethod:: otcextensions.sdk.cce.v1._proxy.Proxy.delete_cluster - - -Cluster Nodes Operations -^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.cce.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.cce.v1._proxy.Proxy.cluster_nodes - .. automethod:: otcextensions.sdk.cce.v1._proxy.Proxy.get_cluster_node - .. automethod:: otcextensions.sdk.cce.v1._proxy.Proxy.find_cluster_node - .. automethod:: otcextensions.sdk.cce.v1._proxy.Proxy.delete_cluster_nodes - .. automethod:: otcextensions.sdk.cce.v1._proxy.Proxy.add_node diff --git a/doc/source/user/proxies/cce_v3.rst b/doc/source/user/proxies/cce_v3.rst deleted file mode 100644 index 816b4bfca..000000000 --- a/doc/source/user/proxies/cce_v3.rst +++ /dev/null @@ -1,40 +0,0 @@ -CCE API -======= - -.. automodule:: otcextensions.sdk.cce.v3._proxy - -The Cloud Container Engine Class --------------------------------- - -The cce high-level interface is available through the ``cce`` member of a -:class:`~openstack.connection.Connection` object. The ``cce`` member will only -be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is -called. - -Cluster Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.cce.v3._proxy.Proxy - - .. automethod:: otcextensions.sdk.cce.v3._proxy.Proxy.clusters - .. automethod:: otcextensions.sdk.cce.v3._proxy.Proxy.get_cluster - .. automethod:: otcextensions.sdk.cce.v3._proxy.Proxy.find_cluster - .. automethod:: otcextensions.sdk.cce.v3._proxy.Proxy.delete_cluster - - -Cluster Nodes Operations -^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.cce.v3._proxy.Proxy - - .. automethod:: otcextensions.sdk.cce.v3._proxy.Proxy.cluster_nodes - .. automethod:: otcextensions.sdk.cce.v3._proxy.Proxy.get_cluster_node - .. automethod:: otcextensions.sdk.cce.v3._proxy.Proxy.find_cluster_node - .. automethod:: otcextensions.sdk.cce.v3._proxy.Proxy.delete_cluster_node - .. automethod:: otcextensions.sdk.cce.v3._proxy.Proxy.create_cluster_node - -Job Operations -^^^^^^^^^^^^^^ - - .. automethod:: otcextensions.sdk.cce.v3._proxy.Proxy.get_job - .. automethod:: otcextensions.sdk.cce.v3._proxy.Proxy.wait_for_job diff --git a/doc/source/user/proxies/dcs.rst b/doc/source/user/proxies/dcs.rst deleted file mode 100644 index ae9e40e1e..000000000 --- a/doc/source/user/proxies/dcs.rst +++ /dev/null @@ -1,56 +0,0 @@ -DCS API -======= - -.. automodule:: otcextensions.sdk.dcs.v1._proxy - -The Distributed Message Service Class -------------------------------------- - -The dcs high-level interface is available through the ``dcs`` -member of a :class:`~openstack.connection.Connection` object. The -``dcs`` member will only be added if the -``otcextensions.sdk.register_otc_extensions(conn)`` method is called. - -Instance Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.instances - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.create_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.get_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.find_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.delete_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.update_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.extend_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.start_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.restart_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.stop_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.stop_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.stop_instance - -Statistics Operations -^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.statistics - -Backup Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.backup_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.backups - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.delete_instance_backup - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.restore_instance - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.restore_records - -Instance Configuration Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.instance_params - .. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.update_instance_params diff --git a/doc/source/user/proxies/deh.rst b/doc/source/user/proxies/deh.rst deleted file mode 100644 index 47c0a9c57..000000000 --- a/doc/source/user/proxies/deh.rst +++ /dev/null @@ -1,26 +0,0 @@ -DeH API -======= - -.. automodule:: otcextensions.sdk.deh.v1._proxy - -The Dedicated Host Service Class --------------------------------- - -The dehs high-level interface is available through the ``deh`` member of a -:class:`~openstack.connection.Connection` object. The ``deh`` member will only -be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is -called. - -Host Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.deh.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.deh.v1._proxy.Proxy.hosts - .. automethod:: otcextensions.sdk.deh.v1._proxy.Proxy.create_host - .. automethod:: otcextensions.sdk.deh.v1._proxy.Proxy.get_host - .. automethod:: otcextensions.sdk.deh.v1._proxy.Proxy.find_host - .. automethod:: otcextensions.sdk.deh.v1._proxy.Proxy.delete_host - .. automethod:: otcextensions.sdk.deh.v1._proxy.Proxy.update_host - .. automethod:: otcextensions.sdk.deh.v1._proxy.Proxy.servers - .. automethod:: otcextensions.sdk.deh.v1._proxy.Proxy.host_types diff --git a/doc/source/user/proxies/dns.rst b/doc/source/user/proxies/dns.rst deleted file mode 100644 index c724f935f..000000000 --- a/doc/source/user/proxies/dns.rst +++ /dev/null @@ -1,49 +0,0 @@ -DNS API -======= - -.. automodule:: otcextensions.sdk.dns.v2._proxy - -The DNS Service Class ---------------------- - -The dns high-level interface is available through the ``dns`` -member of a :class:`~openstack.connection.Connection` object. The -``dns`` member will only be added if the -``otcextensions.sdk.register_otc_extensions(conn)`` method is called. - -Zone Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.dns.v2._proxy.Proxy - - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.zones - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.create_zone - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.get_zone - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.delete_zone - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.update_zone - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.find_zone - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.add_router_to_zone - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.remove_router_from_zone - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.nameservers - -Recordset Operations -^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.dns.v2._proxy.Proxy - - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.recordsets - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.create_recordset - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.get_recordset - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.update_recordset - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.delete_recordset - - -PTR Records Operations -^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.dns.v2._proxy.Proxy - - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.floating_ips - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.set_floating_ip - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.get_floating_ip - .. automethod:: otcextensions.sdk.dns.v2._proxy.Proxy.unset_floating_ip diff --git a/doc/source/user/proxies/kms.rst b/doc/source/user/proxies/kms.rst deleted file mode 100644 index f5c9f81a4..000000000 --- a/doc/source/user/proxies/kms.rst +++ /dev/null @@ -1,46 +0,0 @@ -KMS API -======= - -.. automodule:: otcextensions.sdk.kms.v1._proxy - -The KeyManagementService Class ------------------------------- - -The kms high-level interface is available through the ``kms`` member of a -:class:`~openstack.connection.Connection` object. The ``kms`` member will only -be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is -called. - -CMK (Customer Master Key) Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.kms.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.keys - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.create_key - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.get_key - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.find_key - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.enable_key - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.disable_key - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.schedule_key_deletion - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.cancel_key_deletion - - -DEK (Data Encryption Key) Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.kms.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.create_datakey - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.create_datakey_wo_plain - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.encrypt_datakey - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.decrypt_datakey - -Other Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.kms.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.generate_random - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.get_instance_number - .. automethod:: otcextensions.sdk.kms.v1._proxy.Proxy.quotas diff --git a/doc/source/user/proxies/obs.rst b/doc/source/user/proxies/obs.rst deleted file mode 100644 index e23e34c89..000000000 --- a/doc/source/user/proxies/obs.rst +++ /dev/null @@ -1,35 +0,0 @@ -ObjectBlockStorage OBS API -========================== - -For details on how to use database, see :doc:`/user/guides/obs` - -.. automodule:: otcextensions.sdk.obs.v1._proxy - -The OBS Class -------------- - -The obs high-level interface is available through the ``obs`` member of a -:class:`~openstack.connection.Connection` object. The ``obs`` member will only -be added if the ``otcextensions.sdk.register_otc_Extensions(conn)`` method is -called. - -Container Operations -^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.obs.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.obs.v1._proxy.Proxy.containers - .. automethod:: otcextensions.sdk.obs.v1._proxy.Proxy.get_container - .. automethod:: otcextensions.sdk.obs.v1._proxy.Proxy.create_container - .. automethod:: otcextensions.sdk.obs.v1._proxy.Proxy.delete_container - -Object Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.obs.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.obs.v1._proxy.Proxy.objects - .. automethod:: otcextensions.sdk.obs.v1._proxy.Proxy.get_object - .. automethod:: otcextensions.sdk.obs.v1._proxy.Proxy.create_object - .. automethod:: otcextensions.sdk.obs.v1._proxy.Proxy.delete_object - .. automethod:: otcextensions.sdk.obs.v1._proxy.Proxy.download_object diff --git a/doc/source/user/proxies/rds_v1.rst b/doc/source/user/proxies/rds_v1.rst deleted file mode 100644 index 55b991b86..000000000 --- a/doc/source/user/proxies/rds_v1.rst +++ /dev/null @@ -1,55 +0,0 @@ -Database RDS API -================ - -For details on how to use database, see :doc:`/user/guides/rds` - -.. automodule:: otcextensions.sdk.rds.v1._proxy - -The Database Class ------------------- - -The database high-level interface is available through the ``rds`` member of a -:class:`~openstack.connection.Connection` object. The ``rds`` member will only -be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is -called. - -Datastore Operations -^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.rds.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.datastore_versions - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.get_datastore_version - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.datastore_types - -Flavor Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.rds.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.get_flavor - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.flavors - -Instance Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.rds.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.create_instance - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.update_instance - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.delete_instance - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.get_instance - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.find_instance - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.instances - - -Backup Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.rds.v1._proxy.Proxy - - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.backups - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.create_backup - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.delete_backup - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.get_backup_policy - .. automethod:: otcextensions.sdk.rds.v1._proxy.Proxy.set_backup_policy diff --git a/doc/source/user/proxies/rds_v3.rst b/doc/source/user/proxies/rds_v3.rst deleted file mode 100644 index 2efeddecc..000000000 --- a/doc/source/user/proxies/rds_v3.rst +++ /dev/null @@ -1,55 +0,0 @@ -Database RDS API -================ - -For details on how to use database, see :doc:`/user/guides/rds` - -.. automodule:: otcextensions.sdk.rds.v3._proxy - -The Database Class ------------------- - -The database high-level interface is available through the ``rds`` member of a -:class:`~openstack.connection.Connection` object. The ``rds`` member will only -be added if the ``otcextensions.sdk.register_otc_extensions(conn)`` method is -called. - -Datastore Operations -^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.rds.v3._proxy.Proxy - - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.datastore_versions - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.get_datastore_version - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.datastore_types - -Flavor Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.rds.v3._proxy.Proxy - - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.get_flavor - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.flavors - -Instance Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.rds.v3._proxy.Proxy - - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.create_instance - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.update_instance - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.delete_instance - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.get_instance - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.find_instance - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.instances - - -Backup Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.rds.v3._proxy.Proxy - - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.backups - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.create_backup - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.delete_backup - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.get_backup_policy - .. automethod:: otcextensions.sdk.rds.v3._proxy.Proxy.set_backup_policy diff --git a/doc/source/user/proxies/volume_backup.rst b/doc/source/user/proxies/volume_backup.rst deleted file mode 100644 index 2802809b7..000000000 --- a/doc/source/user/proxies/volume_backup.rst +++ /dev/null @@ -1,34 +0,0 @@ -VolumeBackup API -================ - -For details on how to use auto scaling, see :doc:`/user/guides/volume_backup` - -.. automodule:: otcextensions.sdk.volume_backup.v2._proxy - -The VolumeBackup Class ----------------------- - -The VBS high-level interface is available through the ``volume_backup`` member -of a :class:`~openstack.connection.Connection` object. The ``volume_backup`` -member will only be added if the -``otcextensions.sdk.register_otc_extensions(conn)`` method is called. - -The Backup itself is an OpenStack entity and supported natively as -block_storage.Backup. - - -Backup Policy Operations -^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: otcextensions.sdk.volume_backup.v2._proxy.Proxy - - .. automethod:: otcextensions.sdk.volume_backup.v2._proxy.Proxy.backup_policies - .. automethod:: otcextensions.sdk.volume_backup.v2._proxy.Proxy.create_backup_policy - .. automethod:: otcextensions.sdk.volume_backup.v2._proxy.Proxy.update_backup_policy - .. automethod:: otcextensions.sdk.volume_backup.v2._proxy.Proxy.delete_backup_policy - .. automethod:: otcextensions.sdk.volume_backup.v2._proxy.Proxy.find_backup_policy - .. automethod:: otcextensions.sdk.volume_backup.v2._proxy.Proxy.execute_policy - .. automethod:: otcextensions.sdk.volume_backup.v2._proxy.Proxy.enable_policy - .. automethod:: otcextensions.sdk.volume_backup.v2._proxy.Proxy.disable_policy - .. automethod:: otcextensions.sdk.volume_backup.v2._proxy.Proxy.link_resources_to_policy - .. automethod:: otcextensions.sdk.volume_backup.v2._proxy.Proxy.unlink_resources_of_policy diff --git a/doc/source/user/resource.rst b/doc/source/user/resource.rst deleted file mode 100644 index 8453265f5..000000000 --- a/doc/source/user/resource.rst +++ /dev/null @@ -1,26 +0,0 @@ -**Note: This class is in the process of being applied as the new base class -for resources around the OpenStack SDK. Once that has been completed, -this module will be drop the 2 suffix and be the only resource module.** - -Resource -======== -.. automodule:: openstack.resource - -Components ----------- - -.. autoclass:: openstack.resource.Body - :members: - -.. autoclass:: openstack.resource.Header - :members: - -.. autoclass:: openstack.resource.URI - :members: - -The Resource class ------------------- - -.. autoclass:: openstack.resource.Resource - :members: - :member-order: bysource diff --git a/doc/source/user/resources/dms/v1/group_message.rst b/doc/source/user/resources/dms/v1/group_message.rst deleted file mode 100644 index 94090ce49..000000000 --- a/doc/source/user/resources/dms/v1/group_message.rst +++ /dev/null @@ -1,13 +0,0 @@ -otcextensions.sdk.dcs.v1.group_message -====================================== - -.. automodule:: otcextensions.sdk.dms.v1.group_message - -The DMS GroupMessage Class --------------------------- - -The ``GroupMessage`` class inherits from -:class:`~otcextensions.sdk.sdk_resource.Resource`. - -.. autoclass:: otcextensions.sdk.dms.v1.group_message.GroupMessage - :members: diff --git a/doc/source/user/transition_from_profile.rst b/doc/source/user/transition_from_profile.rst deleted file mode 100644 index a6edc6a5e..000000000 --- a/doc/source/user/transition_from_profile.rst +++ /dev/null @@ -1,186 +0,0 @@ -Transition from Profile -======================= - -.. note:: This section describes migrating code from a previous interface of - openstacksdk and can be ignored by people writing new code. - -If you have code that currently uses the :class:`~openstack.profile.Profile` -object and/or an ``authenticator`` instance from an object based on -``openstack.auth.base.BaseAuthPlugin``, that code should be updated to use the -:class:`~openstack.config.cloud_region.CloudRegion` object instead. - -.. important:: - - :class:`~openstack.profile.Profile` is going away. Existing code using it - should be migrated as soon as possible. - -Writing Code that Works with Both ---------------------------------- - -These examples should all work with both the old and new interface, with one -caveat. With the old interface, the ``CloudConfig`` object comes from the -``os-client-config`` library, and in the new interface that has been moved -into the SDK. In order to write code that works with both the old and new -interfaces, use the following code to import the config namespace: - -.. code-block:: python - - try: - from openstack import config as occ - except ImportError: - from os_client_config import config as occ - -The examples will assume that the config module has been imported in that -manner. - -.. note:: Yes, there is an easier and less verbose way to do all of these. - These are verbose to handle both the old and new interfaces in the - same codebase. - -Replacing authenticator ------------------------ - -There is no direct replacement for ``openstack.auth.base.BaseAuthPlugin``. -``openstacksdk`` uses the `keystoneauth`_ library for authentication -and HTTP interactions. `keystoneauth`_ has `auth plugins`_ that can be used -to control how authentication is done. The ``auth_type`` config parameter -can be set to choose the correct authentication method to be used. - -Replacing Profile ------------------ - -The right way to replace the use of ``openstack.profile.Profile`` depends -a bit on what you're trying to accomplish. Common patterns are listed below, -but in general the approach is either to pass a cloud name to the -`openstack.connection.Connection` constructor, or to construct a -`openstack.config.cloud_region.CloudRegion` object and pass it to the -constructor. - -All of the examples on this page assume that you want to support old and -new interfaces simultaneously. There are easier and less verbose versions -of each that are available if you can just make a clean transition. - -Getting a Connection to a named cloud from clouds.yaml ------------------------------------------------------- - -If you want is to construct a `openstack.connection.Connection` based on -parameters configured in a ``clouds.yaml`` file, or from environment variables: - -.. code-block:: python - - import openstack.connection - - conn = connection.from_config(cloud_name='name-of-cloud-you-want') - -Getting a Connection from python arguments avoiding clouds.yaml ---------------------------------------------------------------- - -If, on the other hand, you want to construct a -`openstack.connection.Connection`, but are in a context where reading config -from a clouds.yaml file is undesirable, such as inside of a Service: - -* create a `openstack.config.loader.OpenStackConfig` object, telling - it to not load yaml files. Optionally pass an ``app_name`` and - ``app_version`` which will be added to user-agent strings. -* get a `openstack.config.cloud_region.CloudRegion` object from it -* get a `openstack.connection.Connection` - -.. code-block:: python - - try: - from openstack import config as occ - except ImportError: - from os_client_config import config as occ - from openstack import connection - - loader = occ.OpenStackConfig( - load_yaml_files=False, - app_name='spectacular-app', - app_version='1.0') - cloud_region = loader.get_one_cloud( - region_name='my-awesome-region', - auth_type='password', - auth=dict( - auth_url='https://auth.example.com', - username='amazing-user', - user_domain_name='example-domain', - project_name='astounding-project', - user_project_name='example-domain', - password='super-secret-password', - )) - conn = connection.from_config(cloud_config=cloud_region) - -.. note:: app_name and app_version are completely optional, and auth_type - defaults to 'password'. They are shown here for clarity as to - where they should go if they want to be set. - -Getting a Connection from python arguments and optionally clouds.yaml ---------------------------------------------------------------------- - -If you want to make a connection from python arguments and want to allow -one of them to optionally be ``cloud`` to allow selection of a named cloud, -it's essentially the same as the previous example, except without -``load_yaml_files=False``. - -.. code-block:: python - - try: - from openstack import config as occ - except ImportError: - from os_client_config import config as occ - from openstack import connection - - loader = occ.OpenStackConfig( - app_name='spectacular-app', - app_version='1.0') - cloud_region = loader.get_one_cloud( - region_name='my-awesome-region', - auth_type='password', - auth=dict( - auth_url='https://auth.example.com', - username='amazing-user', - user_domain_name='example-domain', - project_name='astounding-project', - user_project_name='example-domain', - password='super-secret-password', - )) - conn = connection.from_config(cloud_config=cloud_region) - -Parameters to get_one_cloud ---------------------------- - -The most important things to note are: - -* ``auth_type`` specifies which kind of authentication plugin to use. It - controls how authentication is done, as well as what parameters are required. -* ``auth`` is a dictionary containing the parameters needed by the auth plugin. - The most common information it needs are user, project, domain, auth_url - and password. -* The rest of the keyword arguments to - ``openstack.config.loader.OpenStackConfig.get_one_cloud`` are either - parameters needed by the `keystoneauth Session`_ object, which control how - HTTP connections are made, or parameters needed by the - `keystoneauth Adapter`_ object, which control how services are found in the - Keystone Catalog. - -For `keystoneauth Adapter`_ parameters, since there is one -`openstack.connection.Connection` object but many services, per-service -parameters are formed by using the official ``service_type`` of the service -in question. For instance, to override the endpoint for the ``compute`` -service, the parameter ``compute_endpoint_override`` would be used. - -``region_name`` in ``openstack.profile.Profile`` was a per-service parameter. -This is no longer a valid concept. An `openstack.connection.Connection` is a -connection to a region of a cloud. If you are in an extreme situation where -you have one service in one region and a different service in a different -region, you must use two different `openstack.connection.Connection` objects. - -.. note:: service_type, although a parameter for keystoneauth1.adapter.Adapter, - is not a valid parameter for get_one_cloud. service_type is the key - by which services are referred, so saying - 'compute_service_type="henry"' doesn't have any meaning. - -.. _keystoneauth: https://docs.openstack.org/keystoneauth/latest/ -.. _auth plugins: https://docs.openstack.org/keystoneauth/latest/authentication-plugins.html -.. _keystoneauth Adapter: https://docs.openstack.org/keystoneauth/latest/api/keystoneauth1.html#keystoneauth1.adapter.Adapter -.. _keystoneauth Session: https://docs.openstack.org/keystoneauth/latest/api/keystoneauth1.html#keystoneauth1.session.Session diff --git a/doc/source/user/utils.rst b/doc/source/user/utils.rst deleted file mode 100644 index 5c1f39de9..000000000 --- a/doc/source/user/utils.rst +++ /dev/null @@ -1,3 +0,0 @@ -Utilities -========= -.. automodule:: openstack.utils diff --git a/examples/anti_ddos/get_floating_ip_policies.py b/examples/anti_ddos/get_floating_ip_policies.py new file mode 100644 index 000000000..47d95405e --- /dev/null +++ b/examples/anti_ddos/get_floating_ip_policies.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. +""" +Retrieve Anti-DDoS Policy for a specific Floating IP by using Floating IP id +or an instance of class FloatingIP. Anti-DDoS must be enabled for this IP +otherwise an error occures. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +fip = "floating_ip_id" +policy = conn.anti_ddos.get_floating_ip_policies(fip) +print(policy) diff --git a/examples/anti_ddos/get_floating_ip_status.py b/examples/anti_ddos/get_floating_ip_status.py new file mode 100644 index 000000000..41c3bc366 --- /dev/null +++ b/examples/anti_ddos/get_floating_ip_status.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 Anti-DDoS status of a Floating IP by using id. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +fip = "floating_ip_id" + +status = conn.anti_ddos.get_floating_ip_status(fip) +print(status) diff --git a/examples/anti_ddos/list_configs.py b/examples/anti_ddos/list_configs.py new file mode 100644 index 000000000..8ab079e63 --- /dev/null +++ b/examples/anti_ddos/list_configs.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 Anti-DDoS alarm configurations. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +for config in conn.anti_ddos.configs(): + print(config) diff --git a/examples/anti_ddos/list_floating_ip_events.py b/examples/anti_ddos/list_floating_ip_events.py new file mode 100644 index 000000000..a457fb70b --- /dev/null +++ b/examples/anti_ddos/list_floating_ip_events.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 Anti-DDoS status of a Floating IP by using id. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +fip = "floating_ip_id" + +for event in conn.anti_ddos.floating_ip_events(fip): + print(event) diff --git a/examples/anti_ddos/list_floating_ip_stat_day.py b/examples/anti_ddos/list_floating_ip_stat_day.py new file mode 100644 index 000000000..0d1c38124 --- /dev/null +++ b/examples/anti_ddos/list_floating_ip_stat_day.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. +""" +List Anti-DDoS events per day of a Floating IP by using id. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +fip = "floating_ip_id" + +for event in conn.anti_ddos.floating_ip_stat_day(fip): + print(event) diff --git a/examples/anti_ddos/list_floating_ip_stat_week.py b/examples/anti_ddos/list_floating_ip_stat_week.py new file mode 100644 index 000000000..1ea2e70f1 --- /dev/null +++ b/examples/anti_ddos/list_floating_ip_stat_week.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 Anti-DDoS events per week of all Floating IPs. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +for event in conn.anti_ddos.floating_ip_stat_week(): + print(event) diff --git a/examples/anti_ddos/list_floating_ips.py b/examples/anti_ddos/list_floating_ips.py new file mode 100644 index 000000000..7dfef4690 --- /dev/null +++ b/examples/anti_ddos/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 Anti-DDoS Floating IPs and limit the output with query parameters. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +for fip in conn.anti_ddos.floating_ips(): + print(fip) diff --git a/examples/anti_ddos/protect_floating_ip.py b/examples/anti_ddos/protect_floating_ip.py new file mode 100644 index 000000000..bc158689f --- /dev/null +++ b/examples/anti_ddos/protect_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. +""" +Protect with Anti-DDoS a Floating IP by using id or an instance of class +FloatingIP +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +fip = "floating_ip_id" +conn.anti_ddos.protect_floating_ip(fip) diff --git a/examples/anti_ddos/unprotect_floating_ip.py b/examples/anti_ddos/unprotect_floating_ip.py new file mode 100644 index 000000000..9d55dba19 --- /dev/null +++ b/examples/anti_ddos/unprotect_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. +""" +Unprotect a Floating IP from Anti-DDoS by using id or an instance of class +FloatingIP +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +fip = "floating_ip_id" +conn.anti_ddos.unprotect_floating_ip(fip) diff --git a/examples/anti_ddos/update_floating_ip_policies.py b/examples/anti_ddos/update_floating_ip_policies.py new file mode 100644 index 000000000..2ab5f7634 --- /dev/null +++ b/examples/anti_ddos/update_floating_ip_policies.py @@ -0,0 +1,30 @@ +#!/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 Anti-DDoS Policy attributes. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +fip = "floating_ip_id" +attrs = { + "enable_L7": False, + "traffic_pos_id": 2, + "http_request_pos_id": 1, + "cleaning_access_pos_id": 1, + "app_type_id": 1 +} + +policy = conn.anti_ddos.update_floating_ip_policies(fip, **attrs) diff --git a/examples/auto_scaling/batch_delete_config.py b/examples/auto_scaling/batch_delete_config.py new file mode 100644 index 000000000..7e4b72ec1 --- /dev/null +++ b/examples/auto_scaling/batch_delete_config.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. +""" +Delete multiple Auto-Scaling Configurations by id or instance of class Config +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +config1 = conn.auto_scaling.find_config('test-config1') +config2 = conn.auto_scaling.find_config('test-config2') + +configs = [config1, config2] + +conn.auto_scaling.batch_delete_configs(configs) diff --git a/examples/auto_scaling/batch_instance_action.py b/examples/auto_scaling/batch_instance_action.py new file mode 100644 index 000000000..7b6d44adf --- /dev/null +++ b/examples/auto_scaling/batch_instance_action.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. +""" +Remove an Auto-Scaling Instances of a specific AS Group. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +group = "group_name_or_id" +group = conn.auto_scaling.find_group(group) + +instances = [ + "instance_id", + "instance_id2" +] + +action = "ADD" + +conn.auto_scaling.batch_instance_action( + group, + instances, + action, # ADD, REMOVE, PROTECT, UNPROTECT + delete_instance=False +) diff --git a/examples/auto_scaling/create_config.py b/examples/auto_scaling/create_config.py new file mode 100644 index 000000000..71249cbaa --- /dev/null +++ b/examples/auto_scaling/create_config.py @@ -0,0 +1,36 @@ +#!/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 Configuration. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +attrs = { + 'name': 'test-config', + 'instance_config': { + 'flavorRef': 's2.medium.1', + 'imageRef': '1616e0b6-503a-4698-946f-cf9942c4c73b', + 'disk': [{ + 'size': 20, + 'volume_type': 'SATA', + 'disk_type': 'SYS' + }], + 'key_name': 'test-key', + } +} + +config = conn.auto_scaling.create_config(**attrs) +print(config) diff --git a/examples/auto_scaling/create_group.py b/examples/auto_scaling/create_group.py new file mode 100644 index 000000000..ee488a489 --- /dev/null +++ b/examples/auto_scaling/create_group.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 Auto-Scaling Group. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +attrs = { + "scaling_group_name": "TestGroup", + "scaling_configuration_id": "0d138717-e79d-4fa7-b8aa-37ddec1b3ce7", + "desire_instance_number": 0, + "min_instance_number": 0, + "max_instance_number": 10, + "vpc_id": "26ca2783-dc40-4e3a-95b1-5a0756441e12", + "available_zones": ["eu-de-01", "eu-de-03"], + "networks": [ + { + "id": "25d24fc8-d019-4a34-9fff-0a09fde6a9cb" + } + ] +} + +group = conn.auto_scaling.create_group(**attrs) +print(group) 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/auto_scaling/delete_config.py b/examples/auto_scaling/delete_config.py new file mode 100644 index 000000000..1dff5e3f5 --- /dev/null +++ b/examples/auto_scaling/delete_config.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 Auto-Scaling Configuration by id or instance of class Config +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +config_id = '1234567-ad7a-48ce-8f92-b55c651439d2' +conn.auto_scaling.delete_config(config_id) diff --git a/examples/auto_scaling/delete_group.py b/examples/auto_scaling/delete_group.py new file mode 100644 index 000000000..49c362334 --- /dev/null +++ b/examples/auto_scaling/delete_group.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 Auto-Scaling Group by id or instance of class Group. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +group_id = '1234567-ad7a-48ce-8f92-b55c651439d2' +conn.auto_scaling.delete_group(group_id) diff --git a/examples/auto_scaling/delete_policy.py b/examples/auto_scaling/delete_policy.py new file mode 100644 index 000000000..84891947d --- /dev/null +++ b/examples/auto_scaling/delete_policy.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 Auto-Scaling Policy by id or instance of class Policy. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +policy_id = '1234567-ad7a-48ce-8f92-b55c651439d2' +conn.auto_scaling.delete_policy(policy_id) diff --git a/examples/auto_scaling/execute_policy.py b/examples/auto_scaling/execute_policy.py new file mode 100644 index 000000000..f90d78b2d --- /dev/null +++ b/examples/auto_scaling/execute_policy.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. +""" +Execute an Auto-Scaling Policy by id or an instance of class Policy +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +policy = "policy_name_or_id" +policy = conn.auto_scaling.find_policy(policy) + +conn.auto_scaling.execute_policy(policy) diff --git a/examples/auto_scaling/find_config.py b/examples/auto_scaling/find_config.py new file mode 100644 index 000000000..36969af62 --- /dev/null +++ b/examples/auto_scaling/find_config.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 Auto-Scaling Configuration by name or id. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +config = "config_name_or_id" + +config = conn.auto_scaling.find_config(config) +print(config) diff --git a/examples/auto_scaling/find_group.py b/examples/auto_scaling/find_group.py new file mode 100644 index 000000000..38bc88d9c --- /dev/null +++ b/examples/auto_scaling/find_group.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 Auto-Scaling Group. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +group = "group_name_or_id" + +group = conn.auto_scaling.find_group(group) +print(group) diff --git a/examples/auto_scaling/find_policy.py b/examples/auto_scaling/find_policy.py new file mode 100644 index 000000000..4d33596cd --- /dev/null +++ b/examples/auto_scaling/find_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. +""" +Find Auto-Scaling Policy by name or id. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +policy = "policy_name_or_id" + +policy = conn.auto_scaling.find_policy(policy) +print(policy) diff --git a/examples/auto_scaling/get_config.py b/examples/auto_scaling/get_config.py new file mode 100644 index 000000000..194f394a5 --- /dev/null +++ b/examples/auto_scaling/get_config.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 Auto-Scaling Configuration by id or object +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +config_id = "1234567-6aa0-4c8b-b350-3bd937addeb7" +config = conn.auto_scaling.get_config(config_id) +print(config) diff --git a/examples/auto_scaling/get_group.py b/examples/auto_scaling/get_group.py new file mode 100644 index 000000000..7a884ae90 --- /dev/null +++ b/examples/auto_scaling/get_group.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 Auto-Scaling Group by id or object +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +group_id = "1234567-6aa0-4c8b-b350-3bd937addeb7" +group = conn.auto_scaling.get_group(group_id) +print(group) diff --git a/examples/auto_scaling/get_policy.py b/examples/auto_scaling/get_policy.py new file mode 100644 index 000000000..f3673b16c --- /dev/null +++ b/examples/auto_scaling/get_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 Auto-Scaling Policy by id or object +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +policy_id = "1234567-6aa0-4c8b-b350-3bd937addeb7" +policy = conn.auto_scaling.get_policy(policy_id) +print(policy) diff --git a/examples/auto_scaling/init.py b/examples/auto_scaling/init.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/auto_scaling/list_activities.py b/examples/auto_scaling/list_activities.py new file mode 100644 index 000000000..eafd7f50d --- /dev/null +++ b/examples/auto_scaling/list_activities.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. +""" +List all Auto-Scaling query action logs of an AS group. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +group = "group_name_or_id" +group = conn.auto_scaling.find_group(group) + + +for activity in conn.auto_scaling.activities(group): + print(activity) diff --git a/examples/auto_scaling/list_configs.py b/examples/auto_scaling/list_configs.py new file mode 100644 index 000000000..3fc9a49a8 --- /dev/null +++ b/examples/auto_scaling/list_configs.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. +""" +List all Auto-Scaling Configurations +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for config in conn.auto_scaling.configs(): + print(config) diff --git a/examples/auto_scaling/list_groups.py b/examples/auto_scaling/list_groups.py new file mode 100644 index 000000000..4bcc31811 --- /dev/null +++ b/examples/auto_scaling/list_groups.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. +""" +List all Auto-Scaling Groups +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for group in conn.auto_scaling.groups(): + print(group) diff --git a/examples/auto_scaling/list_instances.py b/examples/auto_scaling/list_instances.py new file mode 100644 index 000000000..d766d31a9 --- /dev/null +++ b/examples/auto_scaling/list_instances.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. +""" +List all Auto-Scaling scaling action logs of a specific AS Group. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +group = "group_name_or_id" +group = conn.auto_scaling.find_group(group) + +for activity in conn.auto_scaling.activities(group): + print(activity) diff --git a/examples/auto_scaling/list_policies.py b/examples/auto_scaling/list_policies.py new file mode 100644 index 000000000..25e5b7ba8 --- /dev/null +++ b/examples/auto_scaling/list_policies.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. +""" +List all Auto-Scaling Policies of a specific AS Group. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +group = "group_name_or_id" +group = conn.auto_scaling.find_group(group) + +for policy in conn.auto_scaling.policies(group): + print(policy) diff --git a/examples/auto_scaling/list_quotas.py b/examples/auto_scaling/list_quotas.py new file mode 100644 index 000000000..098b3b628 --- /dev/null +++ b/examples/auto_scaling/list_quotas.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. +""" +List all Auto-Scaling quotas of a user or a specific AS Group. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +# group = "group_name_or_id" +# group = conn.auto_scaling.find_group(group) + +# If group is set, group quotas ar listed instead of user quotas +for quota in conn.auto_scaling.quotas(group=None): + print(quota) diff --git a/examples/auto_scaling/pause_group.py b/examples/auto_scaling/pause_group.py new file mode 100644 index 000000000..7b4499e97 --- /dev/null +++ b/examples/auto_scaling/pause_group.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. +""" +Pause an Auto-Scaling Group by id or an instance of class Group +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +group = "group_name_or_id" +group = conn.auto_scaling.find_group(group) + +conn.auto_scaling.pause_group(group) diff --git a/examples/auto_scaling/pause_policy.py b/examples/auto_scaling/pause_policy.py new file mode 100644 index 000000000..fcf0a715c --- /dev/null +++ b/examples/auto_scaling/pause_policy.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. +""" +Pause an Auto-Scaling Policy by id or an instance of class Policy +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +policy = "policy_name_or_id" +policy = conn.auto_scaling.find_policy(policy) + +conn.auto_scaling.pause_policy(policy) diff --git a/examples/auto_scaling/remove_instance.py b/examples/auto_scaling/remove_instance.py new file mode 100644 index 000000000..4ada6aa39 --- /dev/null +++ b/examples/auto_scaling/remove_instance.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. +""" +Remove an Auto-Scaling Instances of a specific AS Group. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +instance = "instance_id" + +conn.auto_scaling.remove_instance( + instance, + delete=False # If True, instance will be deleted after remove +) diff --git a/examples/auto_scaling/resume_group.py b/examples/auto_scaling/resume_group.py new file mode 100644 index 000000000..559d6940f --- /dev/null +++ b/examples/auto_scaling/resume_group.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. +""" +Resume an Auto-Scaling Group by id or an instance of class Group +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +group_id = "123456_group_id" + +conn.auto_scaling.resume_group(group_id) diff --git a/examples/auto_scaling/resume_policy.py b/examples/auto_scaling/resume_policy.py new file mode 100644 index 000000000..b740a55dc --- /dev/null +++ b/examples/auto_scaling/resume_policy.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. +""" +Resume an Auto-Scaling Policy by id or an instance of class Policy +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +policy = "policy_name_or_id" +policy = conn.auto_scaling.find_policy(policy) + +conn.auto_scaling.resume_policy(policy) diff --git a/examples/auto_scaling/update_policy.py b/examples/auto_scaling/update_policy.py new file mode 100644 index 000000000..4ef87e2d6 --- /dev/null +++ b/examples/auto_scaling/update_policy.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 Auto-Scaling Policy by using id or an instance of class Policy. +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +policy = "policy_name_or_id" +attrs = { + "scaling_policy_type": "RECURRENCE", + "scaling_policy_name": "policy_01", + "scheduled_policy": { + "launch_time": "16:00", + "recurrence_type": "Daily", + "end_time": "2016-02-08T17:31Z", + "start_time": "2016-01-08T17:31Z" + }, + "scaling_policy_action": { + "operation": "SET", + "instance_number": 2 + } +} + +policy = conn.auto_scaling.find_policy(policy) +conn.auto_scaling.update_policy(policy, **attrs) diff --git a/examples/cce/create_cluster.py b/examples/cce/create_cluster.py new file mode 100644 index 000000000..9ec082bcb --- /dev/null +++ b/examples/cce/create_cluster.py @@ -0,0 +1,53 @@ +#!/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 CCE Cluster +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +attrs = { + "kind": "Cluster", + "apiVersion": "v3", + "metadata": { + "name": "test2" + }, + "spec": { + "type": "VirtualMachine", + "flavor": "cce.s1.small", + "version": "v1.13.10-r0", + "az": "eu-de-01", + "supportIstio": True, + "hostNetwork": { + "vpc": "26ca2783-dc40-4e3a-95b1-5a0756441e12", + "subnet": "25d24fc8-d019-4a34-9fff-0a09fde6a9cb", + "SecurityGroup": "f9ae0767-25be-44fc-a21c-5b8a0da66dec" + }, + "containerNetwork": { + "mode": "overlay_l2", + "cidr": "172.16.0.0/16" + }, + "authentication": { + "mode": "rbac", + "authenticatingProxy": {} + }, + "billingMode": 0, + "kubernetesSvcIpRange": "10.247.0.0/16", + "kubeProxyMode": "iptables" + } +} + +conn.cce.create_cluster(**attrs) diff --git a/examples/cce/create_cluster_node.py b/examples/cce/create_cluster_node.py new file mode 100644 index 000000000..35068f946 --- /dev/null +++ b/examples/cce/create_cluster_node.py @@ -0,0 +1,53 @@ +#!/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 CCE Cluster node +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +attrs = { + "kind": "Cluster", + "apiVersion": "v3", + "metadata": { + "name": "test2" + }, + "spec": { + "type": "VirtualMachine", + "flavor": "cce.s1.small", + "version": "v1.13.10-r0", + "az": "eu-de-01", + "supportIstio": True, + "hostNetwork": { + "vpc": "26ca2783-dc40-4e3a-95b1-5a0756441e12", + "subnet": "25d24fc8-d019-4a34-9fff-0a09fde6a9cb", + "SecurityGroup": "f9ae0767-25be-44fc-a21c-5b8a0da66dec" + }, + "containerNetwork": { + "mode": "overlay_l2", + "cidr": "172.16.0.0/16" + }, + "authentication": { + "mode": "rbac", + "authenticatingProxy": {} + }, + "billingMode": 0, + "kubernetesSvcIpRange": "10.247.0.0/16", + "kubeProxyMode": "iptables" + } +} + +conn.cce.create_cluster_node(**attrs) diff --git a/examples/cce/delete_cluster.py b/examples/cce/delete_cluster.py new file mode 100644 index 000000000..9aff2c8fb --- /dev/null +++ b/examples/cce/delete_cluster.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 a CCE cluster by id or class Cluster +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +cluster_name = "cluster_name" +cluster = conn.cce.find_cluster(cluster_name) +print(cluster) +conn.cce.delete_cluster(cluster) diff --git a/examples/cce/delete_cluster_node.py b/examples/cce/delete_cluster_node.py new file mode 100644 index 000000000..7673875e6 --- /dev/null +++ b/examples/cce/delete_cluster_node.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. +""" +Delete a CCE cluster node +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +cluster = "cluster_name_or_id" +cluster = conn.cce.find_cluster(cluster) +node_id = "node_id" +conn.cce.delete_cluster_node(cluster, node_id) diff --git a/examples/cce/find_cluster.py b/examples/cce/find_cluster.py new file mode 100644 index 000000000..ec1a796bf --- /dev/null +++ b/examples/cce/find_cluster.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 CCE cluster by id or class Cluster +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +cluster = "cluster_name_or_id" +cluster = conn.cce.find_cluster(cluster) +print(cluster) diff --git a/examples/cce/find_cluster_node.py b/examples/cce/find_cluster_node.py new file mode 100644 index 000000000..c1dfd17f3 --- /dev/null +++ b/examples/cce/find_cluster_node.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 a CCE cluster node by name or id +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +cluster = "cluster_name_or_id" +cluster = conn.cce.find_cluster(cluster) +node = "node_name_or_id" +node = conn.cce.find_cluster_node(cluster, node) +print(node) diff --git a/examples/cce/get_cluster.py b/examples/cce/get_cluster.py new file mode 100644 index 000000000..0263c2011 --- /dev/null +++ b/examples/cce/get_cluster.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 CCE cluster by id or class Cluster +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +cluster_id = "123456_cluster_id" +cluster = conn.cce.get_cluster(cluster_id) +print(cluster) diff --git a/examples/cce/get_cluster_node.py b/examples/cce/get_cluster_node.py new file mode 100644 index 000000000..448c49084 --- /dev/null +++ b/examples/cce/get_cluster_node.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. +""" +Get a CCE cluster node by id or class ClusterNode +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +cluster = "cluster_name_or_id" +cluster = conn.cce.find_cluster(cluster) +node_id = "node_id" +node = conn.cce.get_cluster_node(cluster, node_id) +print(node) diff --git a/examples/cce/get_job.py b/examples/cce/get_job.py new file mode 100644 index 000000000..0a3fec904 --- /dev/null +++ b/examples/cce/get_job.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 Job by id or instance of class Job +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +job_id = "123456_job_id" +job = conn.cce.get_job(job_id) +print(job) diff --git a/examples/cce/list_cluster_nodes.py b/examples/cce/list_cluster_nodes.py new file mode 100644 index 000000000..cf0016ac6 --- /dev/null +++ b/examples/cce/list_cluster_nodes.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. +""" +List all nodes of a CCE cluster +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +cluster = "cluster_name_or_id" +cluster = conn.cce.find_cluster(cluster) +for node in conn.cce.cluster_nodes(cluster): + print(node) diff --git a/examples/cce/list_clusters.py b/examples/cce/list_clusters.py new file mode 100644 index 000000000..da61925d7 --- /dev/null +++ b/examples/cce/list_clusters.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. +""" +List all CCE clusters +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for cluster in conn.cce.clusters(): + print(cluster) diff --git a/examples/cce/wait_for_job.py b/examples/cce/wait_for_job.py new file mode 100644 index 000000000..03c033503 --- /dev/null +++ b/examples/cce/wait_for_job.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. +""" +Wait for a job until it reaches a specific status +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +job_id = "123456_job_id" +conn.cce.wait_for_job(job_id, status='success', + failures=None, interval=5, wait=3600) +print('Done') diff --git a/examples/ces/create_alarm.py b/examples/ces/create_alarm.py new file mode 100644 index 000000000..bdbc35e86 --- /dev/null +++ b/examples/ces/create_alarm.py @@ -0,0 +1,89 @@ +#!/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 CloudEye alarm rule +''' +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +attrs = { + "alarm_name": "alarm-test", + "alarm_description": "Test Alarm description", + "metric": { + "namespace": "SYS.ECS", + "dimensions": [ + { + "name": "instance_id", + "value": "33328f02-3814-422e-b688-bfdba93d4051" + }, + { + "name": "instance_id", + "value": "04ab9572-8c9c-41b6-bcc8-51068463b123" + } + ], + "metric_name": "network_outgoing" + }, + "condition": { + "period": 300, + "filter": "average", + "comparison_operator": ">=", + "value": 6, + "unit": "B/s", + "count": 1 + }, + "alarm_enabled": True, + "alarm_action_enabled": True, + "alarm_level": 2, + "ok_actions": [ + { + "type": "notification", + "notificationList": [ + "urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd", + "urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error"] + } + ], + "alarm_actions": [ + { + "type": "notification", + "notificationList": [ + "urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd", + "urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error"] + } + ] +} + + +alarm = conn.ces.create_alarm(**attrs) +print(alarm) + +# OSC command +''' +openstack --os-cloud otc ces alarm create --description "Test Alarm" \ +--namespace SYS.ECS \ +--dimension name=instance_id,value=33328f02-3814-422e-b688-bfdba93d4123 \ +--dimension name=instance_id,value=33328f02-3814-422e-b688-bfdba93d4052 \ +--metric-name "network_outgoing" --period '300' --filter average \ +--comparison-operator '>=' --value '6' --unit 'B/s' --count '1' \ +--enabled True --action-enabled True --level 2 --ok-action-type notification \ +--ok-action-notification-list \ +'urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd' \ +--ok-action-notification-list \ +'urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error' \ +--alarm-action-type notification --alarm-action-notification-list \ +'urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd' \ +--alarm-action-notification-list \ +'urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error' alarm-test +''' diff --git a/examples/ces/create_metric_data.py b/examples/ces/create_metric_data.py new file mode 100644 index 000000000..c5c92f9c3 --- /dev/null +++ b/examples/ces/create_metric_data.py @@ -0,0 +1,61 @@ +#!/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 CloudEye metric data +''' +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +# not working due to lag of compatible API: list instead of proper JSON +attrs = [ + { + "metric": { + "namespace": "MINE.APP", + "dimensions": [ + { + "name": "instance_id", + "value": "33328f02-3814-422e-b688-bfdba93d4050" + } + ], + "metric_name": "cpu_util" + }, + "ttl": 172800, + "collect_time": 1598266684000, + "type": "int", + "value": 60, + "unit": "%" + }, + { + "metric": { + "namespace": "MINE.APP", + "dimensions": [ + { + "name": "instance_id", + "value": "33328f02-3814-422e-b688-bfdba93d4050" + } + ], + "metric_name": "cpu_util" + }, + "ttl": 172800, + "collect_time": 1598266685000, + "type": "int", + "value": 70, + "unit": "%" + } +] + + +data = conn.ces.create_metric_data(**attrs) +print(data) diff --git a/examples/ces/delete_alarm.py b/examples/ces/delete_alarm.py new file mode 100644 index 000000000..f2b97694d --- /dev/null +++ b/examples/ces/delete_alarm.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. +""" +Delete CloudEye alarm rule +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +alarm = 'al1596533022051EZVV2nlZ8' +alarm = conn.ces.find_alarm(alarm) +alarm = conn.ces.delete_alarm(alarm) +print(alarm) diff --git a/examples/ces/find_alarm.py b/examples/ces/find_alarm.py new file mode 100644 index 000000000..0408111ca --- /dev/null +++ b/examples/ces/find_alarm.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 CloudEye alarm rule by name or ID +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +alarm = 'alarm_id_or_name' +alarm = conn.ces.find_alarm(alarm) +print(alarm) diff --git a/examples/ces/get_alarm.py b/examples/ces/get_alarm.py new file mode 100644 index 000000000..e2b9a907a --- /dev/null +++ b/examples/ces/get_alarm.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 CloudEye alarm rule by ID +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +alarm = 'alarm_id' +alarm = conn.ces.get_alarm(alarm) +print(alarm) diff --git a/examples/ces/list_alarms.py b/examples/ces/list_alarms.py new file mode 100644 index 000000000..2d68be2b3 --- /dev/null +++ b/examples/ces/list_alarms.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 CloudEye alarm rules +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for alarm in conn.ces.alarms(): + print(alarm) diff --git a/examples/ces/list_event_data.py b/examples/ces/list_event_data.py new file mode 100644 index 000000000..d7e89b414 --- /dev/null +++ b/examples/ces/list_event_data.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. +""" +List all CloudEye event data +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +query = { + 'namespace': 'SYS.ECS', + 'type': 'instance_host_info', + 'dim.0': 'instance_id,6e83e6e7-3bf4-4b5b-b390-e80447ef1234', # key, value + 'from': '1596067200', # unix timestamp in ms + 'to': '1597929178' # unix timestamp in ms +} + +for data in conn.ces.event_data(**query): + print(data) diff --git a/examples/ces/list_metric_data.py b/examples/ces/list_metric_data.py new file mode 100644 index 000000000..229cdd312 --- /dev/null +++ b/examples/ces/list_metric_data.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +""" +List all CloudEye metric data +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +query = { + 'namespace': 'SYS.ECS', + 'metric_name': 'cpu_util', + 'from': '1556625600000', # unix timestamp in ms + 'to': '1556632800000', # unix timestamp in ms + 'period': 1, + 'filter': 'avg', + 'dim.0': 'instance_id,6e83e6e7-3bf4-4b5b-b390-e80447ef5733', # key, value +} + +for data in conn.ces.metric_data(**query): + print(data) diff --git a/examples/ces/list_metrics.py b/examples/ces/list_metrics.py new file mode 100644 index 000000000..888441533 --- /dev/null +++ b/examples/ces/list_metrics.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 CloudEye metrics +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for metric in conn.ces.metrics(): + print(metric) diff --git a/examples/ces/list_quotas.py b/examples/ces/list_quotas.py new file mode 100644 index 000000000..33f4e1616 --- /dev/null +++ b/examples/ces/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 CloudEye quotas +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for quota in conn.ces.quotas(): + print(quota) diff --git a/examples/ces/switch_alarm_state.py b/examples/ces/switch_alarm_state.py new file mode 100644 index 000000000..4f04734eb --- /dev/null +++ b/examples/ces/switch_alarm_state.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. +""" +Disable / Enable CloudEye alarm state +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +alarm = 'alarm_name_or_id' +alarm = conn.ces.find_alarm(alarm) +alarm = conn.ces.switch_alarm_state(alarm) +print(alarm) 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..b93d9185e --- /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/deh/create_deh_host.py b/examples/deh/create_deh_host.py new file mode 100644 index 000000000..c4e2bf03b --- /dev/null +++ b/examples/deh/create_deh_host.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. +""" +Allocate Dedicated Host +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +attrs = { + 'name': 'deh-name', + 'availability_zone': 'eu-de-01', + 'host_type': 's2-medium', + 'quantity': 1 +} + +host = conn.deh.create_host(**attrs) +if host: + print(host) diff --git a/examples/deh/list_deh_hosts.py b/examples/deh/list_deh_hosts.py new file mode 100644 index 000000000..18adb1b2d --- /dev/null +++ b/examples/deh/list_deh_hosts.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 allocated Dedicated hosts +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for host in conn.deh.hosts(): + print(host) diff --git a/examples/deh/list_deh_servers.py b/examples/deh/list_deh_servers.py new file mode 100644 index 000000000..a84d08ee0 --- /dev/null +++ b/examples/deh/list_deh_servers.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. +""" +List all servers of a Dedicated Host +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +host = 'name_or_id' +host = conn.deh.find_host(name_or_id=host) +for server in conn.deh.servers(host=host): + print(server) diff --git a/examples/deh/list_host_types.py b/examples/deh/list_host_types.py new file mode 100644 index 000000000..77b987eec --- /dev/null +++ b/examples/deh/list_host_types.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 host types in AZ +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +az = 'eu-de-01' +for type in conn.deh.host_types(az=az): + print(type) 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/identity/create_credential.py b/examples/identity/create_credential.py new file mode 100644 index 000000000..3a8ebe590 --- /dev/null +++ b/examples/identity/create_credential.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 AK/SK credentials +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +credential = conn.identity.create_credential( + description='my creds', + user_id='user_id' +) +print(credential) diff --git a/examples/identity/delete_credential.py b/examples/identity/delete_credential.py new file mode 100644 index 000000000..7267890f7 --- /dev/null +++ b/examples/identity/delete_credential.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. +""" +Delete AK/SK credentials +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +name_or_id = 'AK' +credential = conn.identity.find_credential(name_or_id, ignore_missing=False) +response = conn.identity.delete_credential(credential) diff --git a/examples/identity/find_credential.py b/examples/identity/find_credential.py new file mode 100644 index 000000000..2cd39c71c --- /dev/null +++ b/examples/identity/find_credential.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 AK/SK credentials +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +credential = 'AK' +credential = conn.identity.find_credential(credential) +print(credential) diff --git a/examples/identity/get_credential.py b/examples/identity/get_credential.py new file mode 100644 index 000000000..d74a4fbb9 --- /dev/null +++ b/examples/identity/get_credential.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 AK/SK credentials +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +credential = 'AK' +credential = conn.identity.get_credential(credential) +print(credential) diff --git a/examples/identity/list_credentials.py b/examples/identity/list_credentials.py new file mode 100644 index 000000000..5a1b3dfb5 --- /dev/null +++ b/examples/identity/list_credentials.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 AK/SK credentials +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for cred in conn.identity.credentials(): + print(cred) diff --git a/examples/identity/update_credential.py b/examples/identity/update_credential.py new file mode 100644 index 000000000..79a3e9c65 --- /dev/null +++ b/examples/identity/update_credential.py @@ -0,0 +1,30 @@ +#!/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 AK/SK credentials description or status +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +name_or_id = 'AK' +credential = conn.identity.find_credential(name_or_id, ignore_missing=False) +response = conn.identity.update_credential( + credential, + description='my creds', + status='inactive' +) +print(response) 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/examples/vpc/add_route.py b/examples/vpc/add_route.py new file mode 100644 index 000000000..5daba9604 --- /dev/null +++ b/examples/vpc/add_route.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. +""" +Add Route to VPC Peering Connection +""" +import openstack +from otcextensions import sdk + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') +sdk.register_otc_extensions(conn) + +attrs = { + "type": "peering", + "nexthop": "peering-uuid", + "destination": "192.168.100.0/24", + "vpc_id": "local-router-uuid" +} + +route = conn.vpc.add_route(**attrs) +print(route) diff --git a/examples/vpc/create_peering.py b/examples/vpc/create_peering.py new file mode 100644 index 000000000..5e3cb22bc --- /dev/null +++ b/examples/vpc/create_peering.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +""" +Create VPC Peering Connection +""" +import openstack +from otcextensions import sdk + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') +sdk.register_otc_extensions(conn) + +attrs = { + "name": "test-peering", + "request_vpc_info": { + "vpc_id": "requester-router-uuid" + }, + "accept_vpc_info": { + "vpc_id": "accepter-router-uuid" + } +} + +peering = conn.vpc.create_peering(**attrs) +print(peering) diff --git a/examples/vpc/delete_peering.py b/examples/vpc/delete_peering.py new file mode 100644 index 000000000..c99a7fd2e --- /dev/null +++ b/examples/vpc/delete_peering.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 VPC Peering by id or name +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +peering = "peering_id" +conn.vpc.delete_peering(peering) diff --git a/examples/vpc/delete_route.py b/examples/vpc/delete_route.py new file mode 100644 index 000000000..608491515 --- /dev/null +++ b/examples/vpc/delete_route.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 VPC Route By ID +""" +import openstack + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + + +route_id = "route-uuid" +conn.vpc.delete_route(route_id) diff --git a/examples/vpc/find_peering.py b/examples/vpc/find_peering.py new file mode 100644 index 000000000..15eefd713 --- /dev/null +++ b/examples/vpc/find_peering.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 VPC Peering by id or name +""" +import openstack +from otcextensions import sdk + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') +sdk.register_otc_extensions(conn) + + +name_or_id = "name_or_id" +peering = conn.vpc.find_peering(name_or_id, ignore_missing=True) +print(peering) diff --git a/examples/vpc/get_peering.py b/examples/vpc/get_peering.py new file mode 100644 index 000000000..ec56cd726 --- /dev/null +++ b/examples/vpc/get_peering.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. +""" +Get VPC Peering by id or peering Instance +""" +import openstack +from otcextensions import sdk + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') +sdk.register_otc_extensions(conn) + + +peering_id = "peering_id" +peering = conn.vpc.get_peering(peering_id) +print(peering) diff --git a/examples/vpc/get_route.py b/examples/vpc/get_route.py new file mode 100644 index 000000000..9b62c172f --- /dev/null +++ b/examples/vpc/get_route.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. +""" +Get VPC Route by ID +""" +import openstack +from otcextensions import sdk + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') +sdk.register_otc_extensions(conn) + + +route_id = "route-uuid" +route = conn.vpc.get_route(route_id) +print(route) diff --git a/examples/vpc/list_peerings.py b/examples/vpc/list_peerings.py new file mode 100644 index 000000000..455246bff --- /dev/null +++ b/examples/vpc/list_peerings.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 VPC Peerings +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for peering in conn.vpc.peerings(): + print(peering) diff --git a/examples/vpc/list_routes.py b/examples/vpc/list_routes.py new file mode 100644 index 000000000..896a2c51b --- /dev/null +++ b/examples/vpc/list_routes.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 VPC Routes +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +for route in conn.vpc.routes(): + print(route) diff --git a/examples/vpc/set_peering.py b/examples/vpc/set_peering.py new file mode 100644 index 000000000..1a704d67a --- /dev/null +++ b/examples/vpc/set_peering.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. +""" +Accept or Reject VPC Peering request +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +peering = conn.vpc.get_peering("peering_id") + +# accept VPC peering request +set_status = 'accept' +peering = conn.vpc.set_peering(peering=peering, set_status=set_status) +print(peering) + +# Reject VPC peering request +set_status = 'reject' +peering = conn.vpc.set_peering(peering=peering, set_status=set_status) +print(peering) diff --git a/examples/vpc/update_peering.py b/examples/vpc/update_peering.py new file mode 100644 index 000000000..56ca281bb --- /dev/null +++ b/examples/vpc/update_peering.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. +""" +Update VPC Peering attributes +""" +import openstack + + +openstack.enable_logging(True) +conn = openstack.connect(cloud='otc') + +peering = conn.vpc.get_peering("peering_id") +peering = conn.vpc.update_peering(peering=peering, name='new-name') +print(peering) diff --git a/open_points b/open_points deleted file mode 100644 index 2953d9c25..000000000 --- a/open_points +++ /dev/null @@ -1,125 +0,0 @@ -This document gathers issues, which are found during diggint the API and other OS tools working with API - -* on 28.03 native service version discovery request to https://as.eu-de.otc.t-systems.com/autoscaling-api/ caused timeout. AS service is temporarily disabled - -# General: - -* Inconsistent naming between services (AS:create_time, KMS:creation_date, CCE:createAt) -* Inconsistent error message structure between services (i.e. KMS vs RDS). This prohibits code generalization -* No custom service supports proper version discovery. Leads to error messages in the OSC tool and execution delays -* LB: while Neutron LBaaS is "strongly" considered as deprecated and no bindings are present in Ansible/OSC - it will likely not be possible/challenge to upstream this support. -* EVS: volume type list --long returns changing results -* Subnet (in some APIs) is most likely net_id -* Without service discovery and multiple versions it is not possible to get the proper service version in SDK. It falls back to first entry in the VersionFilter -* Tags require different format ("key=value" vs "key*value") - -# KMS: - -* service version discovery is broken. On https://kms.eu-de.otc.t-systems.com/ it returns - {"versions": [{"status": "CURRENT", "id": "v1.0", "links": [{"href": "https://rts.eu-de.otc.t-systems.com/v1/", "rel": "self"}]}]} - In the keystoneauth1 it results to get_endpoint=https://kms.eu-de.otc.t-systems.com/v1 (instead of V1.0). Detailed investigation is expensive, therefore aborted -* does not follow REST, everything is POST with different URLs and not even json['action'] -* is conceptually far away from Barbican -* API Doc: This API allows you to create a plaintext-free DEK, that is, the returned result of this API includes `only the plaintext` of the DEK. -* purpose of KMS is not precise. Attributes change their names/meaning depending on call -* encryption_context is described to be string, in reality dict is expected -* max_length is always expected to be exactly max. Make no sense as a param -* list CMK filter by key_state not working as documented -* format of the timestamp is unknown -* no way to get response in English - -# CCE - -* required header application/type also for GET -* cluster UUID is hidden in a inline metadata structure, making it hard to address it without dirty hacks. - Apis are jumping through this structure in anti-rest pattern -* attribute naming: metadata.uuid vs metadata.uid -* undocumented properties of the cluster.spec field (i.e. `cidr`) -* far away from Magnum -* Cluster has both VPC and VPC_ID, in GET VPC is name, in POST it should be ID -* Subnet is most likely net_id -* In AS sys disk has type "SYS", in CCE - "root" -* Node delete possible only by name, and not id -* service catalog configuration is broken v1 vs v2(v3) with no corrupted discovery and new service type - -# DCS: - -* DCS: in OS DCS is part of Trove. The API is same. In the DCS API is similar to RDS, but not easy mappable -* DCS: Since Redis 3.0.7 (only available in DCS) lots of critical issues (incl. security and possible data corruption), online memory defrag, less mem usage were fixed - -# MRS: -* Inconsistent naming between services ( data_processing-mrs ) - -# OBS: - -* OBS has storage class on Bucket level, but in AWS and all corresponding tools (also s3cmd, s4cmd, Boto) it is on the Object level - -# DNS (Designate): - -* nothing supports private zone (ansible, heat, ~terraform, SDK/CLI). Very hard to cover that everywhere -* Zone transfer, slave zone are not present. Modern Designateclient is not getting clear with response of designate -* API v2 is not implemented - -# VBS: - -* uses offset as a pagination, instead of marker (in docs, in reality marker is supported) -* backup creation takes too long. 1Gb empty volume takes >4 minutes. Functional tests are not reasonable with that. -* create policy requires frequency to be set -* shift implemented stuff to osc - -# CSS: - -* upon creation httpsEnable is str, upon read - bool -* flavors is not OpenStack compatible - -# HEAT: - -* very old level, blocking many OpenSource projects, including i.e. ansible-openshift, RedhatDNS. -* (to be doublechecked) template version check is likely not done, since features of later templates with older version header are passing validation (in the ranges of supported versions) -* validate return ok, doesn't mean create will pass (validation errors i.e. template version doesn't match, condition on a resource level was also added on newton) -* not all CLI calls return result -* Not possible to rely on mountpoint of the OS::Cinder::VolumeAttachment - it's ignored -* usage of Server with block_device_mapping_v2, devicename="sdX" and > 1 device fails. Port is not released leaving system in inconsistent state (if router interface is deleted can be cleaned only manually) -* OS::Neutron::LBaaS::HealthMonitor does not support type HTTPS, but GUI allows it -* update stack with existing template is missing - -# Shade/Ansible: - -* enabling SNAT through Ansible not possible, since upstream expects default as true and sends only false if set (shade:_build_external_gateway_info) -* only able to pass SYS volume size if boot_from_volume=True (default=false) -* on a play retry port in the subnet changes if exists (change IP) and corrupts connection -* Ansible: no support for load balancer -* Ansible (Heat): https://github.com/ansible/ansible/issues/30786 - small fix to see the failure message if stack create/update fails -* Private: yes helps to get public_v4 filled, but it hinders create request with auto_ip:true -* add router interface - -# VPC: - -* VPC uses network wrapped subnets. Simple net with multiple subnets is not properly visible in OTC (in VPCs list subnet count includes all subnets, but in VPC show subnets are missing) - -# TMS: - -* How to assign tag to resource from API? - -# BMS: - -* it is not Ironic, but ECS - -# Network: - -* SecGroup rule "Any" (value=0) is not working as designed. OSC uses defaults, use of 0 results in really 0 as a value. Effect is unknown yet - -# DeH - -* Tag support is not OS compatible - -# OpenStackSDK: - -* LBaaS: pool.healthmonitor_id according to ref api (and in OTC), but in the SDK it is health_monitor_ids (list) (reported under https://storyboard.openstack.org/#!/story/2001872). Some other attributes missing - - pool_member operating_status missing -* LBaaS HM: max_retries_down missing (optional and not present in OTC) - - -# DOC: -* at least on example of ULB LIST allows filtering, but it is not documented diff --git a/otcextensions/_hacking.py b/otcextensions/_hacking.py new file mode 100644 index 000000000..01b05adfc --- /dev/null +++ b/otcextensions/_hacking.py @@ -0,0 +1,43 @@ +# Copyright (c) 2019, Red Hat, Inc. +# +# 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. + +import re + +from hacking import core + +""" +Guidelines for writing new hacking checks + + - Use only for openstacksdk specific tests. OpenStack general tests + should be submitted to the common 'hacking' module. + - Pick numbers in the range O3xx. Find the current test with + the highest allocated number and then pick the next value. + - Keep the test method code in the source file ordered based + on the O3xx value. + - List the new rule in the top level HACKING.rst file + - Add test cases for each new rule to nova/tests/unit/test_hacking.py + +""" + +SETUPCLASS_RE = re.compile(r"def setUpClass\(") + + +@core.flake8ext +def assert_no_setupclass(logical_line): + """Check for use of setUpClass + + O300 + """ + if SETUPCLASS_RE.match(logical_line): + yield (0, "O300: setUpClass not allowed") diff --git a/otcextensions/common/agency_auth.py b/otcextensions/common/agency_auth.py new file mode 100644 index 000000000..06a62ce88 --- /dev/null +++ b/otcextensions/common/agency_auth.py @@ -0,0 +1,195 @@ +# 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. +import json + +from keystoneauth1.identity.v3 import base +from keystoneauth1 import access +from keystoneauth1 import exceptions +from keystoneauth1 import loading +from keystoneauth1 import _utils as utils + + +_logger = utils.get_logger(__name__) + + +class AssumeRoleMethod(base.AuthMethod): + _method_parameters = ['user_id', + 'username', + 'user_domain_id', + 'user_domain_name', + 'password', + 'target_agency_name', + 'target_domain_id', + 'target_domain_name', + 'target_project_id', + 'target_project_name'] + + def get_auth_data(self, session, auth, headers, **kwargs): + user = {'password': self.password} + + if self.user_id: + user['id'] = self.user_id + elif self.username: + user['name'] = self.username + + if self.user_domain_id: + user['domain'] = {'id': self.user_domain_id} + elif self.user_domain_name: + user['domain'] = {'name': self.user_domain_name} + + return 'password', {'user': user} + + def get_assume_role_auth_data(self, session, auth, headers, **kwargs): + agency = {'xrole_name': self.target_agency_name} + + if self.target_domain_id: + agency['domain_id'] = self.target_domain_id + elif self.target_domain_name: + agency['domain_name'] = self.target_domain_name + + return 'assume_role', agency + + def get_cache_id_elements(self): + return dict(('assume_role_%s' % p, getattr(self, p)) + for p in self._method_parameters) + + +class Agency(base.AuthConstructor): + """A plugin for authenticating with a username and password. + It then does assume_role + """ + _auth_method_class = AssumeRoleMethod + + def __init__(self, auth_url, + *args, + **kwargs): + super(Agency, self).__init__(auth_url=auth_url, + *args, + **kwargs) + self.target_project_id = kwargs.get('target_project_id') + self.target_project_name = kwargs.get('target_project_name') + self.target_domain_id = kwargs.get('target_domain_id') + self.target_domain_name = kwargs.get('target_domain_name') + + def get_auth_ref(self, session, **kwargs): + # First do regular authorization + auth_access = super(Agency, self).get_auth_ref(session, **kwargs) + # And now reauth with another scope + headers = { + 'Accept': 'application/json', + 'X-Auth-Token': auth_access._auth_token + } + body = {'auth': {'identity': {}}} + ident = body['auth']['identity'] + rkwargs = {} + + for method in self.auth_methods: + name, auth_data = method.get_assume_role_auth_data( + session, self, headers, request_kwargs=rkwargs) + # NOTE(adriant): Methods like ReceiptMethod don't + # want anything added to the request data, so they + # explicitly return None, which we check for. + if name: + ident.setdefault('methods', []).append(name) + ident[name] = auth_data + + if not ident: + raise exceptions.AuthorizationFailure( + 'Authentication method required (e.g. password)') + + if self.target_project_id: + body['auth']['scope'] = {'project': {'id': self.target_project_id}} + elif self.target_project_name: + scope = body['auth']['scope'] = {'project': {}} + scope['project']['name'] = self.target_project_name + # If project is not set - get a domain scope + elif self.target_domain_id: + body['auth']['scope'] = {'domain': + {'id': self.target_domain_id}} + elif self.target_domain_name: + body['auth']['scope'] = {'domain': + {'name': self.target_domain_name}} + + token_url = self.token_url + + if not self.auth_url.rstrip('/').endswith('v3'): + token_url = '%s/v3/auth/tokens' % self.auth_url.rstrip('/') + + if not self.include_catalog: + token_url += '?nocatalog' + + _logger.debug('Making authentication request to %s', token_url) + resp = session.post(token_url, json=body, headers=headers, + authenticated=False, log=False, **rkwargs) + + try: + _logger.debug(json.dumps(resp.json())) + resp_data = resp.json() + except ValueError: + raise exceptions.InvalidResponse(response=resp) + + if 'token' not in resp_data: + raise exceptions.InvalidResponse(response=resp) + + return access.AccessInfoV3(auth_token=resp.headers['X-Subject-Token'], + body=resp_data) + + +class AgencyLoader(loading.BaseV3Loader): + @property + def plugin_class(self): + return Agency + + def get_options(self, **kwargs): + options = super(AgencyLoader, self).get_options() + options.extend([ + loading.Opt('user-id', help='User ID'), + loading.Opt('username', help='Username', + deprecated=[loading.Opt('user-name')]), + loading.Opt('user-domain-id', help="User's domain id"), + loading.Opt('user-domain-name', help="User's domain name"), + loading.Opt('password', secret=True, prompt='Password: ', + help="User's password"), + + loading.Opt('target-agency-name', help="Agency name"), + loading.Opt('target-project-id', + help="Project id available through agency"), + loading.Opt('target-project-name', + help="Project name available through agency"), + loading.Opt('target-domain-id', + help="Domain id available through agency"), + loading.Opt('target-domain-name', + help="Domain name available through agency"), + ]) + return options + + def load_from_options(self, **kwargs): + if ( + kwargs.get('username') + and not (kwargs.get('user_domain_name') + or kwargs.get('user_domain_id')) + ): + m = "You have provided a username. In the V3 identity API a " \ + "username is only unique within a domain so you must " \ + "also provide either a user_domain_id or user_domain_name." + raise exceptions.OptionError(m) + if ( + not kwargs.get('target_agency_name') + or not (kwargs.get('target_domain_id') + or kwargs.get('target_domain_name')) + ): + m = "Using agency based authorization requires " \ + "target_agency_name, target_domain_id or "\ + "target_domain_name at the very minimum" + raise exceptions.OptionError(m) + + return super(AgencyLoader, self).load_from_options(**kwargs) diff --git a/otcextensions/common/exc.py b/otcextensions/common/exc.py index 897972be5..061ba1c47 100644 --- a/otcextensions/common/exc.py +++ b/otcextensions/common/exc.py @@ -236,6 +236,8 @@ def raise_from_response(response, error_message=None): messages = [content['message'], ] if 'error_code' in content: details = content['error_code'] + if 'error_msg' in content: + messages = [content['error_msg'], ] else: messages = [obj.get('message') for obj in content.values() if isinstance(obj, dict)] diff --git a/otcextensions/osclient/auto_scaling/v1/activity.py b/otcextensions/osclient/auto_scaling/v1/activity.py index ea6d014db..bf44dc171 100644 --- a/otcextensions/osclient/auto_scaling/v1/activity.py +++ b/otcextensions/osclient/auto_scaling/v1/activity.py @@ -31,18 +31,19 @@ class ListAutoScalingActivityLogs(command.Lister): def get_parser(self, prog_name): parser = super(ListAutoScalingActivityLogs, self).get_parser(prog_name) parser.add_argument( - 'group', + '--group', metavar='', + required=True, help=_('AS Group ID or name') ) parser.add_argument( - '--start_time', + '--start-time', metavar='', help=_('Specifies the start time for querying scaling ' 'action logs. Format: `YYYY-MM-DDThh:mm:ssZ`') ) parser.add_argument( - '--end_time', + '--end-time', metavar='', help=_('Specifies the end time for querying scaling ' 'action logs. Format: `YYYY-MM-DDThh:mm:ssZ`') diff --git a/otcextensions/osclient/auto_scaling/v1/config.py b/otcextensions/osclient/auto_scaling/v1/config.py index d29bf03c3..f839cf89e 100644 --- a/otcextensions/osclient/auto_scaling/v1/config.py +++ b/otcextensions/osclient/auto_scaling/v1/config.py @@ -152,13 +152,13 @@ def get_parser(self, prog_name): help=_('Flavor ID or Name for the ECS instance') ) group1.add_argument( - '--image_id', + '--image-id', metavar='', help=_('Image ID for the ECS instance to be created') ) group = parser.add_mutually_exclusive_group() group.add_argument( - '--instance_id', + '--instance-id', metavar='', help=_('AS Configuration name\n' 'Is mutually exclusive with ECS group') @@ -187,14 +187,14 @@ def get_parser(self, prog_name): help=_('Key name for the new ECS instance') ) parser.add_argument( - '--public_ip_bandwith', + '--public-ip-bandwith', metavar='', type=int, help=_('Defines EIP Bandwith (Mbit/s) to be attached ' 'to the new ECS instance') ) parser.add_argument( - '--user_data', + '--user-data', metavar='', help=_('Path to the cloud-init user_data file') ) diff --git a/otcextensions/osclient/auto_scaling/v1/group.py b/otcextensions/osclient/auto_scaling/v1/group.py index cded083a7..0fac7b320 100644 --- a/otcextensions/osclient/auto_scaling/v1/group.py +++ b/otcextensions/osclient/auto_scaling/v1/group.py @@ -62,6 +62,11 @@ class ListAutoScalingGroup(command.Lister): def get_parser(self, prog_name): parser = super(ListAutoScalingGroup, self).get_parser(prog_name) + parser.add_argument( + '--name', + metavar='', + help=_('Name or ID of the AS group') + ) parser.add_argument( '--limit', dest='limit', @@ -78,13 +83,40 @@ def get_parser(self, prog_name): 'specified marker. When used with --limit, set this to ' 'the last ID displayed in the previous run') ) + parser.add_argument( + '--scaling-configuration-id', + metavar='', + help=_('ID of the AS configuration') + ) + parser.add_argument( + '--status', + metavar='', + help=_('Shows AS groups with specific status:\n' + ': AS group is working\n' + ': AS group is paused\n' + ': AS group has malfunctions\n' + ': AS group is being deleted') + ) return parser def take_action(self, parsed_args): client = self.app.client_manager.auto_scaling - data = client.groups() + args = {} + if parsed_args.limit: + args['limit'] = parsed_args.limit + if parsed_args.marker: + args['marker'] = parsed_args.marker + if parsed_args.name: + args['name'] = parsed_args.name + if parsed_args.scaling_configuration_id: + args['scaling_configuration_id'] = \ + parsed_args.scaling_configuration_id + if parsed_args.status: + args['status'] = parsed_args.status + + data = client.groups(**args) return ( self.columns, @@ -137,36 +169,36 @@ def get_parser(self, prog_name): help=_('Name of the new configuration group') ) parser.add_argument( - '--desire_instance_number', + '--desire-instance-number', metavar='', type=int, help=_('Desired number of instances') ) parser.add_argument( - '--min_instance_number', + '--min-instance-number', metavar='', type=int, help=_('Minimal number of instances') ) parser.add_argument( - '--max_instance_number', + '--max-instance-number', metavar='', type=int, help=_('Maximal number of instances') ) parser.add_argument( - '--cool_down_time', + '--cool-down-time', metavar='', type=int, help=_('Specifies cooling duration in seconds') ) parser.add_argument( - '--lb_listener_id', + '--lb-listener-id', metavar='', help=_('Specifies ELB Listener ID') ) parser.add_argument( - '--lbaas_listener', + '--lbaas-listener', metavar='', action='append', help=_('Specifies ULB Listener Information in format: ' @@ -174,47 +206,47 @@ def get_parser(self, prog_name): '(Repeat multiple times, up to 3 times)') ) parser.add_argument( - '--availability_zone', + '--availability-zone', metavar='', action='append', help=_('Specifies the availability zones information ' '(Repeat multiple times)') ) parser.add_argument( - '--subnet', - metavar='', + '--network-id', + metavar='', action='append', required=True, help=_('Network ID of the subnet' '(Repeat multiple times, up to 5 times)') ) parser.add_argument( - '--security_group', + '--security-group', metavar='', action='append', - required=True, + # required=True, help=_('Security Group ID' '(Repeat multiple times)') ) parser.add_argument( - '--router', - metavar='', + '--router-id', + metavar='', required=True, help=_('Router (VPC) ID') ) parser.add_argument( - '--audit_method', + '--audit-method', metavar='', help=_('Specifies the audit method [`NOVA_AUDIT`, `ELB_AUDIT`]') ) parser.add_argument( - '--audit_time', + '--audit-time', metavar='', type=int, help=_('Specifies the audit time in minutes') ) parser.add_argument( - '--terminate_policy', + '--terminate-policy', metavar='', help=_('Specifies the termination policy' ' [`OLD_CONFIG_OLD_INSTANCE` (default), ' @@ -230,7 +262,7 @@ def get_parser(self, prog_name): '(Repeat multiple times)') ) parser.add_argument( - '--delete_public_ip', + '--delete-public-ip', default=False, action='store_true', help=_('Specifies whether to delete EIP when deleting the ECS') @@ -241,17 +273,18 @@ def take_action(self, parsed_args): args = {} args['name'] = parsed_args.name - args['vpc_id'] = parsed_args.router + args['router_id'] = parsed_args.router_id - subnets = [] - for subnet in parsed_args.subnet: - subnets.append({'id': subnet}) - args['networks'] = subnets + networks = [] + for network in parsed_args.network_id: + networks.append({'id': network}) + args['networks'] = networks - sgs = [] - for sg in parsed_args.security_group: - sgs.append({'id': sg}) - args['security_groups'] = sgs + if parsed_args.security_group: + sgs = [] + for sg in parsed_args.security_group: + sgs.append({'id': sg}) + args['security_groups'] = sgs if parsed_args.desire_instance_number: args['desire_instance_number'] = parsed_args.desire_instance_number @@ -337,36 +370,36 @@ def get_parser(self, prog_name): help=_('AS Group name or ID') ) parser.add_argument( - '--desire_instance_number', + '--desire-instance-number', metavar='', type=int, help=_('Desired number of instances') ) parser.add_argument( - '--min_instance_number', + '--min-instance-number', metavar='', type=int, help=_('Minimal number of instances') ) parser.add_argument( - '--max_instance_number', + '--max-instance-number', metavar='', type=int, help=_('Maximal number of instances') ) parser.add_argument( - '--cool_down_time', + '--cool-down-time', metavar='', type=int, help=_('Specifies cooling duration in seconds') ) parser.add_argument( - '--lb_listener_id', + '--lb-listener-id', metavar='', help=_('Specifies ELB Listener ID') ) parser.add_argument( - '--lbaas_listener', + '--lbaas-listener', metavar='', action='append', help=_('Specifies ULB Listener Information in format: ' @@ -374,47 +407,46 @@ def get_parser(self, prog_name): '(Repeat multiple times, up to 3 times)') ) parser.add_argument( - '--availability_zone', + '--availability-zone', metavar='', action='append', help=_('Specifies the availability zones information ' '(Repeat multiple times)') ) parser.add_argument( - '--subnetwork', - metavar='', + '--network-id', + metavar='', + default=[], action='append', - required=True, help=_('Network ID of the subnet' '(Repeat multiple times, up to 5 times)') ) parser.add_argument( - '--security_group', + '--security-group', metavar='', + default=[], action='append', - required=True, help=_('Security Group ID' '(Repeat multiple times)') ) parser.add_argument( - '--network_id', - metavar='', - required=True, - help=_('Network (VPC) ID') + '--router-id', + metavar='', + help=_('Router (VPC) ID') ) parser.add_argument( - '--audit_method', + '--audit-method', metavar='', help=_('Specifies the audit method [`NOVA_AUDIT`, `ELB_AUDIT`]') ) parser.add_argument( - '--audit_time', + '--audit-time', metavar='', type=int, help=_('Specifies the audit time in minutes') ) parser.add_argument( - '--terminate_policy', + '--terminate-policy', metavar='', help=_('Specifies the termination policy' ' [`OLD_CONFIG_OLD_INSTANCE` (default), ' @@ -430,7 +462,7 @@ def get_parser(self, prog_name): '(Repeat multiple times)') ) parser.add_argument( - '--delete_public_ip', + '--delete-public-ip', default=False, action='store_true', help=_('Specifies whether to delete EIP when deleting the ECS') @@ -440,17 +472,20 @@ def get_parser(self, prog_name): def take_action(self, parsed_args): args = {} - args['vpc_id'] = parsed_args.network_id + if parsed_args.router_id: + args['router_id'] = parsed_args.router_id - subnets = [] - for subnet in parsed_args.subnetwork: - subnets.append({'id': subnet}) - args['networks'] = subnets + networks = [] + for network in parsed_args.network_id: + networks.append({'id': network}) + if networks: + args['networks'] = networks sgs = [] for sg in parsed_args.security_group: sgs.append({'id': sg}) - args['security_groups'] = sgs + if sgs: + args['security_groups'] = sgs if parsed_args.desire_instance_number: args['desire_instance_number'] = parsed_args.desire_instance_number @@ -495,7 +530,8 @@ def take_action(self, parsed_args): args['notifications'] = lst client = self.app.client_manager.auto_scaling - group = client.update_group(group=parsed_args.group, **args) + group = client.find_group(parsed_args.group, ignore_missing=False) + group = client.update_group(group, **args) display_columns, columns = _get_columns(group) data = utils.get_item_properties(group, columns, formatters={}) diff --git a/otcextensions/osclient/auto_scaling/v1/instance.py b/otcextensions/osclient/auto_scaling/v1/instance.py index 061c09b78..03f55608d 100644 --- a/otcextensions/osclient/auto_scaling/v1/instance.py +++ b/otcextensions/osclient/auto_scaling/v1/instance.py @@ -31,18 +31,19 @@ class ListAutoScalingInstance(command.Lister): def get_parser(self, prog_name): parser = super(ListAutoScalingInstance, self).get_parser(prog_name) parser.add_argument( - 'group', + '--group', metavar='', + required=True, help=_('AS Group ID or Name for the instances query') ) parser.add_argument( - '--life_cycle_state', + '--life-cycle-state', metavar='', help=_('Life cycle state of the instances to query\n' 'Could be in [`INSERVICE`, `PENDING`, `REMOVING`]') ) parser.add_argument( - '--health_status', + '--health-status', metavar='', help=_('Health status of the instances to query\n' 'Could be in [`INITIALIZING`, `NORMAL`, `ERROR`]') @@ -91,7 +92,7 @@ def get_parser(self, prog_name): help=_('AS Instance ID to be deleted') ) parser.add_argument( - '--delete_instance', + '--delete-instance', action='store_true', default=False, help=_('Specifies, whether instance should be completely deleted') @@ -117,8 +118,9 @@ def get_parser(self, prog_name): parser = super(BatchActionAutoScalingInstance, self).\ get_parser(prog_name) parser.add_argument( - 'group', + '--group', metavar='', + required=True, help=_('AS Group ID or Name') ) parser.add_argument( @@ -134,7 +136,7 @@ def get_parser(self, prog_name): help=_('AS Instance ID to be deleted') ) parser.add_argument( - '--delete_instance', + '--delete-instance', action='store_true', default=False, help=_('Specifies, whether instance should be completely deleted' diff --git a/otcextensions/osclient/auto_scaling/v1/policy.py b/otcextensions/osclient/auto_scaling/v1/policy.py index c3f3b1af8..f0baacbea 100644 --- a/otcextensions/osclient/auto_scaling/v1/policy.py +++ b/otcextensions/osclient/auto_scaling/v1/policy.py @@ -82,6 +82,8 @@ def take_action(self, parsed_args): data = client.policies(group=group.id, **args) + print('querying %s with %s' % (group.id, args)) + return ( self.columns, (utils.get_item_properties( @@ -102,18 +104,26 @@ def get_parser(self, prog_name): parser.add_argument( 'policy', metavar='', - help=_('ID of the configuration policy') + help=_('ID of the configuration policy\n' + 'For Policy Name search --group param is needed') + ) + parser.add_argument( + '--group', + metavar='', + help=_('ScalingGroup ID or Name if Name searched is used') ) return parser def take_action(self, parsed_args): client = self.app.client_manager.auto_scaling - obj = client.get_policy(parsed_args.policy) - - # display_columns, columns = _get_columns(obj) - # data = utils.get_item_properties( - # obj, columns, formatters={'instance_config': _format_instance}) + if parsed_args.group: + group = client.find_group(parsed_args.group, ignore_missing=False) + obj = client.find_policy(parsed_args.policy, + group=group, + ignore_missing=False) + else: + obj = client.get_policy(parsed_args.policy) fmt = set_attributes_for_print_detail(obj) # display_columns, columns = _get_columns(obj) @@ -157,30 +167,30 @@ def get_parser(self, prog_name): help=_('AS Policy type [`ALARM`, `SCHEDULED`, `RECURRENCE`]') ) parser.add_argument( - '--cool_down_time', + '--cool-down-time', metavar='', type=int, help=_('Specifies the cooling time in seconds for the policy') ) parser.add_argument( - '--alarm_id', + '--alarm-id', metavar='', help=_('Specifies the alarm_id for the policy') ) parser.add_argument( - '--action_operation', + '--action-operation', metavar='', help=_('Specifies the policy operation ' 'Can be [`ADD`, `REMOVE`, `SET`]') ) parser.add_argument( - '--action_instance_number', + '--action-instance-number', metavar='', type=int, help=_('Specifies number of instances to be operated') ) parser.add_argument( - '--launch_time', + '--launch-time', metavar='', help=_('Specifies the time when the scaling action is triggered. ' 'The time format must comply with UTC.\n' @@ -188,7 +198,7 @@ def get_parser(self, prog_name): '* when type=`RECURRENCE`, then `hh:mm`\n') ) parser.add_argument( - '--recurrence_type', + '--recurrence-type', metavar='', help=_( 'Specifies the periodic triggering type\n' @@ -197,7 +207,7 @@ def get_parser(self, prog_name): ) ) parser.add_argument( - '--recurrence_value', + '--recurrence-value', metavar='', help=_( 'Specifies the frequency, at which actions are triggered\n' @@ -208,13 +218,13 @@ def get_parser(self, prog_name): ) ) parser.add_argument( - '--start_time', + '--start-time', metavar='', help=_('Specifies the start time in of the action in the ' '`YYYY-MM-DDThh:mmZ` format') ) parser.add_argument( - '--end_time', + '--end-time', metavar='', help=_('Specifies the end time in of the action in the ' '`YYYY-MM-DDThh:mmZ` format\n' @@ -313,7 +323,7 @@ def get_parser(self, prog_name): parser.add_argument( 'policy', metavar='', - help=_('AS Policy name or ID') + help=_('AS Policy ID') ) parser.add_argument( '--group', @@ -324,35 +334,33 @@ def get_parser(self, prog_name): parser.add_argument( '--type', metavar='', - required=True, - # choices=['ALARM', 'SCHEDULED', 'RECURRENCE'], help=_('AS Policy type [`ALARM`, `SCHEDULED`, `RECURRENCE`]') ) parser.add_argument( - '--cool_down_time', + '--cool-down-time', metavar='', type=int, help=_('Specifies the cooling time in seconds for the policy') ) parser.add_argument( - '--alarm_id', + '--alarm-id', metavar='', help=_('Specifies the alarm_id for the policy') ) parser.add_argument( - '--action_operation', + '--action-operation', metavar='', help=_('Specifies the policy operation ' 'Can be [`ADD`, `REMOVE`, `SET`]') ) parser.add_argument( - '--action_instance_number', + '--action-instance-number', metavar='', type=int, help=_('Specifies number of instances to be operated') ) parser.add_argument( - '--launch_time', + '--launch-time', metavar='', help=_('Specifies the time when the scaling action is triggered. ' 'The time format must comply with UTC.\n' @@ -360,7 +368,7 @@ def get_parser(self, prog_name): '* when type=`RECURRENCE`, then `hh:mm`\n') ) parser.add_argument( - '--recurrence_type', + '--recurrence-type', metavar='', help=_( 'Specifies the periodic triggering type\n' @@ -369,7 +377,7 @@ def get_parser(self, prog_name): ) ) parser.add_argument( - '--recurrence_value', + '--recurrence-value', metavar='', help=_( 'Specifies the frequency, at which actions are triggered\n' @@ -380,13 +388,13 @@ def get_parser(self, prog_name): ) ) parser.add_argument( - '--start_time', + '--start-time', metavar='', help=_('Specifies the start time in of the action in the ' '`YYYY-MM-DDThh:mmZ` format') ) parser.add_argument( - '--end_time', + '--end-time', metavar='', help=_('Specifies the end time in of the action in the ' '`YYYY-MM-DDThh:mmZ` format\n' @@ -399,13 +407,14 @@ def take_action(self, parsed_args): policy_attrs = {} # policy_attrs['name'] = parsed_args.name policy_attrs['scaling_group_id'] = parsed_args.group - policy_type = parsed_args.type.upper() - if policy_type not in self.POLICY_TYPES: - msg = (_('Unsupported policy type. Should be one of %s') - % self.POLICY_TYPES) - raise argparse.ArgumentTypeError(msg) - else: - policy_attrs['type'] = policy_type + if parsed_args.type: + policy_type = parsed_args.type.upper() + if policy_type not in self.POLICY_TYPES: + msg = (_('Unsupported policy type. Should be one of %s') + % self.POLICY_TYPES) + raise argparse.ArgumentTypeError(msg) + else: + policy_attrs['type'] = policy_type if parsed_args.alarm_id: policy_attrs['alarm_id'] = parsed_args.alarm_id if parsed_args.cool_down_time: @@ -435,8 +444,9 @@ def take_action(self, parsed_args): client = self.app.client_manager.auto_scaling + policy = client.get_policy(parsed_args.policy) policy = client.update_policy( - policy=parsed_args.policy, **policy_attrs) + policy, **policy_attrs) fmt = set_attributes_for_print_detail(policy) # display_columns, columns = _get_columns(obj) @@ -473,7 +483,7 @@ def get_parser(self, prog_name): parser.add_argument( 'policy', metavar='', - help=_('AS Policy ID or name') + help=_('AS Policy ID') ) return parser @@ -492,7 +502,7 @@ def get_parser(self, prog_name): parser.add_argument( 'policy', metavar='', - help=_('AS Policy ID or name') + help=_('AS Policy ID') ) return parser diff --git a/otcextensions/osclient/auto_scaling/v1/quota.py b/otcextensions/osclient/auto_scaling/v1/quota.py index e47aa7d6d..5a70e2e59 100644 --- a/otcextensions/osclient/auto_scaling/v1/quota.py +++ b/otcextensions/osclient/auto_scaling/v1/quota.py @@ -38,7 +38,13 @@ def get_parser(self, prog_name): def take_action(self, parsed_args): client = self.app.client_manager.auto_scaling - data = client.quotas(group=parsed_args.group) + data = [] + + if parsed_args.group: + group = client.find_group(parsed_args.group, ignore_missing=False) + data = client.quotas(group=group.id) + else: + data = client.quotas() return ( self.columns, diff --git a/otcextensions/osclient/ces/__init__.py b/otcextensions/osclient/ces/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/osclient/ces/client.py b/otcextensions/osclient/ces/client.py new file mode 100644 index 000000000..7da23ee68 --- /dev/null +++ b/otcextensions/osclient/ces/client.py @@ -0,0 +1,44 @@ +# 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. +# +import logging + +from otcextensions import sdk + + +LOG = logging.getLogger(__name__) + +DEFAULT_API_VERSION = '1' +API_VERSION_OPTION = 'os_ces_api_version' +API_NAME = "ces" +API_VERSIONS = { + "1.0": "openstack.connection.Connection", + "1": "openstack.connection.Connection", +} + + +def make_client(instance): + """Returns a CES proxy""" + + conn = instance.sdk_connection + + # register unconditionally, since we need to override default CES + sdk.register_otc_extensions(conn) + + LOG.debug('ces client initialized using OpenStack OTC SDK: %s', + conn.ces) + return conn.ces + + +def build_option_parser(parser): + """Hook to add global options""" + return parser diff --git a/otcextensions/osclient/ces/v1/__init__.py b/otcextensions/osclient/ces/v1/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/osclient/ces/v1/alarm.py b/otcextensions/osclient/ces/v1/alarm.py new file mode 100644 index 000000000..8e0c36be2 --- /dev/null +++ b/otcextensions/osclient/ces/v1/alarm.py @@ -0,0 +1,399 @@ +# 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. +# +'''CES Alarm v1 action implementations''' +import logging + +from osc_lib import utils +from osc_lib.cli import parseractions +from osc_lib.command import command + +from otcextensions.i18n import _ +from otcextensions.common import sdk_utils + +LOG = logging.getLogger(__name__) + + +def _translate_alarm_level(level): + case = { + 1: '1: Critical', + 2: '2: Major', + 3: '3: Minor', + 4: '4: Informational' + } + return case.get(level) + + +def _flatten_output(obj): + data = { + 'id': obj.id, + 'name': obj.name, + 'namespace': obj.metric.namespace, + # The return value of obj.metric.dimensions is a list. The list has + # only one value. It is not possible to have several items inside. + 'dimensions.name': obj.metric.dimensions[0].name, + 'dimensions.value': obj.metric.dimensions[0].value, + 'alarm_level': _translate_alarm_level(obj.alarm_level), + 'enabled': obj.alarm_enabled, + 'action_enabled': obj.alarm_action_enabled, + 'state': obj.alarm_state, + } + return data + + +def _get_columns(item): + column_map = { + } + inv_columns = [''] + return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map, + inv_columns) + + +# TODO(undefined): Implement query arguments -> SDK not working +class ListAlarms(command.Lister): + _description = _('List CES alarms') + columns = ( + 'id', + 'name', + 'namespace', + 'dimensions.name', + 'dimensions.value', + 'alarm_level', + 'enabled', + 'action_enabled', + 'state' + ) + + def get_parser(self, prog_name): + parser = super(ListAlarms, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.ces + + data = client.alarms() + + table = (self.columns, + (utils.get_dict_properties( + _flatten_output(s), self.columns + ) for s in data)) + return table + + +class ShowAlarm(command.ShowOne): + _description = _('Show CloudEye alarm rule details') + + def get_parser(self, prog_name): + parser = super(ShowAlarm, self).get_parser(prog_name) + + parser.add_argument( + 'alarm', + metavar='', + help=_('UUID or name of the alarm rule.') + ) + return parser + + def take_action(self, parsed_args): + + client = self.app.client_manager.ces + + obj = client.find_alarm( + parsed_args.alarm, + ignore_missing=False + ) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class DeleteAlarm(command.Command): + _description = _('Delete CES alarm') + + def get_parser(self, prog_name): + parser = super(DeleteAlarm, self).get_parser(prog_name) + + parser.add_argument( + 'alarm', + metavar='', + nargs='+', + help=_('UUID or name of the alarm.') + ) + + return parser + + def take_action(self, parsed_args): + if parsed_args.alarm: + client = self.app.client_manager.ces + for alarm in parsed_args.alarm: + alarm = client.find_alarm(alarm, ignore_missing=False) + client.delete_alarm(alarm=alarm) + + +class SetAlarm(command.ShowOne): + _description = _('Switch Alarm status.') + + def get_parser(self, prog_name): + parser = super(SetAlarm, self).get_parser(prog_name) + + parser.add_argument( + 'alarm', + metavar='', + help=_('UUID or name of the alarm.') + ) + + return parser + + def take_action(self, parsed_args): + + client = self.app.client_manager.ces + + alarm = client.find_alarm(parsed_args.alarm, ignore_missing=False) + + if alarm: + client.switch_alarm_state( + alarm=alarm + ) + + # instance of alarm needs to be found again due to missing + # return body of alarm rule update function + obj = client.find_alarm( + parsed_args.alarm, + ignore_missing=False + ) + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + return (display_columns, data) + + +class CreateAlarm(command.ShowOne): + _description = _('Create CloudEye alarm rule') + + def get_parser(self, prog_name): + parser = super(CreateAlarm, self).get_parser(prog_name) + + parser.add_argument( + 'name', + metavar='', + help=_('Alarm name') + ) + parser.add_argument( + '--enabled', + metavar='', + default=True, + type=bool, + help=_('State of the alarm.\n' + 'True: enable alarm (default)\n' + 'False: disable alarm\n') + ) + parser.add_argument( + '--description', + metavar='', + help=_('Description of the alarm') + ) + parser.add_argument( + '--action-enabled', + default=False, + type=bool, + help=_('Specifies whether the alarm action is triggered') + ) + parser.add_argument( + '--level', + metavar='', + type=int, + help=_('Indicates the alarm level\n' + '1: critical\n' + '2: major\n' + '3: minor\n' + '4: informational') + ) + + # AlarmActions + parser.add_argument( + '--alarm-action-type', + metavar='', + help=_('Specifies the alarms action type.\n' + 'notification: notification will be sent to user\n' + 'autoscaling: scaling action will be triggered') + ) + parser.add_argument( + '--alarm-action-notification-list', + metavar='', + action='append', + help=_('Specifies the list of objects being notified when ' + 'alarm status changes.\n' + 'URN example structure:\n' + 'urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd\n' + 'The parameter can be given multiple times to ' + 'notify multiple targets.') + ) + + # OkActions + parser.add_argument( + '--ok-action-type', + metavar='', + help=_('Specifies the alarms action type.\n' + 'notification: notification will be sent to user\n' + 'autoscaling: scaling action will be triggered') + ) + parser.add_argument( + '--ok-action-notification-list', + metavar='', + action='append', + help=_('Specifies the list of objects being notified when ' + 'alarm status changes.\n' + 'URN example structure:\n' + 'urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd\n' + 'The parameter can be given multiple times to ' + 'notify multiple targets.') + ) + + # ConditionSpec + parser.add_argument( + '--comparison-operator', + metavar='', + required=True, + help=_('Specifies the conditions comparison operator') + ) + parser.add_argument( + '--count', + metavar='', + type=int, + required=True, + help=_('Specifies how many times the alarm condition has to ' + 'triggered until Alarm raises.\n' + 'Value range: 1 to 5') + ) + parser.add_argument( + '--filter', + metavar='', + required=True, + help=_('Specifies the data rollup method.\n' + 'Values: max, min, average, sum, variance') + ) + parser.add_argument( + '--period', + metavar='', + type=int, + required=True, + help=_('Indicates the interval (in seconds) for checking ' + 'whether the configured alarm rules are met.') + ) + parser.add_argument( + '--unit', + metavar='', + help=_('Specifies data unit.') + ) + parser.add_argument( + '--value', + metavar='', + type=int, + required=True, + help=_('Specifies the alarm threshold.\n' + 'Values: 0 to max(int)') + ) + + # DimensionsSpec for Metrics + parser.add_argument( + '--dimension', + metavar='name=,value=', + action=parseractions.MultiKeyValueAction, + dest='dimensions', + required=True, + required_keys=['name', 'value'], + help=_('Example: \n' + '--dimension name=instance_id,value=123456-bfdba93d4123\n' + 'Repeat option to provide multiple dimensions.') + ) + + # MetricSpec + parser.add_argument( + '--metric-name', + metavar='', + required=True, + help=_('Specifies the metric name') + ) + parser.add_argument( + '--namespace', + metavar='', + required=True, + help=_('Specifies the namespace of the metric such as:\n' + 'SYS.ECS, SYS.AS') + ) + + return parser + + def take_action(self, parsed_args): + + client = self.app.client_manager.ces + + attrs = {} + + attrs['name'] = parsed_args.name + if parsed_args.enabled: + attrs['alarm_enabled'] = parsed_args.enabled + if parsed_args.description: + attrs['alarm_description'] = parsed_args.description + attrs['alarm_action_enabled'] = parsed_args.action_enabled + if parsed_args.level: + attrs['alarm_level'] = parsed_args.level + + ok_actions = [] + alarm_actions = [] + + if parsed_args.action_enabled: + if (parsed_args.ok_action_type + and parsed_args.ok_action_notification_list): + nl = parsed_args.ok_action_notification_list + ok_actions.append({ + 'type': parsed_args.ok_action_type, + 'notificationList': nl + }) + attrs['ok_actions'] = ok_actions + + if (parsed_args.alarm_action_type + and parsed_args.alarm_action_notification_list): + + nl = parsed_args.alarm_action_notification_list + alarm_actions.append({ + 'type': parsed_args.alarm_action_type, + 'notificationList': nl + }) + attrs['alarm_actions'] = alarm_actions + + condition = { + 'comparison_operator': parsed_args.comparison_operator, + 'count': parsed_args.count, + 'filter': parsed_args.filter, + 'period': parsed_args.period, + 'value': parsed_args.value + } + if parsed_args.unit: + condition['unit'] = parsed_args.unit + attrs['condition'] = condition + + metric = { + 'dimensions': parsed_args.dimensions, + 'metric_name': parsed_args.metric_name, + 'namespace': parsed_args.namespace + } + attrs['metric'] = metric + + obj = client.create_alarm( + **attrs + ) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) diff --git a/otcextensions/osclient/ces/v1/event_data.py b/otcextensions/osclient/ces/v1/event_data.py new file mode 100644 index 000000000..1edc7c661 --- /dev/null +++ b/otcextensions/osclient/ces/v1/event_data.py @@ -0,0 +1,87 @@ +# 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. +# +'''CES Alarm v1 action implementations''' +import logging + +from osc_lib import utils +from osc_lib.command import command + +from otcextensions.i18n import _ + +LOG = logging.getLogger(__name__) + + +class ListEventData(command.Lister): + _description = _('List CES event data') + columns = ( + 'timestamp', + 'type', + 'value' + ) + + def get_parser(self, prog_name): + parser = super(ListEventData, self).get_parser(prog_name) + parser.add_argument( + '--namespace', + metavar='', + required=True, + help=_('Specifies the namespace of the metric such as:\n' + 'SYS.ECS, SYS.AS') + ) + parser.add_argument( + '--type', + metavar='', + required=True, + help=_('Specifies the event type such as:\n' + 'instance_host_info') + ) + parser.add_argument( + '--dim', + metavar='', + required=True, + help=_('Specifies the monitoring dimension:\n' + 'dim.0=instance_id,123-456-789') + ) + parser.add_argument( + '--time-from', + metavar='', + required=True, + help=_('UNIX timestamp in ms from which the data is ' + 'collected.') + ) + parser.add_argument( + '--time-to', + metavar='', + required=True, + help=_('UNIX timestamp in ms to which the data is ' + 'collected.') + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.ces + + query = {} + query['namespace'] = parsed_args.namespace + query['type'] = parsed_args.type + query['dim.0'] = parsed_args.dim + query['from'] = parsed_args.time_from + query['to'] = parsed_args.time_to + + data = client.event_data(**query) + + table = (self.columns, + (utils.get_dict_properties( + s, self.columns + ) for s in data)) + return table diff --git a/otcextensions/osclient/ces/v1/metric.py b/otcextensions/osclient/ces/v1/metric.py new file mode 100644 index 000000000..fe9bddf1c --- /dev/null +++ b/otcextensions/osclient/ces/v1/metric.py @@ -0,0 +1,93 @@ +# 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. +# +'''CES Alarm v1 action implementations''' +import logging + +from osc_lib import utils +from osc_lib.command import command + +from otcextensions.i18n import _ + +LOG = logging.getLogger(__name__) + + +class ListMetrics(command.Lister): + _description = _('List CES alarms') + columns = ( + 'namespace', + 'dimensions', + 'metric_name', + 'unit', + ) + + table_columns = ( + 'namespace', + 'dimensions.name', + 'dimensions.value', + 'metric_name', + 'unit', + ) + + def get_parser(self, prog_name): + parser = super(ListMetrics, self).get_parser(prog_name) + + parser.add_argument( + '--namespace', + metavar='', + help=_('Namespace of the monitored object, e.g.\n' + 'SYS.ECS, SYS.VPC') + ) + parser.add_argument( + '--metric-name', + metavar='', + help=_('Name of the alarm rule object.') + ) + parser.add_argument( + '--unit', + metavar='', + help=_('Unit which is measured.') + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.ces + + query = {} + + if parsed_args.namespace: + query['namespace'] = parsed_args.namespace + if parsed_args.metric_name: + query['metric_name'] = parsed_args.metric_name + if parsed_args.unit: + query['unit'] = parsed_args.unit + + data = client.metrics(**query) + + # Modify table output to provide a better metric overview. + # Given data set is taken, splitted and flattened to build the table. + table = () + temp_list = [] + big_list = [] + for s in data: + for item in utils.get_dict_properties(s, self.columns): + if isinstance(item, (list)): + temp_list.append(item[0].name) + temp_list.append(item[0].value) + else: + temp_list.append(item) + big_list.append(tuple(temp_list)) + temp_list = [] + + table = (self.table_columns, big_list) + + return table diff --git a/otcextensions/osclient/ces/v1/metric_data.py b/otcextensions/osclient/ces/v1/metric_data.py new file mode 100644 index 000000000..f61841a18 --- /dev/null +++ b/otcextensions/osclient/ces/v1/metric_data.py @@ -0,0 +1,87 @@ +# 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. +# +'''CES Alarm v1 action implementations''' +import logging + +from osc_lib import utils +from osc_lib.command import command + +from otcextensions.i18n import _ + +LOG = logging.getLogger(__name__) + + +class ListMetricData(command.Lister): + _description = _('List CES event data') + columns = ( + 'timestamp', + 'type', + 'value' + ) + + def get_parser(self, prog_name): + parser = super(ListMetricData, self).get_parser(prog_name) + parser.add_argument( + '--namespace', + metavar='', + required=True, + help=_('Specifies the namespace of the metric such as:\n' + 'SYS.ECS, SYS.AS') + ) + parser.add_argument( + '--type', + metavar='', + required=True, + help=_('Specifies the event type such as:\n' + 'instance_host_info') + ) + parser.add_argument( + '--dim', + metavar='', + required=True, + help=_('Specifies the monitoring dimension:\n' + 'dim.0=instance_id,123-456-789') + ) + parser.add_argument( + '--time-from', + metavar='', + required=True, + help=_('UNIX timestamp in ms from which the data is ' + 'collected.') + ) + parser.add_argument( + '--time-to', + metavar='', + required=True, + help=_('UNIX timestamp in ms to which the data is ' + 'collected.') + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.ces + + query = {} + query['namespace'] = parsed_args.namespace + query['type'] = parsed_args.type + query['dim.0'] = parsed_args.dim + query['from'] = parsed_args.time_from + query['to'] = parsed_args.time_to + + data = client.event_data(**query) + + table = (self.columns, + (utils.get_dict_properties( + s, self.columns + ) for s in data)) + return table diff --git a/otcextensions/osclient/ces/v1/quota.py b/otcextensions/osclient/ces/v1/quota.py new file mode 100644 index 000000000..cf55095df --- /dev/null +++ b/otcextensions/osclient/ces/v1/quota.py @@ -0,0 +1,54 @@ +# 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. +# +'''CES Alarm v1 action implementations''' +import logging + +from osc_lib import utils +from osc_lib.command import command + +from otcextensions.i18n import _ + +LOG = logging.getLogger(__name__) + + +def _flatten_output(obj): + data = { + 'type': obj.resources[0].type, + 'quota': obj.resources[0].quota, + 'used': obj.resources[0].used + } + return data + + +class ListQuotas(command.Lister): + _description = _('List CES alarm quota') + columns = ( + 'type', + 'quota', + 'used' + ) + + def get_parser(self, prog_name): + parser = super(ListQuotas, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.ces + + data = client.quotas() + + table = (self.columns, + (utils.get_dict_properties( + _flatten_output(s), self.columns + ) for s in data)) + return table diff --git a/otcextensions/osclient/deh/v1/host.py b/otcextensions/osclient/deh/v1/host.py index 2975cf08b..ec57059ed 100644 --- a/otcextensions/osclient/deh/v1/host.py +++ b/otcextensions/osclient/deh/v1/host.py @@ -91,11 +91,11 @@ def get_parser(self, prog_name): help=_('Flavor ID.') ) parser.add_argument( - '--state', + '--status', metavar='{' + ','.join(HOST_STATES) + '}', type=lambda s: s.lower(), choices=HOST_STATES, - help=_('Host state filter.') + help=_('Host status filter.') ) parser.add_argument( '--tenant', @@ -142,8 +142,8 @@ def take_action(self, parsed_args): query['host_type_name'] = parsed_args.host_type_name if parsed_args.flavor: query['flavor'] = parsed_args.flavor - if parsed_args.state: - query['state'] = parsed_args.state + if parsed_args.status: + query['status'] = parsed_args.status if parsed_args.tenant: query['tenant'] = parsed_args.tenant if parsed_args.availability_zone: diff --git a/otcextensions/osclient/dms/v1/az.py b/otcextensions/osclient/dms/v1/az.py new file mode 100644 index 000000000..22cf5a843 --- /dev/null +++ b/otcextensions/osclient/dms/v1/az.py @@ -0,0 +1,38 @@ +# 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. +# +'''DMS Instance AZ action implementations''' +from osc_lib import utils +from osc_lib.command import command + +from otcextensions.i18n import _ + + +class ListAZ(command.Lister): + _description = _('List Availability zones') + columns = ('ID', 'name', 'code', 'port', 'has_available_resources') + + def get_parser(self, prog_name): + parser = super(ListAZ, self).get_parser(prog_name) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dms + + data = client.availability_zones() + + table = (self.columns, + (utils.get_item_properties( + s, self.columns, + ) for s in data)) + return table diff --git a/otcextensions/osclient/dms/v1/instance.py b/otcextensions/osclient/dms/v1/instance.py new file mode 100644 index 000000000..f60ca19fe --- /dev/null +++ b/otcextensions/osclient/dms/v1/instance.py @@ -0,0 +1,430 @@ +# 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. +# +'''DMS Instance v1 action implementations''' +from osc_lib import exceptions +from osc_lib import utils +from osc_lib.command import command + +from otcextensions.common import sdk_utils +from otcextensions.i18n import _ + + +INSTANCE_STATUS_CHOICES = ['CREATING', 'CREATEFAILED', 'RUNNING', 'ERROR', + 'STARTING', 'RESTARTING', 'CLOSING', 'FROZEN'] +RETENTION_POLICY_CHOICES = ['produce_reject', 'time_base'] +STORAGE_SPEC_CHOICES = ['dms.physical.storage.high', + 'dms.physical.storage.ultra'] + + +def _get_columns(item): + column_map = {} + hidden = ['location'] + return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map, + hidden) + + +class ListDMSInstance(command.Lister): + _description = _('List DMS Instances') + columns = ('ID', 'name', 'engine_name', 'engine_version', + 'storage_spec_code', 'status', 'connect_address', 'router_id', + 'network_id', 'security_group_id', 'user_name', 'storage', + 'total_storage', 'used_storage') + + def get_parser(self, prog_name): + parser = super(ListDMSInstance, self).get_parser(prog_name) + + parser.add_argument( + '--engine-name', + metavar='', + help=_('Engine name') + ) + + parser.add_argument( + '--status', + metavar='{' + ','.join(INSTANCE_STATUS_CHOICES) + '}', + type=lambda s: s.upper(), + choices=INSTANCE_STATUS_CHOICES, + help=_('Instance status') + ) + + parser.add_argument( + '--include-failure', + action='store_true', + help=_('Include instances failed to create') + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dms + + query_params = {} + for param in ['engine_name', 'status', 'include_failure']: + val = getattr(parsed_args, param) + if val is not None: + query_params[param] = val + + data = client.instances(**query_params) + + table = (self.columns, + (utils.get_item_properties( + s, self.columns, + ) for s in data)) + return table + + +class ShowDMSInstance(command.ShowOne): + _description = _('Show single Instance details') + + def get_parser(self, prog_name): + parser = super(ShowDMSInstance, self).get_parser(prog_name) + parser.add_argument( + 'instance', + metavar='', + help=_('ID of the instance') + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dms + + obj = client.find_instance(parsed_args.instance) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class DeleteDMSInstance(command.Command): + _description = _('Delete DMS Instance') + + def get_parser(self, prog_name): + parser = super(DeleteDMSInstance, self).get_parser(prog_name) + parser.add_argument( + 'instance', + metavar='', + nargs='+', + help=_('ID of the Instance') + ) + return parser + + def take_action(self, parsed_args): + + if parsed_args.instance: + client = self.app.client_manager.dms + for instance in parsed_args.instance: + client.delete_instance(instance) + + +class CreateDMSInstance(command.ShowOne): + _description = _('Create DMS Instance') + + def get_parser(self, prog_name): + parser = super(CreateDMSInstance, self).get_parser(prog_name) + parser.add_argument( + 'name', + metavar='', + help=_('Name of the instance.') + ) + + parser.add_argument( + '--description', + metavar='', + help=_('Description of the instance.') + ) + parser.add_argument( + '--engine-name', + metavar='', + help=_('Engine name. Currently only Kafka is supported.') + ) + parser.add_argument( + '--engine-version', + metavar='', + help=_('Engine version. Currently only "2.3.0" is supported.') + ) + parser.add_argument( + '--storage', + metavar='', + type=int, + required=True, + help=_('Indicates the message storage space with increments ' + 'of 100 GB:\n' + 'Instance with specification being 100MB: 600–90,000 GB\n' + 'Instance with specification being 300MB: 1,200–90,000 GB\n' + 'Instance with specification being 600MB: 2,400–90,000 GB\n' + 'Instance with specification being 1200MB: 4,800–90,000 GB') + ) + parser.add_argument( + '--access-user', + metavar='', + help=_( + 'This parameter is mandatory when engine is set to kafka and ' + 'ssl_enable is set to true. This parameter is invalid when ' + 'ssl_enable is set to false.\n' + 'Indicates a username. A username consists of 4 to 64 ' + 'characters and supports only letters, digits, hyphens (-), ' + 'and underscores (_).') + ) + parser.add_argument( + '--password', + metavar='', + help=_( + 'This parameter is mandatory when engine is set to kafka and ' + 'ssl_enable is set to true. This parameter is invalid when ' + 'ssl_enable is set to false.\n' + 'An instance password must meet the following complexity ' + 'requirements: \n' + '- Must be a string consisting of 8 to 32 characters.\n' + '- Must contain at least two of the following character ' + 'types: \n' + '-- Lowercase letters\n' + '-- Uppercase letters\n' + '-- Digits\n' + '-- Special characters' + ) + ) + parser.add_argument( + '--router', + metavar='', + required=True, + help=_('Router ID or Name') + ) + parser.add_argument( + '--security-group', + metavar='', + required=True, + help=_('Security group ID or Name') + ) + parser.add_argument( + '--network', + metavar='', + required=True, + help=_('Neutron network ID or Name') + ) + parser.add_argument( + '--availability-zone', + metavar='', + required=True, + action='append', + help=_('List of availability zones') + ) + parser.add_argument( + '--product-id', + metavar='', + required=True, + help=_('Product ID of the DMS instance') + ) + parser.add_argument( + '--maintenance-begin', + metavar='', + help=_('Start of the instance maintenance window') + ) + parser.add_argument( + '--maintenance-end', + metavar='', + help=_('End of the instance maintenance window') + ) + parser.add_argument( + '--enable-public-access', + action='store_true', + help=_('Assign public ip to the instance') + ) + parser.add_argument( + '--enable-ssl', + action='store_true', + help=_('Enable SSL for the public access') + ) + parser.add_argument( + '--public-bandwidth', + metavar='', + type=int, + help=_('Public network bandwidth in Mbit/s:\n' + 'When specification 100MB: 3-900\n' + 'When 300MB: 3-900\n' + 'When 600MB: 4-1200\n' + 'When 1200MB: 8-2400') + ) + parser.add_argument( + '--retention-policy', + metavar='{' + ','.join(RETENTION_POLICY_CHOICES) + '}', + type=lambda s: s.lower(), + choices=RETENTION_POLICY_CHOICES, + help=_('Action to be taken when the memory usage reaches the ' + 'disk capacity threshold. Options:\n' + ' `produce_reject`: New messages cannot be created.\n' + ' `time_base`: The earliest messages are deleted.') + ) + parser.add_argument( + '--storage-spec-code', + metavar='{' + ','.join(STORAGE_SPEC_CHOICES) + '}', + type=lambda s: s.lower(), + choices=STORAGE_SPEC_CHOICES, + help=_('The storage I/O specification of a Kafka instance.\n' + 'When specification is 100MB, the storage I/O can be:' + '[`dms.physical.storage.high`, ' + '`dms.physical.storage.ultra`]\n' + 'When specification is 300MB, the storage I/O can be:' + '[`dms.physical.storage.high`, ' + '`dms.physical.storage.ultra`]\n' + 'When specification is 600MB, the storage I/O is ' + '`dms.physical.storage.ultra`.\n' + 'When specification is 1200MB, the storage I/O is ' + '`dms.physical.storage.ultra`.') + ) + + return parser + + def take_action(self, parsed_args): + + attrs = {} + + attrs['name'] = parsed_args.name + for attr in ['description', 'engine_name', 'engine_version', 'storage', + 'access_user', 'password', 'product_id', + 'maintenance_begin', 'maintenance_end', + 'public_bandwidth', + 'retention_policy', 'storage_spec_code']: + val = getattr(parsed_args, attr) + if val is not None: + attrs[attr] = val + + network_client = self.app.client_manager.network + + router_obj = network_client.find_router(parsed_args.router, + ignore_missing=False) + attrs['router_id'] = router_obj.id + net_obj = network_client.find_network(parsed_args.network, + ignore_missing=False) + attrs['network_id'] = net_obj.id + sg_obj = self.app.client_manager.compute.find_security_group( + parsed_args.security_group, ignore_missing=False) + attrs['security_group_id'] = sg_obj.id + + if parsed_args.availability_zone: + attrs['availability_zone'] = parsed_args.availability_zone + + if parsed_args.maintenance_begin and parsed_args.maintenance_end: + attrs['maintenance_begin'] = parsed_args.maintenance_begin + attrs['maintenance_end'] = parsed_args.maintenance_end + elif parsed_args.maintenance_begin or parsed_args.maintenance_end: + raise exceptions.CommandException(_( + '`maintenance_start` and `maintenance_end` can be set only' + 'together')) + if parsed_args.enable_public_access: + attrs['is_public'] = True + if parsed_args.enable_ssl: + attrs['is_ssl'] = True + + client = self.app.client_manager.dms + + obj = client.create_instance(**attrs) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class UpdateDMSInstance(command.ShowOne): + _description = _('Update DMS Instance') + + def get_parser(self, prog_name): + parser = super(UpdateDMSInstance, self).get_parser(prog_name) + parser.add_argument( + 'instance', + metavar='', + help=_('Name or ID of the DMS instance') + ) + parser.add_argument( + '--name', + metavar='', + help=_('New name of the instance.') + ) + parser.add_argument( + '--description', + metavar='', + help=_('New description of the instance.') + ) + parser.add_argument( + '--security-group', + metavar='', + required=True, + help=_('Security group ID or Name') + ) + parser.add_argument( + '--maintenance-begin', + metavar='', + help=_('Start of the instance maintenance window') + ) + parser.add_argument( + '--maintenance-end', + metavar='', + help=_('End of the instance maintenance window') + ) + return parser + + def take_action(self, parsed_args): + + attrs = {} + + attrs['name'] = parsed_args.name + for attr in ['description', 'maintenance_begin', 'maintenance_end']: + val = getattr(parsed_args, attr) + if val is not None: + attrs[attr] = val + + sg_obj = self.app.client_manager.compute.find_security_group( + parsed_args.security_group, ignore_missing=False) + attrs['security_group_id'] = sg_obj.id + + if parsed_args.maintenance_begin and parsed_args.maintenance_end: + attrs['maintenance_begin'] = parsed_args.maintenance_begin + attrs['maintenance_end'] = parsed_args.maintenance_end + elif parsed_args.maintenance_begin or parsed_args.maintenance_end: + raise exceptions.CommandException(_( + '`maintenance_start` and `maintenance_end` can be set only' + 'together')) + + client = self.app.client_manager.dms + + instance = client.find_instance(parsed_args.instance, + ignore_missing=False) + + obj = client.update_instance(instance, **attrs) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class RestartDMSInstance(command.Command): + _description = _('Restart single Instance') + + def get_parser(self, prog_name): + parser = super(RestartDMSInstance, self).get_parser(prog_name) + parser.add_argument( + 'instance', + metavar='', + help=_('ID of the instance') + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dms + + obj = client.find_instance(parsed_args.instance, ignore_missing=False) + + client.restart_instance(obj) + + return diff --git a/otcextensions/osclient/dms/v1/maintenance_window.py b/otcextensions/osclient/dms/v1/maintenance_window.py new file mode 100644 index 000000000..1426d0ad0 --- /dev/null +++ b/otcextensions/osclient/dms/v1/maintenance_window.py @@ -0,0 +1,38 @@ +# 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. +# +'''DMS Instance Maintenance Window action implementations''' +from osc_lib import utils +from osc_lib.command import command + +from otcextensions.i18n import _ + + +class ListMW(command.Lister): + _description = _('List Maintenance Windows') + columns = ('seq', 'begin', 'end', 'is_default') + + def get_parser(self, prog_name): + parser = super(ListMW, self).get_parser(prog_name) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dms + + data = client.maintenance_windows() + + table = (self.columns, + (utils.get_item_properties( + s, self.columns, + ) for s in data)) + return table diff --git a/otcextensions/osclient/dms/v1/product.py b/otcextensions/osclient/dms/v1/product.py new file mode 100644 index 000000000..ed8d55302 --- /dev/null +++ b/otcextensions/osclient/dms/v1/product.py @@ -0,0 +1,41 @@ +# 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. +# +'''DMS Product specification action implementations''' + +from osc_lib import utils +from osc_lib.command import command + +from otcextensions.i18n import _ + + +class ListProduct(command.Lister): + _description = _('List Product specs') + columns = ('spec_code', 'engine_name', 'engine_version', 'tps', 'storage', + 'partition_num', 'product_id', 'availability_zones', + 'unavailable_zones') + + def get_parser(self, prog_name): + parser = super(ListProduct, self).get_parser(prog_name) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dms + + data = client.products() + + table = (self.columns, + (utils.get_item_properties( + s, self.columns, + ) for s in data)) + return table diff --git a/otcextensions/osclient/dms/v1/topic.py b/otcextensions/osclient/dms/v1/topic.py new file mode 100644 index 000000000..220e358f3 --- /dev/null +++ b/otcextensions/osclient/dms/v1/topic.py @@ -0,0 +1,172 @@ +# 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. +# +'''DMS Topic v1 action implementations''' +from osc_lib import utils +from osc_lib.command import command + +from otcextensions.common import sdk_utils +from otcextensions.i18n import _ + + +def _get_columns(item): + column_map = {} + hidden = ['location'] + return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map, + hidden) + + +class ListDMSInstanceTopic(command.Lister): + _description = _('List DMS Instance topics') + columns = ('ID', 'replication', 'partition', 'retention_time', + 'is_sync_flush', 'is_sync_replication') + + def get_parser(self, prog_name): + parser = super(ListDMSInstanceTopic, self).get_parser(prog_name) + + parser.add_argument( + 'instance', + metavar='', + help=_('DMS Instance name or ID') + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dms + + instance_obj = client.find_instance(parsed_args.instance, + ignore_missing=False) + data = client.topics(instance=instance_obj) + + table = (self.columns, + (utils.get_item_properties( + s, self.columns, + ) for s in data)) + return table + + +class DeleteDMSInstanceTopic(command.Command): + _description = _('Delete DMS Instance Topic') + + def get_parser(self, prog_name): + parser = super(DeleteDMSInstanceTopic, self).get_parser(prog_name) + parser.add_argument( + 'instance', + metavar='', + help=_('ID or name of the Instance') + ) + parser.add_argument( + 'topic', + metavar='', + nargs='+', + help=_('Topic ID') + ) + return parser + + def take_action(self, parsed_args): + + if parsed_args.instance: + client = self.app.client_manager.dms + instance = client.find_instance( + parsed_args.instance, + ignore_missing=False) + client.delete_topic(instance=instance, topics=parsed_args.topic) + + +class CreateDMSInstanceTopic(command.ShowOne): + _description = _('Create DMS Instance Topic') + + def get_parser(self, prog_name): + parser = super(CreateDMSInstanceTopic, self).get_parser(prog_name) + parser.add_argument( + 'instance', + metavar='', + help=_('Instance ID or Name.') + ) + parser.add_argument( + 'id', + metavar='', + help=_('Name/ID of the topic.') + ) + parser.add_argument( + '--partition', + metavar='', + type=int, + choices=range(1, 21), + help=_( + 'The number of topic partitions, which is used to set the ' + 'number of concurrently consumed messages. ' + 'Value range: 1–20. Default value: 3.') + ) + parser.add_argument( + '--replication', + metavar='', + type=int, + choices=range(1, 4), + help=_( + 'The number of replicas, which is configured to ensure data ' + 'reliability. Value range: 1–3. Default value: 3.') + ) + parser.add_argument( + '--retention-time', + metavar='', + type=int, + choices=range(1, 169), + default=72, + help=_( + 'The retention period of a message. Its default value is ' + '72. Value range: 1–168. Default value: 72. Unit: hour.') + ) + parser.add_argument( + '--enable-sync-flush', + action='store_true', + help=_( + 'Whether to enable synchronous flushing. ' + 'Default value: false. Synchronous flushing compromises ' + 'performance.') + ) + parser.add_argument( + '--enable-sync-replication', + action='store_true', + help=_( + 'Whether to enable synchronous replication. After this ' + 'function is enabled, the acks parameter on the producer ' + 'client must be set to –1. Otherwise, this parameter does ' + 'not take effect.') + ) + return parser + + def take_action(self, parsed_args): + + attrs = {} + + attrs['id'] = parsed_args.id + for attr in ['partition', 'replication', 'retention_time']: + val = getattr(parsed_args, attr) + if val is not None: + attrs[attr] = val + if parsed_args.enable_sync_flush: + attrs['is_sync_flush'] = True + if parsed_args.enable_sync_replication: + attrs['is_sync_replication'] = True + + client = self.app.client_manager.dms + + instance = client.find_instance(parsed_args.instance, + ignore_missing=False) + + obj = client.create_topic(instance=instance, **attrs) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) diff --git a/otcextensions/osclient/dns/v2/recordset.py b/otcextensions/osclient/dns/v2/recordset.py index 581315365..3ee414c91 100644 --- a/otcextensions/osclient/dns/v2/recordset.py +++ b/otcextensions/osclient/dns/v2/recordset.py @@ -50,16 +50,24 @@ def get_parser(self, prog_name): help=_('UUID or name of the zone. Recordsets of all zones ' 'will be returned if not given.') ) + parser.add_argument( + '--zone-type', + help=_('DNS Zone type (private/public)') + ) return parser def take_action(self, parsed_args): client = self.app.client_manager.dns zone = None + attrs = {} + if parsed_args.zone_type: + attrs['zone_type'] = parsed_args.zone_type if parsed_args.zone: - zone = client.find_zone(parsed_args.zone, ignore_missing=False) + zone = client.find_zone(parsed_args.zone, ignore_missing=False, + **attrs) data = client.recordsets(zone=zone) @@ -81,6 +89,10 @@ def get_parser(self, prog_name): metavar='', help=_('UUID or name of the zone.') ) + parser.add_argument( + '--zone-type', + help=_('DNS Zone type (private/public)') + ) parser.add_argument( 'recordset', @@ -96,6 +108,8 @@ def take_action(self, parsed_args): zone = client.find_zone( parsed_args.zone, + ignore_missing=False, + zone_type=parsed_args.zone_type ) obj = client.find_recordset(zone=zone, @@ -118,6 +132,10 @@ def get_parser(self, prog_name): metavar='', help=_('UUID or name of the zone.') ) + parser.add_argument( + '--zone-type', + help=_('DNS Zone type (private/public)') + ) parser.add_argument( 'recordset', @@ -131,7 +149,8 @@ def get_parser(self, prog_name): def take_action(self, parsed_args): if parsed_args.zone: client = self.app.client_manager.dns - zone = client.find_zone(parsed_args.zone, ignore_missing=False) + zone = client.find_zone(parsed_args.zone, ignore_missing=False, + zone_type=parsed_args.zone_type) for rs in parsed_args.recordset: rs = client.find_recordset(zone=zone, name_or_id=rs, ignore_missing=False) @@ -150,6 +169,10 @@ def get_parser(self, prog_name): metavar='', help=_('UUID or name of the zone.') ) + parser.add_argument( + '--zone-type', + help=_('DNS Zone type (private/public)') + ) parser.add_argument( '--name', metavar='', @@ -193,7 +216,8 @@ def take_action(self, parsed_args): attrs = {'records': []} - zone = client.find_zone(parsed_args.zone, ignore_missing=False) + zone = client.find_zone(parsed_args.zone, ignore_missing=False, + zone_type=parsed_args.zone_type) if parsed_args.name: attrs['name'] = parsed_args.name @@ -228,6 +252,10 @@ def get_parser(self, prog_name): metavar='', help=_('UUID or name of the zone.') ) + parser.add_argument( + '--zone-type', + help=_('DNS Zone type (private/public)') + ) parser.add_argument( 'recordset', metavar='', @@ -268,7 +296,8 @@ def take_action(self, parsed_args): if parsed_args.ttl: attrs['ttl'] = parsed_args.ttl - zone = client.find_zone(parsed_args.zone, ignore_missing=False) + zone = client.find_zone(parsed_args.zone, ignore_missing=False, + zone_type=parsed_args.zone_type) if parsed_args.ttl: attrs['zone_id'] = zone.id diff --git a/otcextensions/osclient/dns/v2/zone.py b/otcextensions/osclient/dns/v2/zone.py index 7f7f5769a..f9ed3616a 100644 --- a/otcextensions/osclient/dns/v2/zone.py +++ b/otcextensions/osclient/dns/v2/zone.py @@ -53,7 +53,7 @@ def get_parser(self, prog_name): metavar='{' + ','.join(ZONE_TYPES) + '}', type=lambda s: s.lower(), choices=ZONE_TYPES, - help=_('Zone type.') + help=_('Zone type. Default lists only public zones.') ) return parser diff --git a/otcextensions/osclient/identity/__init__.py b/otcextensions/osclient/identity/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/osclient/identity/client.py b/otcextensions/osclient/identity/client.py new file mode 100644 index 000000000..064f80485 --- /dev/null +++ b/otcextensions/osclient/identity/client.py @@ -0,0 +1,43 @@ +# 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. +# +import logging + +from otcextensions import sdk + + +LOG = logging.getLogger(__name__) + +DEFAULT_API_VERSION = '3' +API_VERSION_OPTION = 'os_identity_api_version' +API_NAME = "identity" +API_VERSIONS = { + "3": "openstack.connection.Connection", +} + + +def make_client(instance): + """Returns a identity proxy""" + + conn = instance.sdk_connection + + # register unconditionally, since we need to override default DNS + sdk.register_otc_extensions(conn) + + LOG.debug('identity client initialized using OpenStack OTC SDK: %s', + conn.identity) + return conn.identity + + +def build_option_parser(parser): + """Hook to add global options""" + return parser diff --git a/otcextensions/osclient/identity/v3/__init__.py b/otcextensions/osclient/identity/v3/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/osclient/identity/v3/credential.py b/otcextensions/osclient/identity/v3/credential.py new file mode 100644 index 000000000..6300f72c0 --- /dev/null +++ b/otcextensions/osclient/identity/v3/credential.py @@ -0,0 +1,208 @@ +# 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. +# +'''Identity credential v3 action implementations''' +import logging + +from osc_lib import utils +from osc_lib.command import command + +from otcextensions.i18n import _ +from otcextensions.common import sdk_utils + +LOG = logging.getLogger(__name__) + + +def _get_columns(item): + column_map = { + } + return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map) + + +class ListCredentials(command.Lister): + _description = _('List Identity Credentials') + columns = ( + 'access', + 'description', + 'user_id', + 'status', + 'created_at', + ) + + def get_parser(self, prog_name): + parser = super(ListCredentials, self).get_parser(prog_name) + + parser.add_argument( + '--user-id', + metavar='', + help=_('User ID of the user using the credential') + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.identity + + table_columns = ( + 'Access Key', + 'Description', + 'User ID', + 'Status', + 'Created At', + ) + + attrs = {} + + if parsed_args.user_id: + attrs['user_id'] = parsed_args.user_id + + data = client.credentials(**attrs) + + table = (table_columns, + (utils.get_dict_properties( + s, self.columns + ) for s in data)) + return table + + +class ShowCredential(command.ShowOne): + _description = _('Show identity credential details') + + def get_parser(self, prog_name): + parser = super(ShowCredential, self).get_parser(prog_name) + + parser.add_argument( + 'credential', + metavar='', + help=_('Access key of the credential.') + ) + return parser + + def take_action(self, parsed_args): + + client = self.app.client_manager.identity + + obj = client.find_credential( + parsed_args.credential, + ignore_missing=False + ) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class DeleteCredential(command.Command): + _description = _('Delete identity credential') + + def get_parser(self, prog_name): + parser = super(DeleteCredential, self).get_parser(prog_name) + + parser.add_argument( + 'credential', + metavar='', + nargs='+', + help=_('Access key of the credential.') + ) + + return parser + + def take_action(self, parsed_args): + if parsed_args.credential: + client = self.app.client_manager.identity + for credential in parsed_args.credential: + credential = client.find_credential( + credential, + ignore_missing=False) + client.delete_credential(credential=credential) + + +class UpdateCredential(command.ShowOne): + _description = _("Update identity credential.") + + def get_parser(self, prog_name): + parser = super(UpdateCredential, self).get_parser(prog_name) + parser.add_argument( + 'credential', + metavar='', + help=_("Specifies the access key / ID of the credential."), + ) + parser.add_argument( + '--description', + metavar='', + help=_("Provides supplementary information about the credential."), + ) + parser.add_argument( + '--status', + metavar='', + help=_('Switch status of the credential.\n' + 'active: Credential is active\n' + 'inactive: Credential is inactive\n'), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.identity + args_list = [ + 'description', 'status' + ] + attrs = {} + for arg in args_list: + if getattr(parsed_args, arg): + attrs[arg] = getattr(parsed_args, arg) + credential = client.find_credential(parsed_args.credential) + + obj = client.update_credential(credential.id, **attrs) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class CreateCredential(command.ShowOne): + _description = _('Create a identity credential') + + def get_parser(self, prog_name): + parser = super(CreateCredential, self).get_parser(prog_name) + + parser.add_argument( + 'user_id', + metavar='', + help=_('User ID of the user who will use the credential') + ) + parser.add_argument( + '--description', + metavar='', + help=_('Description of the alarm') + ) + + return parser + + def take_action(self, parsed_args): + + client = self.app.client_manager.identity + + attrs = {} + + attrs['user_id'] = parsed_args.user_id + if parsed_args.description: + attrs['description'] = parsed_args.description + + obj = client.create_credential( + **attrs + ) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) 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/load_balancer/v1/health_monitor.py b/otcextensions/osclient/load_balancer/v1/health_monitor.py index bc13bfb9b..684ab9c35 100644 --- a/otcextensions/osclient/load_balancer/v1/health_monitor.py +++ b/otcextensions/osclient/load_balancer/v1/health_monitor.py @@ -36,7 +36,7 @@ def _get_columns(item): HTTP_METHODS = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'CONNECT', 'PATCH'] -TYPE_VALUES = ['HTTP', 'HTTPS', 'PING', 'TCP', 'TLS-HELLO'] +TYPE_VALUES = ['HTTP', 'HTTPS', 'PING', 'TCP', 'TLS-HELLO', 'UDP_CONNECT'] class ListHealthMonitor(command.Lister): @@ -53,7 +53,8 @@ def get_parser(self, prog_name): type=lambda s: s.upper(), choices=TYPE_VALUES, help=_('Health monitor type to use as a filter\n' - 'one of [`HTTP`, `HTTPS`, `PING`, `TCP`, `TLS-HELLO`]') + 'one of [`HTTP`, `HTTPS`, `PING`, `TCP`, `TLS-HELLO`, ' + '`UDP_CONNECT`]') ) return parser @@ -184,7 +185,8 @@ def get_parser(self, prog_name): type=lambda s: s.upper(), # case insensitive required=True, help=_('The type of health monitor.\n' - 'one of [`HTTP`, `HTTPS`, `PING`, `TCP`, `TLS-HELLO`]') + 'one of [`HTTP`, `HTTPS`, `PING`, `TCP`, `TLS-HELLO`, ' + '`UDP_CONNECT`]') ) admin_group = parser.add_mutually_exclusive_group() admin_group.add_argument( diff --git a/otcextensions/osclient/load_balancer/v1/listener.py b/otcextensions/osclient/load_balancer/v1/listener.py index d777a260d..8b21a6f6d 100644 --- a/otcextensions/osclient/load_balancer/v1/listener.py +++ b/otcextensions/osclient/load_balancer/v1/listener.py @@ -22,7 +22,7 @@ LOG = logging.getLogger(__name__) -SUPPORTED_PROTOCOLS = ['TCP', 'HTTP', 'HTTPS'] +SUPPORTED_PROTOCOLS = ['TCP', 'HTTP', 'HTTPS', 'UDP'] _formatters = { 'load_balancer_ids': sdk_utils.ListOfIdsColumnBR, @@ -66,7 +66,7 @@ def get_parser(self, prog_name): type=lambda s: s.upper(), choices=SUPPORTED_PROTOCOLS, help=_('Load balancer listener protocol to query\n' - 'One of [`TCP`, `HTTP`, `HTTPS`]') + 'One of [`TCP`, `HTTP`, `HTTPS`, `UDP`]') ) parser.add_argument( '--protocol_port', @@ -158,7 +158,7 @@ def get_parser(self, prog_name): choices=SUPPORTED_PROTOCOLS, required=True, help=_('The protocol for the listener. ' - 'One of [`TCP`, `HTTP`, `HTTPS`]') + 'One of [`TCP`, `HTTP`, `HTTPS`, `UDP`]') ) parser.add_argument( '--protocol_port', diff --git a/otcextensions/osclient/load_balancer/v1/pool.py b/otcextensions/osclient/load_balancer/v1/pool.py index f3a9404a8..a30e4e669 100644 --- a/otcextensions/osclient/load_balancer/v1/pool.py +++ b/otcextensions/osclient/load_balancer/v1/pool.py @@ -32,7 +32,7 @@ LB_ALGORITHM_VALUES = ['LEAST_CONNECTIONS', 'ROUND_ROBIN', 'SOURCE_IP'] -PROTOCOL_VALUES = ['HTTP', 'HTTPS', 'PROXY', 'TCP'] +PROTOCOL_VALUES = ['HTTP', 'HTTPS', 'PROXY', 'TCP', 'UDP'] def _get_columns(item): @@ -84,7 +84,7 @@ def get_parser(self, prog_name): type=lambda s: s.upper(), choices=PROTOCOL_VALUES, help=_('Load balancer pool protocol to query' - 'one of [`HTTP`, `HTTPS`, `PROXY`, `TCP`]') + 'one of [`HTTP`, `HTTPS`, `PROXY`, `TCP`, `UDP`]') ) parser.add_argument( '--load_balancer', @@ -182,7 +182,7 @@ def get_parser(self, prog_name): choices=PROTOCOL_VALUES, required=True, help=_('The protocol for the pool. ' - 'One of [`HTTP`, `HTTPS`, `PROXY`, `TCP`].') + 'One of [`HTTP`, `HTTPS`, `PROXY`, `TCP`, `UDP`].') ) parser.add_argument( '--lb_algorithm', diff --git a/otcextensions/osclient/nat/__init__.py b/otcextensions/osclient/nat/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/osclient/nat/client.py b/otcextensions/osclient/nat/client.py new file mode 100644 index 000000000..110ddff6f --- /dev/null +++ b/otcextensions/osclient/nat/client.py @@ -0,0 +1,53 @@ +# 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. +# +import logging + +from osc_lib import utils + +from otcextensions import sdk +from otcextensions.i18n import _ + +LOG = logging.getLogger(__name__) + +DEFAULT_API_VERSION = '2' +API_VERSION_OPTION = 'os_nat_api_version' +API_NAME = "nat" +API_VERSIONS = { + "2": "openstack.connection.Connection" +} + + +def make_client(instance): + """Returns a rds proxy""" + + conn = instance.sdk_connection + + if getattr(conn, 'nat', None) is None: + LOG.debug('OTC extensions are not registered. Do that now') + sdk.register_otc_extensions(conn) + + LOG.debug('NAT client initialized using OpenStack OTC SDK: %s', + conn.nat) + return conn.nat + + +def build_option_parser(parser): + """Hook to add global options""" + parser.add_argument( + '--os-nat-api-version', + metavar='', + default=utils.env('OS_NAT_API_VERSION'), + help=_("NAT API version, default=%s " + "(Env: OS_NAT_API_VERSION)") % DEFAULT_API_VERSION + ) + return parser diff --git a/otcextensions/osclient/nat/v2/__init__.py b/otcextensions/osclient/nat/v2/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/osclient/nat/v2/dnat.py b/otcextensions/osclient/nat/v2/dnat.py new file mode 100644 index 000000000..d241a650f --- /dev/null +++ b/otcextensions/osclient/nat/v2/dnat.py @@ -0,0 +1,297 @@ +# 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. +# +"""DNAT v2 action implementations""" +import logging + +from osc_lib import utils +from osc_lib import exceptions +from osc_lib.command import command + +from otcextensions.i18n import _ +from otcextensions.common import sdk_utils + +LOG = logging.getLogger(__name__) + + +def _get_columns(item): + column_map = { + } + return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map) + + +class ListDnatRules(command.Lister): + + _description = _("List DNAT Rules.") + columns = ( + 'Id', + 'Nat Gateway Id', + 'Port Id', + 'Private IP', + 'Floating Ip Address', + 'Protocol', + 'Status' + ) + + def get_parser(self, prog_name): + parser = super(ListDnatRules, self).get_parser(prog_name) + + parser.add_argument( + '--id', + metavar='', + help=_("Specifies the ID of the SNAT rule."), + ) + parser.add_argument( + '--limit', + metavar='', + type=int, + help=_("Limit to fetch number of records."), + ) + parser.add_argument( + '--project-id', + metavar='', + help=_("Specifies the project ID."), + ) + parser.add_argument( + '--nat-gateway-id', + metavar='', + help=_("Specifies the NAT gateway ID."), + ) + parser.add_argument( + '--port-id', + metavar='', + help=_("Specifies the port ID of an ECS or a BMS."), + ) + parser.add_argument( + '--private-ip', + metavar='', + help=_("Specifies the private IP address, for example, " + "the IP address of a Direct Connect connection."), + ) + parser.add_argument( + '--internal-service-port', + metavar='', + help=_("Specifies port used by ECSs or BMSs to provide " + "services for external systems."), + ) + parser.add_argument( + '--floating-ip-id', + metavar='', + help=_("Specifies the Floating IP ID."), + ) + parser.add_argument( + '--floating-ip-address', + metavar='', + help=_("Specifies the Floating IP."), + ) + parser.add_argument( + '--external-service-port', + metavar='', + help=_("Specifies the port for providing external services."), + ) + parser.add_argument( + '--protocol', + metavar='', + help=_("Specifies the protocol type." + "Currently, TCP, UDP, and ANY are supported."), + ) + parser.add_argument( + '--status', + metavar='', + help=_("Specifies the status of the DNAT rule.\n" + "ACTIVE: The resource status is normal.\n" + "PENDING_CREATE: The resource is being created.\n" + "PENDING_UPDATE: The resource is being updated.\n" + "PENDING_DELETE: The resource is being deleted.\n" + "EIP_FREEZED: The EIP of the resource is frozen.\n" + "INACTIVE: The resource status is abnormal."), + ) + parser.add_argument( + '--admin-state-up', + metavar='', + help=_("Specifies whether the DNAT rule is enabled or " + "disabled. The value can be:\n" + "true: The DNAT rule is enabled.\n" + "false: The DNAT rule is disabled."), + ) + parser.add_argument( + '--created-at', + metavar='', + help=_("Specifies when the DNAT rule is created (UTC time). " + "Its value rounds to 6 decimal places forseconds. " + "The format is yyyy-mm-ddhh:mm:ss."), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + args_list = [ + 'id', + 'limit', + 'project_id', + 'nat_gateway_id', + 'port_id', + 'private_ip', + 'internal_service_port', + 'floating_ip_id', + 'floating_ip_address', + 'external_service_port', + 'protocol', + 'status', + 'admin_state_up', + 'created_at' + ] + attrs = {} + for arg in args_list: + val = getattr(parsed_args, arg) + if val: + attrs[arg] = val + data = client.dnat_rules(**attrs) + + return ( + self.columns, + (utils.get_item_properties( + s, + self.columns, + ) for s in data) + ) + + +class ShowDnatRule(command.ShowOne): + _description = _("Show Dnat Rule details") + + def get_parser(self, prog_name): + parser = super(ShowDnatRule, self).get_parser(prog_name) + parser.add_argument( + 'dnat', + metavar='', + help=_("Specifies the ID of the SNAT Rule"), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + obj = client.get_dnat_rule(parsed_args.dnat) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class CreateDnatRule(command.ShowOne): + _description = _("Create new DNAT Rule") + + def get_parser(self, prog_name): + parser = super(CreateDnatRule, self).get_parser(prog_name) + parser.add_argument( + '--nat-gateway-id', + metavar='', + required=True, + help=_("Specifies the ID of the NAT Gateway."), + ) + parser.add_argument( + '--port-id', + metavar='', + help=_("Specifies the port ID of an ECS or a BMS."), + ) + parser.add_argument( + '--private-ip', + metavar='', + help=_("Specifies the private IP address, for example, " + "the IP address of a Direct Connect connection."), + ) + parser.add_argument( + '--internal-service-port', + metavar='', + required=True, + help=_("Specifies port used by ECSs or BMSs to provide " + "services for external systems."), + ) + parser.add_argument( + '--floating-ip-id', + metavar="", + required=True, + help=_("Specifies the Floating IP ID. Multiple " + "Floating IPs are separated using commas."), + ) + parser.add_argument( + '--external-service-port', + metavar='', + required=True, + help=_("Specifies the port for providing external services."), + ) + parser.add_argument( + '--protocol', + metavar='', + required=True, + help=_("Specifies the protocol type."), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + + args_list = [ + 'nat_gateway_id', + 'port_id', + 'private_ip', + 'internal_service_port', + 'floating_ip_id', + 'external_service_port', + 'protocol' + ] + attrs = {} + for arg in args_list: + val = getattr(parsed_args, arg) + if val: + attrs[arg] = val + + obj = client.create_dnat_rule(**attrs) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class DeleteDnatRule(command.Command): + + _description = _("Deletes Dnat Rule(s).") + + def get_parser(self, prog_name): + parser = super(DeleteDnatRule, self).get_parser(prog_name) + parser.add_argument( + 'dnat', + metavar='', + nargs='+', + help=_("Specifies the DNAT Rule(s) ID(s) to delete."), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + result = 0 + for dnat in parsed_args.dnat: + try: + obj = client.get_dnat_rule(dnat) + client.delete_dnat_rule(obj.id) + except Exception as e: + result += 1 + LOG.error(_("Failed to delete DNAT rule with " + "ID '%(dnat)s': %(e)s"), + {'dnat': dnat, 'e': e}) + if result > 0: + total = len(parsed_args.dnat) + msg = (_("%(result)s of %(total)s DNAT Rule(s) failed " + "to delete.") % {'result': result, 'total': total}) + raise exceptions.CommandError(msg) diff --git a/otcextensions/osclient/nat/v2/gateway.py b/otcextensions/osclient/nat/v2/gateway.py new file mode 100644 index 000000000..37f34be56 --- /dev/null +++ b/otcextensions/osclient/nat/v2/gateway.py @@ -0,0 +1,308 @@ +# 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. +# +"""NAT Gateway v2 action implementations""" +import logging + +from osc_lib import utils +from osc_lib import exceptions +from osc_lib.command import command + +from otcextensions.i18n import _ +from otcextensions.common import sdk_utils + +LOG = logging.getLogger(__name__) + + +def _get_columns(item): + column_map = { + } + return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map) + + +class ListNatGateways(command.Lister): + + _description = _("List Nat Gateway.") + columns = ('Id', 'Name', 'Spec', 'Router Id', 'Status') + + def get_parser(self, prog_name): + parser = super(ListNatGateways, self).get_parser(prog_name) + + parser.add_argument( + '--id', + metavar='', + help=_("Specifies the ID of the NAT Gateway."), + ) + parser.add_argument( + '--limit', + metavar='', + type=int, + help=_("Limit to fetch number of records."), + ) + parser.add_argument( + '--project-id', + metavar='', + help=_("Specifies the project ID."), + ) + parser.add_argument( + '--name', + metavar='', + help=_("Specifies the Name of the NAT Gateway."), + ) + parser.add_argument( + '--spec', + metavar='', + help=_("Specifies the type of the NAT Gateway. " + "The value of spec can be:\n" + "1: small type, which supports up to 10,000 " + "SNAT connections.\n" + "2: medium type, which supports up to 50,000 " + "SNAT connections.\n" + "3: large type, which supports up to 200,000 " + "SNAT connections.\n" + "4: extra-large type, which supports up to " + "1,000,000 SNAT connections."), + ) + parser.add_argument( + '--router-id', + metavar='', + help=_("Specifies the router ID."), + ) + parser.add_argument( + '--internal-network-id', + metavar='', + help=_("Specifies the network ID of the downstream " + "interface (the next hop of the DVR) of the " + "NAT Gateway."), + ) + parser.add_argument( + '--status', + metavar='', + help=_("Specifies the status of the NAT Gateway.\n" + "ACTIVE: The resource status is normal.\n" + "PENDING_CREATE: The resource is being created.\n" + "PENDING_UPDATE: The resource is being updated.\n" + "PENDING_DELETE: The resource is being deleted.\n" + "EIP_FREEZED: The EIP of the resource is frozen.\n" + "INACTIVE: The resource status is abnormal."), + ) + parser.add_argument( + '--admin-state-up', + metavar='', + help=_("Specifies whether the NAT Gateway is enabled " + "or disabled. The value can be:\n" + "true: The NAT gateway is up.\n" + "false: The NAT gateway is down."), + ) + parser.add_argument( + '--created-at', + metavar='', + help=_("Specifies when the NAT Gateway is created (UTC time). " + "Its valuerounds to 6 decimal places forseconds. " + "The format is yyyy-mm-ddhh:mm:ss."), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + args_list = [ + 'id', + 'limit', + 'project_id', + 'name', + 'spec', + 'router_id', + 'internal_network_id', + 'status', + 'admin_state_up', + 'created_at'] + attrs = {} + for arg in args_list: + val = getattr(parsed_args, arg) + if val: + attrs[arg] = val + + data = client.gateways(**attrs) + + return (self.columns, (utils.get_item_properties(s, self.columns) + for s in data)) + + +class ShowNatGateway(command.ShowOne): + _description = _("Show NAT Gateway details") + + def get_parser(self, prog_name): + parser = super(ShowNatGateway, self).get_parser(prog_name) + parser.add_argument( + 'gateway', + metavar='', + help=_("Specifies the Name or ID of the NAT Gateway."), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + obj = client.find_gateway(parsed_args.gateway) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class CreateNatGateway(command.ShowOne): + _description = _("Create new NAT Gateway") + + def get_parser(self, prog_name): + parser = super(CreateNatGateway, self).get_parser(prog_name) + parser.add_argument( + 'name', + metavar='', + help=_("Specifies the name of the NAT Gateway."), + ) + parser.add_argument( + '--description', + metavar='', + help=_("Provides supplementary information about " + "the NAT Gateway."), + ) + parser.add_argument( + '--spec', + metavar='', + required=True, + help=_( + "Specifies the type of the NAT Gateway. " + "The value can be:\n" + "1: small type, which supports up to 10,000 " + "SNAT connections.\n" + "2: medium type, which supports up to 50,000 " + "SNAT connections.\n" + "3: large type, which supports up to 200,000 " + "SNAT connections.\n" + "4: extra-large type, which supports up to " + "1,000,000 SNAT connections."), + ) + parser.add_argument( + '--router-id', + metavar='', + required=True, + help=_("Specifies the VPC ID."), + ) + parser.add_argument( + '--internal-network-id', + metavar='', + required=True, + help=_("Specifies the network ID of the downstream interface " + "(the next hop of the DVR) of the NAT Gateway."), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + + args_list = [ + 'name', + 'description', + 'spec', + 'router_id', + 'internal_network_id'] + attrs = {} + for arg in args_list: + val = getattr(parsed_args, arg) + if val: + attrs[arg] = val + + obj = client.create_gateway(**attrs) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class UpdateNatGateway(command.ShowOne): + _description = _("Update a NAT Gateway.") + + def get_parser(self, prog_name): + parser = super(UpdateNatGateway, self).get_parser(prog_name) + parser.add_argument( + 'gateway', + metavar='', + help=_("Specifies the Name or ID of the NAT Gateway."), + ) + parser.add_argument( + '--name', + metavar='', + help=_("Specifies the name of the NAT Gateway."), + ) + parser.add_argument( + '--description', + metavar='', + help=_("Provides supplementary informationabout the NAT gateway."), + ) + parser.add_argument( + '--spec', + metavar='', + help=_("Specifies the type of the NAT Gateway."), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + args_list = [ + 'name', 'description', 'spec' + ] + attrs = {} + for arg in args_list: + if getattr(parsed_args, arg): + attrs[arg] = getattr(parsed_args, arg) + nat_gateway = client.find_gateway(parsed_args.gateway) + + obj = client.update_gateway(nat_gateway.id, **attrs) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class DeleteNatGateway(command.Command): + + _description = _("Deletes NAT Gateway.") + + def get_parser(self, prog_name): + parser = super(DeleteNatGateway, self).get_parser(prog_name) + parser.add_argument( + 'gateway', + metavar='', + nargs='+', + help=_("Nat Gateway(s) to delete (Name or ID)"), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + result = 0 + for gateway in parsed_args.gateway: + try: + obj = client.find_gateway(gateway) + client.delete_gateway(obj.id) + except Exception as e: + result += 1 + LOG.error(_("Failed to delete Nat Gateway with " + "name or ID '%(gateway)s': %(e)s"), + {'gateway': gateway, 'e': e}) + if result > 0: + total = len(parsed_args.gateway) + msg = (_("%(result)s of %(total)s NAT Gateway(s) failed " + "to delete.") % {'result': result, 'total': total}) + raise exceptions.CommandError(msg) diff --git a/otcextensions/osclient/nat/v2/snat.py b/otcextensions/osclient/nat/v2/snat.py new file mode 100644 index 000000000..4dc54cabe --- /dev/null +++ b/otcextensions/osclient/nat/v2/snat.py @@ -0,0 +1,276 @@ +# 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. +# +"""SNAT v2 action implementations""" +import logging + +from osc_lib import utils +from osc_lib import exceptions +from osc_lib.command import command + +from otcextensions.i18n import _ +from otcextensions.common import sdk_utils + +LOG = logging.getLogger(__name__) + + +def _get_columns(item): + column_map = { + } + return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map) + + +class ListSnatRules(command.Lister): + + _description = _("List SNAT Rules.") + columns = ( + 'Id', + 'Nat Gateway Id', + 'Network Id', + 'Cidr', + 'Floating Ip Address', + 'Status' + ) + + def get_parser(self, prog_name): + parser = super(ListSnatRules, self).get_parser(prog_name) + + parser.add_argument( + '--id', + metavar='', + help=_("Specifies the ID of the SNAT rule."), + ) + parser.add_argument( + '--limit', + metavar='', + type=int, + help=_("Limit to fetch number of records."), + ) + parser.add_argument( + '--project-id', + metavar='', + help=_("Specifies the project ID."), + ) + parser.add_argument( + '--nat-gateway-id', + metavar='', + help=_("Specifies the NAT gateway ID."), + ) + parser.add_argument( + '--network-id', + metavar='', + help=_("Specifies the network ID used by the SNAT rule."), + ) + parser.add_argument( + '--cidr', + metavar='', + help=_("Specifies a subset of the VPC subnet CIDR block or " + "a CIDR block of Direct Connect connection."), + ) + parser.add_argument( + '--source-type', + metavar='', + help=_("Specifies Source Type."), + ) + parser.add_argument( + '--floating-ip-id', + metavar='', + help=_("Specifies the Floating IP ID."), + ) + parser.add_argument( + '--floating-ip-address', + metavar='', + help=_("Specifies the Floating IP."), + ) + parser.add_argument( + '--status', + metavar='', + help=_("Specifies the status of the SNAT rule.\n" + "ACTIVE: The resource status is normal.\n" + "PENDING_CREATE: The resource is being created.\n" + "PENDING_UPDATE: The resource is being updated.\n" + "PENDING_DELETE: The resource is being deleted.\n" + "EIP_FREEZED: The EIP of the resource is frozen.\n" + "INACTIVE: The resource status is abnormal."), + ) + parser.add_argument( + '--admin-state-up', + metavar='', + help=_("Specifies whether the SNAT rule is enabled or " + "disabled. The value can be:\n" + "true: The SNAT rule is enabled.\n" + "false: The SNAT rule is disabled."), + ) + parser.add_argument( + '--created-at', + metavar='', + help=_("Specifies when the SNAT rule is created (UTC time). " + "Its value rounds to 6 decimal places for seconds. " + "The format is yyyy-mm-ddhh:mm:ss."), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + args_list = [ + 'id', + 'limit', + 'network_id', + 'project_id', + 'nat_gateway_id', + 'network_id', + 'cidr', + 'source_type', + 'floating_ip_id', + 'floating_ip_address', + 'status', + 'admin_state_up', + 'created_at'] + attrs = {} + for arg in args_list: + val = getattr(parsed_args, arg) + if val: + attrs[arg] = val + + data = client.snat_rules(**attrs) + + return ( + self.columns, + (utils.get_item_properties( + s, + self.columns, + ) for s in data) + ) + + +class ShowSnatRule(command.ShowOne): + _description = _("Show Snat Rule details") + + def get_parser(self, prog_name): + parser = super(ShowSnatRule, self).get_parser(prog_name) + parser.add_argument( + 'snat', + metavar='', + help=_("Specifies the ID of the SNAT Rule."), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + obj = client.get_snat_rule(parsed_args.snat) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class CreateSnatRule(command.ShowOne): + _description = _("Create new SNAT Rule") + + def get_parser(self, prog_name): + parser = super(CreateSnatRule, self).get_parser(prog_name) + parser.add_argument( + '--nat-gateway-id', + required=True, + metavar='', + help=_("Specifies the ID of the NAT gateway."), + ) + parser.add_argument( + '--floating-ip-id', + metavar='', + required=True, + help=_("Specifies the Floating IP ID. Multiple " + "Floating IPs are separated using commas."), + ) + parser.add_argument( + '--network-id', + metavar='', + help=_("Specifies the network ID used by the SNAT rule. " + "This parameter and cidr are alternative."), + ) + parser.add_argument( + '--cidr', + metavar='', + help=_("Specifies CIDR, which can be in the format of a " + "network segment or a host IP address."), + ) + parser.add_argument( + '--source-type', + metavar='', + help=_( + "Specifies the source type.\n" + "0: Either network_id or cidr can be " + "specified in a VPC.\n" + "1: Only cidr can be specified over a " + "Direct Connect connection.\n" + "If no value is entered, the default " + "value 0 (VPC) is used."), + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + + args_list = [ + 'nat_gateway_id', + 'floating_ip_id', + 'network_id', + 'cidr', + 'source_type' + ] + attrs = {} + for arg in args_list: + val = getattr(parsed_args, arg) + if val: + attrs[arg] = val + + obj = client.create_snat_rule(**attrs) + + display_columns, columns = _get_columns(obj) + data = utils.get_item_properties(obj, columns) + + return (display_columns, data) + + +class DeleteSnatRule(command.Command): + + _description = _("Deletes Snat Rule(s).") + + def get_parser(self, prog_name): + parser = super(DeleteSnatRule, self).get_parser(prog_name) + parser.add_argument( + 'snat', + metavar='', + nargs='+', + help=_("Specifies the SNAT rule(s) ID(s) to delete."), + ) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.nat + result = 0 + for snat in parsed_args.snat: + try: + obj = client.get_snat_rule(snat) + client.delete_snat_rule(obj.id) + except Exception as e: + result += 1 + LOG.error(_("Failed to delete SNAT rule with " + "ID '%(snat)s': %(e)s"), + {'snat': snat, 'e': e}) + if result > 0: + total = len(parsed_args.snat) + msg = (_("%(result)s of %(total)s SNAT Rule(s) failed " + "to delete.") % {'result': result, 'total': total}) + raise exceptions.CommandError(msg) diff --git a/otcextensions/osclient/rds/v3/instance.py b/otcextensions/osclient/rds/v3/instance.py index b03f0f863..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): @@ -179,14 +178,15 @@ def get_parser(self, prog_name): help=_("Name of the instance.") ) parser.add_argument( - 'flavor_ref', - metavar='', + 'flavor', + metavar='', help=_("Flavor spec_code") ) disk_group = parser.add_argument_group('Disk data') disk_group.add_argument( '--size', metavar='', + dest='volume_size', type=int, required=True, help=_("Size of the instance disk volume in GB. ") @@ -196,6 +196,7 @@ def get_parser(self, prog_name): metavar='{' + ','.join(DISK_TYPE_CHOICES) + '}', type=lambda s: s.upper(), required=True, + dest='volume_type', choices=[s.upper() for s in DISK_TYPE_CHOICES], help=_("Volume type. (COMMON, ULTRAHIGH).") ) @@ -224,7 +225,7 @@ def get_parser(self, prog_name): ) parser.add_argument( '--configuration', - dest='configuration_id', + dest='configuration', metavar='', default=None, help=_("ID of the configuration group to attach to the instance.") @@ -253,18 +254,20 @@ def get_parser(self, prog_name): new_instance_group.add_argument( '--router-id', metavar='', + dest='router', help=_('ID of a Router the DB should be connected to') ) new_instance_group.add_argument( '--network-id', metavar='', + dest='network', help=_('ID of a Neutron network the DB should be connected to.') ) new_instance_group.add_argument( '--security-group-id', - dest='security_group_id', + dest='security_group', metavar='', - help=_('Security group ID') + help=_('Security group ID.') ) parser.add_argument( '--ha-mode', @@ -272,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', @@ -301,6 +304,17 @@ def get_parser(self, prog_name): metavar='', help=_('Backup ID or Name to create new instance from.') ) + create_from_group.add_argument( + '--backup-keepdays', + metavar='', + help=_('Specifies the retention days for specific backup files.') + ) + create_from_group.add_argument( + '--backup-timeframe', + metavar='', + help=_('Specifies the backup time window. Automated backups will ' + 'be triggered during the backup time window.') + ) create_from_group.add_argument( '--restore-time', metavar='