Ñò
ýÉªWc           @   s  d  d d d d g Z  d d k Z d d k Z d d k Z d d k l Z d d k l Z d	 e f d
 „  ƒ  YZ d  e f d „  ƒ  YZ d e f d „  ƒ  YZ	 d e f d „  ƒ  YZ
 d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z e d j o e ƒ  n d S(   t
   CMSServicet   TomcatServicet
   FTPServicet   WorkflowServicet   GenericServiceiÿÿÿÿN(   t   SSHCommander(   t   HttpRequestDecoratort
   APPServicec           B   s\   e  Z d  Z d Z d e d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 d
 „ Z RS(   s>   su root -c 'export PATH=$PATH:/sbin; service %(name)s %(cmd)s's   service %(name)s %(cmd)si   c         C   sC   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(   t   _APPService__service_namet   _APPService__server_ipt   _APPService__user_namet   _APPService__login_passwordt   _APPService__root_passwordt   _APPService__timeoutt   _APPService__isNativeService(   t   selft   namet   ipaddrt   usert   passwordt
   rootPasswdt   timeoutt   isNative(    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyt   __init__   s    						c         C   s   |  i  S(   N(   R	   (   R   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyt   getServerIp   s    c         C   sò   |  i  o@ t i h |  i d 6d d 6|  _ t i |  i d ƒ i ƒ  GHd  St i h |  i d 6d d 6|  _ t	 |  i
 |  i |  i ƒ } d |  i d |  i
 GH| i |  i |  i |  i ƒ \ } } | GH| d j o d |  i d |  i
 GHn d  S(	   NR   t   startt   cmdt   rs	   starting s    on i    s   fail to start (   R   R   t   NATIVE_SRV_CMDR   t   _APPService__commandt   ost   popent   readt   REMOTE_SRV_CMDR   R	   R
   R   t   execute_interactiveR   R   (   R   t   clientt   statust   output(    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR      s    
!!$c         C   sò   |  i  o@ t i h |  i d 6d d 6|  _ t i |  i d ƒ i ƒ  GHd  St i h |  i d 6d d 6|  _ t	 |  i
 |  i |  i ƒ } d |  i d |  i
 GH| i |  i |  i |  i ƒ \ } } | GH| d j o d |  i d |  i
 GHn d  S(	   NR   t   stopR   R   s	   stopping s    on i    s   fail to stop (   R   R   R   R   R   R   R   R    R!   R   R	   R
   R   R"   R   R   (   R   R#   R$   R%   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR&   -   s    
!!$c         C   sò   |  i  o@ t i h |  i d 6d d 6|  _ t i |  i d ƒ i ƒ  GHd  St i h |  i d 6d d 6|  _ t	 |  i
 |  i |  i ƒ } d |  i d |  i
 GH| i |  i |  i |  i ƒ \ } } | GH| d j o d |  i d |  i
 GHn d  S(	   NR   t   restartR   R   s   restarting s    on i    s   fail to restart (   R   R   R   R   R   R   R   R    R!   R   R	   R
   R   R"   R   R   (   R   R#   R$   R%   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR'   >   s    
!!$c         C   sò   |  i  o@ t i h |  i d 6d d 6|  _ t i |  i d ƒ i ƒ  GHd  St i h |  i d 6d d 6|  _ t	 |  i
 |  i |  i ƒ } d |  i d |  i
 GH| i |  i |  i |  i ƒ \ } } | GH| d j o d |  i d	 |  i
 GHn d  S(
   NR   R$   R   R   s	   checking s    on i    s   fail to get s    status on (   R   R   R   R   R   R   R   R    R!   R   R	   R
   R   R"   R   R   (   R   R#   R$   R%   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR$   O   s    
!!$i    c         C   s   t  S(   N(   t   True(   R   R   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyt   waitforServiceUp`   s    (   t   __name__t
   __module__R!   R   t   FalseR   R   R   R&   R'   R$   R)   (    (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR      s   
					c           B   s,   e  Z d  d d d e d „ Z d d „ Z RS(   t	   localhostt   cmst   cms1234t   root1234c      	   C   s&   t  i |  d | | | | d | ƒ d  S(   NR.   iZ   (   R   R   (   R   R   R   R   R   R   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR   d   s    iÐ  c         C   sÒ   x¸ | d j oª t  i d ƒ | d } yv d |  i ƒ  d } d | d GHt i | ƒ } | d d d j p | d d d	 j o d
 |  i ƒ  d GHt SWq t i j
 o q Xq Wd
 |  i ƒ  d GHt S(   Ni    i   s   https://s   :8443/portals   Waiting service [s   ] to startup...R$   t   200t   302s   cms service on s    started ups    is still down(	   t   timet   sleepR   R   t   requestR(   t   sockett   errorR,   (   R   R   t   urlt   resp(    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR)   g   s     
*	
(   R*   R+   R,   R   R)   (    (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR    c   s   c           B   s,   e  Z d  d d d e d „ Z d d „ Z RS(   R-   R.   R/   R0   c      	   C   s&   t  i |  d | | | | d | ƒd  S(   Nt   tomcatR   (   R   R   (   R   R   R   R   R   R   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR   y   s    i  c         C   sÀ   x¦ | d j o˜ t  i d ƒ | d } yd d |  i ƒ  d } d | d GHt i | d ƒ } | d d d	 j o d
 |  i ƒ  d GHt SWq t i j
 o q Xq Wd
 |  i ƒ  d GHt S(   Ni    i   s   http://s2   :8081/filemanager/services/FileSubsystemWebservices   Waiting service [s   ] to startup...t   GETR$   R1   s   tomcat service on s    started ups    is still down(	   R3   R4   R   R   R5   R(   R6   R7   R,   (   R   R   R8   R9   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR)   |   s     
	
(   R*   R+   R,   R   R)   (    (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR   x   s   c           B   s,   e  Z d  d d d e d „ Z d d „ Z RS(   R-   R.   R/   R0   c      	   C   s&   t  i |  d | | | | d | ƒ d  S(   Nt   workflowiZ   (   R   R   (   R   R   R   R   R   R   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR   Ž   s    i,  c         C   sÀ   x¦ | d j o˜ t  i d ƒ | d } yd d |  i ƒ  d } d | d GHt i | d ƒ } | d d d	 j o d
 |  i ƒ  d GHt SWq t i j
 o q Xq Wd
 |  i ƒ  d GHt S(   Ni    i   s   http://s&   :7070/workflow/services/AdaptorServices   Waiting service [s   ] to startup...R;   R$   R1   s   workflow service on s    started ups    is still down(	   R3   R4   R   R   R5   R(   R6   R7   R,   (   R   R   R8   R9   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR)   ‘   s     
	
(   R*   R+   R,   R   R)   (    (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR      s   c           B   s    e  Z d  d d d e d „ Z RS(   R-   R.   R/   R0   c      	   C   s&   t  i |  d | | | | d | ƒd  S(   Nt   vsftpdR   (   R   R   (   R   R   R   R   R   R   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR   £   s    (   R*   R+   R,   R   (    (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR   ¢   s   c           B   s    e  Z d  d d d e d „ Z RS(   R-   R.   R/   R0   c      	   C   s&   t  i |  | | | | | d | ƒd  S(   NR   (   R   R   (   R   t   svcnameR   R   R   R   R   (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR   §   s    (   R*   R+   R,   R   (    (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyR   ¦   s   c          C   s   t  d t ƒ }  |  i ƒ  d  S(   NR   (   R   R(   R&   (   t   service(    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyt   mainª   s    t   __main__(   t   __all__R3   R6   R   R   R   t   objectR   R    R   R   R   R   R@   R*   (    (    (    sd   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/APPService.pyt   <module>   s   W	