ó oBú]c@s²ddlmZddlZddlmZmZddlmZddlm Z ddlm Z ej e ƒZ de jfd„ƒYZeZee jffgZd „ZdS( iÿÿÿÿ(t b64decodeN(tCepkot SERIAL_PORT(tlog(tsources(tutiltDataSourceCloudSigmacBs\eZdZdZd„Zd„Zd„Zd„Zeeed„Z d„Z d„Z RS( sÍ Uses cepko in order to gather the server context from the VM. For more information about CloudSigma's Server Context: http://cloudsigma-docs.readthedocs.org/en/latest/server_context.html t CloudSigmacCs2tƒ|_d|_tjj||||ƒdS(Nt(Rtcepkotssh_public_keyRt DataSourcet__init__(tselftsys_cfgtdistrotpaths((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceCloudSigma.pyR s  cCsStjdƒtjdƒ}|s3tjdƒtStjd|ƒd|jƒkS(s Uses dmi data to detect if this instance of cloud-init is running in the CloudSigma's infrastructure. s0determining hypervisor product name via dmi datassystem-product-names-system-product-name not available in dmi datasdetected hypervisor as %st cloudsigma(tLOGtdebugRt read_dmi_datatFalsetlower(R tsys_product_name((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceCloudSigma.pytis_running_in_cloudsigma"s  cCs d }|jƒstSy |jjƒj}|d}Wntk rWtjdƒtSX|j |j dƒgƒ|_ |t j kr‰tS|j ddƒjdƒ}|j ddƒ|_d|krÚt|jƒ|_nd|j d iƒkr|d d|_n||_|d |_tS( sj Metadata is the whole server context and /meta/cloud-config is used as userdata. tmetas+CloudSigma: Unable to read from serial portscloudinit-dsmodet base64_fieldsRt,scloudinit-user-datat cloudinitt vendor_dataR N(tNoneRRR talltresultt ExceptionRRt_determine_dsmodetgettdsmodeRtDSMODE_DISABLEDtsplitt userdata_rawRtvendordata_rawtmetadataR tTrue(R R$tserver_contextt server_metaR((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceCloudSigma.pyt _get_data0s,      cCsdtS(s/Return the subplatform metadata source details.s cepko (%s)(R(R ((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceCloudSigma.pyt_get_subplatformSscCsDtjd|jdƒr(|jdd S|jdjdƒdSdS(s† Cleans up and uses the server's name if the latter is set. Otherwise the first part from uuid is being used. s^[A-Za-z0-9 -_\.]+$tnamei=tuuidt-iN(tretmatchR)R&(R tfqdnt resolve_ipt metadata_only((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceCloudSigma.pyt get_hostnameWscCs |jgS(N(R (R ((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceCloudSigma.pytget_public_ssh_keysascCs |jdS(NR0(R)(R ((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceCloudSigma.pytget_instance_idds( t__name__t __module__t__doc__tdsnameR RR-R.RR7R8R9(((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceCloudSigma.pyRs   #  cCstj|tƒS(sK Return a list of data sources that match this set of dependencies (Rtlist_from_dependst datasources(tdepends((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceCloudSigma.pytget_datasource_listrs(tbase64RR2tcloudinit.cs_utilsRRRRtloggingRRt getLoggerR:RR RtDataSourceCloudSigmaNettDEP_FILESYSTEMR?RA(((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceCloudSigma.pyts V