Beispiel #1
0
 def _get_app_version(self, args):
     configs = self._get_config()
     app_id = args.app_id
     version_id = args.version_id
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     return borg_client.get_app_version(app_id, version_id)
Beispiel #2
0
    def _create_app(self, args):
        configs = self._get_config()
        try:
            data = json.loads(args.file.read())
        except ValueError as e:
            raise e

        borg_client = borgclient.BorgClient(configs['host'],
                                            token=configs['token'])
        return borg_client.create_app(**data)
Beispiel #3
0
 def _delete_tasks(self, args):
     configs = self._get_config()
     if_scale = False
     if args.if_scale:
         if_scale = args.if_scale
     task_ids = args.task_ids
     data = {"ids": task_ids}
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     return borg_client.delete_tasks(if_scale, **data)
Beispiel #4
0
 def _delete_multi_apps(self, args):
     configs = self._get_config()
     app_ids = args.app_ids
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     delete_results = []
     for app_id in app_ids:
         result = borg_client.delete_app(app_id)
         delete_results.append({"app_id": app_id, "result": result})
     return delete_results
Beispiel #5
0
 def _authen_handler(self, args):
     username = args.username
     password = args.password
     host = args.host
     borg_client = borgclient.BorgClient(host)
     token_json = borg_client.get_token(username, password)
     if "code" in token_json.keys():
         configs = {'host': host}
         configs.update({'token': token_json['data']})
         self._save_config(configs)
     return token_json
Beispiel #6
0
 def _update_registry(self, args):
     configs = self._get_config()
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     registry_id = args.registry_id
     data = {"userName": args.username, "addr": args.addr}
     if args.name:
         data.update({"name": args.name})
     if args.password:
         data.update({"password": args.password})
     return borg_client.update_registry(registry_id, **data)
Beispiel #7
0
 def _create_registry(self, args):
     configs = self._get_config()
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     data = {
         "userName": args.username,
         "password": args.password,
         "addr": args.addr,
     }
     if args.name:
         data.update({"name": args.name})
     return borg_client.create_registry(**data)
Beispiel #8
0
 def _create_multi_apps(self, args):
     configs = self._get_config()
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     app_dir = args.dir
     files = [f for f in listdir(app_dir) if isfile(join(app_dir, f))]
     created_apps = []
     for file in files:
         app_file = join(app_dir, file)
         try:
             with open(app_file, 'r') as f:
                 data = json.loads(f.read())
                 result = borg_client.create_app(**data)
                 created_apps.append({
                     "source_file": file,
                     "result": result
                 })
         except ValueError as e:
             return "Fail to load file " + file + ", please ensure the data is in json format:\n" + str(
                 e)
     return created_apps
Beispiel #9
0
 def _get_borg_version(self, args):
     host = args.host
     borg_client = borgclient.BorgClient(host)
     return borg_client.get_borg_version()
Beispiel #10
0
 def _health_check(self, args):
     host = args.host
     borg_client = borgclient.BorgClient(host)
     return borg_client.health_check()
Beispiel #11
0
 def _switch_group(self, args):
     configs = self._get_config()
     data = {"groupId": args.group_id}
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     return borg_client.switch_group(**data)
Beispiel #12
0
 def _get_my_info(self, args):
     configs = self._get_config()
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     return borg_client.get_user()
Beispiel #13
0
 def _get_queue(self, args):
     configs = self._get_config()
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     return borg_client.get_queue()
Beispiel #14
0
 def _get_registry(self, args):
     configs = self._get_config()
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     registry_id = args.registry_id
     return borg_client.get_registry(registry_id)
Beispiel #15
0
 def _get_group(self, args):
     configs = self._get_config()
     group_id = args.group_id
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     return borg_client.get_group(group_id)
Beispiel #16
0
 def _get_app_tasks(self, args):
     configs = self._get_config()
     app_id = args.app_id
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     return borg_client.get_app_tasks(app_id)
Beispiel #17
0
 def _logout_handler(self, args):
     configs = self._get_config()
     borg_client = borgclient.BorgClient(configs['host'],
                                         token=configs['token'])
     self._delete_config()
     return borg_client.delete_token()