Ejemplo n.º 1
0
 def create_host(self, host):
     partitions = Partitions()
     result = partitions.add_host(host['partition'], host['name'])
     if result['status'] == 'ok':
         host['uuid'] = str(uuid.uuid4())
         return self.hosts_repository.create_host(host)
     else:
         return {"add_host": "error", "reason": result['reason']}
Ejemplo n.º 2
0
 def create_host(self, host):
     partitions = Partitions()
     result = partitions.add_host(host['partition'], host['name'])
     if result['status'] == 'ok':
         host['uuid'] = str(uuid.uuid4())
         return self.hosts_repository.create_host(host)
     else:
         return {"add_host": "error", "reason": result['reason']}
Ejemplo n.º 3
0
class PartitionsHostHandler(tornado.web.RequestHandler):
    def initialize(self, logger):
        self.partitions = Partitions()
        self.logger = logger

    def put(self, name=None, host=False):
        self.logger.info("partitions PUT name: " + name + "host: " + host)
        if name and host:
            result = self.partitions.add_host(name, host)
            if result['status'] == 'ok':
                response = {"add_host": "success"}
            else:
                response = {"add_host": "error", "reason": result['reason']}
        elif not name and not host_name:
            response = {"update": "error", "reason": "missing name and host parameters"}
        return self.write(json.dumps(response))