File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/imc.zip
Back
PK n��Z��4 4 config_custom_script.pynu �[��� # Copyright (C) 2017 Canonical Ltd. # Copyright (C) 2017-2019 VMware Inc. # # Author: Maitreyee Saikia <msaikia@vmware.com> # # This file is part of cloud-init. See LICENSE file for license information. import logging import os import stat from cloudinit import subp, util LOG = logging.getLogger(__name__) class CustomScriptNotFound(Exception): pass class CustomScriptConstant: CUSTOM_TMP_DIR = "/root/.customization" # The user defined custom script CUSTOM_SCRIPT_NAME = "customize.sh" CUSTOM_SCRIPT = os.path.join(CUSTOM_TMP_DIR, CUSTOM_SCRIPT_NAME) POST_CUSTOM_PENDING_MARKER = "/.guest-customization-post-reboot-pending" # The cc_scripts_per_instance script to launch custom script POST_CUSTOM_SCRIPT_NAME = "post-customize-guest.sh" class RunCustomScript: def __init__(self, scriptname, directory): self.scriptname = scriptname self.directory = directory self.scriptpath = os.path.join(directory, scriptname) def prepare_script(self): if not os.path.exists(self.scriptpath): raise CustomScriptNotFound( "Script %s not found!! Cannot execute custom script!" % self.scriptpath ) util.ensure_dir(CustomScriptConstant.CUSTOM_TMP_DIR) LOG.debug( "Copying custom script to %s", CustomScriptConstant.CUSTOM_SCRIPT ) util.copy(self.scriptpath, CustomScriptConstant.CUSTOM_SCRIPT) # Strip any CR characters from the decoded script content = util.load_file(CustomScriptConstant.CUSTOM_SCRIPT).replace( "\r", "" ) util.write_file( CustomScriptConstant.CUSTOM_SCRIPT, content, mode=0o544 ) class PreCustomScript(RunCustomScript): def execute(self): """Executing custom script with precustomization argument.""" LOG.debug("Executing pre-customization script") self.prepare_script() subp.subp([CustomScriptConstant.CUSTOM_SCRIPT, "precustomization"]) class PostCustomScript(RunCustomScript): def __init__(self, scriptname, directory, ccScriptsDir): super(PostCustomScript, self).__init__(scriptname, directory) self.ccScriptsDir = ccScriptsDir self.ccScriptPath = os.path.join( ccScriptsDir, CustomScriptConstant.POST_CUSTOM_SCRIPT_NAME ) def execute(self): """ This method copy the post customize run script to cc_scripts_per_instance directory and let this module to run post custom script. """ self.prepare_script() LOG.debug("Copying post customize run script to %s", self.ccScriptPath) util.copy( os.path.join( self.directory, CustomScriptConstant.POST_CUSTOM_SCRIPT_NAME ), self.ccScriptPath, ) st = os.stat(self.ccScriptPath) os.chmod(self.ccScriptPath, st.st_mode | stat.S_IEXEC) LOG.info("Creating post customization pending marker") util.ensure_file(CustomScriptConstant.POST_CUSTOM_PENDING_MARKER) # vi: ts=4 expandtab PK n��Z��K K boot_proto.pynu �[��� # Copyright (C) 2015 Canonical Ltd. # Copyright (C) 2015 VMware Inc. # # Author: Sankar Tanguturi <stanguturi@vmware.com> # # This file is part of cloud-init. See LICENSE file for license information. class BootProtoEnum: """Specifies the NIC Boot Settings.""" DHCP = "dhcp" STATIC = "static" # vi: ts=4 expandtab PK n��Z+Q��� � nic.pynu �[��� # Copyright (C) 2015 Canonical Ltd. # Copyright (C) 2015 VMware Inc. # # Author: Sankar Tanguturi <stanguturi@vmware.com> # # This file is part of cloud-init. See LICENSE file for license information. from cloudinit.sources.helpers.vmware.imc.boot_proto import BootProtoEnum from cloudinit.sources.helpers.vmware.imc.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)) # vi: ts=4 expandtab PK n��Z�L 8H H + __pycache__/guestcust_event.cpython-310.pycnu �[��� o �Ad� � @ s G d d� d�Z dS )c @ s e Zd ZdZdZdZdZdZdS )�GuestCustEventEnumz7Specifies different types of Guest Customization Events�d �e �g �h N)�__name__� __module__�__qualname__�__doc__� GUESTCUST_EVENT_CUSTOMIZE_FAILED�$GUESTCUST_EVENT_NETWORK_SETUP_FAILED�GUESTCUST_EVENT_ENABLE_NICS�GUESTCUST_EVENT_QUERY_NICS� r r �V/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/guestcust_event.pyr s r N)r r r r r �<module> s PK n��Z�!R�t t % __pycache__/ipv4_mode.cpython-310.pycnu �[��� o �Ad` � @ s G d d� d�Z dS )c @ s$ e Zd ZdZdZdZdZdZdZdS )�Ipv4ModeEnuma_ 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. �BACKWARDS_COMPATIBLE�STATIC�DHCP�DISABLED�AS_ISN) �__name__� __module__�__qualname__�__doc__�IPV4_MODE_BACKWARDS_COMPATIBLE�IPV4_MODE_STATIC�IPV4_MODE_DHCP�IPV4_MODE_DISABLED�IPV4_MODE_AS_IS� r r �P/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/ipv4_mode.pyr s r N)r r r r r �<module> s PK n��Z�ۉ�� � $ __pycache__/__init__.cpython-310.pycnu �[��� o �Ad � @ s d S )N� r r r �O/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/__init__.py�<module> s PK n��Z��߫� � + __pycache__/guestcust_state.cpython-310.pycnu �[��� o �Ad} � @ s G d d� d�Z dS )c @ s e Zd ZdZdZdZdS )�GuestCustStateEnumz8Specifies different states of Guest Customization engine� � N)�__name__� __module__�__qualname__�__doc__�GUESTCUST_STATE_RUNNING�GUESTCUST_STATE_DONE� r r �V/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/guestcust_state.pyr s r N)r r r r r �<module> s PK n��Z�Y + __pycache__/guestcust_error.cpython-310.pycnu �[��� o �Ad� � @ s G d d� d�Z dS )c @ s e Zd ZdZdZdZdZdS )�GuestCustErrorEnumz8Specifies different errors of Guest Customization engine� � � N)�__name__� __module__�__qualname__�__doc__�GUESTCUST_ERROR_SUCCESS�GUESTCUST_ERROR_SCRIPT_DISABLED�!GUESTCUST_ERROR_WRONG_META_FORMAT� r r �V/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/guestcust_error.pyr s r N)r r r r r �<module> s PK n��Z�nD $ __pycache__/nic_base.cpython-310.pycnu �[��� o �Ad6 � @ s. G d d� d�Z G dd� d�ZG dd� d�ZdS )c @ sl e Zd ZdZedd� �Zedd� �Zedd� �Zedd � �Zed d� �Z edd � �Z edd� �Zdd� ZdS )�NicBasez{ Define what are expected of each nic. The following properties should be provided in an implementation class. c C � t d��)zb Retrieves the mac address of the nic @return (str) : the MACADDR setting �MACADDR��NotImplementedError��self� r �O/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/nic_base.py�mac � zNicBase.macc C r )a 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 �PRIMARYr r r r r �primary s zNicBase.primaryc C r )zu Retrieves whether the nic should be up at the boot time @return (bool) : the ONBOOT setting �ONBOOTr r r r r �onboot"