コード例 #1
0
 def verify_connectivity(self):
     # Dummy call to verify if connection and authentication token work
     response = requests.get(self.base_url +
                             "/mesos_dns/v1/hosts/master.mesos",
                             auth=get_auth(),
                             verify=False)
     return response.ok
コード例 #2
0
 def get_nodes(self):
     response = requests.get(self.base_url + "/system/health/v1/nodes",
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         raise Exception("Unknown error occured: %s" % response.text)
     return response.json()["nodes"]
コード例 #3
0
ファイル: bouncer.py プロジェクト: iss-lab/dcos-deploy
 def get_account(self, name):
     response = requests.get(self.base_url + "/users/" + name,
                             auth=get_auth(),
                             verify=False)
     if response.status_code != 200:
         return None
     return response.json()
コード例 #4
0
ファイル: bouncer.py プロジェクト: iss-lab/dcos-deploy
 def remove_user_from_group(self, user_name, group):
     response = requests.delete(self.base_url + "/groups/%s/users/%s" %
                                (group, user_name),
                                auth=get_auth(),
                                verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Error occured when adding user to group")
コード例 #5
0
ファイル: bouncer.py プロジェクト: iss-lab/dcos-deploy
 def get_groups_for_user(self, name):
     response = requests.get(self.base_url + "/users/%s/groups" % name,
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Error occured when querying groups for user")
     return [g["group"]["gid"] for g in response.json()["array"]]
コード例 #6
0
 def get_deployments(self):
     response = requests.get(self.marathon_url + "/deployments",
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         print(response.text, flush=True)
         raise Exception("Failed to get deployments")
     return response.json()
コード例 #7
0
ファイル: bouncer.py プロジェクト: iss-lab/dcos-deploy
 def get_rids(self):
     response = requests.get(self.base_url + "/acls",
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Error occured when listing permission")
     return [acl["rid"] for acl in response.json()["array"]]
コード例 #8
0
ファイル: bouncer.py プロジェクト: iss-lab/dcos-deploy
 def remove_permission_from_user(self, user_name, rid, action):
     rid = self._encode_rid(rid)
     response = requests.delete(self.base_url + "/acls/%s/users/%s/%s" %
                                (rid, user_name, action),
                                auth=get_auth(),
                                verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Error occured when removing permission from user")
コード例 #9
0
ファイル: bouncer.py プロジェクト: iss-lab/dcos-deploy
 def add_permission_to_user(self, user_name, rid, action):
     rid = self._encode_rid(rid)
     response = requests.put(self.base_url + r"/acls/%s/users/%s/%s" %
                             (rid, user_name, action),
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Error occured when adding permission to user")
コード例 #10
0
ファイル: bouncer.py プロジェクト: iss-lab/dcos-deploy
 def create_account(self, name, description, public_key):
     data = dict(description=description, public_key=public_key)
     response = requests.put(self.base_url + "/users/" + name,
                             json=data,
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Error occured when creating account")
コード例 #11
0
ファイル: bouncer.py プロジェクト: raghu999/dcos-deploy
 def get_permissions_for_user(self, name):
     response = requests.get(self.base_url+"/users/%s/permissions" % name, auth=get_auth(), verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Error occured when querying permissions for user")
     permissions = dict()
     for permission in response.json()["direct"]:
         permissions[permission["rid"]] = [a["name"] for a in permission["actions"]]
     return permissions
コード例 #12
0
 def _get_master_state(self):
     response = requests.get(self.mesos_url + "master/state",
                             auth=get_auth(),
                             verify=False)
     if response.ok:
         return response.json()
     else:
         raise Exception("Failed to get mesos master state: %s" %
                         response.text)
コード例 #13
0
ファイル: cosmos.py プロジェクト: raghu999/dcos-deploy
 def _get_plan_status(self, service_name, plan):
     response = requests.get(get_base_url() + "/service" + service_name +
                             "v1/plans/%s" % plan,
                             auth=get_auth(),
                             verify=False)
     if response.ok:
         return response.json()["status"]
     else:
         return None
コード例 #14
0
 def delete_secret(self, name):
     response = requests.delete(self.base_url + "secret/default/%s" % name,
                                auth=get_auth(),
                                verify=False)
     if response.status_code == 404:
         return
     if not response.ok:
         raise Exception("Could not delete secret %s: %s " %
                         (name, response.text))
コード例 #15
0
ファイル: edgelb.py プロジェクト: iss-lab/dcos-deploy
 def create_pool(self, config):
     """Create a new pool"""
     response = requests.post(self.base_url + "v2/pools",
                              json=config,
                              auth=get_auth(),
                              verify=False)
     if not response.ok:
         raise Exception("Could not create pool %s: %s " %
                         (config["name"], response.text))
コード例 #16
0
ファイル: ca.py プロジェクト: raghu999/dcos-deploy
 def sign_csr(self, csr, hosts=list()):
     data = {"certificate_request": csr, "hosts": hosts}
     response = requests.post(self.base_url + "sign",
                              json=data,
                              auth=get_auth(),
                              verify=False)
     if not response.ok:
         raise Exception("Failed to sign cert: %s" % response.text)
     return response.json()["result"]["certificate"]
コード例 #17
0
ファイル: edgelb.py プロジェクト: iss-lab/dcos-deploy
 def update_pool(self, config):
     """Update an existing pool config"""
     response = requests.put(self.base_url + "v2/pools/%s" % config["name"],
                             json=config,
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         raise Exception("Could not update pool %s: %s " %
                         (config["name"], response.text))
コード例 #18
0
 def get_cluster_info(self):
     response = requests.get(self.base_url +
                             "/dcos-metadata/dcos-version.json",
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         raise Exception("Unknown error occured: %s" % response.text)
     info = response.json()
     return dict(version=info["version"], variant=info["dcos-variant"])
コード例 #19
0
ファイル: edgelb.py プロジェクト: iss-lab/dcos-deploy
 def get_pool(self, name):
     """Get config for a specific pool"""
     response = requests.get(self.base_url + "v2/pools/%s" % name,
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Failed to get pool")
     return response.json()
コード例 #20
0
ファイル: edgelb.py プロジェクト: iss-lab/dcos-deploy
 def delete_pool(self, name):
     response = requests.delete(self.base_url + "v2/pools/%s" % name,
                                auth=get_auth(),
                                verify=False)
     if response.ok:
         return True
     elif response.status_code == 404:
         return False
     else:
         raise Exception("Unknown error occured: %s" % response.text)
コード例 #21
0
 def list_secrets(self):
     """Retrive a list of secrets names"""
     response = requests.get(self.base_url + "secret/default/?list=true",
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Failed to list secrets")
     data = response.json()["array"]
     return data
コード例 #22
0
ファイル: metronome.py プロジェクト: iss-lab/dcos-deploy
 def get_jobs(self):
     response = requests.get(self.metronome_url + "v1/jobs",
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Unknown error occured")
     data = response.json()
     for job in data:
         yield "/" + job["id"].replace(".", "/")
コード例 #23
0
ファイル: bouncer.py プロジェクト: iss-lab/dcos-deploy
 def create_permission(self, rid):
     rid = self._encode_rid(rid)
     response = requests.put(
         self.base_url + "/acls/%s" % rid,
         json=dict(description="created by dcos-deploy"),
         auth=get_auth(),
         verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Error occured when creating permission")
コード例 #24
0
 def has_plans_api(self, service_name):
     if service_name[0] == "/":
         service_name = service_name[1:]
     response = requests.get(get_base_url() + "/service/" + service_name +
                             "/v1/plans/",
                             auth=get_auth(),
                             verify=False)
     if response.ok:
         return True
     else:
         return False
コード例 #25
0
ファイル: edgelb.py プロジェクト: iss-lab/dcos-deploy
 def get_pools(self):
     """Retrive a list of pool names"""
     response = requests.get(self.base_url + "v2/pools",
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         print(response.text)
         raise Exception("Failed to list pools")
     data = response.json()
     for pool in data:
         yield pool["name"]
コード例 #26
0
 def restart_app(self, app_id, wait_for_deployment=False):
     response = requests.post(self.marathon_url +
                              "/apps/%s/restart" % app_id,
                              auth=get_auth(),
                              verify=False)
     if not response.ok:
         print(response.text, flush=True)
         raise Exception("Failed to restart app %s" % app_id)
     deployment_id = response.json()["deploymentId"]
     if wait_for_deployment:
         self.wait_for_specific_deployment(deployment_id)
コード例 #27
0
ファイル: bouncer.py プロジェクト: iss-lab/dcos-deploy
 def delete_account(self, name):
     response = requests.delete(self.base_url + "/users/" + name,
                                auth=get_auth(),
                                verify=False)
     if response.ok:
         return True
     elif response.status_code == 404:
         return False
     else:
         raise Exception("Error occured when deleting account: %s" %
                         response.text)
コード例 #28
0
ファイル: edgelb.py プロジェクト: iss-lab/dcos-deploy
 def ping(self):
     response = requests.get(self.base_url + "ping",
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         if response.status_code == 503:
             return False
         elif response.status_code == 404:
             return False
         else:
             raise Exception("Could not get ping from edgelb: %s" %
                             response.text)
     return True
コード例 #29
0
ファイル: metronome.py プロジェクト: iss-lab/dcos-deploy
 def create_job(self, definition):
     response = requests.post(self.metronome_url + "v0/scheduled-jobs",
                              json=definition,
                              auth=get_auth(),
                              verify=False)
     if response.ok:
         return
     if response.status_code == 422:
         print(response.text)
         raise Exception("Invalid job definition")
     else:
         print(response.text)
         raise Exception("Unknown error occured")
コード例 #30
0
 def get_app_state(self, app_id):
     if not app_id[0] == "/":
         app_id = "/" + app_id
     response = requests.get(self.marathon_url +
                             "/apps%s/?embed=app.counts" % app_id,
                             auth=get_auth(),
                             verify=False)
     if not response.ok:
         if response.status_code == 404:
             return None
         print(response.text, flush=True)
         raise Exception("Failed to get state for %s" % app_id)
     return response.json()["app"]