From f1079b63b6e84ca49b261d1f53a3dfc7a609d51f Mon Sep 17 00:00:00 2001 From: Brian Gustafson Date: Tue, 28 Mar 2017 17:05:54 -0700 Subject: [PATCH] 1.2.0 Release --- CHANGELOG.rst | 16 ++ docs/installation.rst | 148 ++++++------------ .../core/models/attach_volume_details.py | 4 +- .../core/models/create_subnet_details.py | 63 ++++++++ oraclebmc/core/models/create_vcn_details.py | 67 +++++++- oraclebmc/core/models/dhcp_dns_option.py | 38 +++-- oraclebmc/core/models/dhcp_option.py | 10 +- .../core/models/launch_instance_details.py | 61 ++++++++ oraclebmc/core/models/subnet.py | 94 +++++++++++ oraclebmc/core/models/vcn.py | 96 +++++++++++- oraclebmc/core/models/vnic.py | 71 ++++++++- oraclebmc/core/models/volume_attachment.py | 4 +- oraclebmc/core/virtual_network_client.py | 17 +- oraclebmc/identity/identity_client.py | 1 + .../object_storage/object_storage_client.py | 1 + oraclebmc/version.py | 2 +- tests/conftest.py | 14 +- tests/integ/test_large_file_transfer.py | 4 +- tests/integ/test_launch_instance_tutorial.py | 5 +- tests/util.py | 8 +- tox.ini | 4 +- 21 files changed, 581 insertions(+), 147 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e7ffce5320..3464088315 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog `_. +==================== + 1.2.0 - 2017-03-28 +==================== + +------- + Fixed +------- + +* Allow service responses to deserialize to base classes when unknown subtypes are returned. Previously this would result in an exception. + +------- + Added +------- + +* Support hostnames for instances and DNS labels for VCNs and subnets. + ==================== 1.1.2 - 2017-03-16 ==================== diff --git a/docs/installation.rst b/docs/installation.rst index a87f6cf039..8aacd2ba30 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -7,8 +7,8 @@ This topic describes how to install, configure, and use the Oracle Bare Metal Cl The Python SDK supports operations for the following services: * Identity and Access Management Service -* Object Storage Service * Core Services (Networking Service, Compute Service, and Block Volume Service) +* Object Storage Service =============== Prerequisites @@ -22,25 +22,25 @@ The Python SDK supports operations for the following services: Oracle Bare Metal Cloud Services policies, see `Common Policies`_ in the User Guide. * Python version 2.7.5 or 3.5 or later, running on Mac, Windows, or Linux. * The Python SDK uses the `cryptography.io`_ library, which has its own additional `build requirements`_. -* The Python SDK requires `TLS 1.2`_, which versions of `openssl`_ before 1.0.1 do not provide. - If your version of Python was built against an earlier version, you will need to install a new - Python that links against a newer version. * A keypair used for signing API requests, with the public key uploaded to Oracle. Only the user calling - the API should be in possession of the private key. See Configuring the SDK below. + the API should be in possession of the private key. (For more information, see `Configuring the SDK`_.) -.. _Adding Users: https://docs.us-phoenix-1.oraclecloud.com/Content/GSG/Tasks/addingusers.htm -.. _Common Policies: https://docs.us-phoenix-1.oraclecloud.com/Content/Identity/Concepts/commonpolicies.htm -.. _cryptography.io: https://cryptography.io/en/latest/ -.. _build requirements: https://cryptography.io/en/latest/installation/ -.. _TLS 1.2: https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdks.htm -.. _PyPI: https://pypi.python.org/pypi -.. _openssl: https://www.openssl.org/ ==================================== Downloading and Installing the SDK ==================================== -You can install the Python SDK from GitHub or through the Python Package Index (PyPI). +You can install the Python SDK through the Python Package Index (PyPI), or alternatively through GitHub. + +**PyPi** + +To install from `PyPI `_: + + Use the following command:: + + pip install oraclebmc + +**GitHub** To install from GitHub: @@ -56,15 +56,10 @@ To install from GitHub: If you're unable to install the whl file, make sure pip is up to date. Use ``pip install -U pip`` and then try to install the whl file again. -To install from `PyPI `_: - - Use the following command:: - pip install oraclebmc +**Virtual environment (Optional)** - -(Optional) -Oracle recommends that you run the SDK in a virtual environment with virtualenv. +Although optional, Oracle recommends that you run the SDK in a virtual environment with virtualenv. With Linux, it's usually in a separate package from the main Python package. If you need to install virtualenv, use pip install virtualenv. @@ -89,37 +84,27 @@ For instructions, see `SDK and Tool Configuration`_ in the User Guide. .. _SDK and Tool Configuration: https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm -==================== - Note for OSX Users -==================== +Verify OpenSSL Version +---------------------- -OS X already has Python and OpenSSL preinstalled. However, the preinstalled OpenSSL is probably not version 1.0.x or -newer, which is what you need. To check whether you have a supported OpenSSL version, run this command:: +The supported version of OpenSSL for the Python SDK is version 1.0.1 or newer. Run the following command to find out the version of OpenSSL that you have:: python -c "import ssl; print(ssl.OPENSSL_VERSION)" -If the version is ``0.9.x``, you need to reinstall Python and OpenSSL using Homebrew -(a package manager for the OS X platform). - -If you've never used Homebrew to install Python on the system, follow these instructions: - -1. Download and install `Homebrew`_. -2. Use these commands to update Homebrew and then install OpenSSL and Python: - :: +If the version is lower than ``1.0.1``, run the following command to bypass the version issue:: - brew update - brew install openssl - brew install python - - .. note:: + pip install requests[security] - If you get a "Permission denied" message when running any brew command, it's probably because - the OS X permissions model conflicts with Homebrew's default installation location of ``/usr/local``. - You can usually fix this by taking back control of the folder with ``sudo chown -R $(whoami) /usr/local``. +This command instructs the `requests `_ +library used by the Python SDK to use the version of OpenSSL that is bundled with the `cryptography `_ +library used by the SDK. -Check the OpenSSL version again. If it's still 0.9, see `Troubleshooting Mac Issues`_. +**Note:** +If you don't want to use ``requests[security]`` you can update OpenSSL as you normally would. For example, on OS X, use Homebrew to update OpenSSL using the following commands:: -.. _Homebrew: http://brew.sh/ + brew update + brew install openssl + brew install python ================= Troubleshooting @@ -127,66 +112,27 @@ Check the OpenSSL version again. If it's still 0.9, see `Troubleshooting Mac Iss You might encounter issues when installing Python or the SDK, or using the SDK itself. ----------------------------- - Troubleshooting OEL Issues ----------------------------- -On OEL 7.3, if you encounter permission issues when running pip install, you might need to use ``sudo``. +Service Errors +-------------- +Any operation resulting in a service error will cause an exception of type oraclebmc.exceptions.ServiceError to be thrown by the SDK. For information about common service errors returned by BMCS, see `API Errors `_ +. ----------------------------- - Troubleshooting Mac Issues ----------------------------- +Oracle Linux Permission Issues +------------------------------ +On Oracle Linux 7.3, if you encounter permission issues when running pip install, you might need to use ``sudo``. -There are several general types of issues you might encounter. - -OpenSSL Version Still 0.9.x -=========================== - -If the Python installation instructions listed in Mac above still result in OpenSSL version 0.9.x, -it might be one of these reasons: - -* Your python command is pointing to the wrong Python installation. To check, use the which python command. - The default system Python is at ``/usr/bin/python``, whereas the Homebrew-installed version that you want - is typically at ``usr/local/bin``. Edit the ``etc/paths`` file to move the ``usr/local/bin`` line to the - top of the list. Don't remove the system Python line. - -* Your virtualenv is pointing to the wrong Python installation. By default, virtualenv uses ``/usr/bin/python``, - whereas the Homebrew-installed Python is typically at ``usr/local/bin``. To fix this, use this command:: - - virtualenv -p - - For example, if your installation is at /usr/local/bin/python:: - - virtualenv -p /usr/local/bin/python bmcs_sdk_env - -To determine the location of your Homebrew-installed Python, try one of these commands:: - - brew info python - which -a python # (the -a option lists all the Python installations) - brew doctor - -If the above items don't fix the problem, the best strategy is to uninstall and reinstall Python with the following -commands. Note that you will need to reinstall any packages you previously installed into Homebrew's Python via pip. -:: - - brew uninstall openssl - brew uninstall python - brew update - brew install python - -If you're still having problems, you may need slightly different commands depending on the version of Homebrew -that was used to install your Python or OpenSSL libraries. Here's a recent post that may be helpful: -`Updating Python and OpenSSL on OS X`__. - -__ https://community.dev.hpe.com/t5/Blogs/Updating-Python-and-Openssl-on-OS-X/ba-p/237791 - -SSL/TLS or Certificate Exception -================================ - -When trying to use the SDK, if you get an exception related to SSL/TLS or certificates/certificate validation, -the underlying issue is that OpenSSL is the wrong version (0.9.x). See the solution for uninstalling and -reinstalling Python above. Make sure to also reinstall the wheel with this command:: - - pip install oraclebmc-*-py2.py3-none-any.whl +SSL/TLS or Certificate Issues +----------------------------- +When trying to use the SDK, if you get an exception related to SSL/TLS or certificates/certificate validation, see the command for installing requests[security] in `Verify OpenSSL Version`_. +.. _Adding Users: https://docs.us-phoenix-1.oraclecloud.com/Content/GSG/Tasks/addingusers.htm +.. _Common Policies: https://docs.us-phoenix-1.oraclecloud.com/Content/Identity/Concepts/commonpolicies.htm +.. _cryptography.io: https://cryptography.io/en/latest/ +.. _build requirements: https://cryptography.io/en/latest/installation/ +.. _TLS 1.2: https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdks.htm +.. _PyPI link: https://pypi.python.org/pypi +.. _openssl: https://www.openssl.org/ +.. _ConfiguringSDK: Configuring the SDK +.. _OSXUsers: Verify OpenSSL Version \ No newline at end of file diff --git a/oraclebmc/core/models/attach_volume_details.py b/oraclebmc/core/models/attach_volume_details.py index 22db178a4d..662abfe681 100644 --- a/oraclebmc/core/models/attach_volume_details.py +++ b/oraclebmc/core/models/attach_volume_details.py @@ -38,8 +38,8 @@ def get_subtype(object_dictionary): if type == 'iscsi': return 'AttachIScsiVolumeDetails' - - raise ValueError('Could not resolve subtype type based on the object dictionary.') + else: + return 'AttachVolumeDetails' @property def display_name(self): diff --git a/oraclebmc/core/models/create_subnet_details.py b/oraclebmc/core/models/create_subnet_details.py index bc8979eb5d..9f9bd20254 100644 --- a/oraclebmc/core/models/create_subnet_details.py +++ b/oraclebmc/core/models/create_subnet_details.py @@ -15,6 +15,7 @@ def __init__(self): 'compartment_id': 'str', 'dhcp_options_id': 'str', 'display_name': 'str', + 'dns_label': 'str', 'route_table_id': 'str', 'security_list_ids': 'list[str]', 'vcn_id': 'str' @@ -26,6 +27,7 @@ def __init__(self): 'compartment_id': 'compartmentId', 'dhcp_options_id': 'dhcpOptionsId', 'display_name': 'displayName', + 'dns_label': 'dnsLabel', 'route_table_id': 'routeTableId', 'security_list_ids': 'securityListIds', 'vcn_id': 'vcnId' @@ -36,6 +38,7 @@ def __init__(self): self._compartment_id = None self._dhcp_options_id = None self._display_name = None + self._dns_label = None self._route_table_id = None self._security_list_ids = None self._vcn_id = None @@ -170,6 +173,66 @@ def display_name(self, display_name): """ self._display_name = display_name + @property + def dns_label(self): + """ + Gets the dns_label of this CreateSubnetDetails. + A DNS label for the subnet, used in conjunction with the VNIC's hostname and + VCN's DNS label to form a fully qualified domain name (FQDN) for each VNIC + within this subnet (e.g., `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + Must be unique within the VCN and comply with + `RFC 952`__ and + `RFC 1123`__. The value cannot be changed. + + This value must be set if you want to use the VCN Resolver to resolve the + hostnames of instances in the subnet. It can only be set if the VCN itself + was created with a DNS label. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `subnet-123` + + __ https://tools.ietf.org/html/rfc952 + __ https://tools.ietf.org/html/rfc1123 + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :return: The dns_label of this CreateSubnetDetails. + :rtype: str + """ + return self._dns_label + + @dns_label.setter + def dns_label(self, dns_label): + """ + Sets the dns_label of this CreateSubnetDetails. + A DNS label for the subnet, used in conjunction with the VNIC's hostname and + VCN's DNS label to form a fully qualified domain name (FQDN) for each VNIC + within this subnet (e.g., `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + Must be unique within the VCN and comply with + `RFC 952`__ and + `RFC 1123`__. The value cannot be changed. + + This value must be set if you want to use the VCN Resolver to resolve the + hostnames of instances in the subnet. It can only be set if the VCN itself + was created with a DNS label. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `subnet-123` + + __ https://tools.ietf.org/html/rfc952 + __ https://tools.ietf.org/html/rfc1123 + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :param dns_label: The dns_label of this CreateSubnetDetails. + :type: str + """ + self._dns_label = dns_label + @property def route_table_id(self): """ diff --git a/oraclebmc/core/models/create_vcn_details.py b/oraclebmc/core/models/create_vcn_details.py index 8fe4e76f1a..8eef20a579 100644 --- a/oraclebmc/core/models/create_vcn_details.py +++ b/oraclebmc/core/models/create_vcn_details.py @@ -12,18 +12,21 @@ def __init__(self): self.swagger_types = { 'cidr_block': 'str', 'compartment_id': 'str', - 'display_name': 'str' + 'display_name': 'str', + 'dns_label': 'str' } self.attribute_map = { 'cidr_block': 'cidrBlock', 'compartment_id': 'compartmentId', - 'display_name': 'displayName' + 'display_name': 'displayName', + 'dns_label': 'dnsLabel' } self._cidr_block = None self._compartment_id = None self._display_name = None + self._dns_label = None @property def cidr_block(self): @@ -101,6 +104,66 @@ def display_name(self, display_name): """ self._display_name = display_name + @property + def dns_label(self): + """ + Gets the dns_label of this CreateVcnDetails. + A DNS label for the VCN, used in conjunction with the VNIC's hostname and + subnet's DNS label to form a fully qualified domain name (FQDN) for each VNIC + within this subnet (e.g., `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + Not required to be unique, but it's a best practice to set unique DNS labels + for VCNs in your tenancy. Must comply with + `RFC 952`__ and + `RFC 1123`__. The value cannot be changed. + + You must set this value if you want instances to be able to use hostnames to + resolve other instances in the VCN. Otherwise the VCN Resolver will not work. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `vcn-1` + + __ https://tools.ietf.org/html/rfc952 + __ https://tools.ietf.org/html/rfc1123 + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :return: The dns_label of this CreateVcnDetails. + :rtype: str + """ + return self._dns_label + + @dns_label.setter + def dns_label(self, dns_label): + """ + Sets the dns_label of this CreateVcnDetails. + A DNS label for the VCN, used in conjunction with the VNIC's hostname and + subnet's DNS label to form a fully qualified domain name (FQDN) for each VNIC + within this subnet (e.g., `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + Not required to be unique, but it's a best practice to set unique DNS labels + for VCNs in your tenancy. Must comply with + `RFC 952`__ and + `RFC 1123`__. The value cannot be changed. + + You must set this value if you want instances to be able to use hostnames to + resolve other instances in the VCN. Otherwise the VCN Resolver will not work. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `vcn-1` + + __ https://tools.ietf.org/html/rfc952 + __ https://tools.ietf.org/html/rfc1123 + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :param dns_label: The dns_label of this CreateVcnDetails. + :type: str + """ + self._dns_label = dns_label + def __repr__(self): return formatted_flat_dict(self) diff --git a/oraclebmc/core/models/dhcp_dns_option.py b/oraclebmc/core/models/dhcp_dns_option.py index da91cab78b..31e0ea82b5 100644 --- a/oraclebmc/core/models/dhcp_dns_option.py +++ b/oraclebmc/core/models/dhcp_dns_option.py @@ -56,12 +56,19 @@ def custom_dns_servers(self, custom_dns_servers): def server_type(self): """ Gets the server_type of this DhcpDnsOption. - - *VcnLocal:* Reserved for future use. - - *VcnLocalPlusInternet:* Instances can resolve only internet host - names (no Internet Gateway is required). The instances still need to use - their IP addresses to communicate with each other. This is the default - value in the default set of DHCP options in the VCN. - - *CustomDnsServer:* Instances use a DNS server of your choice (three maximum). + - **VcnLocal:** Reserved for future use. + + - **VcnLocalPlusInternet:** Also referred to as \"Internet and VCN Resolver\". + Instances can resolve internet hostnames (no Internet Gateway is required), + and can resolve hostnames of instances in the VCN. This is the default + value in the default set of DHCP options in the VCN. For the VCN Resolver to + work across the VCN, there must also be a DNS label set for the VCN, a DNS + label set for each subnet, and a hostname for each instance. For more information, + see `DNS in Your Virtual Cloud Network`__. + + - **CustomDnsServer:** Instances use a DNS server of your choice (three maximum). + + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm :return: The server_type of this DhcpDnsOption. @@ -73,12 +80,19 @@ def server_type(self): def server_type(self, server_type): """ Sets the server_type of this DhcpDnsOption. - - *VcnLocal:* Reserved for future use. - - *VcnLocalPlusInternet:* Instances can resolve only internet host - names (no Internet Gateway is required). The instances still need to use - their IP addresses to communicate with each other. This is the default - value in the default set of DHCP options in the VCN. - - *CustomDnsServer:* Instances use a DNS server of your choice (three maximum). + - **VcnLocal:** Reserved for future use. + + - **VcnLocalPlusInternet:** Also referred to as \"Internet and VCN Resolver\". + Instances can resolve internet hostnames (no Internet Gateway is required), + and can resolve hostnames of instances in the VCN. This is the default + value in the default set of DHCP options in the VCN. For the VCN Resolver to + work across the VCN, there must also be a DNS label set for the VCN, a DNS + label set for each subnet, and a hostname for each instance. For more information, + see `DNS in Your Virtual Cloud Network`__. + + - **CustomDnsServer:** Instances use a DNS server of your choice (three maximum). + + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm :param server_type: The server_type of this DhcpDnsOption. diff --git a/oraclebmc/core/models/dhcp_option.py b/oraclebmc/core/models/dhcp_option.py index 385e72ac4b..672ea454d9 100644 --- a/oraclebmc/core/models/dhcp_option.py +++ b/oraclebmc/core/models/dhcp_option.py @@ -29,13 +29,16 @@ def get_subtype(object_dictionary): if type == 'DomainNameServer': return 'DhcpDnsOption' - - raise ValueError('Could not resolve subtype type based on the object dictionary.') + else: + return 'DhcpOption' @property def type(self): """ Gets the type of this DhcpOption. + The specific DHCP option. `DomainNameServer` + (for :class:`DhcpDnsOption`). + :return: The type of this DhcpOption. :rtype: str @@ -46,6 +49,9 @@ def type(self): def type(self, type): """ Sets the type of this DhcpOption. + The specific DHCP option. `DomainNameServer` + (for :class:`DhcpDnsOption`). + :param type: The type of this DhcpOption. :type: str diff --git a/oraclebmc/core/models/launch_instance_details.py b/oraclebmc/core/models/launch_instance_details.py index 8c6b2f7729..dbbb6bec7e 100644 --- a/oraclebmc/core/models/launch_instance_details.py +++ b/oraclebmc/core/models/launch_instance_details.py @@ -13,6 +13,7 @@ def __init__(self): 'availability_domain': 'str', 'compartment_id': 'str', 'display_name': 'str', + 'hostname_label': 'str', 'image_id': 'str', 'ipxe_script': 'str', 'metadata': 'dict(str, str)', @@ -24,6 +25,7 @@ def __init__(self): 'availability_domain': 'availabilityDomain', 'compartment_id': 'compartmentId', 'display_name': 'displayName', + 'hostname_label': 'hostnameLabel', 'image_id': 'imageId', 'ipxe_script': 'ipxeScript', 'metadata': 'metadata', @@ -34,6 +36,7 @@ def __init__(self): self._availability_domain = None self._compartment_id = None self._display_name = None + self._hostname_label = None self._image_id = None self._ipxe_script = None self._metadata = None @@ -120,6 +123,64 @@ def display_name(self, display_name): """ self._display_name = display_name + @property + def hostname_label(self): + """ + Gets the hostname_label of this LaunchInstanceDetails. + The hostname for the VNIC that is created during instance launch. + Used for DNS. The value is the hostname portion of the instance's + fully qualified domain name (FQDN) (e.g., `bminstance-1` in FQDN + `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + Must be unique across all VNICs in the subnet and comply with + `RFC 952`__ and + `RFC 1123`__. + The value cannot be changed, and it can be retrieved from the + :class:`Vnic`. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `bminstance-1` + + __ https://tools.ietf.org/html/rfc952 + __ https://tools.ietf.org/html/rfc1123 + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :return: The hostname_label of this LaunchInstanceDetails. + :rtype: str + """ + return self._hostname_label + + @hostname_label.setter + def hostname_label(self, hostname_label): + """ + Sets the hostname_label of this LaunchInstanceDetails. + The hostname for the VNIC that is created during instance launch. + Used for DNS. The value is the hostname portion of the instance's + fully qualified domain name (FQDN) (e.g., `bminstance-1` in FQDN + `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + Must be unique across all VNICs in the subnet and comply with + `RFC 952`__ and + `RFC 1123`__. + The value cannot be changed, and it can be retrieved from the + :class:`Vnic`. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `bminstance-1` + + __ https://tools.ietf.org/html/rfc952 + __ https://tools.ietf.org/html/rfc1123 + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :param hostname_label: The hostname_label of this LaunchInstanceDetails. + :type: str + """ + self._hostname_label = hostname_label + @property def image_id(self): """ diff --git a/oraclebmc/core/models/subnet.py b/oraclebmc/core/models/subnet.py index a622ee5ff8..9b5882b9c8 100644 --- a/oraclebmc/core/models/subnet.py +++ b/oraclebmc/core/models/subnet.py @@ -15,10 +15,12 @@ def __init__(self): 'compartment_id': 'str', 'dhcp_options_id': 'str', 'display_name': 'str', + 'dns_label': 'str', 'id': 'str', 'lifecycle_state': 'str', 'route_table_id': 'str', 'security_list_ids': 'list[str]', + 'subnet_domain_name': 'str', 'time_created': 'datetime', 'vcn_id': 'str', 'virtual_router_ip': 'str', @@ -31,10 +33,12 @@ def __init__(self): 'compartment_id': 'compartmentId', 'dhcp_options_id': 'dhcpOptionsId', 'display_name': 'displayName', + 'dns_label': 'dnsLabel', 'id': 'id', 'lifecycle_state': 'lifecycleState', 'route_table_id': 'routeTableId', 'security_list_ids': 'securityListIds', + 'subnet_domain_name': 'subnetDomainName', 'time_created': 'timeCreated', 'vcn_id': 'vcnId', 'virtual_router_ip': 'virtualRouterIp', @@ -46,10 +50,12 @@ def __init__(self): self._compartment_id = None self._dhcp_options_id = None self._display_name = None + self._dns_label = None self._id = None self._lifecycle_state = None self._route_table_id = None self._security_list_ids = None + self._subnet_domain_name = None self._time_created = None self._vcn_id = None self._virtual_router_ip = None @@ -183,6 +189,54 @@ def display_name(self, display_name): """ self._display_name = display_name + @property + def dns_label(self): + """ + Gets the dns_label of this Subnet. + A DNS label for the subnet, used in conjunction with the VNIC's hostname and + VCN's DNS label to form a fully qualified domain name (FQDN) for each VNIC + within this subnet (e.g., `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + + The absence of this parameter means the VCN Resolver will not resolve hostnames + of instances in this subnet. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `subnet-123` + + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :return: The dns_label of this Subnet. + :rtype: str + """ + return self._dns_label + + @dns_label.setter + def dns_label(self, dns_label): + """ + Sets the dns_label of this Subnet. + A DNS label for the subnet, used in conjunction with the VNIC's hostname and + VCN's DNS label to form a fully qualified domain name (FQDN) for each VNIC + within this subnet (e.g., `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + + The absence of this parameter means the VCN Resolver will not resolve hostnames + of instances in this subnet. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `subnet-123` + + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :param dns_label: The dns_label of this Subnet. + :type: str + """ + self._dns_label = dns_label + @property def id(self): """ @@ -285,6 +339,46 @@ def security_list_ids(self, security_list_ids): """ self._security_list_ids = security_list_ids + @property + def subnet_domain_name(self): + """ + Gets the subnet_domain_name of this Subnet. + The subnet's domain name, which consists of the subnet's DNS label, + the VCN's DNS label, and the `oraclevcn.com` domain. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `subnet-123.vcn-1.oraclevcn.com` + + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :return: The subnet_domain_name of this Subnet. + :rtype: str + """ + return self._subnet_domain_name + + @subnet_domain_name.setter + def subnet_domain_name(self, subnet_domain_name): + """ + Sets the subnet_domain_name of this Subnet. + The subnet's domain name, which consists of the subnet's DNS label, + the VCN's DNS label, and the `oraclevcn.com` domain. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `subnet-123.vcn-1.oraclevcn.com` + + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :param subnet_domain_name: The subnet_domain_name of this Subnet. + :type: str + """ + self._subnet_domain_name = subnet_domain_name + @property def time_created(self): """ diff --git a/oraclebmc/core/models/vcn.py b/oraclebmc/core/models/vcn.py index bfe0a17628..9b126b0b51 100644 --- a/oraclebmc/core/models/vcn.py +++ b/oraclebmc/core/models/vcn.py @@ -16,9 +16,11 @@ def __init__(self): 'default_route_table_id': 'str', 'default_security_list_id': 'str', 'display_name': 'str', + 'dns_label': 'str', 'id': 'str', 'lifecycle_state': 'str', - 'time_created': 'datetime' + 'time_created': 'datetime', + 'vcn_domain_name': 'str' } self.attribute_map = { @@ -28,9 +30,11 @@ def __init__(self): 'default_route_table_id': 'defaultRouteTableId', 'default_security_list_id': 'defaultSecurityListId', 'display_name': 'displayName', + 'dns_label': 'dnsLabel', 'id': 'id', 'lifecycle_state': 'lifecycleState', - 'time_created': 'timeCreated' + 'time_created': 'timeCreated', + 'vcn_domain_name': 'vcnDomainName' } self._cidr_block = None @@ -39,9 +43,11 @@ def __init__(self): self._default_route_table_id = None self._default_security_list_id = None self._display_name = None + self._dns_label = None self._id = None self._lifecycle_state = None self._time_created = None + self._vcn_domain_name = None @property def cidr_block(self): @@ -191,6 +197,52 @@ def display_name(self, display_name): """ self._display_name = display_name + @property + def dns_label(self): + """ + Gets the dns_label of this Vcn. + A DNS label for the VCN, used in conjunction with the VNIC's hostname and + subnet's DNS label to form a fully qualified domain name (FQDN) for each VNIC + within this subnet (e.g., `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + + The absence of this parameter means the VCN Resolver will not work for this VCN. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `vcn-1` + + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :return: The dns_label of this Vcn. + :rtype: str + """ + return self._dns_label + + @dns_label.setter + def dns_label(self, dns_label): + """ + Sets the dns_label of this Vcn. + A DNS label for the VCN, used in conjunction with the VNIC's hostname and + subnet's DNS label to form a fully qualified domain name (FQDN) for each VNIC + within this subnet (e.g., `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + + The absence of this parameter means the VCN Resolver will not work for this VCN. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `vcn-1` + + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :param dns_label: The dns_label of this Vcn. + :type: str + """ + self._dns_label = dns_label + @property def id(self): """ @@ -273,6 +325,46 @@ def time_created(self, time_created): """ self._time_created = time_created + @property + def vcn_domain_name(self): + """ + Gets the vcn_domain_name of this Vcn. + The VCN's domain name, which consists of the VCN's DNS label, and the + `oraclevcn.com` domain. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `vcn-1.oraclevcn.com` + + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :return: The vcn_domain_name of this Vcn. + :rtype: str + """ + return self._vcn_domain_name + + @vcn_domain_name.setter + def vcn_domain_name(self, vcn_domain_name): + """ + Sets the vcn_domain_name of this Vcn. + The VCN's domain name, which consists of the VCN's DNS label, and the + `oraclevcn.com` domain. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `vcn-1.oraclevcn.com` + + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :param vcn_domain_name: The vcn_domain_name of this Vcn. + :type: str + """ + self._vcn_domain_name = vcn_domain_name + def __repr__(self): return formatted_flat_dict(self) diff --git a/oraclebmc/core/models/vnic.py b/oraclebmc/core/models/vnic.py index 92964f0d3e..841cbc3071 100644 --- a/oraclebmc/core/models/vnic.py +++ b/oraclebmc/core/models/vnic.py @@ -13,6 +13,7 @@ def __init__(self): 'availability_domain': 'str', 'compartment_id': 'str', 'display_name': 'str', + 'hostname_label': 'str', 'id': 'str', 'lifecycle_state': 'str', 'private_ip': 'str', @@ -25,6 +26,7 @@ def __init__(self): 'availability_domain': 'availabilityDomain', 'compartment_id': 'compartmentId', 'display_name': 'displayName', + 'hostname_label': 'hostnameLabel', 'id': 'id', 'lifecycle_state': 'lifecycleState', 'private_ip': 'privateIp', @@ -36,6 +38,7 @@ def __init__(self): self._availability_domain = None self._compartment_id = None self._display_name = None + self._hostname_label = None self._id = None self._lifecycle_state = None self._private_ip = None @@ -119,11 +122,67 @@ def display_name(self, display_name): """ self._display_name = display_name + @property + def hostname_label(self): + """ + Gets the hostname_label of this Vnic. + The hostname for the VNIC that is created during instance launch. + Used for DNS. The value is the hostname portion of the instance's + fully qualified domain name (FQDN) (e.g., `bminstance-1` in FQDN + `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + Must be unique across all VNICs in the subnet and comply with + `RFC 952`__ and + `RFC 1123`__. + The value cannot be changed. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `bminstance-1` + + __ https://tools.ietf.org/html/rfc952 + __ https://tools.ietf.org/html/rfc1123 + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :return: The hostname_label of this Vnic. + :rtype: str + """ + return self._hostname_label + + @hostname_label.setter + def hostname_label(self, hostname_label): + """ + Sets the hostname_label of this Vnic. + The hostname for the VNIC that is created during instance launch. + Used for DNS. The value is the hostname portion of the instance's + fully qualified domain name (FQDN) (e.g., `bminstance-1` in FQDN + `bminstance-1.subnet-123.vcn-1.oraclevcn.com`). + Must be unique across all VNICs in the subnet and comply with + `RFC 952`__ and + `RFC 1123`__. + The value cannot be changed. + + For more information, see + `DNS in Your Virtual Cloud Network`__. + + Example: `bminstance-1` + + __ https://tools.ietf.org/html/rfc952 + __ https://tools.ietf.org/html/rfc1123 + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm + + + :param hostname_label: The hostname_label of this Vnic. + :type: str + """ + self._hostname_label = hostname_label + @property def id(self): """ Gets the id of this Vnic. - The VNIC's Oracle ID (OCID). + The OCID of the VNIC. :return: The id of this Vnic. @@ -135,7 +194,7 @@ def id(self): def id(self, id): """ Sets the id of this Vnic. - The VNIC's Oracle ID (OCID). + The OCID of the VNIC. :param id: The id of this Vnic. @@ -177,7 +236,7 @@ def lifecycle_state(self, lifecycle_state): def private_ip(self): """ Gets the private_ip of this Vnic. - The private IP addresses of the VNIC, which is within the VNIC subnet + The private IP address of the VNIC. The address is within the subnet's CIDR and is accessible within the VCN. @@ -190,7 +249,7 @@ def private_ip(self): def private_ip(self, private_ip): """ Sets the private_ip of this Vnic. - The private IP addresses of the VNIC, which is within the VNIC subnet + The private IP address of the VNIC. The address is within the subnet's CIDR and is accessible within the VCN. @@ -203,7 +262,7 @@ def private_ip(self, private_ip): def public_ip(self): """ Gets the public_ip of this Vnic. - The public IP address of the VNIC, which Oracle performs NAT for at the gateway. + The public IP address of the VNIC. :return: The public_ip of this Vnic. @@ -215,7 +274,7 @@ def public_ip(self): def public_ip(self, public_ip): """ Sets the public_ip of this Vnic. - The public IP address of the VNIC, which Oracle performs NAT for at the gateway. + The public IP address of the VNIC. :param public_ip: The public_ip of this Vnic. diff --git a/oraclebmc/core/models/volume_attachment.py b/oraclebmc/core/models/volume_attachment.py index 12f7c4bf66..19c9b7574a 100644 --- a/oraclebmc/core/models/volume_attachment.py +++ b/oraclebmc/core/models/volume_attachment.py @@ -53,8 +53,8 @@ def get_subtype(object_dictionary): if type == 'iscsi': return 'IScsiVolumeAttachment' - - raise ValueError('Could not resolve subtype type based on the object dictionary.') + else: + return 'VolumeAttachment' @property def attachment_type(self): diff --git a/oraclebmc/core/virtual_network_client.py b/oraclebmc/core/virtual_network_client.py index 6dec031ce4..11c83a4606 100644 --- a/oraclebmc/core/virtual_network_client.py +++ b/oraclebmc/core/virtual_network_client.py @@ -93,10 +93,8 @@ def create_cpe(self, create_cpe_details, **kwargs): def create_dhcp_options(self, create_dhcp_details, **kwargs): """ CreateDhcpOptions - Creates a new set of DHCP options for the specified VCN. The only option available to use is - :class:`DhcpDnsOption`, which lets you specify how DNS (host name resolution) is - handled in the subnets in your VCN. For more information, see - `Managing DHCP Options`__. + Creates a new set of DHCP options for the specified VCN. For more information, see + :class:`DhcpOptions`. For the purposes of access control, you must provide the OCID of the compartment where you want the set of DHCP options to reside. Notice that the set of options doesn't have to be in the same compartment as the VCN, @@ -108,7 +106,6 @@ def create_dhcp_options(self, create_dhcp_details, **kwargs): You may optionally specify a *display name* for the set of DHCP options, otherwise a default is provided. It does not have to be unique, and you can change it. - __ {{DOC_SERVER_URL}}/Content/Network/Tasks/managingDHCP.htm __ {{DOC_SERVER_URL}}/Content/Identity/Concepts/overview.htm __ {{DOC_SERVER_URL}}/Content/General/Concepts/identifiers.htm @@ -570,6 +567,10 @@ def create_subnet(self, create_subnet_details, **kwargs): You may optionally specify a *display name* for the subnet, otherwise a default is provided. It does not have to be unique, and you can change it. + You can also add a DNS label for the subnet, which is required if you want the VCN Resolver to resolve + hostnames for instances in the subnet. For more information, see + `DNS in Your Virtual Cloud Network`__. + __ {{DOC_SERVER_URL}}/Content/Network/Tasks/managingsubnets.htm __ {{DOC_SERVER_URL}}/Content/General/Concepts/servicelimits.htm __ {{DOC_SERVER_URL}}/Content/Identity/Concepts/overview.htm @@ -577,6 +578,7 @@ def create_subnet(self, create_subnet_details, **kwargs): __ {{DOC_SERVER_URL}}/Content/Network/Tasks/managingroutetables.htm __ {{DOC_SERVER_URL}}/Content/Network/Concepts/securitylists.htm __ {{DOC_SERVER_URL}}/Content/Network/Tasks/managingDHCP.htm + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm :param CreateSubnetDetails create_subnet_details: (required) @@ -639,6 +641,10 @@ def create_vcn(self, create_vcn_details, **kwargs): You may optionally specify a *display name* for the VCN, otherwise a default is provided. It does not have to be unique, and you can change it. + You can also add a DNS label for the VCN, which is required if you want the instances to use the VCN Resolver + option for DNS in the VCN. For more information, see + `DNS in Your Virtual Cloud Network`__. + The VCN automatically comes with a default route table, default security list, and default set of DHCP options. The OCID for each is returned in the response. You can't delete these default objects, but you can change their contents (i.e., route rules, etc.) @@ -651,6 +657,7 @@ def create_vcn(self, create_vcn_details, **kwargs): __ https://tools.ietf.org/html/rfc1918 __ {{DOC_SERVER_URL}}/Content/Identity/Concepts/overview.htm __ {{DOC_SERVER_URL}}/Content/General/Concepts/identifiers.htm + __ {{DOC_SERVER_URL}}/Content/Network/Concepts/dns.htm __ {{DOC_SERVER_URL}}/Content/Network/Concepts/overview.htm#three diff --git a/oraclebmc/identity/identity_client.py b/oraclebmc/identity/identity_client.py index 764ebe63dc..5b7929e0e0 100644 --- a/oraclebmc/identity/identity_client.py +++ b/oraclebmc/identity/identity_client.py @@ -1546,6 +1546,7 @@ def update_swift_password(self, user_id, swift_password_id, update_swift_passwor UpdateSwiftPassword Updates the specified Swift password's description. + :param str user_id: (required) The OCID of the user. diff --git a/oraclebmc/object_storage/object_storage_client.py b/oraclebmc/object_storage/object_storage_client.py index f53a51e5f5..2d657f71c4 100644 --- a/oraclebmc/object_storage/object_storage_client.py +++ b/oraclebmc/object_storage/object_storage_client.py @@ -268,6 +268,7 @@ def get_namespace(self, **kwargs): Get the name of the namespace for the user making the request. An account name must be unique, must start with a letter, and can have up to 15 lower case letters and numbers. You cannot use spaces and special characters. + :param str opc_client_request_id: (optional) The client request ID for tracing diff --git a/oraclebmc/version.py b/oraclebmc/version.py index 00e5756827..8ece74908e 100644 --- a/oraclebmc/version.py +++ b/oraclebmc/version.py @@ -1,4 +1,4 @@ # coding: utf-8 # Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. -__version__ = "1.1.2" +__version__ = "1.2.0" diff --git a/tests/conftest.py b/tests/conftest.py index 7880afb22a..7719be7363 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,10 +1,13 @@ +import os import pytest import oraclebmc +from tests.util import get_resource_path + def pytest_addoption(parser): parser.addoption("--config-file", action="store", help="location of the config file", - default=oraclebmc.config.DEFAULT_LOCATION) + default=get_resource_path('config')) parser.addoption("--config-profile", action="store", help="profile to use from the config file", default=oraclebmc.config.DEFAULT_PROFILE) @@ -22,10 +25,11 @@ def config_profile(request): @pytest.fixture def config(config_file, config_profile): - return oraclebmc.config.from_file( - file_location=config_file, - profile_name=config_profile - ) + config = oraclebmc.config.from_file(file_location=config_file, profile_name=config_profile) + pass_phrase = os.environ.get('PYTHON_TESTS_ADMIN_PASS_PHRASE') + if pass_phrase: + config['pass_phrase'] = pass_phrase + return config @pytest.fixture diff --git a/tests/integ/test_large_file_transfer.py b/tests/integ/test_large_file_transfer.py index b8cd79c4c2..7832cc6352 100644 --- a/tests/integ/test_large_file_transfer.py +++ b/tests/integ/test_large_file_transfer.py @@ -55,7 +55,7 @@ def write_bucket(namespace, object_storage, config, names): def test_large_file_transfer(namespace, object_storage, write_bucket, names): - """Download, upload, and delete a large file (2.6 GB)""" + """Download, upload, and delete a large file.""" response = object_storage.head_object( namespace, names["read-bucket"], @@ -70,6 +70,7 @@ def test_large_file_transfer(namespace, object_storage, write_bucket, names): total_size = 0 chunk_size = 512 initial_max_memory_usage = tests.util.max_memory_usage() + print("Initial memory usage: {} bytes".format(str(initial_max_memory_usage))) with tests.util.timer('get large file'): response = object_storage.get_object( @@ -121,4 +122,5 @@ def test_large_file_transfer(namespace, object_storage, write_bucket, names): assert uploaded_content_length == file_size max_memory = tests.util.max_memory_usage() + print("Final max memory usage: {} bytes".format(str(max_memory))) assert max_memory < file_size diff --git a/tests/integ/test_launch_instance_tutorial.py b/tests/integ/test_launch_instance_tutorial.py index c9c1292b51..80579c3f41 100644 --- a/tests/integ/test_launch_instance_tutorial.py +++ b/tests/integ/test_launch_instance_tutorial.py @@ -1,6 +1,5 @@ import tests.util import oraclebmc -import os.path import time import pytest @@ -15,8 +14,8 @@ def test_tutorial(virtual_network, compute, block_storage, config): # getting these dynamically based on a specified environment. availability_domain = 'kIdk:PHX-AD-2' compartment = config["tenancy"] - filename = os.path.expanduser('~/.ssh/id_rsa.pub') - with open(filename) as f: + + with open(tests.util.get_key_file_path("public_ssh_key.pub")) as f: public_key = f.read().strip() vcn = None diff --git a/tests/util.py b/tests/util.py index 907720c3f8..5b8d0dbf2e 100644 --- a/tests/util.py +++ b/tests/util.py @@ -22,8 +22,14 @@ def get_resource_directory(): return os.path.join(here, "resources") +def get_key_file_path(file_name): + """Get the absolute path to a file in the keys directory.""" + here = os.path.abspath(os.path.dirname(__file__)) + return os.path.join(here, "..", "keys", file_name) + + def get_resource_path(file_name): - return get_resource_directory() + '/' + file_name + return os.path.join(get_resource_directory(), file_name) @contextmanager diff --git a/tox.ini b/tox.ini index b95234d9fa..047f0e1463 100644 --- a/tox.ini +++ b/tox.ini @@ -2,11 +2,11 @@ envlist = py27, py35, flake8 [testenv] +passenv = PYTHON_TESTS_ADMIN_PASS_PHRASE deps = -r{toxinidir}/requirements.txt commands = - py.test tests/unit [] + py.test tests/unit tests/integ [] -s [testenv:flake8] -basepython = python3.5 deps = flake8 commands = flake8 oraclebmc docs tests examples