Example #1
0
 def show_volume_transfer(self, transfer_id):
     """Returns the details of a volume transfer."""
     url = "os-volume-transfer/%s" % str(transfer_id)
     resp, body = self.get(url)
     body = json.loads(body)
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, body['transfer'])
Example #2
0
 def get_instance_action(self, server_id, request_id):
     """Returns the action details of the provided server."""
     resp, body = self.get("servers/%s/os-instance-actions/%s" %
                           (server_id, request_id))
     body = json.loads(body)
     self.validate_response(schema.get_instance_action, resp, body)
     return service_client.ResponseBody(resp, body['instanceAction'])
 def show_instance_usage_audit_log(self, time_before):
     url = 'os-instance_usage_audit_log/%s' % time_before
     resp, body = self.get(url)
     body = json.loads(body)
     self.validate_response(schema.get_instance_usage_audit_log, resp, body)
     return service_client.ResponseBody(resp,
                                        body["instance_usage_audit_log"])
Example #4
0
 def update_snapshot(self, snapshot_id, **kwargs):
     """Updates a snapshot."""
     put_body = json.dumps({'snapshot': kwargs})
     resp, body = self.put('snapshots/%s' % snapshot_id, put_body)
     body = json.loads(body)
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, body['snapshot'])
Example #5
0
 def get_volume_attachment(self, server_id, attach_id):
     """Return details about the given volume attachment."""
     resp, body = self.get('servers/%s/os-volume_attachments/%s' %
                           (server_id, attach_id))
     body = json.loads(body)
     self.validate_response(schema.get_volume_attachment, resp, body)
     return service_client.ResponseBody(resp, body['volumeAttachment'])
Example #6
0
 def get_region(self, region_id):
     """Get region."""
     url = 'regions/%s' % region_id
     resp, body = self.get(url)
     self.expected_success(200, resp.status)
     body = json.loads(body)
     return service_client.ResponseBody(resp, body['region'])
Example #7
0
 def show_snapshot_metadata(self, snapshot_id):
     """Get metadata of the snapshot."""
     url = "snapshots/%s/metadata" % str(snapshot_id)
     resp, body = self.get(url)
     body = json.loads(body)
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, body['metadata'])
    def show_default_quota_set(self, tenant_id):
        """List the default volume quota set for a tenant."""

        url = 'os-quota-sets/%s/defaults' % tenant_id
        resp, body = self.get(url)
        self.expected_success(200, resp.status)
        return service_client.ResponseBody(resp, self._parse_resp(body))
Example #9
0
 def show_image(self, image_id):
     """Returns the details of a single image."""
     resp, body = self.get("images/%s" % image_id)
     self.expected_success(200, resp.status)
     body = json.loads(body)
     self.validate_response(schema.get_image, resp, body)
     return service_client.ResponseBody(resp, body['image'])
Example #10
0
 def get_service(self, service_id):
     """Get Service."""
     url = 'services/%s' % service_id
     resp, body = self.get(url)
     self.expected_success(200, resp.status)
     body = json.loads(body)
     return service_client.ResponseBody(resp, body['service'])
 def show_volume_type(self, volume_id):
     """Returns the details of a single volume_type."""
     url = "types/%s" % str(volume_id)
     resp, body = self.get(url)
     body = json.loads(body)
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, body['volume_type'])
Example #12
0
 def get_credential(self, credential_id):
     """To GET Details of a credential."""
     resp, body = self.get('credentials/%s' % credential_id)
     self.expected_success(200, resp.status)
     body = json.loads(body)
     body['credential']['blob'] = json.loads(body['credential']['blob'])
     return service_client.ResponseBody(resp, body['credential'])
Example #13
0
 def create_agent(self, **kwargs):
     """Create an agent build."""
     post_body = json.dumps({'agent': kwargs})
     resp, body = self.post('os-agents', post_body)
     body = json.loads(body)
     self.validate_response(schema.create_agent, resp, body)
     return service_client.ResponseBody(resp, body['agent'])
Example #14
0
 def show_volume_metadata(self, volume_id):
     """Get metadata of the volume."""
     url = "volumes/%s/metadata" % str(volume_id)
     resp, body = self.get(url)
     body = json.loads(body)
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, body['metadata'])
Example #15
0
    def reboot_host(self, hostname):
        """reboot a host."""

        resp, body = self.get("os-hosts/%s/reboot" % hostname)
        body = json.loads(body)
        self.validate_response(schema.reboot_host, resp, body)
        return service_client.ResponseBody(resp, body['host'])
Example #16
0
 def update_image_metadata(self, image_id, meta):
     """Updates the metadata for an image."""
     post_body = json.dumps({'metadata': meta})
     resp, body = self.post('images/%s/metadata' % image_id, post_body)
     body = json.loads(body)
     self.validate_response(schema.image_metadata, resp, body)
     return service_client.ResponseBody(resp, body['metadata'])
