Пример #1
0
def ssh_run_command_async(ssh, cmd):
    try:
        ssh.start_command(cmd)
        return True
    except Exception, e:
        LOG.warn("Execute command %s failed with Exception:%s" % (cmd, str(e)))
        return False
Пример #2
0
 def get_cp_hfscheck_attribute(self, cp_name, hfscheck_attr):
     '''
     Get the hfscheck attribute while checkpoint creating.
     @cp_name:   String;The check point need to be get attribute.
     @hfscheck_attr:String;The attribute in hfscheck part
     @output:Boolean;True if succeed
     '''
     hfscheck_obj = self.get_cp_attribute(cp_name, 'hfscheck_obj')
     if (hfscheck_obj == False): return False
     for name, value in vars(hfscheck_obj).items():
         #print "name=%s value=%s" %(name,value)
         if (name == hfscheck_attr): return value
     LOG.warn("%s: Failed to get checkpoint:%s attribute %s" %
              (self.__classname, cp_name, attr))
     return False
Пример #3
0
 def get_cp_attribute(self, cp_name, attribute):
     '''
     Get the attribute value  of the specific check point. call command "avmaint lscp"
     @cp_name:    String;The checkpoint name to be search
     @attribute:      String;The attribute name of the specific check point.
     @output:    String or False; The attribute value of the specific check point
     '''
     cpobjs = self._get_all_status()
     if (cpobjs == False): return False
     for cpobj in cpobjs:
         LOG.info("cpobj.tag:%s" % (cpobj.tag))
         if (cpobj.tag == cp_name):
             for name, value in vars(cpobj).items():
                 LOG.info("name=%s value=%s" % (name, value))
                 if (name == attribute): return value
     LOG.warn("%s: Failed to get checkpoint:%s attribute %s" %
              (self.__classname, cp_name, attribute))
     return False
Пример #4
0
def ssh_run_command(ssh, cmd):
    try:
        result = ssh.run_command(cmd)
    except Exception, e:
        LOG.warn("Execute command %s failed with Exception:%s" % (cmd, str(e)))
        return ''
Пример #5
0
        result = ssh.run_command(cmd)
    except Exception, e:
        LOG.warn("Execute command %s failed with Exception:%s" % (cmd, str(e)))
        return False
    if result[2]: return False
    return True


def ssh_run_command(ssh, cmd):
    try:
        result = ssh.run_command(cmd)
    except Exception, e:
        LOG.warn("Execute command %s failed with Exception:%s" % (cmd, str(e)))
        return ''
    if result[2]:
        LOG.warn("cmd failed:%s" % (cmd))
        for i in range(2):
            LOG.warn("result[%d] :%s" % (i, result[i]))
        return ''
    #stdout
    return result[0]


def ssh_run_command_async(ssh, cmd):
    try:
        ssh.start_command(cmd)
        return True
    except Exception, e:
        LOG.warn("Execute command %s failed with Exception:%s" % (cmd, str(e)))
        return False