Esempio n. 1
0
 def project_lists(self):
     """
     Return the project lists of the user.
     """
     url = get_api_server_url('/api/projects/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 2
0
 def list_hosts(self):
     """
     List all hosts.
     """
     url = get_api_server_url('/api/hosts/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 3
0
 def list_users(self):
     """
     Get user lists only for admin user.
     """
     url = get_api_server_url('/api/users/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 4
0
 def list_projects(self):
     """
     List all projects for admin user.
     """
     url = get_api_server_url('/api/projects/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 5
0
 def get_project(self, project_id):
     """
     Get the detail info of the project.
     """
     url = get_api_server_url('/api/projects/{}/'.format(project_id))
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 6
0
 def get_resourcelimits(self):
     """
     Get the resource limits list.
     """
     url = get_api_server_url('/api/resourcelimits/')
     res = self.client.get(url)
     return json.loads(res.text)
Esempio n. 7
0
 def get_resourcelimit(self, lid):
     """
     Get the resource limit with id lid.
     """
     url = get_api_server_url('/api/resourcelimits/{}/'.format(lid))
     res = self.client.get(url)
     return json.loads(res.text)
Esempio n. 8
0
 def list_projects(self):
     """
     List all projects for admin user.
     """
     url = get_api_server_url('/api/projects/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 9
0
 def get_public_images(self):
     """
     Get public images.
     """
     url = get_api_server_url('/api/publics/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 10
0
 def get_project(self, project_id):
     """
     Get the detail info of the project.
     """
     url = get_api_server_url('/api/projects/{}/'.format(project_id))
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 11
0
 def list_users(self):
     """
     Get user lists only for admin user.
     """
     url = get_api_server_url('/api/users/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 12
0
 def get_public_images(self):
     """
     Get public images.
     """
     url = get_api_server_url('/api/publics/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 13
0
 def get_resourcelimits(self):
     """
     Get the resource limits list.
     """
     url = get_api_server_url('/api/resourcelimits/')
     res = self.client.get(url)
     return json.loads(res.text)
Esempio n. 14
0
 def project_lists(self):
     """
     Return the project lists of the user.
     """
     url = get_api_server_url('/api/projects/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 15
0
 def list_resource_modules(self):
     """
     Return resource modules only for admin user.
     """
     url = get_api_server_url('/api/resourcelimits/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 16
0
 def list_resource_modules(self):
     """
     Return resource modules only for admin user.
     """
     url = get_api_server_url('/api/resourcelimits/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 17
0
 def list_hosts(self):
     """
     List all hosts.
     """
     url = get_api_server_url('/api/hosts/')
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 18
0
 def get_resourcelimit(self, lid):
     """
     Get the resource limit with id lid.
     """
     url = get_api_server_url('/api/resourcelimits/{}/'.format(lid))
     res = self.client.get(url)
     return json.loads(res.text)
Esempio n. 19
0
 def get_volume_username(self, project_id, volume_id):
     """
     Get the username of the volume.
     """
     url = get_api_server_url('/api/projects/{}/volumes/{}/username/'.format(
         project_id, volume_id))
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 20
0
 def download_from_volume(self, project_id, volume_id):
     """
     Download data from volume with id volume_id.
     """
     url = get_api_server_url('/api/projects/{}/volumes/{}/download/'
         .format(project_id, volume_id))
     response = self.client.get(url)
     return response
Esempio n. 21
0
 def delete_resource_module(self, module_id):
     url = get_api_server_url('/api/resourcelimits/{}/'.format(module_id))
     headers = {'X-CSRFToken': self.client.cookies['csrftoken']}
     res = self.client.delete(url, headers=headers)
     # print(res.status_code)
     if res.status_code == 204:
         return True
     return False
Esempio n. 22
0
 def delete_resource_module(self, module_id):
     url = get_api_server_url('/api/resourcelimits/{}/'.format(module_id))
     headers = {'X-CSRFToken': self.client.cookies['csrftoken']}
     res = self.client.delete(url, headers=headers)
     # print(res.status_code)
     if res.status_code == 204:
         return True
     return False
Esempio n. 23
0
 def download_from_volume(self, project_id, volume_id):
     """
     Download data from volume with id volume_id.
     """
     url = get_api_server_url('/api/projects/{}/volumes/{}/download/'
         .format(project_id, volume_id))
     response = self.client.get(url)
     return response
Esempio n. 24
0
 def get_pods(self, project_id, application_id):
     """
     Get the pod lists of app with application_id in project project_id.
     """
     url = get_api_server_url('/api/projects/{}/applications/{}/pods/'
         .format(project_id, application_id))
     res = self.client.get(url)
     return json.loads(res.text)
Esempio n. 25
0
 def get_environments(self, project_id, application_id):
     """
     Get environments of application with id application_id.
     """
     url = get_api_server_url('/api/projects/{}/applications/{}/envs/'
         .format(project_id, application_id))
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 26
0
 def get_application_username(self, project_id, application_id):
     """
     Get the username of the application.
     """
     url = get_api_server_url('/api/projects/{}/applications/{}/username/'.format(
         project_id, application_id))
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 27
0
 def get_environments(self, project_id, application_id):
     """
     Get environments of application with id application_id.
     """
     url = get_api_server_url('/api/projects/{}/applications/{}/envs/'
         .format(project_id, application_id))
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 28
0
 def get_volume_username(self, project_id, volume_id):
     """
     Get the username of the volume.
     """
     url = get_api_server_url('/api/projects/{}/volumes/{}/username/'.format(
         project_id, volume_id))
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 29
0
 def get_pods(self, project_id, application_id):
     """
     Get the pod lists of app with application_id in project project_id.
     """
     url = get_api_server_url('/api/projects/{}/applications/{}/pods/'
         .format(project_id, application_id))
     res = self.client.get(url)
     return json.loads(res.text)
Esempio n. 30
0
 def get_application_username(self, project_id, application_id):
     """
     Get the username of the application.
     """
     url = get_api_server_url('/api/projects/{}/applications/{}/username/'.format(
         project_id, application_id))
     response = self.client.get(url)
     return json.loads(response.text)
Esempio n. 31
0
 def get_pod_logs(self, project_id, pod_name, tail=20):
     """
     Get the tail n lines logs of pod named pod_name in project project_id.
     """
     url = get_api_server_url('/api/projects/{}/pods/{}/logs/'.format(
         project_id, pod_name))
     params = {'tail': tail}
     res = self.client.get(url, params=params)
     return json.loads(res.text)
Esempio n. 32
0
 def get_pod_logs(self, project_id, pod_name, tail=20):
     """
     Get the tail n lines logs of pod named pod_name in project project_id.
     """
     url = get_api_server_url('/api/projects/{}/pods/{}/logs/'.format(
         project_id, pod_name))
     params = {'tail': tail}
     res = self.client.get(url, params=params)
     return json.loads(res.text)
Esempio n. 33
0
    def list_projects_for_user(self, user_id):
        """
        List all projects for user with user_id.
        """
        url = get_api_server_url('/api/list-projects')
        params = {'user': user_id}

        response = self.client.get(url, params=params)
        return json.loads(response.text)
Esempio n. 34
0
 def login(self, data):
     """
     Return cookies.
     """
     url = get_api_server_url('/api/auth/login/')
     self.client.get(url)
     data['csrfmiddlewaretoken'] = self.client.cookies['csrftoken']
     self.client.post(url, data)
     return self.client.cookies
Esempio n. 35
0
    def list_pods_for_app(self, app_id):
        """
        List all pods for app with app_id.
        """
        url = get_api_server_url('/api/list-pods')
        params = {'app': app_id}

        response = self.client.get(url, params=params)
        return json.loads(response.text)
Esempio n. 36
0
 def delete_user(self, user_id):
     """
     Admin user delete user with user_id.
     """
     url = get_api_server_url('/api/users/{}/'.format(user_id))
     headers = {
         'X-CSRFToken': self.client.cookies['csrftoken'],
     }
     self.client.delete(url, headers=headers)
Esempio n. 37
0
 def create_project(self, data):
     """
     Create an project for user.
     """
     url = get_api_server_url('/api/projects/')
     response = self.client.post(url, data)
     if response.status_code == 201:
         return True
     return False
Esempio n. 38
0
    def list_apps_for_project(self, project_id):
        """
        List all apps for project with project_id.
        """
        url = get_api_server_url('/api/list-apps')
        params = {'project': project_id}

        response = self.client.get(url, params=params)
        return json.loads(response.text)
Esempio n. 39
0
 def login(self, data):
     """
     Return cookies.
     """
     url = get_api_server_url('/api/auth/login/')
     self.client.get(url)
     data['csrfmiddlewaretoken'] = self.client.cookies['csrftoken']
     self.client.post(url, data)
     return self.client.cookies
Esempio n. 40
0
 def registry(self, data):
     """
     User registry.
     """
     url = get_api_server_url('/api/registry/')
     headers = {
         'X-CSRFToken': self.client.cookies['csrftoken'],
     }
     response = self.client.post(url, data=data, headers=headers)
Esempio n. 41
0
 def create_project(self, data):
     """
     Create an project for user.
     """
     url = get_api_server_url('/api/projects/')
     response = self.client.post(url, data)
     if response.status_code == 201:
         return True
     return False
Esempio n. 42
0
 def delete_user(self, user_id):
     """
     Admin user delete user with user_id.
     """
     url = get_api_server_url('/api/users/{}/'.format(user_id))
     headers = {
         'X-CSRFToken': self.client.cookies['csrftoken'],
     }
     self.client.delete(url, headers=headers)
Esempio n. 43
0
    def list_apps_for_project(self, project_id):
        """
        List all apps for project with project_id.
        """
        url = get_api_server_url('/api/list-apps')
        params = {'project': project_id}

        response = self.client.get(url, params=params)
        return json.loads(response.text)
Esempio n. 44
0
    def list_pods_for_app(self, app_id):
        """
        List all pods for app with app_id.
        """
        url = get_api_server_url('/api/list-pods')
        params = {'app': app_id}

        response = self.client.get(url, params=params)
        return json.loads(response.text)
Esempio n. 45
0
    def list_projects_for_user(self, user_id):
        """
        List all projects for user with user_id.
        """
        url = get_api_server_url('/api/list-projects')
        params = {'user': user_id}

        response = self.client.get(url, params=params)
        return json.loads(response.text)
Esempio n. 46
0
 def registry(self, data):
     """
     User registry.
     """
     url = get_api_server_url('/api/registry/')
     headers = {
         'X-CSRFToken': self.client.cookies['csrftoken'],
     }
     response = self.client.post(url, data=data, headers=headers)
Esempio n. 47
0
 def delete_project(self, project_id):
     """
     Delete the project with id project_id.
     """
     url = get_api_server_url('/api/projects/{}/'.format(project_id))
     headers = {'X-CSRFToken': self.client.cookies['csrftoken']}
     res = self.client.delete(url, headers=headers)
     if res.status_code == 204:
         return True
     return False
Esempio n. 48
0
 def delete_project(self, project_id):
     """
     Delete the project with id project_id.
     """
     url = get_api_server_url('/api/projects/{}/'.format(project_id))
     headers = {'X-CSRFToken': self.client.cookies['csrftoken']}
     res = self.client.delete(url, headers=headers)
     if res.status_code == 204:
         return True
     return False
Esempio n. 49
0
 def get_image(self, project_id, image_id):
     """
     Get the detail info of the image.
     """
     url = get_api_server_url('/api/projects/{}/images/{}/'.format(
         project_id, image_id))
     response = self.client.get(url)
     image = json.loads(response.text)
     image['user'] = self.get_image_username(project_id=project_id,
         image_id=image_id)
     return image
Esempio n. 50
0
 def get_application(self, project_id, application_id):
     """
     Get the detail info of the application.
     """
     url = get_api_server_url('/api/projects/{}/applications/{}/'.format(
         project_id, application_id))
     response = self.client.get(url)
     application = json.loads(response.text)
     application['user'] = self.get_application_username(
         project_id=project_id, application_id=application['id'])
     return application
Esempio n. 51
0
 def get_autoscaler(self, project_id, application_id):
     """
     Get autoscaler of application with id application_id.
     """
     url = get_api_server_url('/api/projects/{}/applications/{}/scalers/'
         .format(project_id, application_id))
     response = self.client.get(url)
     scalers = json.loads(response.text)
     if scalers:
         return scalers[0]
     return {}
Esempio n. 52
0
 def get_volume(self, project_id, volume_id):
     """
     Get the detail info of the volume.
     """
     url = get_api_server_url('/api/projects/{}/volumes/{}/'.format(
         project_id, volume_id))
     response = self.client.get(url)
     volume = json.loads(response.text)
     volume['user'] = self.get_volume_username(project_id=project_id,
         volume_id=volume_id)
     return volume
Esempio n. 53
0
 def clear_volume(self, project_id, volume_id):
     """
     Clear data of volume with id volume_id.
     """
     url = get_api_server_url('/api/projects/{}/volumes/{}/clear/'
         .format(project_id, volume_id))
     response = self.client.get(url)
     if response.status_code == 200:
         return True
     else:
         return False
Esempio n. 54
0
    def registry(self, data):
        """
        User registry.
        """
        url = get_api_server_url('/api/users/')
        response = self.client.post(url, data)
        user_url = json.loads(response.text)['url']
        password_url = user_url + 'set_password/'
        self.client.post(password_url, data)

        return self.login(data)
Esempio n. 55
0
 def get_autoscaler(self, project_id, application_id):
     """
     Get autoscaler of application with id application_id.
     """
     url = get_api_server_url('/api/projects/{}/applications/{}/scalers/'
         .format(project_id, application_id))
     response = self.client.get(url)
     scalers = json.loads(response.text)
     if scalers:
         return scalers[0]
     return {}
Esempio n. 56
0
 def clear_volume(self, project_id, volume_id):
     """
     Clear data of volume with id volume_id.
     """
     url = get_api_server_url('/api/projects/{}/volumes/{}/clear/'
         .format(project_id, volume_id))
     response = self.client.get(url)
     if response.status_code == 200:
         return True
     else:
         return False