Example #17
0
 def _update_resource(self, uri, post_data):
     req_uri = self.uri_prefix + uri
     req_post_data = json.dumps(post_data)
     resp, body = self.put(req_uri, req_post_data)
     body = json.loads(body)
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, body)
Example #18
0
 def enable_disable_user(self, user_id, enabled):
     """Enables or disables a user."""
     put_body = {'enabled': enabled}
     put_body = json.dumps({'user': put_body})
     resp, body = self.put('users/%s/enabled' % user_id, put_body)
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, self._parse_resp(body))
Example #19
0
    def update_endpoint(self, endpoint_id, service_id=None, interface=None,
                        url=None, region=None, enabled=None, **kwargs):
        """Updates an endpoint with given parameters.

        Normally this function wouldn't allow setting values that are not
        allowed for 'enabled'. Use `force_enabled` to set a non-boolean.

        """
        post_body = {}
        if service_id is not None:
            post_body['service_id'] = service_id
        if interface is not None:
            post_body['interface'] = interface
        if url is not None:
            post_body['url'] = url
        if region is not None:
            post_body['region'] = region
        if 'force_enabled' in kwargs:
            post_body['enabled'] = kwargs['force_enabled']
        elif enabled is not None:
            post_body['enabled'] = enabled
        post_body = json.dumps({'endpoint': post_body})
        resp, body = self.patch('endpoints/%s' % endpoint_id, post_body)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return service_client.ResponseBody(resp, body['endpoint'])
Example #20
0
 def update_user_password(self, user_id, new_pass):
     """Update User Password."""
     put_body = {'password': new_pass, 'id': user_id}
     put_body = json.dumps({'user': put_body})
     resp, body = self.put('users/%s/OS-KSADM/password' % user_id, put_body)
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, self._parse_resp(body))
Example #21
0
 def show_snapshot(self, snapshot_id):
     """Returns the details of a single snapshot."""
     url = "snapshots/%s" % str(snapshot_id)
     resp, body = self.get(url)
     body = json.loads(body)
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, body['snapshot'])
Example #22
0
 def assign_user_role(self, tenant_id, user_id, role_id):
     """Add roles to a user on a tenant."""
     resp, body = self.put(
         '/tenants/%s/users/%s/roles/OS-KSADM/%s' %
         (tenant_id, user_id, role_id), "")
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, self._parse_resp(body))
Example #23
0
 def set_server_metadata_item(self, server_id, key, meta):
     post_body = json.dumps({'meta': meta})
     resp, body = self.put('servers/%s/metadata/%s' % (server_id, key),
                           post_body)
     body = json.loads(body)
     self.validate_response(schema.set_get_server_metadata_item, resp, body)
     return service_client.ResponseBody(resp, body['meta'])
Example #24
0
 def show_backup(self, backup_id):
     """Returns the details of a single backup."""
     url = "backups/%s" % str(backup_id)
     resp, body = self.get(url)
     body = json.loads(body)
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, body['backup'])
Example #25
0
 def list_interfaces(self, server_id):
     """
     List the interfaces used in an instance.
     """
     resp, body = self.get('/'.join(['servers', server_id, 'os-interface']))
     body = json.loads(body)
     return service_client.ResponseBody(resp, body)
Example #26
0
 def export_backup(self, backup_id):
     """Export backup metadata record."""
     url = "backups/%s/export_record" % backup_id
     resp, body = self.get(url)
     body = json.loads(body)
     self.expected_success(200, resp.status)
     return service_client.ResponseBody(resp, body['backup-record'])
 def show_baremetal_node(self, baremetal_node_id):
     """Returns the details of a single baremetal node."""
     url = 'os-baremetal-nodes/%s' % baremetal_node_id
     resp, body = self.get(url)
     body = json.loads(body)
     self.validate_response(schema.get_baremetal_node, resp, body)
     return service_client.ResponseBody(resp, body['node'])
Example #28
0
    def shutdown_host(self, hostname):
        """Shutdown a host."""

        resp, body = self.get("os-hosts/%s/shutdown" % hostname)
        body = json.loads(body)
        self.validate_response(schema.shutdown_host, resp, body)
        return service_client.ResponseBody(resp, body['host'])
Example #29
0
 def remove_fixed_ip(self, server_id, **kwargs):
     """Remove input fixed IP from input server instance."""
     post_body = json.dumps({'removeFixedIp': kwargs})
     resp, body = self.post('servers/%s/action' % server_id, post_body)
     self.validate_response(servers_schema.server_actions_common_schema,
                            resp, body)
     return service_client.ResponseBody(resp, body)
Example #30
0
 def volume_roll_detaching(self, volume_id):
     """Volume Roll Detaching."""
     # cinder/api/contrib/volume_actions.py#L170
     post_body = json.dumps({'os-roll_detaching': {}})
     resp, body = self.post('volumes/%s/action' % volume_id, post_body)
     self.expected_success(202, resp.status)
     return service_client.ResponseBody(resp, body)