Exemple #1
0
    def build_map(self):

        fc = func_client.Overlord("*")
        fc.timeout = self.options.timeout
        minion_hash = fc.overlord.map_minions(self.options.only_alive==True)

        for minion in minion_hash.keys(): #clean hash of any top-level errors
            if utils.is_error(minion_hash[minion]):
                minion_hash[minion] = {}

        if self.options.verbose:
            print "- built the following map:"
            print minion_hash

        if self.options.append:
            try:
                oldmap = file(DEFAULT_TREE, 'r').read()
                old_hash = yaml.load(oldmap).next()
                oldmap.close()
            except e:
                sys.stderr.write("ERROR: old map could not be read, append failed\n")
                sys.exit(-1)

            merged_map = {}
            merged_map.update(old_hash)
            merged_map.update(minion_hash)

            if self.options.verbose:
                print "- appended new map to the following map:"
                print old_hash
                print "  resulting in:"
                print merged_map

            minion_hash = merged_map

        if self.options.verbose:
            print "- writing to %s" % DEFAULT_TREE

        mapfile = file(DEFAULT_TREE, 'w')
        data = yaml.dump(minion_hash)
        mapfile.write(data)
Exemple #2
0
    def build_map(self):

        minion_hash = func_client.Overlord("*").overlord.map_minions(
            self.options.only_alive == True)

        for minion in minion_hash.keys():  #clean hash of any top-level errors
            if utils.is_error(minion_hash[minion]):
                minion_hash[minion] = {}

        if self.options.verbose:
            print "- built the following map:"
            print minion_hash

        if self.options.append:
            try:
                oldmap = file(DEFAULT_TREE, 'r').read()
                old_hash = yaml.load(oldmap).next()
                oldmap.close()
            except e:
                sys.stderr.write(
                    "ERROR: old map could not be read, append failed\n")
                sys.exit(-1)

            merged_map = {}
            merged_map.update(old_hash)
            merged_map.update(minion_hash)

            if self.options.verbose:
                print "- appended new map to the following map:"
                print old_hash
                print "  resulting in:"
                print merged_map

            minion_hash = merged_map

        if self.options.verbose:
            print "- writing to %s" % DEFAULT_TREE

        mapfile = file(DEFAULT_TREE, 'w')
        data = yaml.dump(minion_hash)
        mapfile.write(data)
Exemple #3
0
    def build_map(self):

        minion_hash = func_client.Overlord("*").overlord.map_minions(
            self.options.only_alive == True)

        if self.options.verbose:
            print "- built the following map:"
            print minion_hash

        if self.options.append:
            try:
                oldmap = file(DEFAULT_TREE, 'r').read()
                old_hash = yaml.load(oldmap).next()
                oldmap.close()
            except e:
                print "ERROR: old map could not be read, append failed"
                sys.exit(-1)

            merged_map = {}
            merged_map.update(old_hash)
            merged_map.update(minion_hash)

            if self.options.verbose:
                print "- appended new map to the following map:"
                print old_hash
                print "  resulting in:"
                print merged_map

            minion_hash = merged_map

        if self.options.verbose:
            print "- writing to %s" % DEFAULT_TREE

        mapfile = file(DEFAULT_TREE, 'w')
        data = yaml.dump(minion_hash)
        mapfile.write(data)
Exemple #4
0
 def _deserialize(self, buf):
     data = yaml.load(buf).next()
     return data
Exemple #5
0
 def _deserialize(self, buf):
     data = yaml.load(buf).next()
     return data