def rescue_alt_image(self, server_id, admin_pw=None, rescue_id=None, version='v2'): """ Performs a rescue by replacing the compute instance with an alternate rescue image :param server_id: the uuid for the server to rescue :param rescue_id: optional uuid of the image to replace the rescued instance with :param version: keystone authentication version (v2 or v3) :return: """ ks = keystone.create_keystone(version=version) nova_url = ks.service_catalog.url_for(service_type="compute", endpoint_type="publicURL") rescue_url = os.path.join(nova_url, "servers/{}/rescue".format(server_id)) hdr = {"X-Auth-Token": ks.auth_token} print("Sending rescue api to url: {}".format(rescue_url)) http = httplib2.Http() if rescue_id is not None: request = {"rescue": {"rescue_image_ref": rescue_id}} if admin_pw is not None: request["rescue"]["adminPass"] = admin_pw print("Request: {}".format(json.dumps(request))) return http.request(rescue_url, "POST", headers=hdr, body=json.dumps(request)) return http.request(rescue_url, "POST", headers=hdr)
def __init__(self): self.ks = keystone.create_keystone() self.storage_location = sc.Connection(authurl=self.ks.auth_url, user=self.ks.username, key=self.ks.password, tenant_name=self.ks.tenant_name, auth_version='2.0').get_auth()[0]
def __init__(self, version: int) -> object: """ :type version: int """ ks = keystone.create_keystone() heat_url = ks.auth_url + '/%s' % ks.tenant_id self.heat_session_obj = hc(version, endpoint=heat_url, token=ks.auth_token)
def __init__(self, version: int) -> object: self.keystone_cl = keystone.create_keystone() if version not in ["1", "2"]: raise ArgumentError("Invalid glance version choice") url_for = self.keystone_cl.service_catalog.url_for glance_endpt = url_for(service_type="image", endpoint_type="publicURL") + "/v" + version self.glance_session = GlanceFactory(endpoint=glance_endpt, token=self.keystone_cl.auth_token)