예제 #1
0
파일: corosync.py 프로젝트: lge/crmsh
def pull_configuration(from_node):
    '''
    Copy the configuration from the given node to this node
    '''
    local_path = conf()
    _, fname = tmpfiles.create()
    print "Retrieving %s:%s..." % (from_node, local_path)
    cmd = ['scp', '-qC',
           '-o', 'PasswordAuthentication=no',
           '-o', 'StrictHostKeyChecking=no',
           '%s:%s' % (from_node, local_path),
           fname]
    rc = utils.ext_cmd_nosudo(cmd, shell=False)
    if rc == 0:
        data = open(fname).read()
        newhash = hash(data)
        if os.path.isfile(local_path):
            oldata = open(local_path).read()
            oldhash = hash(oldata)
            if newhash == oldhash:
                print "No change."
                return
        print "Writing %s..."
        local_file = open(local_path, 'w')
        local_file.write(data)
        local_file.close()
    else:
        raise ValueError("Failed to retrieve %s from %s" % (local_path, from_node))
예제 #2
0
def pull_configuration(from_node):
    '''
    Copy the configuration from the given node to this node
    '''
    local_path = conf()
    _, fname = tmpfiles.create()
    print "Retrieving %s:%s..." % (from_node, local_path)
    cmd = [
        'scp', '-qC', '-o', 'PasswordAuthentication=no', '-o',
        'StrictHostKeyChecking=no',
        '%s:%s' % (from_node, local_path), fname
    ]
    rc = utils.ext_cmd_nosudo(cmd, shell=False)
    if rc == 0:
        data = open(fname).read()
        newhash = hash(data)
        if os.path.isfile(local_path):
            oldata = open(local_path).read()
            oldhash = hash(oldata)
            if newhash == oldhash:
                print "No change."
                return
        print "Writing %s..."
        local_file = open(local_path, 'w')
        local_file.write(data)
        local_file.close()
    else:
        raise ValueError("Failed to retrieve %s from %s" %
                         (local_path, from_node))
예제 #3
0
파일: crm_gv.py 프로젝트: lge/crmsh
 def image(self, img_type, outf):
     if not config.core.dot:
         common_err("dot not found")
         return False
     dotf = self.totmpf()
     if not dotf:
         return False
     tmpfiles.add(dotf)
     return (utils.ext_cmd_nosudo("%s -T%s -o%s %s" %
                                  (config.core.dot, img_type, outf, dotf)) == 0)
예제 #4
0
 def image(self, img_type, outf):
     if not config.core.dot:
         common_err("dot not found")
         return False
     dotf = self.totmpf()
     if not dotf:
         return False
     tmpfiles.add(dotf)
     return (utils.ext_cmd_nosudo(
         "%s -T%s -o%s %s" % (config.core.dot, img_type, outf, dotf)) == 0)