desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Delete the given metadata item from an instance.'
| @wrap_check_policy
@check_instance_lock
@check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.PAUSED, vm_states.SUSPENDED, vm_states.STOPPED], task_state=None)
def delete_instance_metadata(self, context, instance, key):
| self.db.instance_metadata_delete(context, instance['uuid'], key)
instance['metadata'] = {}
notifications.send_update(context, instance, instance)
self.compute_rpcapi.change_instance_metadata(context, instance=instance, diff={key: ['-']})
|
'Updates or creates instance metadata.
If delete is True, metadata items that are not specified in the
`metadata` argument will be deleted.'
| @wrap_check_policy
@check_instance_lock
@check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.PAUSED, vm_states.SUSPENDED, vm_states.STOPPED], task_state=None)
def update_instance_metadata(self, context, instance, metadata, delete=False):
| orig = self.get_instance_metadata(context, instance)
if delete:
_metadata = metadata
else:
_metadata = orig.copy()
_metadata.update(metadata)
self._check_metadata_properties_quota(context, _metadata)
metadata = self.db.instance_metadata_update(context, instance['uuid'], _meta... |
'Get all faults for a list of instance uuids.'
| def get_instance_faults(self, context, instances):
| if (not instances):
return {}
for instance in instances:
check_policy(context, 'get_instance_faults', instance)
uuids = [instance['uuid'] for instance in instances]
return self.db.instance_fault_get_by_instance_uuids(context, uuids)
|
'Get all bdm tables for specified instance.'
| def get_instance_bdms(self, context, instance):
| return self.db.block_device_mapping_get_all_by_instance(context, instance['uuid'])
|
'Migrate a server lively to a new host.'
| @check_instance_state(vm_state=[vm_states.ACTIVE])
def live_migrate(self, context, instance, block_migration, disk_over_commit, host_name):
| LOG.debug(_('Going to try to live migrate instance to %s'), (host_name or 'another host'), instance=instance)
instance = self.update(context, instance, task_state=task_states.MIGRATING, expected_task_state=None)
self.scheduler_rpcapi.live_migration(context, block_migration, disk_o... |
'Running evacuate to target host.
Checking vm compute host state, if the host not in expected_state,
raising an exception.'
| @check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.STOPPED], task_state=[None])
def evacuate(self, context, instance, host, on_shared_storage, admin_password=None):
| LOG.debug(_('vm evacuation scheduled'))
inst_host = instance['host']
service = self.db.service_get_by_compute_host(context, inst_host)
if self.servicegroup_api.service_is_up(service):
msg = (_('Instance compute service state on %(inst_host)s expected to be down, ... |
'Raise HostNotFound if compute host doesn\'t exist.'
| def _assert_host_exists(self, context, host_name):
| service = self.db.service_get_by_host_and_topic(context, host_name, CONF.compute_topic)
if (not service):
raise exception.HostNotFound(host=host_name)
return service['host']
|
'Sets the specified host\'s ability to accept new instances.'
| def set_host_enabled(self, context, host_name, enabled):
| host_name = self._assert_host_exists(context, host_name)
return self.rpcapi.set_host_enabled(context, enabled=enabled, host=host_name)
|
'Returns the result of calling "uptime" on the target host.'
| def get_host_uptime(self, context, host_name):
| host_name = self._assert_host_exists(context, host_name)
return self.rpcapi.get_host_uptime(context, host=host_name)
|
'Reboots, shuts down or powers up the host.'
| def host_power_action(self, context, host_name, action):
| host_name = self._assert_host_exists(context, host_name)
return self.rpcapi.host_power_action(context, action=action, host=host_name)
|
'Start/Stop host maintenance window. On start, it triggers
guest VMs evacuation.'
| def set_host_maintenance(self, context, host_name, mode):
| host_name = self._assert_host_exists(context, host_name)
return self.rpcapi.host_maintenance_mode(context, host_param=host_name, mode=mode, host=host_name)
|
'Returns a list of services, optionally filtering the results.
If specified, \'filters\' should be a dictionary containing services
attributes and matching values. Ie, to get a list of services for
the \'compute\' topic, use filters={\'topic\': \'compute\'}.'
| def service_get_all(self, context, filters=None, set_zones=False):
| if (filters is None):
filters = {}
disabled = filters.pop('disabled', None)
services = self.db.service_get_all(context, disabled=disabled)
if (set_zones or ('availability_zone' in filters)):
services = availability_zones.set_availability_zones(context, services)
ret_services = []
... |
'Get service entry for the given compute hostname.'
| def service_get_by_compute_host(self, context, host_name):
| return self.db.service_get_by_compute_host(context, host_name)
|
'Return all instances on the given host.'
| def instance_get_all_by_host(self, context, host_name):
| return self.db.instance_get_all_by_host(context, host_name)
|
'Return the task logs within a given range, optionally
filtering by host and/or state.'
| def task_log_get_all(self, context, task_name, period_beginning, period_ending, host=None, state=None):
| return self.db.task_log_get_all(context, task_name, period_beginning, period_ending, host=host, state=state)
|
'Return compute node entry for particular integer ID.'
| def compute_node_get(self, context, compute_id):
| return self.db.compute_node_get(context, int(compute_id))
|
'Creates the model for the aggregate.'
| def create_aggregate(self, context, aggregate_name, availability_zone):
| values = {'name': aggregate_name}
metadata = None
if availability_zone:
metadata = {'availability_zone': availability_zone}
aggregate = self.db.aggregate_create(context, values, metadata=metadata)
aggregate = self._get_aggregate_info(context, aggregate)
del aggregate['hosts']
del agg... |
'Get an aggregate by id.'
| def get_aggregate(self, context, aggregate_id):
| aggregate = self.db.aggregate_get(context, aggregate_id)
return self._get_aggregate_info(context, aggregate)
|
'Get all the aggregates.'
| def get_aggregate_list(self, context):
| aggregates = self.db.aggregate_get_all(context)
return [self._get_aggregate_info(context, a) for a in aggregates]
|
'Update the properties of an aggregate.'
| def update_aggregate(self, context, aggregate_id, values):
| aggregate = self.db.aggregate_update(context, aggregate_id, values)
return self._get_aggregate_info(context, aggregate)
|
'Updates the aggregate metadata.
If a key is set to None, it gets removed from the aggregate metadata.'
| def update_aggregate_metadata(self, context, aggregate_id, metadata):
| for key in metadata.keys():
if (not metadata[key]):
try:
self.db.aggregate_metadata_delete(context, aggregate_id, key)
metadata.pop(key)
except exception.AggregateMetadataNotFound as e:
LOG.warn(e.message)
self.db.aggregate_metadata... |
'Deletes the aggregate.'
| def delete_aggregate(self, context, aggregate_id):
| hosts = self.db.aggregate_host_get_all(context, aggregate_id)
if (len(hosts) > 0):
raise exception.InvalidAggregateAction(action='delete', aggregate_id=aggregate_id, reason='not empty')
self.db.aggregate_delete(context, aggregate_id)
|
'Adds the host to an aggregate.'
| def add_host_to_aggregate(self, context, aggregate_id, host_name):
| self.db.service_get_by_compute_host(context, host_name)
aggregate = self.db.aggregate_get(context, aggregate_id)
self.db.aggregate_host_add(context, aggregate_id, host_name)
self.compute_rpcapi.add_aggregate_host(context, aggregate=aggregate, host_param=host_name, host=host_name)
return self.get_agg... |
'Removes host from the aggregate.'
| def remove_host_from_aggregate(self, context, aggregate_id, host_name):
| self.db.service_get_by_compute_host(context, host_name)
aggregate = self.db.aggregate_get(context, aggregate_id)
self.db.aggregate_host_delete(context, aggregate_id, host_name)
self.compute_rpcapi.remove_aggregate_host(context, aggregate=aggregate, host_param=host_name, host=host_name)
return self.g... |
'Builds a dictionary with aggregate props, metadata and hosts.'
| def _get_aggregate_info(self, context, aggregate):
| metadata = self.db.aggregate_metadata_get(context, aggregate['id'])
hosts = self.db.aggregate_host_get_all(context, aggregate['id'])
result = dict(aggregate.iteritems())
del result['metadetails']
result['metadata'] = metadata
result['hosts'] = hosts
return result
|
'Import a key pair using an existing public key.'
| def import_key_pair(self, context, user_id, key_name, public_key):
| self._validate_keypair_name(context, user_id, key_name)
count = QUOTAS.count(context, 'key_pairs', user_id)
try:
QUOTAS.limit_check(context, key_pairs=(count + 1))
except exception.OverQuota:
raise exception.KeypairLimitExceeded()
try:
fingerprint = crypto.generate_fingerprin... |
'Create a new key pair.'
| def create_key_pair(self, context, user_id, key_name):
| self._validate_keypair_name(context, user_id, key_name)
count = QUOTAS.count(context, 'key_pairs', user_id)
try:
QUOTAS.limit_check(context, key_pairs=(count + 1))
except exception.OverQuota:
raise exception.KeypairLimitExceeded()
(private_key, public_key, fingerprint) = crypto.gener... |
'Delete a keypair by name.'
| def delete_key_pair(self, context, user_id, key_name):
| self.db.key_pair_destroy(context, user_id, key_name)
|
'List key pairs.'
| def get_key_pairs(self, context, user_id):
| key_pairs = self.db.key_pair_get_all_by_user(context, user_id)
rval = []
for key_pair in key_pairs:
rval.append({'name': key_pair['name'], 'public_key': key_pair['public_key'], 'fingerprint': key_pair['fingerprint']})
return rval
|
'Get a keypair by name.'
| def get_key_pair(self, context, user_id, key_name):
| key_pair = self.db.key_pair_get(context, user_id, key_name)
return {'name': key_pair['name'], 'public_key': key_pair['public_key'], 'fingerprint': key_pair['fingerprint']}
|
'Validate given security group property.
:param value: the value to validate, as a string or unicode
:param property: the property, either \'name\' or \'description\'
:param allowed: the range of characters allowed'
| def validate_property(self, value, property, allowed):
| try:
val = value.strip()
except AttributeError:
msg = (_('Security group %s is not a string or unicode') % property)
self.raise_invalid_property(msg)
if (not val):
msg = (_('Security group %s cannot be empty.') % property)
self.r... |
'Ensure that a context has a security group.
Creates a security group for the security context if it does not
already exist.
:param context: the security context'
| def ensure_default(self, context):
| (existed, group) = self.db.security_group_ensure_default(context)
if (not existed):
self.sgh.trigger_security_group_create_refresh(context, group)
|
'Check if the security group is already associated
with the instance. If Yes, return True.'
| def is_associated_with_server(self, security_group, instance_uuid):
| if (not security_group):
return False
instances = security_group.get('instances')
if (not instances):
return False
for inst in instances:
if (instance_uuid == inst['uuid']):
return True
return False
|
'Add security group to the instance.'
| @wrap_check_security_groups_policy
def add_to_instance(self, context, instance, security_group_name):
| security_group = self.db.security_group_get_by_name(context, context.project_id, security_group_name)
instance_uuid = instance['uuid']
if self.is_associated_with_server(security_group, instance_uuid):
raise exception.SecurityGroupExistsForInstance(security_group_id=security_group['id'], instance_id=... |
'Remove the security group associated with the instance.'
| @wrap_check_security_groups_policy
def remove_from_instance(self, context, instance, security_group_name):
| security_group = self.db.security_group_get_by_name(context, context.project_id, security_group_name)
instance_uuid = instance['uuid']
if (not self.is_associated_with_server(security_group, instance_uuid)):
raise exception.SecurityGroupNotExistsForInstance(security_group_id=security_group['id'], ins... |
'Add security group rule(s) to security group.
Note: the Nova security group API doesn\'t support adding muliple
security group rules at once but the EC2 one does. Therefore,
this function is writen to support both.'
| def add_rules(self, context, id, name, vals):
| count = QUOTAS.count(context, 'security_group_rules', id)
try:
projected = (count + len(vals))
QUOTAS.limit_check(context, security_group_rules=projected)
except exception.OverQuota:
msg = _('Quota exceeded, too many security group rules.')
self.raise_over_q... |
'Indicates whether the specified rule values are already
defined in the default security group rules.'
| def default_rule_exists(self, context, values):
| for rule in self.db.security_group_default_rule_list(context):
is_duplicate = True
keys = ('cidr', 'from_port', 'to_port', 'protocol')
for key in keys:
if (rule.get(key) != values.get(key)):
is_duplicate = False
break
if is_duplicate:
... |
'Called when a rule is added to or removed from a security_group.'
| def trigger_rules_refresh(self, context, id):
| security_group = self.db.security_group_get(context, id)
for instance in security_group['instances']:
if (instance['host'] is not None):
self.security_group_rpcapi.refresh_instance_security_rules(context, instance['host'], instance)
|
'Called when a security group gains a new or loses a member.
Sends an update request to each compute node for each instance for
which this is relevant.'
| def trigger_members_refresh(self, context, group_ids):
| security_group_rules = set()
for group_id in group_ids:
security_group_rules.update(self.db.security_group_rule_get_by_security_group_grantee(context, group_id))
security_groups = set()
for rule in security_group_rules:
security_group = self.db.security_group_get(context, rule['parent_gr... |
'Calculate an I/O based load by counting I/O heavy operations.'
| @property
def io_workload(self):
| def _get(state, state_type):
key = ('num_%s_%s' % (state_type, state))
return self.get(key, 0)
num_builds = _get(vm_states.BUILDING, 'vm')
num_migrations = _get(task_states.RESIZE_MIGRATING, 'task')
num_rebuilds = _get(task_states.REBUILDING, 'task')
num_resizes = _get(task_states.RE... |
'Calculate current load of the compute host based on
task states.'
| def calculate_workload(self):
| current_workload = 0
for k in self:
if (k.startswith('num_task') and (not k.endswith('None'))):
current_workload += self[k]
return current_workload
|
'Update stats after an instance is changed.'
| def update_stats_for_instance(self, instance):
| uuid = instance['uuid']
if (uuid in self.states):
old_state = self.states[uuid]
self._decrement(('num_vm_%s' % old_state['vm_state']))
self._decrement(('num_task_%s' % old_state['task_state']))
self._decrement(('num_os_type_%s' % old_state['os_type']))
self._decrement(('n... |
'Save the useful bits of instance state for tracking purposes.'
| def _extract_state_from_instance(self, instance):
| uuid = instance['uuid']
vm_state = instance['vm_state']
task_state = instance['task_state']
os_type = instance['os_type']
project_id = instance['project_id']
vcpus = instance['vcpus']
self.states[uuid] = dict(vm_state=vm_state, task_state=task_state, os_type=os_type, project_id=project_id, v... |
'Compute operation requiring claimed resources has failed or
been aborted.'
| @lockutils.synchronized(COMPUTE_RESOURCE_SEMAPHORE, 'nova-')
def abort(self):
| LOG.debug((_('Aborting claim: %s') % self), instance=self.instance)
self.tracker.abort_instance_claim(self.instance)
|
'Test if this claim can be satisfied given available resources and
optional oversubscription limits
This should be called before the compute node actually consumes the
resources required to execute the claim.
:param resources: available local compute node resources
:returns: Return true if resources are available to cl... | def test(self, resources, limits=None):
| if (not limits):
limits = {}
memory_mb_limit = limits.get('memory_mb')
disk_gb_limit = limits.get('disk_gb')
vcpu_limit = limits.get('vcpu')
msg = _('Attempting claim: memory %(memory_mb)d MB, disk %(disk_gb)d GB, VCPUs %(vcpus)d')
params = {'memory_mb': self.m... |
'Test if the given type of resource needed for a claim can be safely
allocated.'
| def _test(self, type_, unit, total, used, requested, limit):
| msg = _('Total %(type_)s: %(total)d %(unit)s, used: %(used)d %(unit)s')
LOG.audit((msg % locals()), instance=self.instance)
if (limit is None):
LOG.audit((_('%(type_)s limit not specified, defaulting to unlimited') % locals()), instance=self.instance)
retu... |
'Compute operation requiring claimed resources has failed or
been aborted.'
| @lockutils.synchronized(COMPUTE_RESOURCE_SEMAPHORE, 'nova-')
def abort(self):
| LOG.debug((_('Aborting claim: %s') % self), instance=self.instance)
self.tracker.abort_resize_claim(self.instance['uuid'], self.instance_type)
|
'Is the target cell in a read-only mode?'
| def _cell_read_only(self, cell_name):
| return False
|
'Override compute API\'s checking of this. It\'ll happen in
child cell'
| def _check_requested_networks(self, context, requested_networks):
| return
|
'Override compute API\'s checking of this. It\'ll happen in
child cell'
| def _validate_image_href(self, context, image_href):
| return
|
'Backup the given instance.'
| def backup(self, context, instance, name, backup_type, rotation, extra_properties=None, image_id=None):
| image_meta = super(ComputeCellsAPI, self).backup(context, instance, name, backup_type, rotation, extra_properties=extra_properties, image_id=image_id)
image_id = image_meta['id']
self._cast_to_cells(context, instance, 'backup', name, backup_type=backup_type, rotation=rotation, extra_properties=extra_propert... |
'Snapshot the given instance.'
| def snapshot(self, context, instance, name, extra_properties=None, image_id=None):
| image_meta = super(ComputeCellsAPI, self).snapshot(context, instance, name, extra_properties=extra_properties, image_id=image_id)
image_id = image_meta['id']
self._cast_to_cells(context, instance, 'snapshot', name, extra_properties=extra_properties, image_id=image_id)
return image_meta
|
'We can use the base functionality, but I left this here just
for completeness.'
| def create(self, *args, **kwargs):
| return super(ComputeCellsAPI, self).create(*args, **kwargs)
|
'Updates the state of a compute instance.
For example to \'active\' or \'error\'.
Also sets \'task_state\' to None.
Used by admin_actions api
:param context: The security context
:param instance: The instance to update
:param new_state: A member of vm_state to change
the instance\'s state to,
eg. \'active\''
| def update_state(self, context, instance, new_state):
| self.update(context, instance, pass_on_state_change=True, vm_state=new_state, task_state=None)
|
'Update an instance.
:param pass_on_state_change: if true, the state change will be passed
on to child cells'
| def update(self, context, instance, pass_on_state_change=False, **kwargs):
| cell_name = instance['cell_name']
if (cell_name and self._cell_read_only(cell_name)):
raise exception.InstanceInvalidState(attr='vm_state', instance_uuid=instance['uuid'], state='temporary_readonly', method='update')
rv = super(ComputeCellsAPI, self).update(context, instance, **kwargs)
kwargs_co... |
'Terminate an instance.'
| def _handle_cell_delete(self, context, instance, method, method_name):
| cell_name = instance['cell_name']
if (cell_name and self._cell_read_only(cell_name)):
raise exception.InstanceInvalidState(attr='vm_state', instance_uuid=instance['uuid'], state='temporary_readonly', method=method_name)
method(context, instance)
try:
self._cast_to_cells(context, instance... |
'Restore a previously deleted (but not reclaimed) instance.'
| @validate_cell
def restore(self, context, instance):
| super(ComputeCellsAPI, self).restore(context, instance)
self._cast_to_cells(context, instance, 'restore')
|
'Force delete a previously deleted (but not reclaimed) instance.'
| @validate_cell
def force_delete(self, context, instance):
| super(ComputeCellsAPI, self).force_delete(context, instance)
self._cast_to_cells(context, instance, 'force_delete')
|
'Stop an instance.'
| @validate_cell
def stop(self, context, instance, do_cast=True):
| super(ComputeCellsAPI, self).stop(context, instance)
if do_cast:
self._cast_to_cells(context, instance, 'stop', do_cast=True)
else:
return self._call_to_cells(context, instance, 'stop', do_cast=False)
|
'Start an instance.'
| @validate_cell
def start(self, context, instance):
| super(ComputeCellsAPI, self).start(context, instance)
self._cast_to_cells(context, instance, 'start')
|
'Reboot the given instance.'
| @validate_cell
def reboot(self, context, instance, *args, **kwargs):
| super(ComputeCellsAPI, self).reboot(context, instance, *args, **kwargs)
self._cast_to_cells(context, instance, 'reboot', *args, **kwargs)
|
'Rebuild the given instance with the provided attributes.'
| @validate_cell
def rebuild(self, context, instance, *args, **kwargs):
| super(ComputeCellsAPI, self).rebuild(context, instance, *args, **kwargs)
self._cast_to_cells(context, instance, 'rebuild', *args, **kwargs)
|
'Evacuate the given instance with the provided attributes.'
| @validate_cell
def evacuate(self, context, instance, *args, **kwargs):
| super(ComputeCellsAPI, self).evacuate(context, instance, *args, **kwargs)
self._cast_to_cells(context, instance, 'evacuate', *args, **kwargs)
|
'Reverts a resize, deleting the \'new\' instance in the process.'
| @check_instance_state(vm_state=[vm_states.RESIZED])
@validate_cell
def revert_resize(self, context, instance):
| super(ComputeCellsAPI, self).revert_resize(context, instance)
self._cast_to_cells(context, instance, 'revert_resize')
|
'Confirms a migration/resize and deletes the \'old\' instance.'
| @check_instance_state(vm_state=[vm_states.RESIZED])
@validate_cell
def confirm_resize(self, context, instance):
| super(ComputeCellsAPI, self).confirm_resize(context, instance)
self._cast_to_cells(context, instance, 'confirm_resize')
|
'Resize (ie, migrate) a running instance.
If flavor_id is None, the process is considered a migration, keeping
the original flavor_id. If flavor_id is not None, the instance should
be migrated to a new host and resized to the new flavor_id.'
| @check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.STOPPED], task_state=[None])
@validate_cell
def resize(self, context, instance, flavor_id=None, *args, **kwargs):
| super(ComputeCellsAPI, self).resize(context, instance, flavor_id=flavor_id, *args, **kwargs)
old_instance_type = instance_types.extract_instance_type(instance)
if (not flavor_id):
new_instance_type = old_instance_type
else:
new_instance_type = instance_types.get_instance_type_by_flavor_i... |
'Add fixed_ip from specified network to given instance.'
| @validate_cell
def add_fixed_ip(self, context, instance, *args, **kwargs):
| super(ComputeCellsAPI, self).add_fixed_ip(context, instance, *args, **kwargs)
self._cast_to_cells(context, instance, 'add_fixed_ip', *args, **kwargs)
|
'Remove fixed_ip from specified network to given instance.'
| @validate_cell
def remove_fixed_ip(self, context, instance, *args, **kwargs):
| super(ComputeCellsAPI, self).remove_fixed_ip(context, instance, *args, **kwargs)
self._cast_to_cells(context, instance, 'remove_fixed_ip', *args, **kwargs)
|
'Pause the given instance.'
| @validate_cell
def pause(self, context, instance):
| super(ComputeCellsAPI, self).pause(context, instance)
self._cast_to_cells(context, instance, 'pause')
|
'Unpause the given instance.'
| @validate_cell
def unpause(self, context, instance):
| super(ComputeCellsAPI, self).unpause(context, instance)
self._cast_to_cells(context, instance, 'unpause')
|
'Retrieve diagnostics for the given instance.'
| def get_diagnostics(self, context, instance):
| super(ComputeCellsAPI, self).get_diagnostics(context, instance)
return self._call_to_cells(context, instance, 'get_diagnostics')
|
'Suspend the given instance.'
| @validate_cell
def suspend(self, context, instance):
| super(ComputeCellsAPI, self).suspend(context, instance)
self._cast_to_cells(context, instance, 'suspend')
|
'Resume the given instance.'
| @validate_cell
def resume(self, context, instance):
| super(ComputeCellsAPI, self).resume(context, instance)
self._cast_to_cells(context, instance, 'resume')
|
'Rescue the given instance.'
| @validate_cell
def rescue(self, context, instance, rescue_password=None):
| super(ComputeCellsAPI, self).rescue(context, instance, rescue_password=rescue_password)
self._cast_to_cells(context, instance, 'rescue', rescue_password=rescue_password)
|
'Unrescue the given instance.'
| @validate_cell
def unrescue(self, context, instance):
| super(ComputeCellsAPI, self).unrescue(context, instance)
self._cast_to_cells(context, instance, 'unrescue')
|
'Set the root/admin password for the given instance.'
| @validate_cell
def set_admin_password(self, context, instance, password=None):
| super(ComputeCellsAPI, self).set_admin_password(context, instance, password=password)
self._cast_to_cells(context, instance, 'set_admin_password', password=password)
|
'Write a file to the given instance.'
| @validate_cell
def inject_file(self, context, instance, *args, **kwargs):
| super(ComputeCellsAPI, self).inject_file(context, instance, *args, **kwargs)
self._cast_to_cells(context, instance, 'inject_file', *args, **kwargs)
|
'Get a url to a VNC Console.'
| @wrap_check_policy
@validate_cell
def get_vnc_console(self, context, instance, console_type):
| if (not instance['host']):
raise exception.InstanceNotReady(instance_id=instance['uuid'])
connect_info = self._call_to_cells(context, instance, 'get_vnc_connect_info', console_type)
self.consoleauth_rpcapi.authorize_console(context, connect_info['token'], console_type, connect_info['host'], connect_... |
'Get a url to a SPICE Console.'
| @wrap_check_policy
@validate_cell
def get_spice_console(self, context, instance, console_type):
| if (not instance['host']):
raise exception.InstanceNotReady(instance_id=instance['uuid'])
connect_info = self._call_to_cells(context, instance, 'get_spice_connect_info', console_type)
self.consoleauth_rpcapi.authorize_console(context, connect_info['token'], console_type, connect_info['host'], connec... |
'Get console output for an an instance.'
| @validate_cell
def get_console_output(self, context, instance, *args, **kwargs):
| super(ComputeCellsAPI, self).get_console_output(context, instance, *args, **kwargs)
return self._call_to_cells(context, instance, 'get_console_output', *args, **kwargs)
|
'Lock the given instance.'
| def lock(self, context, instance):
| super(ComputeCellsAPI, self).lock(context, instance)
self._cast_to_cells(context, instance, 'lock')
|
'Unlock the given instance.'
| def unlock(self, context, instance):
| super(ComputeCellsAPI, self).lock(context, instance)
self._cast_to_cells(context, instance, 'unlock')
|
'Reset networking on the instance.'
| @validate_cell
def reset_network(self, context, instance):
| super(ComputeCellsAPI, self).reset_network(context, instance)
self._cast_to_cells(context, instance, 'reset_network')
|
'Inject network info for the instance.'
| @validate_cell
def inject_network_info(self, context, instance):
| super(ComputeCellsAPI, self).inject_network_info(context, instance)
self._cast_to_cells(context, instance, 'inject_network_info')
|
'Attach an existing volume to an existing instance.'
| @wrap_check_policy
@validate_cell
def attach_volume(self, context, instance, volume_id, device=None):
| if (device and (not block_device.match_device(device))):
raise exception.InvalidDevicePath(path=device)
device = self.compute_rpcapi.reserve_block_device_name(context, device=device, instance=instance, volume_id=volume_id)
try:
volume = self.volume_api.get(context, volume_id)
self.vo... |
'Detach a volume from an instance.'
| @check_instance_lock
@validate_cell
def _detach_volume(self, context, instance, volume_id):
| check_policy(context, 'detach_volume', instance)
volume = self.volume_api.get(context, volume_id)
self.volume_api.check_detach(context, volume)
self._cast_to_cells(context, instance, 'detach_volume', volume_id)
|
'Makes calls to network_api to associate_floating_ip.
:param address: is a string floating ip address'
| @wrap_check_policy
@validate_cell
def associate_floating_ip(self, context, instance, address):
| self._cast_to_cells(context, instance, 'associate_floating_ip', address)
|
'Delete the given metadata item from an instance.'
| @validate_cell
def delete_instance_metadata(self, context, instance, key):
| super(ComputeCellsAPI, self).delete_instance_metadata(context, instance, key)
self._cast_to_cells(context, instance, 'delete_instance_metadata', key)
|
'Cannot check this in API cell. This will be checked in the
target child cell.'
| def _assert_host_exists(self, context, host_name):
| pass
|
'Get all instances by host. Host might have a cell prepended
to it, so we\'ll need to strip it out. We don\'t need to proxy
this call to cells, as we have instance information here in
the API cell.'
| def instance_get_all_by_host(self, context, host_name):
| (cell_name, host_name) = cells_utils.split_cell_and_item(host_name)
instances = super(HostAPI, self).instance_get_all_by_host(context, host_name)
if cell_name:
instances = [i for i in instances if (i['cell_name'] == cell_name)]
return instances
|
'Return the task logs within a given range from cells,
optionally filtering by the host and/or state. For cells, the
host should be a path like \'path!to!cell@host\'. If no @host
is given, only task logs from a particular cell will be returned.'
| def task_log_get_all(self, context, task_name, beginning, ending, host=None, state=None):
| return self.cells_rpcapi.task_log_get_all(context, task_name, beginning, ending, host=host, state=state)
|
'Get a compute node from a particular cell by its integer ID.
compute_id should be in the format of \'path!to!cell@ID\'.'
| def compute_node_get(self, context, compute_id):
| return self.cells_rpcapi.compute_node_get(context, compute_id)
|
'Add aggregate host.
:param ctxt: request context
:param aggregate_id:
:param host_param: This value is placed in the message to be the \'host\'
parameter for the remote method.
:param host: This is the host to send the message to.'
| def add_aggregate_host(self, ctxt, aggregate, host_param, host, slave_info=None):
| aggregate_p = jsonutils.to_primitive(aggregate)
self.cast(ctxt, self.make_msg('add_aggregate_host', aggregate=aggregate_p, host=host_param, slave_info=slave_info), topic=_compute_topic(self.topic, ctxt, host, None), version='2.14')
|
'Set host maintenance mode
:param ctxt: request context
:param host_param: This value is placed in the message to be the \'host\'
parameter for the remote method.
:param mode:
:param host: This is the host to send the message to.'
| def host_maintenance_mode(self, ctxt, host_param, mode, host):
| return self.call(ctxt, self.make_msg('host_maintenance_mode', host=host_param, mode=mode), topic=_compute_topic(self.topic, ctxt, host, None))
|
'Remove aggregate host.
:param ctxt: request context
:param aggregate_id:
:param host_param: This value is placed in the message to be the \'host\'
parameter for the remote method.
:param host: This is the host to send the message to.'
| def remove_aggregate_host(self, ctxt, aggregate, host_param, host, slave_info=None):
| aggregate_p = jsonutils.to_primitive(aggregate)
self.cast(ctxt, self.make_msg('remove_aggregate_host', aggregate=aggregate_p, host=host_param, slave_info=slave_info), topic=_compute_topic(self.topic, ctxt, host, None), version='2.15')
|
'Add our hop to the routing_path.'
| def _append_hop(self):
| routing_path = ((self.routing_path and (self.routing_path + _PATH_CELL_SEP)) or '')
self.routing_path = (routing_path + self.our_path_part)
self.hop_count += 1
|
'Check if we\'re at the max hop count. If we are and do_raise is
True, raise CellMaxHopCountReached. If we are at the max and
do_raise is False... return True, else False.'
| def _at_max_hop_count(self, do_raise=True):
| if (self.hop_count >= self.max_hop_count):
if do_raise:
raise exception.CellMaxHopCountReached(hop_count=self.hop_count)
return True
return False
|
'Its been determined that we should process this message in this
cell. Go through the MessageRunner to call the appropriate
method for this message. Catch the response and/or exception and
encode it within a Response instance. Return it so the caller
can potentially return it to another cell... or return it to
a cal... | def _process_locally(self):
| try:
resp_value = self.msg_runner._process_message_locally(self)
failure = False
except Exception as exc:
resp_value = sys.exc_info()
failure = True
LOG.exception(_('Error processing message locally: %(exc)s'), locals())
return Response(self.routing_path, ... |
'Shortcut to creating a response queue in the MessageRunner.'
| def _setup_response_queue(self):
| self.resp_queue = self.msg_runner._setup_response_queue(self)
|
'Shortcut to deleting a response queue in the MessageRunner.'
| def _cleanup_response_queue(self):
| if self.resp_queue:
self.msg_runner._cleanup_response_queue(self)
self.resp_queue = None
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.