| Server IP : 23.254.227.96 / Your IP : 216.73.216.183 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3.6/site-packages/cloudinit/sources/__pycache__/ |
Upload File : |
3
��bqq � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl m
Z
ddl mZ ddl m
Z
mZ ddlmZmZmZ dZeje�ZdZd Zd
Zed�ZdZd
ZdZdZdZdZ dZ!dZ"dZ#G dd� de
j$�Z%dd� Z&dd� Z'dd� Z(dd� Z)dd � Z*d!d"� Z+d#d$� Z,d%d&� Z-efd'd
�Z.efd(d)�Z/efd*d+�Z0efd,d-�Z1d.d/� Z2d0d1� Z3e%e
j4ffe%e
j4e
j5ffgZ6d2d3� Z7d4d5� Z8dBd7d8�Z9d9d:� Z:d;d<� Z;d=d>� Z<d?d@� Z=edAk�r�e=� dS )Ca� Cloud-Init DataSource for VMware
This module provides a cloud-init datasource for VMware systems and supports
multiple transports types, including:
* EnvVars
* GuestInfo
Netifaces (https://github.com/al45tair/netifaces)
Please note this module relies on the netifaces project to introspect the
runtime, network configuration of the host on which this datasource is
running. This is in contrast to the rest of cloud-init which uses the
cloudinit/netinfo module.
The reasons for using netifaces include:
* Netifaces is built in C and is more portable across multiple systems
and more deterministic than shell exec'ing local network commands and
parsing their output.
* Netifaces provides a stable way to determine the view of the host's
network after DHCP has brought the network online. Unlike most other
datasources, this datasource still provides support for JINJA queries
based on networking information even when the network is based on a
DHCP lease. While this does not tie this datasource directly to
netifaces, it does mean the ability to consistently obtain the
correct information is paramount.
* It is currently possible to execute this datasource on macOS
(which many developers use today) to print the output of the
get_host_info function. This function calls netifaces to obtain
the same runtime network configuration that the datasource would
persist to the local system's instance data.
However, the netinfo module fails on macOS. The result is either a
hung operation that requires a SIGINT to return control to the user,
or, if brew is used to install iproute2mac, the ip commands are used
but produce output the netinfo module is unable to parse.
While macOS is not a target of cloud-init, this feature is quite
useful when working on this datasource.
For more information about this behavior, please see the following
PR comment, https://bit.ly/3fG7OVh.
The authors of this datasource are not opposed to moving away from
netifaces. The goal may be to eventually do just that. This proviso was
added to the top of this module as a way to remind future-us and others
why netifaces was used in the first place in order to either smooth the
transition away from netifaces or embrace it further up the cloud-init
stack.
� N)�dmi)�log)�sources�util)�ProcessExecutionError�subp�whichz/sys/class/dmi/id/product_uuidzNo value foundZenvvar� guestinfozvmware-rpctoolZredactzcleanup-guestinfo�
VMX_GUESTINFOz---z
local-ipv4z
local-ipv6zwait-on-network�ipv4�ipv6c @ sZ e Zd ZdZdZddd�Zdd� Zdd � Zd
d� Ze dd
� �Z
dd� Zdd� Zdd� Z
dS )�DataSourceVMwarea�
Setting the hostname:
The hostname is set by way of the metadata key "local-hostname".
Setting the instance ID:
The instance ID may be set by way of the metadata key "instance-id".
However, if this value is absent then the instance ID is read
from the file /sys/class/dmi/id/product_uuid.
Configuring the network:
The network is configured by setting the metadata key "network"
with a value consistent with Network Config Versions 1 or 2,
depending on the Linux distro's version of cloud-init:
Network Config Version 1 - http://bit.ly/cloudinit-net-conf-v1
Network Config Version 2 - http://bit.ly/cloudinit-net-conf-v2
For example, CentOS 7's official cloud-init package is version
0.7.9 and does not support Network Config Version 2. However,
this datasource still supports supplying Network Config Version 2
data as long as the Linux distro's cloud-init package is new
enough to parse the data.
The metadata key "network.encoding" may be used to indicate the
format of the metadata key "network". Valid encodings are base64
and gzip+base64.
ZVMwareNc C s$ t jj| ||||� d | _t| _d S )N)r �
DataSource�__init__�data_access_method�VMWARE_RPCTOOL�vmware_rpctool)�selfZsys_cfg�distro�pathsZud_proc� r �&/usr/lib/python3.6/DataSourceVMware.pyr � s zDataSourceVMware.__init__c C s. d\}}}t jjtd�rBtd�}td�}td�}|s<|s<|rBt| _| js�tjd�}|dkrht j
d� dS d |j� kr�t j
d
� dS | js�| jr�t
d| j�}t
d| j�}t
d| j�}|s�|s�|r�t| _| js�t jd� dS t jd| j� � tt|��| _|| _|| _| j� | j�s"| j�s"| j�r&d
S dS dS )ay
_get_data loads the metadata, userdata, and vendordata from one of
the following locations in the given order:
* envvars
* guestinfo
Please note when updating this function with support for new data
transports, the order should match the order in the dscheck_VMware
function from the file ds-identify.
N� �metadataZuserdataZ
vendordatazsystem-product-namezNo system-product-name foundFZvmwarezNot a VMware platformz)failed to find a valid data access methodzusing data access method %sT)NNN)�os�environ�getr
�guestinfo_envvar�DATA_ACCESS_METHOD_ENVVARr r Z
read_dmi_data�LOG�debug�lowerr r �DATA_ACCESS_METHOD_GUESTINFO�error�info�_get_subplatform�process_metadata�load_json_or_yamlr Zuserdata_rawZvendordata_raw�redact_keys)r ZmdZudZvdZsystem_typer r r � _get_data� sB
zDataSourceVMware._get_datac C s<