Merge "Fix and enable H403 tests"
This commit is contained in:
@@ -158,7 +158,8 @@ class Lockout(wsgi.Middleware):
|
||||
|
||||
There is a possible race condition where simultaneous requests could
|
||||
sneak in before the lockout hits, but this is extremely rare and would
|
||||
only result in a couple of extra failed attempts."""
|
||||
only result in a couple of extra failed attempts.
|
||||
"""
|
||||
|
||||
def __init__(self, application):
|
||||
"""middleware can use fake for testing."""
|
||||
|
||||
@@ -1369,7 +1369,8 @@ class CloudController(object):
|
||||
|
||||
def terminate_instances(self, context, instance_id, **kwargs):
|
||||
"""Terminate each instance in instance_id, which is a list of ec2 ids.
|
||||
instance_id is a kwarg so its name cannot be modified."""
|
||||
instance_id is a kwarg so its name cannot be modified.
|
||||
"""
|
||||
previous_states = self._ec2_ids_to_instances(context, instance_id)
|
||||
LOG.debug(_("Going to start terminating instances"))
|
||||
for instance in previous_states:
|
||||
@@ -1388,7 +1389,8 @@ class CloudController(object):
|
||||
|
||||
def stop_instances(self, context, instance_id, **kwargs):
|
||||
"""Stop each instances in instance_id.
|
||||
Here instance_id is a list of instance ids"""
|
||||
Here instance_id is a list of instance ids
|
||||
"""
|
||||
instances = self._ec2_ids_to_instances(context, instance_id, True)
|
||||
LOG.debug(_("Going to stop instances"))
|
||||
for instance in instances:
|
||||
@@ -1397,7 +1399,8 @@ class CloudController(object):
|
||||
|
||||
def start_instances(self, context, instance_id, **kwargs):
|
||||
"""Start each instances in instance_id.
|
||||
Here instance_id is a list of instance ids"""
|
||||
Here instance_id is a list of instance ids
|
||||
"""
|
||||
instances = self._ec2_ids_to_instances(context, instance_id, True)
|
||||
LOG.debug(_("Going to start instances"))
|
||||
for instance in instances:
|
||||
|
||||
@@ -34,7 +34,8 @@ def _translate_keys(cons):
|
||||
|
||||
def _translate_detail_keys(cons):
|
||||
"""Coerces a console instance into proper dictionary format with
|
||||
correctly mapped attributes """
|
||||
correctly mapped attributes.
|
||||
"""
|
||||
pool = cons['pool']
|
||||
info = {'id': cons['id'],
|
||||
'console_type': pool['console_type'],
|
||||
|
||||
@@ -201,7 +201,8 @@ class HostController(object):
|
||||
|
||||
def _set_host_maintenance(self, context, host_name, mode=True):
|
||||
"""Start/Stop host maintenance window. On start, it triggers
|
||||
guest VMs evacuation."""
|
||||
guest VMs evacuation.
|
||||
"""
|
||||
LOG.audit(_("Putting host %(host_name)s in maintenance mode "
|
||||
"%(mode)s."),
|
||||
{'host_name': host_name, 'mode': mode})
|
||||
@@ -218,8 +219,10 @@ class HostController(object):
|
||||
|
||||
def _set_enabled_status(self, context, host_name, enabled):
|
||||
"""Sets the specified host's ability to accept new instances.
|
||||
|
||||
:param enabled: a boolean - if False no new VMs will be able to start
|
||||
on the host"""
|
||||
on the host
|
||||
"""
|
||||
if enabled:
|
||||
LOG.audit(_("Enabling host %s.") % host_name)
|
||||
else:
|
||||
|
||||
@@ -106,7 +106,8 @@ class SimpleTenantUsageController(object):
|
||||
|
||||
def _get_flavor(self, context, compute_api, instance, flavors_cache):
|
||||
"""Get flavor information from the instance's system_metadata,
|
||||
allowing a fallback to lookup by-id for deleted instances only."""
|
||||
allowing a fallback to lookup by-id for deleted instances only.
|
||||
"""
|
||||
try:
|
||||
return flavors.extract_flavor(instance)
|
||||
except KeyError:
|
||||
|
||||
@@ -183,7 +183,8 @@ def create_image_bdm(image_ref, boot_index=0):
|
||||
|
||||
def legacy_mapping(block_device_mapping):
|
||||
"""Transform a list of block devices of an instance back to the
|
||||
legacy data format."""
|
||||
legacy data format.
|
||||
"""
|
||||
|
||||
legacy_block_device_mapping = []
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ class MuteChildWeigher(weights.BaseCellWeigher):
|
||||
def _weigh_object(self, cell, weight_properties):
|
||||
"""Check cell against the last_seen timestamp that indicates the time
|
||||
that the most recent capability or capacity update was received from
|
||||
the given cell."""
|
||||
the given cell.
|
||||
"""
|
||||
|
||||
last_seen = cell.last_seen
|
||||
secs = CONF.cells.mute_child_interval
|
||||
|
||||
@@ -101,8 +101,10 @@ CATEGORIES = {
|
||||
|
||||
|
||||
def methods_of(obj):
|
||||
"""Get all callable methods of an object that don't start with underscore
|
||||
returns a list of tuples of the form (method_name, method)"""
|
||||
"""Get all callable methods of an object that don't start with underscore.
|
||||
|
||||
returns a list of tuples of the form (method_name, method)
|
||||
"""
|
||||
result = []
|
||||
for i in dir(obj):
|
||||
if callable(getattr(obj, i)) and not i.startswith('_'):
|
||||
|
||||
+27
-11
@@ -139,19 +139,22 @@ class ShellCommands(object):
|
||||
def bpython(self):
|
||||
"""Runs a bpython shell.
|
||||
|
||||
Falls back to Ipython/python shell if unavailable"""
|
||||
Falls back to Ipython/python shell if unavailable
|
||||
"""
|
||||
self.run('bpython')
|
||||
|
||||
def ipython(self):
|
||||
"""Runs an Ipython shell.
|
||||
|
||||
Falls back to Python shell if unavailable"""
|
||||
Falls back to Python shell if unavailable
|
||||
"""
|
||||
self.run('ipython')
|
||||
|
||||
def python(self):
|
||||
"""Runs a python shell.
|
||||
|
||||
Falls back to Python shell if unavailable"""
|
||||
Falls back to Python shell if unavailable
|
||||
"""
|
||||
self.run('python')
|
||||
|
||||
@args('--shell', metavar='<bpython|ipython|python >',
|
||||
@@ -193,7 +196,9 @@ class ShellCommands(object):
|
||||
@args('--path', metavar='<path>', help='Script path')
|
||||
def script(self, path):
|
||||
"""Runs the script from the specified path with flags set properly.
|
||||
arguments: path"""
|
||||
|
||||
arguments: path
|
||||
"""
|
||||
exec(compile(open(path).read(), path, 'exec'), locals(), globals())
|
||||
|
||||
|
||||
@@ -335,13 +340,17 @@ class FixedIpCommands(object):
|
||||
@args('--address', metavar='<ip address>', help='IP address')
|
||||
def reserve(self, address):
|
||||
"""Mark fixed ip as reserved
|
||||
arguments: address"""
|
||||
|
||||
arguments: address
|
||||
"""
|
||||
return self._set_reserved(address, True)
|
||||
|
||||
@args('--address', metavar='<ip address>', help='IP address')
|
||||
def unreserve(self, address):
|
||||
"""Mark fixed ip as free to use
|
||||
arguments: address"""
|
||||
|
||||
arguments: address
|
||||
"""
|
||||
return self._set_reserved(address, False)
|
||||
|
||||
def _set_reserved(self, address, reserved):
|
||||
@@ -421,8 +430,10 @@ class FloatingIpCommands(object):
|
||||
|
||||
@args('--host', metavar='<host>', help='Host')
|
||||
def list(self, host=None):
|
||||
"""Lists all floating ips (optionally by host)
|
||||
Note: if host is given, only active floating IPs are returned"""
|
||||
"""Lists all floating ips (optionally by host).
|
||||
|
||||
Note: if host is given, only active floating IPs are returned
|
||||
"""
|
||||
ctxt = context.get_admin_context()
|
||||
try:
|
||||
if host is None:
|
||||
@@ -810,7 +821,8 @@ class HostCommands(object):
|
||||
|
||||
def list(self, zone=None):
|
||||
"""Show a list of all physical hosts. Filter by zone.
|
||||
args: [zone]"""
|
||||
args: [zone]
|
||||
"""
|
||||
print "%-25s\t%-15s" % (_('host'),
|
||||
_('zone'))
|
||||
ctxt = context.get_admin_context()
|
||||
@@ -1008,7 +1020,9 @@ class AgentBuildCommands(object):
|
||||
|
||||
def list(self, hypervisor=None):
|
||||
"""Lists all agent builds.
|
||||
arguments: <none>"""
|
||||
|
||||
arguments: <none>
|
||||
"""
|
||||
fmt = "%-10s %-8s %12s %s"
|
||||
ctxt = context.get_admin_context()
|
||||
by_hypervisor = {}
|
||||
@@ -1178,7 +1192,9 @@ CATEGORIES = {
|
||||
|
||||
def methods_of(obj):
|
||||
"""Get all callable methods of an object that don't start with underscore
|
||||
returns a list of tuples of the form (method_name, method)"""
|
||||
|
||||
returns a list of tuples of the form (method_name, method)
|
||||
"""
|
||||
result = []
|
||||
for i in dir(obj):
|
||||
if callable(getattr(obj, i)) and not i.startswith('_'):
|
||||
|
||||
+10
-6
@@ -557,7 +557,8 @@ class API(base.Base):
|
||||
block_device_mapping,
|
||||
auto_disk_config, reservation_id):
|
||||
"""Verify all the input parameters regardless of the provisioning
|
||||
strategy being performed."""
|
||||
strategy being performed.
|
||||
"""
|
||||
if min_count > 1 or max_count > 1:
|
||||
if any(map(lambda bdm: 'volume_id' in bdm, block_device_mapping)):
|
||||
msg = _('Cannot attach one or more volumes to multiple'
|
||||
@@ -722,7 +723,8 @@ class API(base.Base):
|
||||
reservation_id=None, scheduler_hints=None):
|
||||
"""Verify all the input parameters regardless of the provisioning
|
||||
strategy being performed and schedule the instance(s) for
|
||||
creation."""
|
||||
creation.
|
||||
"""
|
||||
|
||||
# Normalize and setup some parameters
|
||||
if reservation_id is None:
|
||||
@@ -2622,7 +2624,8 @@ class HostAPI(base.Base):
|
||||
|
||||
def set_host_maintenance(self, context, host_name, mode):
|
||||
"""Start/Stop host maintenance window. On start, it triggers
|
||||
guest VMs evacuation."""
|
||||
guest VMs evacuation.
|
||||
"""
|
||||
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)
|
||||
@@ -2656,10 +2659,11 @@ class HostAPI(base.Base):
|
||||
return self.db.service_get_by_compute_host(context, host_name)
|
||||
|
||||
def service_update(self, context, host_name, binary, params_to_update):
|
||||
"""
|
||||
Enable / Disable a service.
|
||||
"""Enable / Disable a service.
|
||||
|
||||
For compute services, this stops new builds and migrations going to
|
||||
the host."""
|
||||
the host.
|
||||
"""
|
||||
service = db.service_get_by_args(context, host_name, binary)
|
||||
return db.service_update(context, service['id'], params_to_update)
|
||||
|
||||
|
||||
@@ -235,7 +235,8 @@ def remove_flavor_access(flavorid, projectid, ctxt=None):
|
||||
|
||||
def extract_flavor(instance, prefix=''):
|
||||
"""Create an InstanceType-like object from instance's system_metadata
|
||||
information."""
|
||||
information.
|
||||
"""
|
||||
|
||||
instance_type = {}
|
||||
sys_meta = utils.instance_sys_meta(instance)
|
||||
@@ -253,7 +254,8 @@ def save_flavor_info(metadata, instance_type, prefix=''):
|
||||
|
||||
This can be used to update system_metadata in place from a type, as well
|
||||
as stash information about another instance_type for later use (such as
|
||||
during resize)."""
|
||||
during resize).
|
||||
"""
|
||||
|
||||
for key in system_metadata_flavor_props.keys():
|
||||
to_key = '%sinstance_type_%s' % (prefix, key)
|
||||
@@ -263,7 +265,8 @@ def save_flavor_info(metadata, instance_type, prefix=''):
|
||||
|
||||
def delete_flavor_info(metadata, *prefixes):
|
||||
"""Delete flavor instance_type information from instance's system_metadata
|
||||
by prefix."""
|
||||
by prefix.
|
||||
"""
|
||||
|
||||
for key in system_metadata_flavor_props.keys():
|
||||
for prefix in prefixes:
|
||||
|
||||
@@ -2776,7 +2776,8 @@ class ComputeManager(manager.SchedulerDependentManager):
|
||||
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
|
||||
def host_maintenance_mode(self, context, host, mode):
|
||||
"""Start/Stop host maintenance window. On start, it triggers
|
||||
guest VMs evacuation."""
|
||||
guest VMs evacuation.
|
||||
"""
|
||||
return self.driver.host_maintenance_mode(host, mode)
|
||||
|
||||
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
|
||||
@@ -2974,7 +2975,8 @@ class ComputeManager(manager.SchedulerDependentManager):
|
||||
|
||||
def _attach_volume_boot(self, context, instance, volume, mountpoint):
|
||||
"""Attach a volume to an instance at boot time. So actual attach
|
||||
is done by instance creation"""
|
||||
is done by instance creation.
|
||||
"""
|
||||
|
||||
instance_id = instance['id']
|
||||
instance_uuid = instance['uuid']
|
||||
@@ -3941,7 +3943,8 @@ class ComputeManager(manager.SchedulerDependentManager):
|
||||
"""Align instance power state between the database and hypervisor.
|
||||
|
||||
If the instance is not found on the hypervisor, but is in the database,
|
||||
then a stop() API will be called on the instance."""
|
||||
then a stop() API will be called on the instance.
|
||||
"""
|
||||
|
||||
# We re-query the DB to get the latest instance info to minimize
|
||||
# (not eliminate) race condition.
|
||||
|
||||
@@ -45,7 +45,8 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class LocalAPI(object):
|
||||
"""A local version of the conductor API that does database updates
|
||||
locally instead of via RPC"""
|
||||
locally instead of via RPC.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
# TODO(danms): This needs to be something more generic for
|
||||
|
||||
+21
-9
@@ -888,8 +888,10 @@ def network_delete_safe(context, network_id):
|
||||
|
||||
def network_disassociate(context, network_id, disassociate_host=True,
|
||||
disassociate_project=True):
|
||||
"""Disassociate the network from project or host and raise if it does
|
||||
not exist."""
|
||||
"""Disassociate the network from project or host
|
||||
|
||||
Raises if it does not exist.
|
||||
"""
|
||||
return IMPL.network_disassociate(context, network_id, disassociate_host,
|
||||
disassociate_project)
|
||||
|
||||
@@ -1110,7 +1112,9 @@ def block_device_mapping_update(context, bdm_id, values, legacy=True):
|
||||
|
||||
def block_device_mapping_update_or_create(context, values, legacy=True):
|
||||
"""Update an entry of block device mapping.
|
||||
If not existed, create a new entry"""
|
||||
|
||||
If not existed, create a new entry
|
||||
"""
|
||||
return IMPL.block_device_mapping_update_or_create(context, values, legacy)
|
||||
|
||||
|
||||
@@ -1412,8 +1416,11 @@ def instance_type_extra_specs_delete(context, flavor_id, key):
|
||||
|
||||
def instance_type_extra_specs_update_or_create(context, flavor_id,
|
||||
extra_specs):
|
||||
"""Create or update instance type extra specs. This adds or modifies the
|
||||
key/value pairs specified in the extra specs dict argument"""
|
||||
"""Create or update instance type extra specs.
|
||||
|
||||
This adds or modifies the key/value pairs specified in the
|
||||
extra specs dict argument
|
||||
"""
|
||||
IMPL.instance_type_extra_specs_update_or_create(context, flavor_id,
|
||||
extra_specs)
|
||||
|
||||
@@ -1557,7 +1564,9 @@ def vol_usage_update(context, id, rd_req, rd_bytes, wr_req, wr_bytes,
|
||||
last_refreshed=None, update_totals=False,
|
||||
session=None):
|
||||
"""Update cached volume usage for a volume
|
||||
Creates new record if needed."""
|
||||
|
||||
Creates new record if needed.
|
||||
"""
|
||||
return IMPL.vol_usage_update(context, id, rd_req, rd_bytes, wr_req,
|
||||
wr_bytes, instance_id, project_id, user_id,
|
||||
availability_zone,
|
||||
@@ -1607,7 +1616,8 @@ def aggregate_metadata_get_by_host(context, host, key=None):
|
||||
|
||||
Returns a dictionary where each value is a set, this is to cover the case
|
||||
where there two aggregates have different values for the same key.
|
||||
Optional key filter"""
|
||||
Optional key filter
|
||||
"""
|
||||
return IMPL.aggregate_metadata_get_by_host(context, host, key)
|
||||
|
||||
|
||||
@@ -1622,8 +1632,10 @@ def aggregate_host_get_by_metadata_key(context, key):
|
||||
|
||||
|
||||
def aggregate_update(context, aggregate_id, values):
|
||||
"""Update the attributes of an aggregates. If values contains a metadata
|
||||
key, it updates the aggregate metadata too."""
|
||||
"""Update the attributes of an aggregates.
|
||||
|
||||
If values contains a metadata key, it updates the aggregate metadata too.
|
||||
"""
|
||||
return IMPL.aggregate_update(context, aggregate_id, values)
|
||||
|
||||
|
||||
|
||||
@@ -496,7 +496,8 @@ def _prep_stats_dict(values):
|
||||
@require_admin_context
|
||||
def compute_node_create(context, values):
|
||||
"""Creates a new ComputeNode and populates the capacity fields
|
||||
with the most recent data."""
|
||||
with the most recent data.
|
||||
"""
|
||||
_prep_stats_dict(values)
|
||||
convert_datetimes(values, 'created_at', 'deleted_at', 'updated_at')
|
||||
|
||||
|
||||
@@ -104,7 +104,8 @@ class ComputeNode(BASE, NovaBase):
|
||||
|
||||
class ComputeNodeStat(BASE, NovaBase):
|
||||
"""Stats related to the current workload of a compute host that are
|
||||
intended to aid in making scheduler decisions."""
|
||||
intended to aid in making scheduler decisions.
|
||||
"""
|
||||
__tablename__ = 'compute_node_stats'
|
||||
__table_args__ = (
|
||||
Index('ix_compute_node_stats_compute_node_id', 'compute_node_id'),
|
||||
|
||||
@@ -47,7 +47,8 @@ def get_table(engine, name):
|
||||
"""Returns an sqlalchemy table dynamically from db.
|
||||
|
||||
Needed because the models don't work for us in migrations
|
||||
as models will be far out of sync with the current data."""
|
||||
as models will be far out of sync with the current data.
|
||||
"""
|
||||
metadata = MetaData()
|
||||
metadata.bind = engine
|
||||
return Table(name, metadata, autoload=True)
|
||||
|
||||
@@ -246,7 +246,8 @@ class GlanceImageService(object):
|
||||
|
||||
def get_location(self, context, image_id):
|
||||
"""Returns the direct url representing the backend storage location,
|
||||
or None if this attribute is not shown by Glance."""
|
||||
or None if this attribute is not shown by Glance.
|
||||
"""
|
||||
try:
|
||||
client = GlanceClientWrapper()
|
||||
image_meta = client.call(context, 2, 'get', image_id)
|
||||
|
||||
+2
-1
@@ -478,7 +478,8 @@ class API(base.Base):
|
||||
def setup_networks_on_host(self, context, instance, host=None,
|
||||
teardown=False):
|
||||
"""Setup or teardown the network structures on hosts related to
|
||||
instance"""
|
||||
instance.
|
||||
"""
|
||||
host = host or instance['host']
|
||||
# NOTE(tr3buchet): host is passed in cases where we need to setup
|
||||
# or teardown the networks on a host which has been migrated to/from
|
||||
|
||||
+4
-2
@@ -53,7 +53,8 @@ class L3Driver(object):
|
||||
"""Add a floating IP bound to the fixed IP with an optional
|
||||
l3_interface_id. Some drivers won't care about the
|
||||
l3_interface_id so just pass None in that case. Network
|
||||
is also an optional parameter."""
|
||||
is also an optional parameter.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def remove_floating_ip(self, floating_ip, fixed_ip, l3_interface_id,
|
||||
@@ -138,7 +139,8 @@ class LinuxNetL3(L3Driver):
|
||||
class NullL3(L3Driver):
|
||||
"""The L3 driver that doesn't do anything. This class can be used when
|
||||
nova-network should not manipulate L3 forwarding at all (e.g., in a Flat
|
||||
or FlatDHCP scenario)."""
|
||||
or FlatDHCP scenario).
|
||||
"""
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -84,8 +84,10 @@ class DNSEntry(object):
|
||||
|
||||
def __init__(self, ldap_object):
|
||||
"""ldap_object is an instance of ldap.LDAPObject.
|
||||
|
||||
It should already be initialized and bound before
|
||||
getting passed in here."""
|
||||
getting passed in here.
|
||||
"""
|
||||
self.lobj = ldap_object
|
||||
self.ldap_tuple = None
|
||||
self.qualified_domain = None
|
||||
@@ -307,7 +309,8 @@ class LdapDNS(dns_driver.DNSDriver):
|
||||
"""Driver for PowerDNS using ldap as a back end.
|
||||
|
||||
This driver assumes ldap-method=strict, with all domains
|
||||
in the top-level, aRecords only."""
|
||||
in the top-level, aRecords only.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.lobj = ldap.initialize(CONF.ldap_dns_url)
|
||||
|
||||
@@ -232,7 +232,8 @@ class RPCAllocateFixedIP(object):
|
||||
|
||||
def deallocate_fixed_ip(self, context, address, host=None, teardown=True):
|
||||
"""Call the superclass deallocate_fixed_ip if i'm the correct host
|
||||
otherwise call to the correct host"""
|
||||
otherwise call to the correct host
|
||||
"""
|
||||
fixed_ip = self.db.fixed_ip_get_by_address(context, address)
|
||||
network = self._get_network_by_id(context, fixed_ip['network_id'])
|
||||
|
||||
@@ -578,7 +579,8 @@ class NetworkManager(manager.Manager):
|
||||
def build_network_info_model(self, context, vifs, networks,
|
||||
rxtx_factor, instance_host):
|
||||
"""Builds a NetworkInfo object containing all network information
|
||||
for an instance"""
|
||||
for an instance.
|
||||
"""
|
||||
nw_info = network_model.NetworkInfo()
|
||||
for vif in vifs:
|
||||
vif_dict = {'id': vif['uuid'],
|
||||
|
||||
@@ -179,7 +179,8 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
||||
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. Multiple rules are
|
||||
installed to a security group in quantum using bulk support."""
|
||||
installed to a security group in quantum using bulk support.
|
||||
"""
|
||||
|
||||
quantum = quantumv2.get_client(context)
|
||||
body = self._make_quantum_security_group_rules_list(vals)
|
||||
@@ -265,7 +266,8 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
||||
|
||||
def get_instances_security_groups_bindings(self, context):
|
||||
"""Returns a dict(instance_id, [security_groups]) to allow obtaining
|
||||
all of the instances and their security groups in one shot."""
|
||||
all of the instances and their security groups in one shot.
|
||||
"""
|
||||
quantum = quantumv2.get_client(context)
|
||||
ports = quantum.list_ports().get('ports')
|
||||
security_groups = quantum.list_security_groups().get('security_groups')
|
||||
|
||||
@@ -179,7 +179,8 @@ class SecurityGroupBase(object):
|
||||
|
||||
def populate_security_groups(self, instance, security_groups):
|
||||
"""Called when populating the database for an instances
|
||||
security groups."""
|
||||
security groups.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def create_security_group(self, context, name, description):
|
||||
|
||||
@@ -157,7 +157,8 @@ def _send_instance_update_notification(context, instance, old_vm_state=None,
|
||||
old_task_state=None, new_vm_state=None, new_task_state=None,
|
||||
service="compute", host=None):
|
||||
"""Send 'compute.instance.update' notification to inform observers
|
||||
about instance state changes"""
|
||||
about instance state changes.
|
||||
"""
|
||||
|
||||
payload = info_from_instance(context, instance, None, None)
|
||||
|
||||
|
||||
@@ -190,7 +190,8 @@ class NovaObject(object):
|
||||
@classmethod
|
||||
def obj_name(cls):
|
||||
"""Return a canonical name for this object which will be used over
|
||||
the wire for remote hydration."""
|
||||
the wire for remote hydration.
|
||||
"""
|
||||
return cls.__name__
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -26,7 +26,8 @@ class ComputeCapabilitiesFilter(filters.BaseHostFilter):
|
||||
|
||||
def _satisfies_extra_specs(self, capabilities, instance_type):
|
||||
"""Check that the capabilities provided by the compute service
|
||||
satisfy the extra specs associated with the instance type"""
|
||||
satisfy the extra specs associated with the instance type.
|
||||
"""
|
||||
if 'extra_specs' not in instance_type:
|
||||
return True
|
||||
|
||||
|
||||
@@ -309,8 +309,9 @@ class SchedulerManager(manager.Manager):
|
||||
return self.backdoor_port
|
||||
|
||||
def select_hosts(self, context, request_spec, filter_properties):
|
||||
"""Returns host(s) best suited for this request_spec and
|
||||
filter_properties"""
|
||||
"""Returns host(s) best suited for this request_spec
|
||||
and filter_properties.
|
||||
"""
|
||||
hosts = self.driver.select_hosts(context, request_spec,
|
||||
filter_properties)
|
||||
return jsonutils.to_primitive(hosts)
|
||||
|
||||
+2
-1
@@ -117,7 +117,8 @@ class Service(service.Service):
|
||||
|
||||
A service takes a manager and enables rpc by listening to queues based
|
||||
on topic. It also periodically runs tasks on the manager and reports
|
||||
it state to the database services table."""
|
||||
it state to the database services table.
|
||||
"""
|
||||
|
||||
def __init__(self, host, binary, topic, manager, report_interval=None,
|
||||
periodic_enable=None, periodic_fuzzy_delay=None,
|
||||
|
||||
@@ -276,7 +276,8 @@ class ApiEc2TestCase(test.TestCase):
|
||||
|
||||
def test_describe_instances(self):
|
||||
"""Test that, after creating a user and a project, the describe
|
||||
instances call to the API works properly"""
|
||||
instances call to the API works properly.
|
||||
"""
|
||||
self.expect_http()
|
||||
self.mox.ReplayAll()
|
||||
self.assertEqual(self.ec2.get_all_instances(), [])
|
||||
@@ -290,7 +291,8 @@ class ApiEc2TestCase(test.TestCase):
|
||||
|
||||
def test_get_all_key_pairs(self):
|
||||
"""Test that, after creating a user and project and generating
|
||||
a key pair, that the API call to list key pairs works properly"""
|
||||
a key pair, that the API call to list key pairs works properly.
|
||||
"""
|
||||
keyname = "".join(random.choice("sdiuisudfsdcnpaqwertasd")
|
||||
for x in range(random.randint(4, 8)))
|
||||
self.expect_http()
|
||||
@@ -302,7 +304,8 @@ class ApiEc2TestCase(test.TestCase):
|
||||
|
||||
def test_create_duplicate_key_pair(self):
|
||||
"""Test that, after successfully generating a keypair,
|
||||
requesting a second keypair with the same name fails sanely"""
|
||||
requesting a second keypair with the same name fails sanely.
|
||||
"""
|
||||
self.expect_http()
|
||||
self.mox.ReplayAll()
|
||||
self.ec2.create_key_pair('test')
|
||||
@@ -351,10 +354,11 @@ class ApiEc2TestCase(test.TestCase):
|
||||
|
||||
def test_group_name_valid_chars_security_group(self):
|
||||
"""Test that we sanely handle invalid security group names.
|
||||
|
||||
EC2 API Spec states we should only accept alphanumeric characters,
|
||||
spaces, dashes, and underscores. Amazon implementation
|
||||
accepts more characters - so, [:print:] is ok. """
|
||||
|
||||
accepts more characters - so, [:print:] is ok.
|
||||
"""
|
||||
bad_strict_ec2 = "aa \t\x01\x02\x7f"
|
||||
bad_amazon_ec2 = "aa #^% -=99"
|
||||
test_raise = [
|
||||
@@ -385,7 +389,9 @@ class ApiEc2TestCase(test.TestCase):
|
||||
|
||||
def test_group_name_valid_length_security_group(self):
|
||||
"""Test that we sanely handle invalid security group names.
|
||||
API Spec states that the length should not exceed 255 chars """
|
||||
|
||||
API Spec states that the length should not exceed 255 char.
|
||||
"""
|
||||
self.expect_http()
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
||||
@@ -2346,7 +2346,8 @@ class CloudTestCase(test.TestCase):
|
||||
def test_instance_initiated_shutdown_behavior(self):
|
||||
def test_dia_iisb(expected_result, **kwargs):
|
||||
"""test describe_instance_attribute
|
||||
attribute instance_initiated_shutdown_behavior"""
|
||||
attribute instance_initiated_shutdown_behavior
|
||||
"""
|
||||
kwargs.update({'instance_type': CONF.default_flavor,
|
||||
'max_count': 1})
|
||||
instance_id = self._run_instance(**kwargs)
|
||||
|
||||
@@ -778,7 +778,8 @@ def wire_HTTPConnection_to_WSGI(host, app):
|
||||
"""
|
||||
class HTTPConnectionDecorator(object):
|
||||
"""Wraps the real HTTPConnection class so that when you instantiate
|
||||
the class you might instead get a fake instance."""
|
||||
the class you might instead get a fake instance.
|
||||
"""
|
||||
|
||||
def __init__(self, wrapped):
|
||||
self.wrapped = wrapped
|
||||
|
||||
@@ -237,7 +237,8 @@ class ServersControllerTest(test.TestCase):
|
||||
|
||||
def test_unique_host_id(self):
|
||||
"""Create two servers with the same host and different
|
||||
project_ids and check that the hostId's are unique"""
|
||||
project_ids and check that the hostId's are unique.
|
||||
"""
|
||||
def return_instance_with_host(self, *args):
|
||||
project_id = str(uuid.uuid4())
|
||||
return fakes.stub_instance(id=1, uuid=FAKE_UUID,
|
||||
|
||||
@@ -1063,7 +1063,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
"""spawn failure test.
|
||||
|
||||
Make sure that when there is a spawning problem,
|
||||
the instance goes to ERROR state, keeping the task state"""
|
||||
the instance goes to ERROR state, keeping the task state.
|
||||
"""
|
||||
def fake(*args, **kwargs):
|
||||
raise test.TestingException()
|
||||
self.stubs.Set(self.compute.driver, 'spawn', fake)
|
||||
@@ -1081,7 +1082,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
"""spawn network deallocate test.
|
||||
|
||||
Make sure that when an instance is not found during spawn
|
||||
that the network is deallocated"""
|
||||
that the network is deallocated
|
||||
"""
|
||||
instance = self._create_instance()
|
||||
|
||||
def fake(*args, **kwargs):
|
||||
@@ -3576,7 +3578,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
|
||||
def test_resize_same_source_fails(self):
|
||||
"""Ensure instance fails to migrate when source and destination are
|
||||
the same host"""
|
||||
the same host.
|
||||
"""
|
||||
reservations = self._ensure_quota_reservations_rolledback()
|
||||
instance = jsonutils.to_primitive(self._create_fake_instance())
|
||||
self.compute.run_instance(self.context, instance=instance)
|
||||
@@ -7434,7 +7437,8 @@ class ComputeAPITestCase(BaseTestCase):
|
||||
|
||||
def test_reservation_id_one_instance(self):
|
||||
"""Verify building an instance has a reservation_id that
|
||||
matches return value from create"""
|
||||
matches return value from create.
|
||||
"""
|
||||
(refs, resv_id) = self.compute_api.create(self.context,
|
||||
flavors.get_default_flavor(), None)
|
||||
try:
|
||||
@@ -7446,7 +7450,7 @@ class ComputeAPITestCase(BaseTestCase):
|
||||
def test_reservation_ids_two_instances(self):
|
||||
"""Verify building 2 instances at once results in a
|
||||
reservation_id being returned equal to reservation id set
|
||||
in both instances
|
||||
in both instances.
|
||||
"""
|
||||
(refs, resv_id) = self.compute_api.create(self.context,
|
||||
flavors.get_default_flavor(), None,
|
||||
@@ -8268,7 +8272,8 @@ def _create_service_entries(context, values={'avail_zone1': ['fake_host1',
|
||||
|
||||
class ComputeAPIAggrTestCase(BaseTestCase):
|
||||
"""This is for unit coverage of aggregate-related methods
|
||||
defined in nova.compute.api."""
|
||||
defined in nova.compute.api.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(ComputeAPIAggrTestCase, self).setUp()
|
||||
@@ -8378,7 +8383,8 @@ class ComputeAPIAggrTestCase(BaseTestCase):
|
||||
|
||||
class ComputeAggrTestCase(BaseTestCase):
|
||||
"""This is for unit coverage of aggregate-related methods
|
||||
defined in nova.compute.manager."""
|
||||
defined in nova.compute.manager.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(ComputeAggrTestCase, self).setUp()
|
||||
|
||||
@@ -1418,8 +1418,11 @@ class TestNovaMigrations(BaseMigrationTestCase, CommonTestsMixIn):
|
||||
self.assertTrue(db_utils.check_shadow_table(engine, 'console_pools'))
|
||||
|
||||
def _unique_constraint_check_migrate_185(self, engine, check=True):
|
||||
"""Test check unique constraint behavior. It should be the same before
|
||||
and after migration because we changed their names only."""
|
||||
"""Test check unique constraint behavior.
|
||||
|
||||
It should be the same before and after migration because we
|
||||
changed their names only.
|
||||
"""
|
||||
|
||||
data_list = [
|
||||
("floating_ips", {'address': '10.12.14.16', 'deleted': 0}),
|
||||
|
||||
@@ -57,8 +57,10 @@ class _StorageDict(dict):
|
||||
self.clear()
|
||||
|
||||
def hgetall(self, key):
|
||||
"""Returns the hash for the given key; creates
|
||||
the hash if the key doesn't exist."""
|
||||
"""Returns the hash for the given key
|
||||
|
||||
Creates the hash if the key doesn't exist.
|
||||
"""
|
||||
try:
|
||||
return self[key]
|
||||
except KeyError:
|
||||
|
||||
@@ -2132,7 +2132,9 @@ class AdminActionsSamplesJsonTest(ServersSampleBase):
|
||||
|
||||
def setUp(self):
|
||||
"""setUp Method for AdminActions api samples extension
|
||||
This method creates the server that will be used in each tests"""
|
||||
|
||||
This method creates the server that will be used in each tests
|
||||
"""
|
||||
super(AdminActionsSamplesJsonTest, self).setUp()
|
||||
self.uuid = self._post_server()
|
||||
|
||||
|
||||
@@ -405,7 +405,8 @@ class LinuxNetworkTestCase(test.TestCase):
|
||||
def test_linux_bridge_driver_plug(self):
|
||||
"""Makes sure plug doesn't drop FORWARD by default.
|
||||
|
||||
Ensures bug 890195 doesn't reappear."""
|
||||
Ensures bug 890195 doesn't reappear.
|
||||
"""
|
||||
|
||||
def fake_execute(*args, **kwargs):
|
||||
return "", ""
|
||||
@@ -423,7 +424,8 @@ class LinuxNetworkTestCase(test.TestCase):
|
||||
def test_vlan_override(self):
|
||||
"""Makes sure vlan_interface flag overrides network bridge_interface.
|
||||
|
||||
Allows heterogeneous networks a la bug 833426"""
|
||||
Allows heterogeneous networks a la bug 833426
|
||||
"""
|
||||
|
||||
driver = linux_net.LinuxBridgeInterfaceDriver()
|
||||
|
||||
@@ -452,7 +454,8 @@ class LinuxNetworkTestCase(test.TestCase):
|
||||
def test_flat_override(self):
|
||||
"""Makes sure flat_interface flag overrides network bridge_interface.
|
||||
|
||||
Allows heterogeneous networks a la bug 833426"""
|
||||
Allows heterogeneous networks a la bug 833426
|
||||
"""
|
||||
|
||||
driver = linux_net.LinuxBridgeInterfaceDriver()
|
||||
|
||||
|
||||
@@ -1069,7 +1069,8 @@ class VlanNetworkTestCase(test.TestCase):
|
||||
|
||||
def test_ip_association_and_allocation_of_other_project(self):
|
||||
"""Makes sure that we cannot deallocaate or disassociate
|
||||
a public ip of other project"""
|
||||
a public ip of other project.
|
||||
"""
|
||||
|
||||
def network_get(_context, network_id, project_only="allow_none"):
|
||||
return networks[network_id]
|
||||
@@ -1123,7 +1124,8 @@ class VlanNetworkTestCase(test.TestCase):
|
||||
def test_deallocate_fixed(self):
|
||||
"""Verify that release is called properly.
|
||||
|
||||
Ensures https://bugs.launchpad.net/nova/+bug/973442 doesn't return"""
|
||||
Ensures https://bugs.launchpad.net/nova/+bug/973442 doesn't return
|
||||
"""
|
||||
|
||||
def network_get(_context, network_id, project_only="allow_none"):
|
||||
return networks[network_id]
|
||||
@@ -1193,7 +1195,8 @@ class VlanNetworkTestCase(test.TestCase):
|
||||
def test_deallocate_fixed_no_vif(self):
|
||||
"""Verify that deallocate doesn't raise when no vif is returned.
|
||||
|
||||
Ensures https://bugs.launchpad.net/nova/+bug/968457 doesn't return"""
|
||||
Ensures https://bugs.launchpad.net/nova/+bug/968457 doesn't return
|
||||
"""
|
||||
|
||||
def network_get(_context, network_id, project_only="allow_none"):
|
||||
return networks[network_id]
|
||||
@@ -1905,7 +1908,8 @@ class RPCAllocateTestCase(test.TestCase):
|
||||
"""Test to verify bug 855030 doesn't resurface.
|
||||
|
||||
Mekes sure _rpc_allocate_fixed_ip returns a value so the call
|
||||
returns properly and the greenpool completes."""
|
||||
returns properly and the greenpool completes.
|
||||
"""
|
||||
address = '10.10.10.10'
|
||||
|
||||
def fake_allocate(*args, **kwargs):
|
||||
|
||||
@@ -77,7 +77,8 @@ class FakeHostManager(host_manager.HostManager):
|
||||
"""host1: free_ram_mb=1024-512-512=0, free_disk_gb=1024-512-512=0
|
||||
host2: free_ram_mb=2048-512=1536 free_disk_gb=2048-512=1536
|
||||
host3: free_ram_mb=4096-1024=3072 free_disk_gb=4096-1024=3072
|
||||
host4: free_ram_mb=8192 free_disk_gb=8192"""
|
||||
host4: free_ram_mb=8192 free_disk_gb=8192
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(FakeHostManager, self).__init__()
|
||||
|
||||
@@ -41,7 +41,8 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
||||
|
||||
def test_filter_hosts_avoid(self):
|
||||
"""Test to make sure _filter_hosts() filters original hosts if
|
||||
avoid_original_host is True."""
|
||||
avoid_original_host is True.
|
||||
"""
|
||||
|
||||
hosts = ['host1', 'host2', 'host3']
|
||||
request_spec = dict(instance_properties=dict(host='host2'))
|
||||
@@ -53,7 +54,8 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
||||
|
||||
def test_filter_hosts_no_avoid(self):
|
||||
"""Test to make sure _filter_hosts() does not filter original
|
||||
hosts if avoid_original_host is False."""
|
||||
hosts if avoid_original_host is False.
|
||||
"""
|
||||
|
||||
hosts = ['host1', 'host2', 'host3']
|
||||
request_spec = dict(instance_properties=dict(host='host2'))
|
||||
|
||||
@@ -160,7 +160,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
||||
|
||||
def test_schedule_happy_day(self):
|
||||
"""Make sure there's nothing glaringly wrong with _schedule()
|
||||
by doing a happy day pass through."""
|
||||
by doing a happy day pass through.
|
||||
"""
|
||||
|
||||
self.next_weight = 1.0
|
||||
|
||||
@@ -625,7 +626,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
||||
|
||||
def test_schedule_large_host_pool(self):
|
||||
"""Hosts should still be chosen if pool size
|
||||
is larger than number of filtered hosts"""
|
||||
is larger than number of filtered hosts.
|
||||
"""
|
||||
|
||||
sched = fakes.FakeFilterScheduler()
|
||||
|
||||
@@ -653,7 +655,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
||||
|
||||
def test_schedule_chooses_best_host(self):
|
||||
"""If scheduler_host_subset_size is 1, the largest host with greatest
|
||||
weight should be returned"""
|
||||
weight should be returned.
|
||||
"""
|
||||
|
||||
self.flags(scheduler_host_subset_size=1)
|
||||
|
||||
@@ -697,8 +700,10 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
||||
|
||||
def test_select_hosts_happy_day(self):
|
||||
"""select_hosts is basically a wrapper around the _select() method.
|
||||
|
||||
Similar to the _select tests, this just does a happy path test to
|
||||
ensure there is nothing glaringly wrong."""
|
||||
ensure there is nothing glaringly wrong.
|
||||
"""
|
||||
|
||||
self.next_weight = 1.0
|
||||
|
||||
|
||||
@@ -961,7 +961,8 @@ class SchedulerTestCase(test.NoDBTestCase):
|
||||
|
||||
class SchedulerDriverBaseTestCase(SchedulerTestCase):
|
||||
"""Test cases for base scheduler driver class methods
|
||||
that can't will fail if the driver is changed"""
|
||||
that can't will fail if the driver is changed.
|
||||
"""
|
||||
|
||||
def test_unimplemented_schedule_run_instance(self):
|
||||
fake_args = (1, 2, 3)
|
||||
|
||||
@@ -618,6 +618,7 @@ class Connection(object):
|
||||
self._event_callbacks[eventid] = [callback, opaque]
|
||||
|
||||
def getCapabilities(self):
|
||||
"""Return spoofed capabilities."""
|
||||
return '''<capabilities>
|
||||
<host>
|
||||
<uuid>cef19ce0-0ca2-11df-855d-b19fbce37686</uuid>
|
||||
|
||||
@@ -309,6 +309,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
|
||||
class FakeConn():
|
||||
def getCapabilities(self):
|
||||
"""Ensure standard capabilities being returned."""
|
||||
return """<capabilities>
|
||||
<host><cpu><arch>x86_64</arch></cpu></host>
|
||||
</capabilities>"""
|
||||
@@ -4841,7 +4842,8 @@ class LibvirtDriverTestCase(test.TestCase):
|
||||
|
||||
def test_migrate_disk_and_power_off_exception(self):
|
||||
"""Test for nova.virt.libvirt.libvirt_driver.LivirtConnection
|
||||
.migrate_disk_and_power_off. """
|
||||
.migrate_disk_and_power_off.
|
||||
"""
|
||||
|
||||
self.counter = 0
|
||||
self.checked_shared_storage = False
|
||||
@@ -4885,7 +4887,8 @@ class LibvirtDriverTestCase(test.TestCase):
|
||||
|
||||
def test_migrate_disk_and_power_off(self):
|
||||
"""Test for nova.virt.libvirt.libvirt_driver.LivirtConnection
|
||||
.migrate_disk_and_power_off. """
|
||||
.migrate_disk_and_power_off.
|
||||
"""
|
||||
|
||||
disk_info = [{'type': 'qcow2', 'path': '/test/disk',
|
||||
'virt_disk_size': '10737418240',
|
||||
@@ -4957,7 +4960,8 @@ class LibvirtDriverTestCase(test.TestCase):
|
||||
|
||||
def _test_finish_migration(self, power_on):
|
||||
"""Test for nova.virt.libvirt.libvirt_driver.LivirtConnection
|
||||
.finish_migration. """
|
||||
.finish_migration.
|
||||
"""
|
||||
|
||||
disk_info = [{'type': 'qcow2', 'path': '/test/disk',
|
||||
'local_gb': 10, 'backing_file': '/base/disk'},
|
||||
@@ -5037,7 +5041,8 @@ class LibvirtDriverTestCase(test.TestCase):
|
||||
|
||||
def _test_finish_revert_migration(self, power_on):
|
||||
"""Test for nova.virt.libvirt.libvirt_driver.LivirtConnection
|
||||
.finish_revert_migration. """
|
||||
.finish_revert_migration.
|
||||
"""
|
||||
powered_on = power_on
|
||||
self.fake_create_domain_called = False
|
||||
|
||||
@@ -5324,8 +5329,7 @@ class LibvirtDriverTestCase(test.TestCase):
|
||||
|
||||
|
||||
class LibvirtVolumeUsageTestCase(test.TestCase):
|
||||
"""Test for nova.virt.libvirt.libvirt_driver.LibvirtDriver
|
||||
.get_all_volume_usage"""
|
||||
"""Test for LibvirtDriver.get_all_volume_usage."""
|
||||
|
||||
def setUp(self):
|
||||
super(LibvirtVolumeUsageTestCase, self).setUp()
|
||||
|
||||
@@ -39,7 +39,8 @@ def catch_notimplementederror(f):
|
||||
|
||||
If a particular call makes a driver raise NotImplementedError, we
|
||||
log it so that we can extract this information afterwards to
|
||||
automatically generate a hypervisor/feature support matrix."""
|
||||
automatically generate a hypervisor/feature support matrix.
|
||||
"""
|
||||
def wrapped_func(self, *args, **kwargs):
|
||||
try:
|
||||
return f(self, *args, **kwargs)
|
||||
@@ -147,7 +148,8 @@ class _FakeDriverBackendTestCase(object):
|
||||
class VirtDriverLoaderTestCase(_FakeDriverBackendTestCase, test.TestCase):
|
||||
"""Test that ComputeManager can successfully load both
|
||||
old style and new style drivers and end up with the correct
|
||||
final class"""
|
||||
final class.
|
||||
"""
|
||||
|
||||
# if your driver supports being tested in a fake way, it can go here
|
||||
#
|
||||
|
||||
@@ -99,7 +99,9 @@ def stubout_determine_is_pv_objectstore(stubs):
|
||||
|
||||
def stubout_is_snapshot(stubs):
|
||||
"""Always returns true
|
||||
xenapi fake driver does not create vmrefs for snapshots """
|
||||
|
||||
xenapi fake driver does not create vmrefs for snapshots.
|
||||
"""
|
||||
|
||||
def f(*args):
|
||||
return True
|
||||
|
||||
@@ -1780,7 +1780,8 @@ class CompareVersionTestCase(test.TestCase):
|
||||
|
||||
class XenAPIHostTestCase(stubs.XenAPITestBase):
|
||||
"""Tests HostState, which holds metrics from XenServer that get
|
||||
reported back to the Schedulers."""
|
||||
reported back to the Schedulers.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(XenAPIHostTestCase, self).setUp()
|
||||
@@ -2742,7 +2743,8 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase):
|
||||
|
||||
def test_add_host_to_aggregate_invalid_changing_status(self):
|
||||
"""Ensure InvalidAggregateAction is raised when adding host while
|
||||
aggregate is not ready."""
|
||||
aggregate is not ready.
|
||||
"""
|
||||
aggregate = self._aggregate_setup(aggr_state=pool_states.CHANGING)
|
||||
self.assertRaises(exception.InvalidAggregateAction,
|
||||
self.conn.add_to_aggregate, self.context,
|
||||
@@ -2750,7 +2752,8 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase):
|
||||
|
||||
def test_add_host_to_aggregate_invalid_dismissed_status(self):
|
||||
"""Ensure InvalidAggregateAction is raised when aggregate is
|
||||
deleted."""
|
||||
deleted.
|
||||
"""
|
||||
aggregate = self._aggregate_setup(aggr_state=pool_states.DISMISSED)
|
||||
self.assertRaises(exception.InvalidAggregateAction,
|
||||
self.conn.add_to_aggregate, self.context,
|
||||
@@ -2758,7 +2761,8 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase):
|
||||
|
||||
def test_add_host_to_aggregate_invalid_error_status(self):
|
||||
"""Ensure InvalidAggregateAction is raised when aggregate is
|
||||
in error."""
|
||||
in error.
|
||||
"""
|
||||
aggregate = self._aggregate_setup(aggr_state=pool_states.ERROR)
|
||||
self.assertRaises(exception.InvalidAggregateAction,
|
||||
self.conn.add_to_aggregate, self.context,
|
||||
@@ -2788,7 +2792,8 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase):
|
||||
|
||||
def test_remove_host_from_aggregate_invalid_dismissed_status(self):
|
||||
"""Ensure InvalidAggregateAction is raised when aggregate is
|
||||
deleted."""
|
||||
deleted.
|
||||
"""
|
||||
aggregate = self._aggregate_setup(aggr_state=pool_states.DISMISSED)
|
||||
self.assertRaises(exception.InvalidAggregateAction,
|
||||
self.conn.remove_from_aggregate, self.context,
|
||||
@@ -2796,7 +2801,8 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase):
|
||||
|
||||
def test_remove_host_from_aggregate_invalid_changing_status(self):
|
||||
"""Ensure InvalidAggregateAction is raised when aggregate is
|
||||
changing."""
|
||||
changing.
|
||||
"""
|
||||
aggregate = self._aggregate_setup(aggr_state=pool_states.CHANGING)
|
||||
self.assertRaises(exception.InvalidAggregateAction,
|
||||
self.conn.remove_from_aggregate, self.context,
|
||||
|
||||
+13
-6
@@ -208,7 +208,8 @@ def last_completed_audit_period(unit=None, before=None):
|
||||
|
||||
returns: 2 tuple of datetimes (begin, end)
|
||||
The begin timestamp of this audit period is the same as the
|
||||
end of the previous."""
|
||||
end of the previous.
|
||||
"""
|
||||
if not unit:
|
||||
unit = CONF.instance_usage_audit_period
|
||||
|
||||
@@ -637,8 +638,11 @@ def get_shortened_ipv6_cidr(address):
|
||||
|
||||
|
||||
def is_valid_cidr(address):
|
||||
"""Check if the provided ipv4 or ipv6 address is a valid
|
||||
CIDR address or not"""
|
||||
"""Check if address is valid
|
||||
|
||||
The provided address can be a IPv6 or a IPv4
|
||||
CIDR address.
|
||||
"""
|
||||
try:
|
||||
# Validate the correct CIDR Address
|
||||
netaddr.IPNetwork(address)
|
||||
@@ -661,8 +665,10 @@ def is_valid_cidr(address):
|
||||
|
||||
|
||||
def get_ip_version(network):
|
||||
"""Returns the IP version of a network (IPv4 or IPv6). Raises
|
||||
AddrFormatError if invalid network."""
|
||||
"""Returns the IP version of a network (IPv4 or IPv6).
|
||||
|
||||
Raises AddrFormatError if invalid network.
|
||||
"""
|
||||
if netaddr.IPNetwork(network).version == 6:
|
||||
return "IPv6"
|
||||
elif netaddr.IPNetwork(network).version == 4:
|
||||
@@ -1062,7 +1068,8 @@ def get_wrapped_function(function):
|
||||
|
||||
class ExceptionHelper(object):
|
||||
"""Class to wrap another and translate the ClientExceptions raised by its
|
||||
function calls to the actual ones"""
|
||||
function calls to the actual ones.
|
||||
"""
|
||||
|
||||
def __init__(self, target):
|
||||
self._target = target
|
||||
|
||||
+12
-6
@@ -136,7 +136,8 @@ class ComputeDriver(object):
|
||||
|
||||
def init_host(self, host):
|
||||
"""Initialize anything that is necessary for the driver to function,
|
||||
including catching up with currently running VM's on the given host."""
|
||||
including catching up with currently running VM's on the given host.
|
||||
"""
|
||||
# TODO(Vek): Need to pass context in for access to auth_token
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -290,12 +291,14 @@ class ComputeDriver(object):
|
||||
|
||||
def get_all_bw_counters(self, instances):
|
||||
"""Return bandwidth usage counters for each interface on each
|
||||
running VM"""
|
||||
running VM.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_all_volume_usage(self, context, compute_host_bdms):
|
||||
"""Return usage info for volumes attached to vms on
|
||||
a given host"""
|
||||
a given host.-
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_host_ip_addr(self):
|
||||
@@ -741,7 +744,8 @@ class ComputeDriver(object):
|
||||
|
||||
def host_maintenance_mode(self, host, mode):
|
||||
"""Start/Stop host maintenance window. On start, it triggers
|
||||
guest VMs evacuation."""
|
||||
guest VMs evacuation.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def set_host_enabled(self, host, enabled):
|
||||
@@ -922,7 +926,8 @@ class ComputeDriver(object):
|
||||
Register a callback to receive asynchronous event
|
||||
notifications from hypervisors. The callback will
|
||||
be invoked with a single parameter, which will be
|
||||
an instance of the nova.virt.event.Event class."""
|
||||
an instance of the nova.virt.event.Event class.
|
||||
"""
|
||||
|
||||
self._compute_event_callback = callback
|
||||
|
||||
@@ -931,7 +936,8 @@ class ComputeDriver(object):
|
||||
|
||||
Invokes the event callback registered by the
|
||||
compute manager to dispatch the event. This
|
||||
must only be invoked from a green thread."""
|
||||
must only be invoked from a green thread.
|
||||
"""
|
||||
|
||||
if not self._compute_event_callback:
|
||||
LOG.debug("Discarding event %s" % str(event))
|
||||
|
||||
+4
-2
@@ -56,7 +56,8 @@ class InstanceEvent(Event):
|
||||
All events emitted by a virtualization driver which
|
||||
are associated with a virtual domain instance are
|
||||
subclasses of this base object. This object records
|
||||
the UUID associated with the instance."""
|
||||
the UUID associated with the instance.
|
||||
"""
|
||||
|
||||
def __init__(self, uuid, timestamp=None):
|
||||
super(InstanceEvent, self).__init__(timestamp)
|
||||
@@ -74,7 +75,8 @@ class LifecycleEvent(InstanceEvent):
|
||||
events of this class are emitted. The EVENT_LIFECYCLE_XX
|
||||
constants defined why lifecycle change occurred. This
|
||||
event allows detection of an instance starting/stopping
|
||||
without need for polling"""
|
||||
without need for polling.
|
||||
"""
|
||||
|
||||
def __init__(self, uuid, transition, timestamp=None):
|
||||
super(LifecycleEvent, self).__init__(uuid, timestamp)
|
||||
|
||||
+6
-3
@@ -272,13 +272,15 @@ class FakeDriver(driver.ComputeDriver):
|
||||
|
||||
def get_all_bw_counters(self, instances):
|
||||
"""Return bandwidth usage counters for each interface on each
|
||||
running VM"""
|
||||
running VM.
|
||||
"""
|
||||
bw = []
|
||||
return bw
|
||||
|
||||
def get_all_volume_usage(self, context, compute_host_bdms):
|
||||
"""Return usage info for volumes attached to vms on
|
||||
a given host"""
|
||||
a given host.
|
||||
"""
|
||||
volusage = []
|
||||
return volusage
|
||||
|
||||
@@ -408,7 +410,8 @@ class FakeDriver(driver.ComputeDriver):
|
||||
|
||||
def host_maintenance_mode(self, host, mode):
|
||||
"""Start/Stop host maintenance window. On start, it triggers
|
||||
guest VMs evacuation."""
|
||||
guest VMs evacuation.
|
||||
"""
|
||||
if not mode:
|
||||
return 'off_maintenance'
|
||||
return 'on_maintenance'
|
||||
|
||||
+12
-6
@@ -61,7 +61,9 @@ class FirewallDriver(object):
|
||||
|
||||
def prepare_instance_filter(self, instance, network_info):
|
||||
"""Prepare filters for the instance.
|
||||
At this point, the instance isn't running yet."""
|
||||
|
||||
At this point, the instance isn't running yet.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def filter_defer_apply_on(self):
|
||||
@@ -90,14 +92,16 @@ class FirewallDriver(object):
|
||||
"""Refresh security group rules from data store
|
||||
|
||||
Gets called when a rule has been added to or removed from
|
||||
the security group."""
|
||||
the security group.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def refresh_security_group_members(self, security_group_id):
|
||||
"""Refresh security group members from data store
|
||||
|
||||
Gets called when an instance gets added to or removed from
|
||||
the security group."""
|
||||
the security group.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def refresh_instance_security_rules(self, instance):
|
||||
@@ -105,7 +109,8 @@ class FirewallDriver(object):
|
||||
|
||||
Gets called when an instance gets added to or removed from
|
||||
the security group the instance is a member of or if the
|
||||
group gains or looses a rule."""
|
||||
group gains or looses a rule.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def refresh_provider_fw_rules(self):
|
||||
@@ -213,8 +218,9 @@ class IptablesFirewallDriver(FirewallDriver):
|
||||
|
||||
def _filters_for_instance(self, chain_name, network_info):
|
||||
"""Creates a rule corresponding to each ip that defines a
|
||||
jump to the corresponding instance - chain for all the traffic
|
||||
destined to that ip."""
|
||||
jump to the corresponding instance - chain for all the traffic
|
||||
destined to that ip.
|
||||
"""
|
||||
# make sure this is legacy nw_info
|
||||
network_info = self._handle_network_info_model(network_info)
|
||||
|
||||
|
||||
@@ -154,8 +154,10 @@ class HostOps(object):
|
||||
self._stats = data
|
||||
|
||||
def get_host_stats(self, refresh=False):
|
||||
"""Return the current state of the host. If 'refresh' is
|
||||
True, run the update first."""
|
||||
"""Return the current state of the host.
|
||||
|
||||
If 'refresh' is True, run the update first.
|
||||
"""
|
||||
LOG.debug(_("get_host_stats called"))
|
||||
|
||||
if refresh or not self._stats:
|
||||
|
||||
@@ -84,7 +84,8 @@ def has_disk_dev(mapping, disk_dev):
|
||||
corresponding disk_info tuple has a device name
|
||||
matching disk_dev
|
||||
|
||||
Returns True if the disk_dev is in use."""
|
||||
Returns True if the disk_dev is in use.
|
||||
"""
|
||||
|
||||
for disk in mapping:
|
||||
info = mapping[disk]
|
||||
@@ -102,7 +103,8 @@ def get_dev_prefix_for_disk_bus(disk_bus):
|
||||
form a disk dev 'hda'
|
||||
|
||||
Returns the dev prefix or raises an
|
||||
exception if the disk bus is unknown."""
|
||||
exception if the disk bus is unknown.
|
||||
"""
|
||||
|
||||
if CONF.libvirt_disk_prefix:
|
||||
return CONF.libvirt_disk_prefix
|
||||
@@ -134,7 +136,8 @@ def get_dev_count_for_disk_bus(disk_bus):
|
||||
Determine how many disks can be supported in
|
||||
a single VM for a particular disk bus.
|
||||
|
||||
Returns the number of disks supported."""
|
||||
Returns the number of disks supported.
|
||||
"""
|
||||
|
||||
if disk_bus == "ide":
|
||||
return 4
|
||||
@@ -201,7 +204,8 @@ def get_disk_bus_for_device_type(virt_type,
|
||||
return 'virtio', while for a CDROM it will return 'ide'
|
||||
|
||||
Returns the disk_bus, or returns None if the device
|
||||
type is not supported for this virtualization"""
|
||||
type is not supported for this virtualization
|
||||
"""
|
||||
|
||||
# Prefer a disk bus set against the image first of all
|
||||
if image_meta:
|
||||
@@ -241,7 +245,8 @@ def get_disk_bus_for_disk_dev(virt_type, disk_dev):
|
||||
the currently configured virtualization technology
|
||||
|
||||
Returns the disk bus, or raises an Exception if
|
||||
the disk dev prefix is unknown."""
|
||||
the disk dev prefix is unknown.
|
||||
"""
|
||||
|
||||
if disk_dev[:2] == 'hd':
|
||||
return "ide"
|
||||
@@ -274,7 +279,8 @@ def get_next_disk_info(mapping, disk_bus,
|
||||
determine the next available disk dev that can be assigned
|
||||
for the disk bus.
|
||||
|
||||
Returns the disk_info for the next available disk."""
|
||||
Returns the disk_info for the next available disk.
|
||||
"""
|
||||
|
||||
disk_dev = find_disk_dev_for_disk_bus(mapping,
|
||||
disk_bus,
|
||||
@@ -298,7 +304,8 @@ def get_disk_mapping(virt_type, instance,
|
||||
'disk.local', 'disk.swap' and 'disk.config' images have
|
||||
been overriden by the block device mapping.
|
||||
|
||||
Returns the guest disk mapping for the devices."""
|
||||
Returns the guest disk mapping for the devices.
|
||||
"""
|
||||
|
||||
inst_type = flavors.extract_flavor(instance)
|
||||
|
||||
@@ -425,7 +432,8 @@ def get_disk_info(virt_type, instance, block_device_info=None,
|
||||
- cdrom_bus: the bus for CDROMs
|
||||
- mapping: the disk mapping
|
||||
|
||||
Returns the disk mapping disk."""
|
||||
Returns the disk mapping disk.
|
||||
"""
|
||||
|
||||
disk_bus = get_disk_bus_for_device_type(virt_type, image_meta, "disk")
|
||||
cdrom_bus = get_disk_bus_for_device_type(virt_type, image_meta, "cdrom")
|
||||
|
||||
@@ -24,7 +24,8 @@ classes based on common operational needs / policies
|
||||
|
||||
def set_vif_guest_frontend_config(conf, mac, model, driver):
|
||||
"""Populate a LibvirtConfigGuestInterface instance
|
||||
with guest frontend details"""
|
||||
with guest frontend details.
|
||||
"""
|
||||
conf.mac_addr = mac
|
||||
if model is not None:
|
||||
conf.model = model
|
||||
@@ -34,7 +35,8 @@ def set_vif_guest_frontend_config(conf, mac, model, driver):
|
||||
|
||||
def set_vif_host_backend_bridge_config(conf, brname, tapname=None):
|
||||
"""Populate a LibvirtConfigGuestInterface instance
|
||||
with host backend details for a software bridge"""
|
||||
with host backend details for a software bridge.
|
||||
"""
|
||||
conf.net_type = "bridge"
|
||||
conf.source_dev = brname
|
||||
if tapname:
|
||||
@@ -48,7 +50,8 @@ def set_vif_host_backend_ethernet_config(conf, tapname):
|
||||
host device.
|
||||
|
||||
NB use of this configuration is discouraged by
|
||||
libvirt project and will mark domains as 'tainted'"""
|
||||
libvirt project and will mark domains as 'tainted'.
|
||||
"""
|
||||
|
||||
conf.net_type = "ethernet"
|
||||
conf.target_dev = tapname
|
||||
@@ -57,7 +60,8 @@ def set_vif_host_backend_ethernet_config(conf, tapname):
|
||||
|
||||
def set_vif_host_backend_ovs_config(conf, brname, interfaceid, tapname=None):
|
||||
"""Populate a LibvirtConfigGuestInterface instance
|
||||
with host backend details for an OpenVSwitch bridge"""
|
||||
with host backend details for an OpenVSwitch bridge.
|
||||
"""
|
||||
|
||||
conf.net_type = "bridge"
|
||||
conf.source_dev = brname
|
||||
@@ -72,7 +76,8 @@ def set_vif_host_backend_802qbg_config(conf, devname, managerid,
|
||||
typeid, typeidversion,
|
||||
instanceid, tapname=None):
|
||||
"""Populate a LibvirtConfigGuestInterface instance
|
||||
with host backend details for an 802.1qbg device"""
|
||||
with host backend details for an 802.1qbg device.
|
||||
"""
|
||||
|
||||
conf.net_type = "direct"
|
||||
conf.source_dev = devname
|
||||
@@ -89,7 +94,8 @@ def set_vif_host_backend_802qbg_config(conf, devname, managerid,
|
||||
def set_vif_host_backend_802qbh_config(conf, devname, profileid,
|
||||
tapname=None):
|
||||
"""Populate a LibvirtConfigGuestInterface instance
|
||||
with host backend details for an 802.1qbh device"""
|
||||
with host backend details for an 802.1qbh device.
|
||||
"""
|
||||
|
||||
conf.net_type = "direct"
|
||||
conf.source_dev = devname
|
||||
|
||||
+27
-13
@@ -420,7 +420,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
permitted to use libvirt python APIs, and the
|
||||
driver.queue_event method. In particular any use
|
||||
of logging is forbidden, since it will confuse
|
||||
eventlet's greenthread integration"""
|
||||
eventlet's greenthread integration
|
||||
"""
|
||||
|
||||
while True:
|
||||
libvirt.virEventRunDefaultImpl()
|
||||
@@ -430,7 +431,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
|
||||
This is a green thread which waits for events to
|
||||
arrive from the libvirt event loop thread. This
|
||||
then dispatches the events to the compute manager."""
|
||||
then dispatches the events to the compute manager.
|
||||
"""
|
||||
|
||||
while True:
|
||||
self._dispatch_events()
|
||||
@@ -442,7 +444,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
NB: this method is executing in a native thread, not
|
||||
an eventlet coroutine. It can only invoke other libvirt
|
||||
APIs, or use self.queue_event(). Any use of logging APIs
|
||||
in particular is forbidden."""
|
||||
in particular is forbidden.
|
||||
"""
|
||||
|
||||
self = opaque
|
||||
|
||||
@@ -465,7 +468,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
|
||||
This method is called by the native event thread to
|
||||
put events on the queue for later dispatch by the
|
||||
green thread."""
|
||||
green thread.
|
||||
"""
|
||||
|
||||
if self._event_queue is None:
|
||||
LOG.debug("Event loop thread is not active, "
|
||||
@@ -484,7 +488,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
"""Wait for & dispatch events from native thread
|
||||
|
||||
Blocks until native thread indicates some events
|
||||
are ready. Then dispatches all queued events."""
|
||||
are ready. Then dispatches all queued events.
|
||||
"""
|
||||
|
||||
# Wait to be notified that there are some
|
||||
# events pending
|
||||
@@ -507,7 +512,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
"""Create a self-pipe for the native thread to synchronize on.
|
||||
|
||||
This code is taken from the eventlet tpool module, under terms
|
||||
of the Apache License v2.0."""
|
||||
of the Apache License v2.0.
|
||||
"""
|
||||
|
||||
self._event_queue = native_Queue.Queue()
|
||||
try:
|
||||
@@ -1936,7 +1942,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
|
||||
def get_host_capabilities(self):
|
||||
"""Returns an instance of config.LibvirtConfigCaps representing
|
||||
the capabilities of the host"""
|
||||
the capabilities of the host.
|
||||
"""
|
||||
if not self._caps:
|
||||
xmlstr = self._conn.getCapabilities()
|
||||
self._caps = vconfig.LibvirtConfigCaps()
|
||||
@@ -1951,7 +1958,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
def get_host_cpu_for_guest(self):
|
||||
"""Returns an instance of config.LibvirtConfigGuestCPU
|
||||
representing the host's CPU model & topology with
|
||||
policy for configuring a guest to match"""
|
||||
policy for configuring a guest to match
|
||||
"""
|
||||
|
||||
caps = self.get_host_capabilities()
|
||||
hostcpu = caps.host.cpu
|
||||
@@ -2796,7 +2804,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
|
||||
def get_all_volume_usage(self, context, compute_host_bdms):
|
||||
"""Return usage info for volumes attached to vms on
|
||||
a given host"""
|
||||
a given host.
|
||||
"""
|
||||
vol_usage = []
|
||||
|
||||
for instance_bdms in compute_host_bdms:
|
||||
@@ -3118,7 +3127,9 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
|
||||
def _check_shared_storage_test_file(self, filename):
|
||||
"""Confirms existence of the tmpfile under CONF.instances_path.
|
||||
Cannot confirm tmpfile return False."""
|
||||
|
||||
Cannot confirm tmpfile return False.
|
||||
"""
|
||||
tmp_file = os.path.join(CONF.instances_path, filename)
|
||||
if not os.path.exists(tmp_file):
|
||||
return False
|
||||
@@ -3526,7 +3537,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
def get_host_stats(self, refresh=False):
|
||||
"""Return the current state of the host.
|
||||
|
||||
If 'refresh' is True, run update the stats first."""
|
||||
If 'refresh' is True, run update the stats first.
|
||||
"""
|
||||
return self.host_state.get_host_stats(refresh=refresh)
|
||||
|
||||
def get_host_uptime(self, host):
|
||||
@@ -3709,7 +3721,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
|
||||
def _cleanup_failed_migration(self, inst_base):
|
||||
"""Make sure that a failed migrate doesn't prevent us from rolling
|
||||
back in a revert."""
|
||||
back in a revert.
|
||||
"""
|
||||
shutil.rmtree(inst_base)
|
||||
|
||||
def finish_revert_migration(self, instance, network_info,
|
||||
@@ -3857,7 +3870,8 @@ class HostState(object):
|
||||
def get_host_stats(self, refresh=False):
|
||||
"""Return the current state of the host.
|
||||
|
||||
If 'refresh' is True, run update the stats first."""
|
||||
If 'refresh' is True, run update the stats first.
|
||||
"""
|
||||
if refresh:
|
||||
self.update_status()
|
||||
return self._stats
|
||||
|
||||
@@ -83,7 +83,8 @@ class NWFilterFirewall(base_firewall.FirewallDriver):
|
||||
def nova_dhcp_filter():
|
||||
"""The standard allow-dhcp-server filter is an <ip> one, so it uses
|
||||
ebtables to allow traffic through. Without a corresponding rule in
|
||||
iptables, it'll get blocked anyway."""
|
||||
iptables, it'll get blocked anyway.
|
||||
"""
|
||||
|
||||
return '''<filter name='nova-allow-dhcp-server' chain='ipv4'>
|
||||
<uuid>891e4787-e5c0-d59b-cbd6-41bc3c6b36fc</uuid>
|
||||
|
||||
@@ -550,7 +550,8 @@ def file_delete(path):
|
||||
def find_disk(virt_dom):
|
||||
"""Find root device path for instance
|
||||
|
||||
May be file or device"""
|
||||
May be file or device
|
||||
"""
|
||||
xml_desc = virt_dom.XMLDesc(0)
|
||||
domain = etree.fromstring(xml_desc)
|
||||
if CONF.libvirt_type == 'lxc':
|
||||
|
||||
@@ -495,7 +495,8 @@ class LibvirtGenericVIFDriver(LibvirtBaseVIFDriver):
|
||||
class LibvirtBridgeDriver(LibvirtGenericVIFDriver):
|
||||
"""Retained in Grizzly for compatibility with Quantum
|
||||
drivers which do not yet report 'vif_type' port binding.
|
||||
Will be deprecated in Havana, and removed in Ixxxx."""
|
||||
Will be deprecated in Havana, and removed in Ixxxx.
|
||||
"""
|
||||
|
||||
def get_config(self, instance, network, mapping, image_meta):
|
||||
LOG.deprecated(_("The LibvirtBridgeDriver VIF driver is now "
|
||||
@@ -515,7 +516,8 @@ class LibvirtBridgeDriver(LibvirtGenericVIFDriver):
|
||||
class LibvirtOpenVswitchDriver(LibvirtGenericVIFDriver):
|
||||
"""Retained in Grizzly for compatibility with Quantum
|
||||
drivers which do not yet report 'vif_type' port binding.
|
||||
Will be deprecated in Havana, and removed in Ixxxx."""
|
||||
Will be deprecated in Havana, and removed in Ixxxx.
|
||||
"""
|
||||
|
||||
def get_bridge_name(self, network):
|
||||
return network.get('bridge') or CONF.libvirt_ovs_bridge
|
||||
@@ -543,7 +545,8 @@ class LibvirtOpenVswitchDriver(LibvirtGenericVIFDriver):
|
||||
class LibvirtHybridOVSBridgeDriver(LibvirtGenericVIFDriver):
|
||||
"""Retained in Grizzly for compatibility with Quantum
|
||||
drivers which do not yet report 'vif_type' port binding.
|
||||
Will be deprecated in Havana, and removed in Ixxxx."""
|
||||
Will be deprecated in Havana, and removed in Ixxxx.
|
||||
"""
|
||||
|
||||
def get_bridge_name(self, network):
|
||||
return network.get('bridge') or CONF.libvirt_ovs_bridge
|
||||
@@ -571,7 +574,8 @@ class LibvirtHybridOVSBridgeDriver(LibvirtGenericVIFDriver):
|
||||
class LibvirtOpenVswitchVirtualPortDriver(LibvirtGenericVIFDriver):
|
||||
"""Retained in Grizzly for compatibility with Quantum
|
||||
drivers which do not yet report 'vif_type' port binding.
|
||||
Will be deprecated in Havana, and removed in Ixxxx."""
|
||||
Will be deprecated in Havana, and removed in Ixxxx.
|
||||
"""
|
||||
|
||||
def get_bridge_name(self, network):
|
||||
return network.get('bridge') or CONF.libvirt_ovs_bridge
|
||||
@@ -599,7 +603,8 @@ class LibvirtOpenVswitchVirtualPortDriver(LibvirtGenericVIFDriver):
|
||||
class QuantumLinuxBridgeVIFDriver(LibvirtGenericVIFDriver):
|
||||
"""Retained in Grizzly for compatibility with Quantum
|
||||
drivers which do not yet report 'vif_type' port binding.
|
||||
Will be deprecated in Havana, and removed in Ixxxx."""
|
||||
Will be deprecated in Havana, and removed in Ixxxx.
|
||||
"""
|
||||
|
||||
def get_bridge_name(self, network):
|
||||
def_bridge = ("brq" + network['id'])[:network_model.NIC_NAME_LEN]
|
||||
|
||||
@@ -795,7 +795,8 @@ class LibvirtFibreChannelVolumeDriver(LibvirtBaseVolumeDriver):
|
||||
|
||||
class LibvirtScalityVolumeDriver(LibvirtBaseVolumeDriver):
|
||||
"""Scality SOFS Nova driver. Provide hypervisors with access
|
||||
to sparse files on SOFS. """
|
||||
to sparse files on SOFS.
|
||||
"""
|
||||
|
||||
def __init__(self, connection):
|
||||
"""Create back-end to SOFS and check connection."""
|
||||
|
||||
@@ -69,7 +69,8 @@ class PowerVMDriver(driver.ComputeDriver):
|
||||
|
||||
def init_host(self, host):
|
||||
"""Initialize anything that is necessary for the driver to function,
|
||||
including catching up with currently running VM's on the given host."""
|
||||
including catching up with currently running VM's on the given host.
|
||||
"""
|
||||
pass
|
||||
|
||||
def get_info(self, instance):
|
||||
|
||||
@@ -296,12 +296,15 @@ class VMwareESXDriver(driver.ComputeDriver):
|
||||
|
||||
def update_host_status(self):
|
||||
"""Update the status info of the host, and return those values
|
||||
to the calling program."""
|
||||
to the calling program.
|
||||
"""
|
||||
return self.host_state.update_status()
|
||||
|
||||
def get_host_stats(self, refresh=False):
|
||||
"""Return the current state of the host. If 'refresh' is
|
||||
True, run the update first."""
|
||||
"""Return the current state of the host.
|
||||
|
||||
If 'refresh' is True, run the update first.
|
||||
"""
|
||||
return self.host_state.get_host_stats(refresh=refresh)
|
||||
|
||||
def host_power_action(self, host, action):
|
||||
@@ -310,7 +313,8 @@ class VMwareESXDriver(driver.ComputeDriver):
|
||||
|
||||
def host_maintenance_mode(self, host, mode):
|
||||
"""Start/Stop host maintenance window. On start, it triggers
|
||||
guest VMs evacuation."""
|
||||
guest VMs evacuation.
|
||||
"""
|
||||
return self._host.host_maintenance_mode(host, mode)
|
||||
|
||||
def set_host_enabled(self, host, enabled):
|
||||
|
||||
@@ -57,7 +57,8 @@ class Host(object):
|
||||
|
||||
def host_maintenance_mode(self, host, mode):
|
||||
"""Start/Stop host maintenance window. On start, it triggers
|
||||
guest VMs evacuation."""
|
||||
guest VMs evacuation.
|
||||
"""
|
||||
host_mor = self._session._call_method(vim_util, "get_objects",
|
||||
"HostSystem")[0].obj
|
||||
LOG.debug(_("Set maintenance mod on %(host)s to %(mode)s") % locals())
|
||||
|
||||
@@ -36,7 +36,8 @@ GLANCE_POLL_INTERVAL = 5
|
||||
|
||||
class ThreadSafePipe(queue.LightQueue):
|
||||
"""The pipe to hold the data which the reader writes to and the writer
|
||||
reads from."""
|
||||
reads from.
|
||||
"""
|
||||
|
||||
def __init__(self, maxsize, transfer_size):
|
||||
queue.LightQueue.__init__(self, maxsize)
|
||||
@@ -44,9 +45,12 @@ class ThreadSafePipe(queue.LightQueue):
|
||||
self.transferred = 0
|
||||
|
||||
def read(self, chunk_size):
|
||||
"""Read data from the pipe. Chunksize if ignored for we have ensured
|
||||
"""Read data from the pipe.
|
||||
|
||||
Chunksize if ignored for we have ensured
|
||||
that the data chunks written to the pipe by readers is the same as the
|
||||
chunks asked for by the Writer."""
|
||||
chunks asked for by the Writer.
|
||||
"""
|
||||
if self.transferred < self.transfer_size:
|
||||
data_item = self.get()
|
||||
self.transferred += len(data_item)
|
||||
@@ -73,7 +77,8 @@ class ThreadSafePipe(queue.LightQueue):
|
||||
|
||||
class GlanceWriteThread(object):
|
||||
"""Ensures that image data is written to in the glance client and that
|
||||
it is in correct ('active')state."""
|
||||
it is in correct ('active')state.
|
||||
"""
|
||||
|
||||
def __init__(self, context, input, image_service, image_id,
|
||||
image_meta=None):
|
||||
@@ -92,7 +97,8 @@ class GlanceWriteThread(object):
|
||||
|
||||
def _inner():
|
||||
"""Function to do the image data transfer through an update
|
||||
and thereon checks if the state is 'active'."""
|
||||
and thereon checks if the state is 'active'.
|
||||
"""
|
||||
self.image_service.update(self.context,
|
||||
self.image_id,
|
||||
self.image_meta,
|
||||
@@ -143,7 +149,8 @@ class GlanceWriteThread(object):
|
||||
|
||||
class IOThread(object):
|
||||
"""Class that reads chunks from the input file and writes them to the
|
||||
output file till the transfer is completely done."""
|
||||
output file till the transfer is completely done.
|
||||
"""
|
||||
|
||||
def __init__(self, input, output):
|
||||
self.input = input
|
||||
@@ -156,7 +163,8 @@ class IOThread(object):
|
||||
|
||||
def _inner():
|
||||
"""Read data from the input and write the same to the output
|
||||
until the transfer completes."""
|
||||
until the transfer completes.
|
||||
"""
|
||||
self._running = True
|
||||
while self._running:
|
||||
try:
|
||||
|
||||
@@ -44,8 +44,11 @@ class GlanceFileRead(object):
|
||||
self.iter = self.get_next()
|
||||
|
||||
def read(self, chunk_size):
|
||||
"""Read an item from the queue. The chunk size is ignored for the
|
||||
Client ImageBodyIterator uses its own CHUNKSIZE."""
|
||||
"""Read an item from the queue.
|
||||
|
||||
The chunk size is ignored for the Client ImageBodyIterator
|
||||
uses its own CHUNKSIZE.
|
||||
"""
|
||||
try:
|
||||
return self.iter.next()
|
||||
except StopIteration:
|
||||
|
||||
@@ -36,7 +36,8 @@ def start_transfer(context, read_file_handle, data_size,
|
||||
"""Start the data transfer from the reader to the writer.
|
||||
Reader writes to the pipe and the writer reads from the pipe. This means
|
||||
that the total transfer time boils down to the slower of the read/write
|
||||
and not the addition of the two times."""
|
||||
and not the addition of the two times.
|
||||
"""
|
||||
|
||||
if not image_meta:
|
||||
image_meta = {}
|
||||
|
||||
+22
-11
@@ -238,7 +238,8 @@ class XenAPIDriver(driver.ComputeDriver):
|
||||
instance_type, network_info,
|
||||
block_device_info=None):
|
||||
"""Transfers the VHD of a running instance to another host, then shuts
|
||||
off the instance copies over the COW disk"""
|
||||
off the instance copies over the COW disk
|
||||
"""
|
||||
# NOTE(vish): Xen currently does not use network info.
|
||||
return self._vmops.migrate_disk_and_power_off(context, instance,
|
||||
dest, instance_type, block_device_info)
|
||||
@@ -307,7 +308,8 @@ class XenAPIDriver(driver.ComputeDriver):
|
||||
|
||||
def get_all_bw_counters(self, instances):
|
||||
"""Return bandwidth usage counters for each interface on each
|
||||
running VM"""
|
||||
running VM.
|
||||
"""
|
||||
|
||||
# we only care about VMs that correspond to a nova-managed
|
||||
# instance:
|
||||
@@ -456,13 +458,15 @@ class XenAPIDriver(driver.ComputeDriver):
|
||||
|
||||
def get_instance_disk_info(self, instance_name):
|
||||
"""Used by libvirt for live migration. We rely on xenapi
|
||||
checks to do this for us."""
|
||||
checks to do this for us.
|
||||
"""
|
||||
pass
|
||||
|
||||
def pre_block_migration(self, ctxt, instance_ref, disk_info_json):
|
||||
"""Used by libvirt for live migration. We rely on xenapi
|
||||
checks to do this for us. May be used in the future to
|
||||
populate the vdi/vif maps"""
|
||||
populate the vdi/vif maps.
|
||||
"""
|
||||
pass
|
||||
|
||||
def live_migration(self, ctxt, instance_ref, dest,
|
||||
@@ -524,29 +528,34 @@ class XenAPIDriver(driver.ComputeDriver):
|
||||
"""Updates security group rules for all instances associated with a
|
||||
given security group.
|
||||
|
||||
Invoked when security group rules are updated."""
|
||||
Invoked when security group rules are updated.
|
||||
"""
|
||||
return self._vmops.refresh_security_group_rules(security_group_id)
|
||||
|
||||
def refresh_security_group_members(self, security_group_id):
|
||||
"""Updates security group rules for all instances associated with a
|
||||
given security group.
|
||||
|
||||
Invoked when instances are added/removed to a security group."""
|
||||
Invoked when instances are added/removed to a security group.
|
||||
"""
|
||||
return self._vmops.refresh_security_group_members(security_group_id)
|
||||
|
||||
def refresh_instance_security_rules(self, instance):
|
||||
"""Updates security group rules for specified instance.
|
||||
|
||||
Invoked when instances are added/removed to a security group
|
||||
or when a rule is added/removed to a security group."""
|
||||
or when a rule is added/removed to a security group.
|
||||
"""
|
||||
return self._vmops.refresh_instance_security_rules(instance)
|
||||
|
||||
def refresh_provider_fw_rules(self):
|
||||
return self._vmops.refresh_provider_fw_rules()
|
||||
|
||||
def get_host_stats(self, refresh=False):
|
||||
"""Return the current state of the host. If 'refresh' is
|
||||
True, run the update first."""
|
||||
"""Return the current state of the host.
|
||||
|
||||
If 'refresh' is True, run the update first.
|
||||
"""
|
||||
return self.host_state.get_host_stats(refresh=refresh)
|
||||
|
||||
def host_power_action(self, host, action):
|
||||
@@ -572,7 +581,8 @@ class XenAPIDriver(driver.ComputeDriver):
|
||||
|
||||
def host_maintenance_mode(self, host, mode):
|
||||
"""Start/Stop host maintenance window. On start, it triggers
|
||||
guest VMs evacuation."""
|
||||
guest VMs evacuation.
|
||||
"""
|
||||
return self._host.host_maintenance_mode(host, mode)
|
||||
|
||||
def add_to_aggregate(self, context, aggregate, host, **kwargs):
|
||||
@@ -670,7 +680,8 @@ class XenAPISession(object):
|
||||
|
||||
def _get_product_version_and_brand(self):
|
||||
"""Return a tuple of (major, minor, rev) for the host version and
|
||||
a string of the product brand"""
|
||||
a string of the product brand.
|
||||
"""
|
||||
software_version = self._get_software_version()
|
||||
|
||||
product_version_str = software_version.get('product_version')
|
||||
|
||||
@@ -200,7 +200,8 @@ def create_vbd(vm_ref, vdi_ref, userdevice=0):
|
||||
|
||||
def after_VBD_create(vbd_ref, vbd_rec):
|
||||
"""Create read-only fields and backref from VM and VDI to VBD when VBD
|
||||
is created."""
|
||||
is created.
|
||||
"""
|
||||
vbd_rec['currently_attached'] = False
|
||||
vbd_rec['device'] = ''
|
||||
|
||||
@@ -243,7 +244,8 @@ def create_task(name_label):
|
||||
|
||||
def create_local_pifs():
|
||||
"""Adds a PIF for each to the local database with VLAN=-1.
|
||||
Do this one per host."""
|
||||
Do this one per host.
|
||||
"""
|
||||
for host_ref in _db_content['host'].keys():
|
||||
_create_local_pif(host_ref)
|
||||
|
||||
@@ -251,7 +253,8 @@ def create_local_pifs():
|
||||
def create_local_srs():
|
||||
"""Create an SR that looks like the one created on the local disk by
|
||||
default by the XenServer installer. Do this one per host. Also, fake
|
||||
the installation of an ISO SR."""
|
||||
the installation of an ISO SR.
|
||||
"""
|
||||
for host_ref in _db_content['host'].keys():
|
||||
create_sr(name_label='Local storage',
|
||||
type='lvm',
|
||||
@@ -365,7 +368,8 @@ def check_for_session_leaks():
|
||||
|
||||
def as_value(s):
|
||||
"""Helper function for simulating XenAPI plugin responses. It
|
||||
escapes and wraps the given argument."""
|
||||
escapes and wraps the given argument.
|
||||
"""
|
||||
return '<value>%s</value>' % saxutils.escape(s)
|
||||
|
||||
|
||||
@@ -373,7 +377,8 @@ def as_json(*args, **kwargs):
|
||||
"""Helper function for simulating XenAPI plugin responses for those
|
||||
that are returning JSON. If this function is given plain arguments,
|
||||
then these are rendered as a JSON list. If it's given keyword
|
||||
arguments then these are rendered as a JSON dict."""
|
||||
arguments then these are rendered as a JSON dict.
|
||||
"""
|
||||
arg = args or kwargs
|
||||
return jsonutils.dumps(arg)
|
||||
|
||||
|
||||
@@ -63,8 +63,10 @@ class Dom0IptablesFirewallDriver(firewall.IptablesFirewallDriver):
|
||||
|
||||
def _provider_rules(self):
|
||||
"""Generate a list of rules from provider for IP4 & IP6.
|
||||
|
||||
Note: We could not use the common code from virt.firewall because
|
||||
XS doesn't accept the '-m multiport' option"""
|
||||
XS doesn't accept the '-m multiport' option.
|
||||
"""
|
||||
|
||||
ctxt = context.get_admin_context()
|
||||
ipv4_rules = []
|
||||
|
||||
@@ -49,7 +49,8 @@ class Host(object):
|
||||
|
||||
def host_maintenance_mode(self, host, mode):
|
||||
"""Start/Stop host maintenance window. On start, it triggers
|
||||
guest VMs evacuation."""
|
||||
guest VMs evacuation.
|
||||
"""
|
||||
if not mode:
|
||||
return 'off_maintenance'
|
||||
host_list = [host_ref for host_ref in
|
||||
|
||||
@@ -1534,7 +1534,8 @@ def compile_metrics(start_time, stop_time=None):
|
||||
"""Compile bandwidth usage, cpu, and disk metrics for all VMs on
|
||||
this host.
|
||||
Note that some stats, like bandwidth, do not seem to be very
|
||||
accurate in some of the data from XenServer (mdragon). """
|
||||
accurate in some of the data from XenServer (mdragon).
|
||||
"""
|
||||
start_time = int(start_time)
|
||||
|
||||
xml = _get_rrd_updates(_get_rrd_server(), start_time)
|
||||
@@ -2359,7 +2360,8 @@ def _prepare_injectables(inst, network_info):
|
||||
|
||||
def ensure_correct_host(session):
|
||||
"""Ensure we're connected to the host we're running on. This is the
|
||||
required configuration for anything that uses vdi_attached_here."""
|
||||
required configuration for anything that uses vdi_attached_here.
|
||||
"""
|
||||
this_vm_uuid = get_this_vm_uuid()
|
||||
|
||||
try:
|
||||
|
||||
@@ -1001,7 +1001,8 @@ class VMOps(object):
|
||||
|
||||
def check_resize_func_name(self):
|
||||
"""Check the function name used to resize an instance based
|
||||
on product_brand and product_version."""
|
||||
on product_brand and product_version.
|
||||
"""
|
||||
|
||||
brand = self._session.product_brand
|
||||
version = self._session.product_version
|
||||
@@ -1412,7 +1413,8 @@ class VMOps(object):
|
||||
|
||||
def get_all_bw_counters(self):
|
||||
"""Return running bandwidth counter for each interface on each
|
||||
running VM"""
|
||||
running VM.
|
||||
"""
|
||||
counters = vm_utils.fetch_bandwidth(self._session)
|
||||
bw = {}
|
||||
for vm_ref, vm_rec in vm_utils.list_vms(self._session):
|
||||
|
||||
@@ -39,7 +39,7 @@ commands =
|
||||
commands = {posargs}
|
||||
|
||||
[flake8]
|
||||
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E711,E712,H302,H303,H403,H404,F403,F811,F841
|
||||
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E711,E712,H302,H303,H404,F403,F811,F841
|
||||
builtins = _
|
||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,plugins,tools
|
||||
|
||||
|
||||
Reference in New Issue
Block a user