summaryrefslogtreecommitdiff
path: root/cloudinit/sources/helpers/openstack.py
Commit message (Collapse)AuthorAgeFilesLines
* openstack/static: honor the DNS servers associated with a network (#2138)Gonéri Le Bouder2023-04-281-0/+8
| | | | | | | | | The `network_data.json` allows the definition of the DNS through the `services` list at the network level. See: - https://opendev.org/openstack/nova/src/commit/700db274c613d6f8f30e5cdc3462beaeb0fda456/nova/tests/unit/network/test_network_info.py#L979-L980 - https://opendev.org/openstack/metalsmith/src/commit/f98dfa61c1d7475b81c20dabbf2c74198c38c793/metalsmith/test/test_network_metadata.py#L52-L90 - https://opendev.org/openstack/nova/commit/4b333b989dfc778a8b61db4a1b8552e988a10471
* Refactor: Drop inheritance from object (#1728)Alberto Contreras2022-09-141-1/+1
| | | As we do not support python2 anymore, we can remove those 8 chars.
* Misc module cleanup (#1418)Brett Holman2022-04-291-2/+2
| | | | - move datasource helpers to dedicated directory - drop unnecessary executable bit on shebangless python files
* Adopt Black and isort (SC-700) (#1157)James Falcon2021-12-151-202/+236
| | | | | Applied Black and isort, fixed any linting issues, updated tox.ini and CI.
* openstack: read the dynamic metadata group vendor_data2.json (#777)Andrew Bogott2021-02-051-0/+5
| | | | | | | Add support for openstack's dynamic vendor data, which appears under openstack/latest/vendor_data2.json This adds vendor_data2 to all pathways; it should be a no-op for non-OpenStack providers. LP: #1841104
* Explicit set IPV6_AUTOCONF and IPV6_FORCE_ACCEPT_RA on static6 (#634)Eduardo Otubo2020-10-291-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | The static and static6 subnet types for network_data.json were being ignored by the Openstack handler, this would cause the code to break and not function properly. As of today, if a static6 configuration is chosen, the interface will still eventually be available to receive router advertisements or be set from NetworkManager to wait for them and cycle the interface in negative case. It is safe to assume that if the interface is manually configured to use static ipv6 address, there's no need to wait for router advertisements. This patch will set automatically IPV6_AUTOCONF and IPV6_FORCE_ACCEPT_RA both to "no" in this case. This patch fixes the specific behavior only for RHEL flavor and sysconfig renderer. It also introduces new unit tests for the specific case as well as adjusts some existent tests to be compatible with the new options. This patch also addresses this problem by assigning the appropriate subnet type for each case on the openstack handler. rhbz: #1889635 rhbz: #1889635 Signed-off-by: Eduardo Otubo otubo@redhat.com
* tox: bump the pylint version to 2.6.0 in the default run (#544)Paride Legovini2020-08-251-14/+20
| | | | | | Changes: tox: bump the pylint version to 2.6.0 in the default run Fix pylint 2.6.0 W0707 warnings (raise-missing-from)
* cloudinit: fix tip-pylint failures and bump pinned pylint version (#478)Daniel Watkins2020-07-061-1/+4
| | | | | | | | | | Specifically: * disable E1102 in cloudinit/sources/helpers/openstack.py for reasons described in a comment, and * refactor `abs_join` to require at least one positional argument; this matches os.path.join's signature, and that mismatch is what was causing pylint to emit a warning * bump to pylint 2.4.2
* Move subp into its own module. (#416)Scott Moser2020-06-081-1/+2
| | | | | | | | | | | | | | | | | This was painful, but it finishes a TODO from cloudinit/subp.py. It moves the following from util to subp: ProcessExecutionError subp which target_path I moved subp_blob_in_tempfile into cc_chef, which is its only caller. That saved us from having to deal with it using write_file and temp_utils from subp (which does not import any cloudinit things now). It is arguable that 'target_path' could be moved to a 'path_utils' or something, but in order to use it from subp and also from utils, we had to get it out of utils.
* test: fix all flake8 E741 errors (#401)Joshua Powers2020-06-011-6/+11
| | | | This removes the use of variables named ‘l’, ‘O’, or ‘I’. Generally these are used in list comprehension to read the line of lines.
* Add physical network type: cascading to openstack helpers (#200)sab-systems2020-02-251-0/+1
| | | | | * Add physical network type: cascading to openstack helpers * add new helpers test for checking all openstack KNOWN_PHYSICAL_TYPES get type 'physical'.
* Start removing dependency on six (#178)Daniel Watkins2020-01-211-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * url_helper: drop six * url_helper: sort imports * log: drop six * log: sort imports * handlers/__init__: drop six * handlers/__init__: sort imports * user_data: drop six * user_data: sort imports * sources/__init__: drop six * sources/__init__: sort imports * DataSourceOVF: drop six * DataSourceOVF: sort imports * sources/helpers/openstack: drop six * sources/helpers/openstack: sort imports * mergers/m_str: drop six This also allowed simplification of the logic, as we will never encounter a non-string text type. * type_utils: drop six * mergers/m_dict: drop six * mergers/m_list: drop six * cmd/query: drop six * mergers/__init__: drop six * net/cmdline: drop six * reporting/handlers: drop six * reporting/handlers: sort imports
* net: IPv6, accept_ra, slaac, stateless (#51)Harald2019-11-201-7/+14
| | | | | | | | | | | | | | | | | | | | | Router advertisements are required for the default route to be set up, thus accept_ra should be enabled for dhcpv6-stateful. sysconf: IPV6_FORCE_ACCEPT_RA controls accept_ra sysctl. eni: mode static and mode dhcp 'accept_ra' controls sysctl. Add 'accept-ra: true|false' parameter to config v1 and v2. When True: accept_ra is set to '1'. When False: accept_ra is set to '0'. When not defined in config the value is left to the operating system default. This change also extend the IPv6 support to distinguish between slaac and dhcpv6-stateless. SLAAC is autoconfig without any options from DHCP, while stateless auto-configures the address and the uses DHCP for other options. LP: #1806014 LP: #1808647
* net: handle openstack dhcpv6-stateless configurationHarald Jensås2019-10-161-1/+2
| | | | | | | | | | | | | | | | | | | | Openstack subnets can be configured to use SLAAC by setting ipv6_address_mode=dhcpv6-stateless. When this is the case the sysconfig interface configuration should use IPV6_AUTOCONF=yes and not set DHCPV6C=yes. This change sets the subnets type property to the full network['type'] from openstack metadata. cloudinit/net/sysconfig.py and cloudinit/net/eni.py are updated to support new subnet types: - 'ipv6_dhcpv6-stateless' => IPV6_AUTOCONF=yes - 'ipv6_dhcpv6-stateful' => DHCPV6C=yes Type 'dhcp6' in sysconfig is kept for backward compatibility with any implementations that set subnet_type == 'dhcp6'. LP: #1847517
* helpers/openstack: Treat unknown link types as physicalDaniel Watkins2019-03-041-6/+6
| | | | | | | | | Some deployments of OpenStack expose link types to the guest which cloud-init doesn't recognise. These will almost always be physical, so we can operate more robustly if we assume that they are (whilst warning the user that we're seeing something unexpected). LP: #1639263
* Add support for Infiniband network interfaces (IPoIB).Mark Goddard2018-09-261-0/+11
| | | | | | | | | | | | | | | | | | OpenStack ironic references Infiniband interfaces via a 6 byte 'MAC address' formed from bytes 13-15 and 18-20 of interface's hardware address. This address is used as the ethernet_mac_address of Infiniband links in network_data.json in configdrives generated by OpenStack nova. We can use this address to map links in network_data.json to their corresponding interface names. When generating interface configuration files, we need to use the interface's full hardware address as the HWADDR, rather than the 6 byte MAC address provided by network_data.json. This change allows IB interfaces to be referenced in this dual mode - by MAC address and hardware address, depending on the context. Support TYPE=InfiniBand for sysconfig configuration of IB interfaces.
* OpenStack: Support setting mac address on bond.Fabian Wiesel2018-09-141-0/+2
| | | | | | | Fix a bug where setting of mac address on a bond device was ignored when provided in OpenStack network_config.json. LP: #1682064
* EphemeralIPv4Network: Be more explicit when adding default route.Scott Moser2018-09-131-0/+1
| | | | | | | | | | | | | | | | | On OpenStack based OVH public cloud, we got DHCP response with   fixed-address 54.36.113.86;   option subnet-mask 255.255.255.255;   option routers 54.36.112.1; The router clearly is not on the subnet. So 'ip' would fail when we tried to add the default route. The solution here is to add an explicit route on that interface to the router and then add the default route. Also add 'bgpovs' to the list of 'physical' types for OpenStack network configuration. That type is used on OVH public cloud. LP: #1792415
* OpenStack: support reading of newer versions of metdata.Scott Moser2018-09-131-0/+16
| | | | | | | | Mark as supported for reading some newer versions of openstack metadata: 2016-06-30 : Newton one 2016-10-06 : Newton two 2017-02-22 : Ocata 2018-08-27 : Rocky
* OpenStack: fix bug causing 'latest' version to be used from network.Scott Moser2018-09-121-1/+1
| | | | | | | | | | Cloud-init was reading a list of versions from the OpenStack metadata service (http://169.254.169.254/openstack/) and attempt to select the newest known supported version. The problem was that the list of versions was not being decoded, so we were comparing a list of bytes (found versions) to a list of strings (known versions). LP: #1792157
* Add datasource Oracle Compute Infrastructure (OCI).Scott Moser2018-08-171-4/+2
| | | | | | | | | | | This adds a Oracle specific datasource that functions with OCI. It is a simplified version of the OpenStack metadata server with support for vendor-data. It does not support the OCI-C (classic) platform. Also here is a move of BrokenMetadata to common 'sources' as this was the third occurrence of that class.
* pylint: pay attention to unused variable warnings.Scott Moser2018-04-191-1/+1
| | | | | This enables warnings produced by pylint for unused variables (W0612), and fixes the existing errors.
* Remove (and/or fix) URL shortener referencesJon Grimm2017-04-121-1/+1
| | | | | | | | | Several references that were using URL shorteners are now broken due to their service going away, making it painful to even figure out what they were supposed to be pointing at. Put back long URLS using '# noqa' to make flake8 happy. LP: #1669727
* OpenStack: add 'dvs' to the list of physical link types.Scott Moser2017-04-031-0/+1
| | | | | | | Links presented in network_data.json to the guest running on ESXi are of type 'dvs'. LP: #1674946
* LICENSE: Allow dual licensing GPL-3 or Apache 2.0Jon Grimm2016-12-221-17/+7
| | | | | | | | | | | | | | | | | | This has been a recurring ask and we had initially just made the change to the cloud-init 2.0 codebase. As the current thinking is we'll just continue to enhance the current codebase, its desirable to relicense to match what we'd intended as part of the 2.0 plan here. - put a brief description of license in LICENSE file - put full license versions in LICENSE-GPLv3 and LICENSE-Apache2.0 - simplify the per-file header to reference LICENSE - tox: ignore H102 (Apache License Header check) Add license header to files that ship. Reformat headers, make sure everything has vi: at end of file. Non-shipping files do not need the copyright header, but at the moment tests/ have it.
* OpenStack: extend physical types to include hyperv, hw_veb, vhost_user.Scott Moser2016-11-281-2/+14
| | | | | | | This extends the list of device 'types' that are considered to be physical to include hyperv, hw_veb, and vhost_user. LP: #1642679
* Allow link type of null in network_data.jsonJon Grimm2016-09-121-7/+7
| | | | | | | | | | Treat null type as yet another physical type, seen in real-world openstack cloud. Also, support the case where network_data.json provides mac addresses in upper case. Rackspace public cloud currently does that. LP: #1621968
* Generate a dummy bond name for OpenStackScott Moser2016-08-231-8/+50
| | | | | | | | | | | | | | | | The OpenStack network_data.json does not provide a name for bond links. This change makes it so a dummy one is generated and used instead to satisfy cloud-init which does require one. In order to write the correct link (underlying 'link' names) for the bonds, we maintain a list of info by ids so we can easily get the right device name. Also: * add a vlan test case that similarly references an id rather than name. * make bond interfaces auto LP: #1605749
* MAAS: add vendor-data supportScott Moser2016-08-121-25/+0
| | | | | | | | | | Add vendor-data support to maas which will behave like the openstack vendor-data does. Data returned from maas must be yaml loadable. Also update the main in DataSourceMAAS to "just work" on a maas deployed system. LP: #1612313
* ConfigDrive: recognize 'tap' as a link type.Scott Moser2016-08-111-1/+1
| | | | | | | | This just adds 'tap' to the list of types that are understood to be physical or virtual network devices. Openstack basically exposes the type of the host device through. LP: #1610784
* Another stray occurence of a dict comprehension being removedJoshua Harlow2016-07-131-2/+2
|
* Remove another stray dict comprehensionJoshua Harlow2016-07-131-2/+2
|
* fix some errors reported by pylintScott Moser2016-06-151-1/+1
| | | | | | pylint --errors-only found several errors. Some of the changes here represent real errors, others just code that pylint did not like.
* Rebase against masterJoshua Harlow2016-06-061-28/+52
|\
| * openstack: support decoding when reading files, use that for network_configScott Moser2016-06-021-7/+11
| | | | | | | | | | | | | | The network config file is /etc/network/interfaces formated. We will decode that here so that the user can expect that it is a string. The issue was that it was bytes but convert_eni_data was expecting a string.
* | Remerge against head/masterJoshua Harlow2016-05-191-0/+125
|\ \ | |/ |/|
| * Adjust net module to be more isolatedJoshua Harlow2016-05-191-0/+4
| | | | | | | | | | This allows it to be used outside of cloudinit more easily in the future.
| * Fix py26 for rhel (and older versions of python)Joshua Harlow2016-05-111-4/+4
| |
| * Add the bridge net typeJoshua Harlow2016-05-051-0/+5
| |
| * Work on refactoring (and adding) network conversion testsJoshua Harlow2016-05-051-0/+116
| |
* | Fix up a ton of flake8 issuesJoshua Harlow2016-05-121-2/+2
|/
* fix openstack versions s/KILO/LIBERY drop networkdata read helperRyan Harper2016-03-231-27/+2
|
* configdata: parse and convert openstack network_data json to network_configRyan Harper2016-03-231-1/+33
|
* move towards user-data being binaryScott Moser2015-02-251-1/+1
| | | | | | | | | | | | | | | | UrlResponse: biggest change... make readurl return bytes, making user know what to do with it. util: add load_tfile_or_url for loading text file or url as read_file_or_url now returns bytes ec2_utils: all meta-data is text, remove non-obvious string translations DigitalOcean: adjust for ec2_utils DataSourceGCE, DataSourceMAAS: user-data is binary other fields are text. openstack.py: read paths without decoding to text. This is ok as paths other than user-data are json, and load_json will handle load_file still returns text, and that is what most things use.
* Largely merge lp:~harlowja/cloud-init/py2-3 albeit manually because it seemedBarry Warsaw2015-01-211-4/+6
| | | | | | to be behind trunk. `tox -e py27` passes full test suite. Now to work on replacing mocker.
* when loading vendordata allow it to be string or listScott Moser2014-09-111-1/+5
|
* Openstack: Vendor data cleanupScott Moser2014-09-101-0/+25
| | | | | | | | | | For now, this vendor data handling is just added to openstack. However, in an effort to allow sanely handling of multi-part vendor-data that is namespaced, we add openstack.convert_vendordata_json . That basically takes whatever was loaded from vendordata and takes the 'cloud-init' key if it is a dict. This way the author can namespace cloud-init, basically telling it to ignore everything else.
* drop version= from readersScott Moser2014-09-101-16/+7
| | | | | | | | instead of taking a version that they should look for, the readers now just select the highest supported version. definitely a use case later for having version= but nothing is using it now.
* fix log messageScott Moser2014-09-101-1/+1
|
* make BaseReader select latest supported versionScott Moser2014-09-101-6/+13
|