Example #1
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))
Example #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))
Example #3
0
File: crm_gv.py Project: 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)
Example #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)