예제 #1
0
 def ha_node_get(self):
     node_name = self.args.name
     result = self.zk.get_node(node_name)
     if self.args.format == 'pretty':
         print(utils.format_output('node', result))
     else:
         print(result.to_dict())
예제 #2
0
 def ha_service_list(self):
     result = self.zk.list_services(self.args.node, self.args.role,
                                    self.args.status)
     if self.args.format == 'pretty':
         print(utils.format_output('service', result))
     else:
         print(result.to_dict())
예제 #3
0
 def ha_node_list(self):
     result = self.zk.list_nodes(node_role_filter=self.args.role,
                                 node_type_filter=self.args.type)
     if self.args.format == 'pretty':
         print(utils.format_output('node', result))
     else:
         dict_result = []
         for node in result:
             dict_result.append(node.to_dict())
         print(dict_result)
예제 #4
0
 def ha_node_update(self):
     node_name = self.args.name
     if self.args.maintain is None and not self.args.role:
         raise exceptions.ClientError("Too few arguments")
     maintain = self.args.maintain
     role = self.args.role
     result = self.zk.update_node(node_name, maintain, role)
     if self.args.format == 'pretty':
         print(utils.format_output('node', result))
     else:
         print(result.to_dict())
예제 #5
0
    def ha_node_create(self):
        if self.args.type == 'zookeeper':
            if self.args.role != 'zookeeper':
                raise argparse.ArgumentTypeError(
                    'zookeeper node must  be zookeeper type.')
        else:
            if self.args.role == 'zookeeper':
                raise argparse.ArgumentTypeError(
                    'zookeeper node must be zookeeper type.')

        result = self.zk.create_node(self.args.name, self.args.role,
                                     self.args.type, self.args.ip)

        if self.args.format == 'pretty':
            print(utils.format_output('node', result))
        else:
            print(result.to_dict())
예제 #6
0
 def ha_service_get(self):
     result = self.zk.get_service(self.args.name.lower(), self.args.node)
     if self.args.format == 'pretty':
         print(utils.format_output('service', result))
     else:
         print(result.to_dict())
예제 #7
0
 def ha_node_list(self):
     result = self.zk.list_nodes()
     if self.args.format == 'pretty':
         print(utils.format_output('node', result))
     else:
         print(result.to_dict())
예제 #8
0
 def repo_list(self):
     r = repo.Repo(self.args.server, self.args.app_id, self.args.app_key)
     repos = r.list()
     print(utils.format_output('repo', repos))
     print("Total: %s" % len(repos))