File: //lib/python2.7/site-packages/azurelinuxagent/common/osutil/bigip.pyc
�
d�bc @ s* d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z yK d d l
j j Z d d l
j j j Z d d l m Z d d l m Z WnR e k
rd d l j Z d d l j j Z d d l m Z d d l m Z n Xd e f d � � YZ d S( i����N( t array_to_bytes( t OSUtilError( t
DefaultOSUtilt BigIpOSUtilc B s� e Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z
d � Z d
� Z d d d � Z d d
d � Z d � Z d d � Z d � Z e d � Z d � Z d � Z d � Z d � Z RS( c C s t t | � j � d S( N( t superR t __init__( t self( ( sG /usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/bigip.pyR / s c C s� xc t d d � D]R } t j d � t j d d t �} | d k rU t j d � Pn t j d � q W| d k rv t St d � � d
S( sW Wait for mcpd to become available
All configuration happens in mcpd so we need to wait that this is
available before we go provisioning the system. I call this method
at the first opportunity I have (during the DVD mounting call).
This ensures that the rest of the provisioning does not need to wait
for mcpd to be available unless it absolutely wants to.
:return bool: Returns True upon success
:raises OSUtilError: Raises exception if mcpd does not come up within
roughly 50 minutes (100 * 30 seconds)
i id s Checking to see if mcpd is upsU /usr/bin/tmsh -a show sys mcp-state field-fmt 2>/dev/null | grep phase | grep runningt chk_erri s mcpd is up!i s5 mcpd hasn't completed initialization! Cannot proceed!N(
t ranget loggert infot shellutilt runt Falset timet sleept TrueR ( R t retriest rc( ( sG /usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/bigip.pyt _wait_until_mcpd_is_initialized2 s
c C s5 d } t j | � } | d k r1 t j d � n | S( Ns /usr/bin/tmsh save sys configi s, WARNING: Cannot save sys config on 1st boot.( R R R t error( R t cmdR ( ( sG /usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/bigip.pyt _save_sys_configO s
c C s t j d d t �S( Ns /usr/bin/bigstart restart sshdR ( R R R
( R ( ( sG /usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/bigip.pyt restart_ssh_serviceV s c C s t j d j | j � d t �S( Ns /sbin/service {0} stopR ( R R t formatt service_nameR
( R ( ( sG /usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/bigip.pyt stop_agent_serviceY s c C s t j d j | j � d t �S( Ns /sbin/service {0} startR ( R R R R R
( R ( ( sG /usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/bigip.pyt start_agent_service\ s c C s t j d j | j � d t �S( Ns /sbin/chkconfig --add {0}R ( R R R R R
( R ( ( sG /usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/bigip.pyt register_agent_service_ s c C s t j d j | j � d t �S( Ns /sbin/chkconfig --del {0}R ( R R R R R
( R ( ( sG /usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/bigip.pyt unregister_agent_serviceb s c C s | j d d g � S( Ns /sbin/pidoft dhclient( t
_get_dhcp_pid( R ( ( sG /usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/bigip.pyt get_dhcp_pide s c C s d S( s> Set the static hostname of the device
Normally, tmsh is used to set the hostname for the system. For our
purposes at this time though, I would hesitate to trust this function.
Azure(Stack) uses the name that you provide in the Web UI or ARM (for
example) as the value of the hostname argument to this method. The
problem is that there is nowhere in the UI that specifies the
restrictions and checks that tmsh has for the hostname.
For example, if you set the name "bigip1" in the Web UI, Azure(Stack)
considers that a perfectly valid name. When WAAgent gets around to
running though, tmsh will reject that value because it is not a fully
qualified domain name. The proper value should have been bigip.xxx.yyy
WAAgent will not fail if this command fails, but the hostname will not
be what the user set either. Currently we do not set the hostname when
WAAgent starts up, so I am passing on setting it here too.
:param hostname: The hostname to set on the device
N( t None( R t hostname( ( sG /usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/bigip.pyt set_hostnameh s c C s d S( s� Sets the DHCP hostname
See `set_hostname` for an explanation of why I pass here
:param hostname: The hostname to set on the device
N( R! ( R R"