summaryrefslogtreecommitdiff
path: root/cloudinit/sources/helpers/vmware
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/sources/helpers/vmware')
-rw-r--r--cloudinit/sources/helpers/vmware/__init__.py13
-rw-r--r--cloudinit/sources/helpers/vmware/imc/__init__.py13
-rw-r--r--cloudinit/sources/helpers/vmware/imc/boot_proto.py25
-rw-r--r--cloudinit/sources/helpers/vmware/imc/config.py95
-rw-r--r--cloudinit/sources/helpers/vmware/imc/config_file.py129
-rw-r--r--cloudinit/sources/helpers/vmware/imc/config_namespace.py25
-rw-r--r--cloudinit/sources/helpers/vmware/imc/config_nic.py247
-rw-r--r--cloudinit/sources/helpers/vmware/imc/config_source.py23
-rw-r--r--cloudinit/sources/helpers/vmware/imc/guestcust_error.py24
-rw-r--r--cloudinit/sources/helpers/vmware/imc/guestcust_event.py27
-rw-r--r--cloudinit/sources/helpers/vmware/imc/guestcust_state.py25
-rw-r--r--cloudinit/sources/helpers/vmware/imc/guestcust_util.py128
-rw-r--r--cloudinit/sources/helpers/vmware/imc/ipv4_mode.py45
-rw-r--r--cloudinit/sources/helpers/vmware/imc/nic.py147
-rw-r--r--cloudinit/sources/helpers/vmware/imc/nic_base.py154
15 files changed, 0 insertions, 1120 deletions
diff --git a/cloudinit/sources/helpers/vmware/__init__.py b/cloudinit/sources/helpers/vmware/__init__.py
deleted file mode 100644
index 386225d5..00000000
--- a/cloudinit/sources/helpers/vmware/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# vi: ts=4 expandtab
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/cloudinit/sources/helpers/vmware/imc/__init__.py b/cloudinit/sources/helpers/vmware/imc/__init__.py
deleted file mode 100644
index 386225d5..00000000
--- a/cloudinit/sources/helpers/vmware/imc/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# vi: ts=4 expandtab
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/cloudinit/sources/helpers/vmware/imc/boot_proto.py b/cloudinit/sources/helpers/vmware/imc/boot_proto.py
deleted file mode 100644
index fb53ec1d..00000000
--- a/cloudinit/sources/helpers/vmware/imc/boot_proto.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2015 Canonical Ltd.
-# Copyright (C) 2015 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-class BootProtoEnum(object):
- """Specifies the NIC Boot Settings."""
-
- DHCP = 'dhcp'
- STATIC = 'static'
diff --git a/cloudinit/sources/helpers/vmware/imc/config.py b/cloudinit/sources/helpers/vmware/imc/config.py
deleted file mode 100644
index d645c497..00000000
--- a/cloudinit/sources/helpers/vmware/imc/config.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2015 Canonical Ltd.
-# Copyright (C) 2015 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-from .nic import Nic
-
-
-class Config(object):
- """
- Stores the Contents specified in the Customization
- Specification file.
- """
-
- DNS = 'DNS|NAMESERVER|'
- SUFFIX = 'DNS|SUFFIX|'
- PASS = 'PASSWORD|-PASS'
- TIMEZONE = 'DATETIME|TIMEZONE'
- UTC = 'DATETIME|UTC'
- HOSTNAME = 'NETWORK|HOSTNAME'
- DOMAINNAME = 'NETWORK|DOMAINNAME'
-
- def __init__(self, configFile):
- self._configFile = configFile
-
- @property
- def host_name(self):
- """Return the hostname."""
- return self._configFile.get(Config.HOSTNAME, None)
-
- @property
- def domain_name(self):
- """Return the domain name."""
- return self._configFile.get(Config.DOMAINNAME, None)
-
- @property
- def timezone(self):
- """Return the timezone."""
- return self._configFile.get(Config.TIMEZONE, None)
-
- @property
- def utc(self):
- """Retrieves whether to set time to UTC or Local."""
- return self._configFile.get(Config.UTC, None)
-
- @property
- def admin_password(self):
- """Return the root password to be set."""
- return self._configFile.get(Config.PASS, None)
-
- @property
- def name_servers(self):
- """Return the list of DNS servers."""
- res = []
- cnt = self._configFile.get_count_with_prefix(Config.DNS)
- for i in range(1, cnt + 1):
- key = Config.DNS + str(i)
- res.append(self._configFile[key])
-
- return res
-
- @property
- def dns_suffixes(self):
- """Return the list of DNS Suffixes."""
- res = []
- cnt = self._configFile.get_count_with_prefix(Config.SUFFIX)
- for i in range(1, cnt + 1):
- key = Config.SUFFIX + str(i)
- res.append(self._configFile[key])
-
- return res
-
- @property
- def nics(self):
- """Return the list of associated NICs."""
- res = []
- nics = self._configFile['NIC-CONFIG|NICS']
- for nic in nics.split(','):
- res.append(Nic(nic, self._configFile))
-
- return res
diff --git a/cloudinit/sources/helpers/vmware/imc/config_file.py b/cloudinit/sources/helpers/vmware/imc/config_file.py
deleted file mode 100644
index bb9fb7dc..00000000
--- a/cloudinit/sources/helpers/vmware/imc/config_file.py
+++ /dev/null
@@ -1,129 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2015 Canonical Ltd.
-# Copyright (C) 2015 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import logging
-
-try:
- import configparser
-except ImportError:
- import ConfigParser as configparser
-
-from .config_source import ConfigSource
-
-logger = logging.getLogger(__name__)
-
-
-class ConfigFile(ConfigSource, dict):
- """ConfigFile module to load the content from a specified source."""
-
- def __init__(self, filename):
- self._loadConfigFile(filename)
- pass
-
- def _insertKey(self, key, val):
- """
- Inserts a Key Value pair.
-
- Keyword arguments:
- key -- The key to insert
- val -- The value to insert for the key
-
- """
- key = key.strip()
- val = val.strip()
-
- if key.startswith('-') or '|-' in key:
- canLog = False
- else:
- canLog = True
-
- # "sensitive" settings shall not be logged
- if canLog:
- logger.debug("ADDED KEY-VAL :: '%s' = '%s'" % (key, val))
- else:
- logger.debug("ADDED KEY-VAL :: '%s' = '*****************'" % key)
-
- self[key] = val
-
- def _loadConfigFile(self, filename):
- """
- Parses properties from the specified config file.
-
- Any previously available properties will be removed.
- Sensitive data will not be logged in case the key starts
- from '-'.
-
- Keyword arguments:
- filename - The full path to the config file.
- """
- logger.info('Parsing the config file %s.' % filename)
-
- config = configparser.ConfigParser()
- config.optionxform = str
- config.read(filename)
-
- self.clear()
-
- for category in config.sections():
- logger.debug("FOUND CATEGORY = '%s'" % category)
-
- for (key, value) in config.items(category):
- self._insertKey(category + '|' + key, value)
-
- def should_keep_current_value(self, key):
- """
- Determines whether a value for a property must be kept.
-
- If the propery is missing, it is treated as it should be not
- changed by the engine.
-
- Keyword arguments:
- key -- The key to search for.
- """
- # helps to distinguish from "empty" value which is used to indicate
- # "removal"
- return key not in self
-
- def should_remove_current_value(self, key):
- """
- Determines whether a value for the property must be removed.
-
- If the specified key is empty, it is treated as it should be
- removed by the engine.
-
- Return true if the value can be removed, false otherwise.
-
- Keyword arguments:
- key -- The key to search for.
- """
- # helps to distinguish from "missing" value which is used to indicate
- # "keeping unchanged"
- if key in self:
- return not bool(self[key])
- else:
- return False
-
- def get_count_with_prefix(self, prefix):
- """
- Return the total count of keys that start with the specified prefix.
-
- Keyword arguments:
- prefix -- prefix of the key
- """
- return len([key for key in self if key.startswith(prefix)])
diff --git a/cloudinit/sources/helpers/vmware/imc/config_namespace.py b/cloudinit/sources/helpers/vmware/imc/config_namespace.py
deleted file mode 100644
index b28830f5..00000000
--- a/cloudinit/sources/helpers/vmware/imc/config_namespace.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2015 Canonical Ltd.
-# Copyright (C) 2015 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-from .config_source import ConfigSource
-
-
-class ConfigNamespace(ConfigSource):
- """Specifies the Config Namespace."""
- pass
diff --git a/cloudinit/sources/helpers/vmware/imc/config_nic.py b/cloudinit/sources/helpers/vmware/imc/config_nic.py
deleted file mode 100644
index 511cc918..00000000
--- a/cloudinit/sources/helpers/vmware/imc/config_nic.py
+++ /dev/null
@@ -1,247 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2015 Canonical Ltd.
-# Copyright (C) 2016 VMware INC.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import logging
-import os
-import re
-
-from cloudinit import util
-
-logger = logging.getLogger(__name__)
-
-
-class NicConfigurator(object):
- def __init__(self, nics):
- """
- Initialize the Nic Configurator
- @param nics (list) an array of nics to configure
- """
- self.nics = nics
- self.mac2Name = {}
- self.ipv4PrimaryGateway = None
- self.ipv6PrimaryGateway = None
- self.find_devices()
- self._primaryNic = self.get_primary_nic()
-
- def get_primary_nic(self):
- """
- Retrieve the primary nic if it exists
- @return (NicBase): the primary nic if exists, None otherwise
- """
- primary_nics = [nic for nic in self.nics if nic.primary]
- if not primary_nics:
- return None
- elif len(primary_nics) > 1:
- raise Exception('There can only be one primary nic',
- [nic.mac for nic in primary_nics])
- else:
- return primary_nics[0]
-
- def find_devices(self):
- """
- Create the mac2Name dictionary
- The mac address(es) are in the lower case
- """
- cmd = ['ip', 'addr', 'show']
- (output, err) = util.subp(cmd)
- sections = re.split(r'\n\d+: ', '\n' + output)[1:]
-
- macPat = r'link/ether (([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2}))'
- for section in sections:
- match = re.search(macPat, section)
- if not match: # Only keep info about nics
- continue
- mac = match.group(1).lower()
- name = section.split(':', 1)[0]
- self.mac2Name[mac] = name
-
- def gen_one_nic(self, nic):
- """
- Return the lines needed to configure a nic
- @return (str list): the string list to configure the nic
- @param nic (NicBase): the nic to configure
- """
- lines = []
- name = self.mac2Name.get(nic.mac.lower())
- if not name:
- raise ValueError('No known device has MACADDR: %s' % nic.mac)
-
- if nic.onboot:
- lines.append('auto %s' % name)
-
- # Customize IPv4
- lines.extend(self.gen_ipv4(name, nic))
-
- # Customize IPv6
- lines.extend(self.gen_ipv6(name, nic))
-
- lines.append('')
-
- return lines
-
- def gen_ipv4(self, name, nic):
- """
- Return the lines needed to configure the IPv4 setting of a nic
- @return (str list): the string list to configure the gateways
- @param name (str): name of the nic
- @param nic (NicBase): the nic to configure
- """
- lines = []
-
- bootproto = nic.bootProto.lower()
- if nic.ipv4_mode.lower() == 'disabled':
- bootproto = 'manual'
- lines.append('iface %s inet %s' % (name, bootproto))
-
- if bootproto != 'static':
- return lines
-
- # Static Ipv4
- v4 = nic.staticIpv4
- if v4.ip:
- lines.append(' address %s' % v4.ip)
- if v4.netmask:
- lines.append(' netmask %s' % v4.netmask)
-
- # Add the primary gateway
- if nic.primary and v4.gateways:
- self.ipv4PrimaryGateway = v4.gateways[0]
- lines.append(' gateway %s metric 0' % self.ipv4PrimaryGateway)
- return lines
-
- # Add routes if there is no primary nic
- if not self._primaryNic:
- lines.extend(self.gen_ipv4_route(nic, v4.gateways))
-
- return lines
-
- def gen_ipv4_route(self, nic, gateways):
- """
- Return the lines needed to configure additional Ipv4 route
- @return (str list): the string list to configure the gateways
- @param nic (NicBase): the nic to configure
- @param gateways (str list): the list of gateways
- """
- lines = []
-
- for gateway in gateways:
- lines.append(' up route add default gw %s metric 10000' %
- gateway)
-
- return lines
-
- def gen_ipv6(self, name, nic):
- """
- Return the lines needed to configure the gateways for a nic
- @return (str list): the string list to configure the gateways
- @param name (str): name of the nic
- @param nic (NicBase): the nic to configure
- """
- lines = []
-
- if not nic.staticIpv6:
- return lines
-
- # Static Ipv6
- addrs = nic.staticIpv6
- lines.append('iface %s inet6 static' % name)
- lines.append(' address %s' % addrs[0].ip)
- lines.append(' netmask %s' % addrs[0].netmask)
-
- for addr in addrs[1:]:
- lines.append(' up ifconfig %s inet6 add %s/%s' % (name, addr.ip,
- addr.netmask))
- # Add the primary gateway
- if nic.primary:
- for addr in addrs:
- if addr.gateway:
- self.ipv6PrimaryGateway = addr.gateway
- lines.append(' gateway %s' % self.ipv6PrimaryGateway)
- return lines
-
- # Add routes if there is no primary nic
- if not self._primaryNic:
- lines.extend(self._genIpv6Route(name, nic, addrs))
-
- return lines
-
- def _genIpv6Route(self, name, nic, addrs):
- lines = []
-
- for addr in addrs:
- lines.append(' up route -A inet6 add default gw '
- '%s metric 10000' % addr.gateway)
-
- return lines
-
- def generate(self):
- """Return the lines that is needed to configure the nics"""
- lines = []
- lines.append('iface lo inet loopback')
- lines.append('auto lo')
- lines.append('')
-
- for nic in self.nics:
- lines.extend(self.gen_one_nic(nic))
-
- return lines
-
- def clear_dhcp(self):
- logger.info('Clearing DHCP leases')
-
- # Ignore the return code 1.
- util.subp(["pkill", "dhclient"], rcs=[0, 1])
- util.subp(["rm", "-f", "/var/lib/dhcp/*"])
-
- def if_down_up(self):
- names = []
- for nic in self.nics:
- name = self.mac2Name.get(nic.mac.lower())
- names.append(name)
-
- for name in names:
- logger.info('Bring down interface %s' % name)
- util.subp(["ifdown", "%s" % name])
-
- self.clear_dhcp()
-
- for name in names:
- logger.info('Bring up interface %s' % name)
- util.subp(["ifup", "%s" % name])
-
- def configure(self):
- """
- Configure the /etc/network/intefaces
- Make a back up of the original
- """
- containingDir = '/etc/network'
-
- interfaceFile = os.path.join(containingDir, 'interfaces')
- originalFile = os.path.join(containingDir,
- 'interfaces.before_vmware_customization')
-
- if not os.path.exists(originalFile) and os.path.exists(interfaceFile):
- os.rename(interfaceFile, originalFile)
-
- lines = self.generate()
- with open(interfaceFile, 'w') as fp:
- for line in lines:
- fp.write('%s\n' % line)
-
- self.if_down_up()
diff --git a/cloudinit/sources/helpers/vmware/imc/config_source.py b/cloudinit/sources/helpers/vmware/imc/config_source.py
deleted file mode 100644
index 28ef306a..00000000
--- a/cloudinit/sources/helpers/vmware/imc/config_source.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2015 Canonical Ltd.
-# Copyright (C) 2015 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-class ConfigSource(object):
- """Specifies a source for the Config Content."""
- pass
diff --git a/cloudinit/sources/helpers/vmware/imc/guestcust_error.py b/cloudinit/sources/helpers/vmware/imc/guestcust_error.py
deleted file mode 100644
index d1546852..00000000
--- a/cloudinit/sources/helpers/vmware/imc/guestcust_error.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2016 Canonical Ltd.
-# Copyright (C) 2016 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-class GuestCustErrorEnum(object):
- """Specifies different errors of Guest Customization engine"""
-
- GUESTCUST_ERROR_SUCCESS = 0
diff --git a/cloudinit/sources/helpers/vmware/imc/guestcust_event.py b/cloudinit/sources/helpers/vmware/imc/guestcust_event.py
deleted file mode 100644
index ce90c898..00000000
--- a/cloudinit/sources/helpers/vmware/imc/guestcust_event.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2016 Canonical Ltd.
-# Copyright (C) 2016 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-class GuestCustEventEnum(object):
- """Specifies different types of Guest Customization Events"""
-
- GUESTCUST_EVENT_CUSTOMIZE_FAILED = 100
- GUESTCUST_EVENT_NETWORK_SETUP_FAILED = 101
- GUESTCUST_EVENT_ENABLE_NICS = 103
- GUESTCUST_EVENT_QUERY_NICS = 104
diff --git a/cloudinit/sources/helpers/vmware/imc/guestcust_state.py b/cloudinit/sources/helpers/vmware/imc/guestcust_state.py
deleted file mode 100644
index 422a096d..00000000
--- a/cloudinit/sources/helpers/vmware/imc/guestcust_state.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2016 Canonical Ltd.
-# Copyright (C) 2016 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-class GuestCustStateEnum(object):
- """Specifies different states of Guest Customization engine"""
-
- GUESTCUST_STATE_RUNNING = 4
- GUESTCUST_STATE_DONE = 5
diff --git a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py b/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
deleted file mode 100644
index c07c5949..00000000
--- a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
+++ /dev/null
@@ -1,128 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2016 Canonical Ltd.
-# Copyright (C) 2016 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import logging
-import os
-import time
-
-from cloudinit import util
-
-from .guestcust_event import GuestCustEventEnum
-from .guestcust_state import GuestCustStateEnum
-
-logger = logging.getLogger(__name__)
-
-
-CLOUDINIT_LOG_FILE = "/var/log/cloud-init.log"
-QUERY_NICS_SUPPORTED = "queryNicsSupported"
-NICS_STATUS_CONNECTED = "connected"
-
-
-# This will send a RPC command to the underlying
-# VMware Virtualization Platform.
-def send_rpc(rpc):
- if not rpc:
- return None
-
- out = ""
- err = "Error sending the RPC command"
-
- try:
- logger.debug("Sending RPC command: %s", rpc)
- (out, err) = util.subp(["vmware-rpctool", rpc], rcs=[0])
- # Remove the trailing newline in the output.
- if out:
- out = out.rstrip()
- except Exception as e:
- logger.debug("Failed to send RPC command")
- logger.exception(e)
-
- return (out, err)
-
-
-# This will send the customization status to the
-# underlying VMware Virtualization Platform.
-def set_customization_status(custstate, custerror, errormessage=None):
- message = ""
-
- if errormessage:
- message = CLOUDINIT_LOG_FILE + "@" + errormessage
- else:
- message = CLOUDINIT_LOG_FILE
-
- rpc = "deployPkg.update.state %d %d %s" % (custstate, custerror, message)
- (out, err) = send_rpc(rpc)
- return (out, err)
-
-
-# This will read the file nics.txt in the specified directory
-# and return the content
-def get_nics_to_enable(dirpath):
- if not dirpath:
- return None
-
- NICS_SIZE = 1024
- nicsfilepath = os.path.join(dirpath, "nics.txt")
- if not os.path.exists(nicsfilepath):
- return None
-
- with open(nicsfilepath, 'r') as fp:
- nics = fp.read(NICS_SIZE)
-
- return nics
-
-
-# This will send a RPC command to the underlying VMware Virtualization platform
-# and enable nics.
-def enable_nics(nics):
- if not nics:
- logger.warning("No Nics found")
- return
-
- enableNicsWaitRetries = 5
- enableNicsWaitCount = 5
- enableNicsWaitSeconds = 1
-
- for attempt in range(0, enableNicsWaitRetries):
- logger.debug("Trying to connect interfaces, attempt %d", attempt)
- (out, err) = set_customization_status(
- GuestCustStateEnum.GUESTCUST_STATE_RUNNING,
- GuestCustEventEnum.GUESTCUST_EVENT_ENABLE_NICS,
- nics)
- if not out:
- time.sleep(enableNicsWaitCount * enableNicsWaitSeconds)
- continue
-
- if out != QUERY_NICS_SUPPORTED:
- logger.warning("NICS connection status query is not supported")
- return
-
- for count in range(0, enableNicsWaitCount):
- (out, err) = set_customization_status(
- GuestCustStateEnum.GUESTCUST_STATE_RUNNING,
- GuestCustEventEnum.GUESTCUST_EVENT_QUERY_NICS,
- nics)
- if out and out == NICS_STATUS_CONNECTED:
- logger.info("NICS are connected on %d second", count)
- return
-
- time.sleep(enableNicsWaitSeconds)
-
- logger.warning("Can't connect network interfaces after %d attempts",
- enableNicsWaitRetries)
diff --git a/cloudinit/sources/helpers/vmware/imc/ipv4_mode.py b/cloudinit/sources/helpers/vmware/imc/ipv4_mode.py
deleted file mode 100644
index 873ddc3b..00000000
--- a/cloudinit/sources/helpers/vmware/imc/ipv4_mode.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2015 Canonical Ltd.
-# Copyright (C) 2015 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-class Ipv4ModeEnum(object):
- """
- The IPv4 configuration mode which directly represents the user's goal.
-
- This mode effectively acts as a contract of the in-guest customization
- engine. It must be set based on what the user has requested and should
- not be changed by those layers. It's up to the in-guest engine to
- interpret and materialize the user's request.
- """
-
- # The legacy mode which only allows dhcp/static based on whether IPv4
- # addresses list is empty or not
- IPV4_MODE_BACKWARDS_COMPATIBLE = 'BACKWARDS_COMPATIBLE'
-
- # IPv4 must use static address. Reserved for future use
- IPV4_MODE_STATIC = 'STATIC'
-
- # IPv4 must use DHCPv4. Reserved for future use
- IPV4_MODE_DHCP = 'DHCP'
-
- # IPv4 must be disabled
- IPV4_MODE_DISABLED = 'DISABLED'
-
- # IPv4 settings should be left untouched. Reserved for future use
- IPV4_MODE_AS_IS = 'AS_IS'
diff --git a/cloudinit/sources/helpers/vmware/imc/nic.py b/cloudinit/sources/helpers/vmware/imc/nic.py
deleted file mode 100644
index b5d704ea..00000000
--- a/cloudinit/sources/helpers/vmware/imc/nic.py
+++ /dev/null
@@ -1,147 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2015 Canonical Ltd.
-# Copyright (C) 2015 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-from .boot_proto import BootProtoEnum
-from .nic_base import NicBase, StaticIpv4Base, StaticIpv6Base
-
-
-class Nic(NicBase):
- """
- Holds the information about each NIC specified
- in the customization specification file
- """
-
- def __init__(self, name, configFile):
- self._name = name
- self._configFile = configFile
-
- def _get(self, what):
- return self._configFile.get(self.name + '|' + what, None)
-
- def _get_count_with_prefix(self, prefix):
- return self._configFile.get_count_with_prefix(self.name + prefix)
-
- @property
- def name(self):
- return self._name
-
- @property
- def mac(self):
- return self._get('MACADDR').lower()
-
- @property
- def primary(self):
- value = self._get('PRIMARY')
- if value:
- value = value.lower()
- return value == 'yes' or value == 'true'
- else:
- return False
-
- @property
- def onboot(self):
- value = self._get('ONBOOT')
- if value:
- value = value.lower()
- return value == 'yes' or value == 'true'
- else:
- return False
-
- @property
- def bootProto(self):
- value = self._get('BOOTPROTO')
- if value:
- return value.lower()
- else:
- return ""
-
- @property
- def ipv4_mode(self):
- value = self._get('IPv4_MODE')
- if value:
- return value.lower()
- else:
- return ""
-
- @property
- def staticIpv4(self):
- """
- Checks the BOOTPROTO property and returns StaticIPv4Addr
- configuration object if STATIC configuration is set.
- """
- if self.bootProto == BootProtoEnum.STATIC:
- return [StaticIpv4Addr(self)]
- else:
- return None
-
- @property
- def staticIpv6(self):
- cnt = self._get_count_with_prefix('|IPv6ADDR|')
-
- if not cnt:
- return None
-
- result = []
- for index in range(1, cnt + 1):
- result.append(StaticIpv6Addr(self, index))
-
- return result
-
-
-class StaticIpv4Addr(StaticIpv4Base):
- """Static IPV4 Setting."""
-
- def __init__(self, nic):
- self._nic = nic
-
- @property
- def ip(self):
- return self._nic._get('IPADDR')
-
- @property
- def netmask(self):
- return self._nic._get('NETMASK')
-
- @property
- def gateways(self):
- value = self._nic._get('GATEWAY')
- if value:
- return [x.strip() for x in value.split(',')]
- else:
- return None
-
-
-class StaticIpv6Addr(StaticIpv6Base):
- """Static IPV6 Address."""
-
- def __init__(self, nic, index):
- self._nic = nic
- self._index = index
-
- @property
- def ip(self):
- return self._nic._get('IPv6ADDR|' + str(self._index))
-
- @property
- def netmask(self):
- return self._nic._get('IPv6NETMASK|' + str(self._index))
-
- @property
- def gateway(self):
- return self._nic._get('IPv6GATEWAY|' + str(self._index))
diff --git a/cloudinit/sources/helpers/vmware/imc/nic_base.py b/cloudinit/sources/helpers/vmware/imc/nic_base.py
deleted file mode 100644
index 3c892db0..00000000
--- a/cloudinit/sources/helpers/vmware/imc/nic_base.py
+++ /dev/null
@@ -1,154 +0,0 @@
-# vi: ts=4 expandtab
-#
-# Copyright (C) 2015 Canonical Ltd.
-# Copyright (C) 2015 VMware Inc.
-#
-# Author: Sankar Tanguturi <stanguturi@vmware.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-class NicBase(object):
- """
- Define what are expected of each nic.
- The following properties should be provided in an implementation class.
- """
-
- @property
- def mac(self):
- """
- Retrieves the mac address of the nic
- @return (str) : the MACADDR setting
- """
- raise NotImplementedError('MACADDR')
-
- @property
- def primary(self):
- """
- Retrieves whether the nic is the primary nic
- Indicates whether NIC will be used to define the default gateway.
- If none of the NICs is configured to be primary, default gateway won't
- be set.
- @return (bool): the PRIMARY setting
- """
- raise NotImplementedError('PRIMARY')
-
- @property
- def onboot(self):
- """
- Retrieves whether the nic should be up at the boot time
- @return (bool) : the ONBOOT setting
- """
- raise NotImplementedError('ONBOOT')
-
- @property
- def bootProto(self):
- """
- Retrieves the boot protocol of the nic
- @return (str): the BOOTPROTO setting, valid values: dhcp and static.
- """
- raise NotImplementedError('BOOTPROTO')
-
- @property
- def ipv4_mode(self):
- """
- Retrieves the IPv4_MODE
- @return (str): the IPv4_MODE setting, valid values:
- backwards_compatible, static, dhcp, disabled, as_is
- """
- raise NotImplementedError('IPv4_MODE')
-
- @property
- def staticIpv4(self):
- """
- Retrieves the static IPv4 configuration of the nic
- @return (StaticIpv4Base list): the static ipv4 setting
- """
- raise NotImplementedError('Static IPv4')
-
- @property
- def staticIpv6(self):
- """
- Retrieves the IPv6 configuration of the nic
- @return (StaticIpv6Base list): the static ipv6 setting
- """
- raise NotImplementedError('Static Ipv6')
-
- def validate(self):
- """
- Validate the object
- For example, the staticIpv4 property is required and should not be
- empty when ipv4Mode is STATIC
- """
- raise NotImplementedError('Check constraints on properties')
-
-
-class StaticIpv4Base(object):
- """
- Define what are expected of a static IPv4 setting
- The following properties should be provided in an implementation class.
- """
-
- @property
- def ip(self):
- """
- Retrieves the Ipv4 address
- @return (str): the IPADDR setting
- """
- raise NotImplementedError('Ipv4 Address')
-
- @property
- def netmask(self):
- """
- Retrieves the Ipv4 NETMASK setting
- @return (str): the NETMASK setting
- """
- raise NotImplementedError('Ipv4 NETMASK')
-
- @property
- def gateways(self):
- """
- Retrieves the gateways on this Ipv4 subnet
- @return (str list): the GATEWAY setting
- """
- raise NotImplementedError('Ipv4 GATEWAY')
-
-
-class StaticIpv6Base(object):
- """Define what are expected of a static IPv6 setting
- The following properties should be provided in an implementation class.
- """
-
- @property
- def ip(self):
- """
- Retrieves the Ipv6 address
- @return (str): the IPv6ADDR setting
- """
- raise NotImplementedError('Ipv6 Address')
-
- @property
- def netmask(self):
- """
- Retrieves the Ipv6 NETMASK setting
- @return (str): the IPv6NETMASK setting
- """
- raise NotImplementedError('Ipv6 NETMASK')
-
- @property
- def gateway(self):
- """
- Retrieves the Ipv6 GATEWAY setting
- @return (str): the IPv6GATEWAY setting
- """
- raise NotImplementedError('Ipv6 GATEWAY')