Merge "Remove translation of log messages"

This commit is contained in:
Jenkins 2017-06-30 18:32:52 +00:00 committed by Gerrit Code Review
commit 14f8258865
15 changed files with 253 additions and 200 deletions

View File

@ -18,7 +18,6 @@ from oslo_service import loopingcall
from oslo_log import log as logging from oslo_log import log as logging
from oslo_config import cfg from oslo_config import cfg
from cinder.i18n import _LE
from cinder.exception import VolumeNotFound, NotFound, APITimeout, InvalidConfigurationValue from cinder.exception import VolumeNotFound, NotFound, APITimeout, InvalidConfigurationValue
from cinder.volume.driver import BaseVD from cinder.volume.driver import BaseVD
@ -135,7 +134,7 @@ class EBSDriver(BaseVD):
try: try:
ebs_vol = self._find(volume['id'], self._conn.get_all_volumes) ebs_vol = self._find(volume['id'], self._conn.get_all_volumes)
except NotFound: except NotFound:
LOG.error(_LE('Volume %s was not found'), volume['id']) LOG.error('Volume %s was not found', volume['id'])
return return
self._conn.delete_volume(ebs_vol.id) self._conn.delete_volume(ebs_vol.id)
@ -209,7 +208,7 @@ class EBSDriver(BaseVD):
try: try:
ebs_ss = self._find(snapshot['id'], self._conn.get_all_snapshots) ebs_ss = self._find(snapshot['id'], self._conn.get_all_snapshots)
except NotFound: except NotFound:
LOG.error(_LE('Snapshot %s was not found'), snapshot['id']) LOG.error('Snapshot %s was not found', snapshot['id'])
return return
self._conn.delete_snapshot(ebs_ss.id) self._conn.delete_snapshot(ebs_ss.id)
@ -217,7 +216,7 @@ class EBSDriver(BaseVD):
try: try:
ebs_ss = self._find(snapshot['id'], self._conn.get_all_snapshots) ebs_ss = self._find(snapshot['id'], self._conn.get_all_snapshots)
except NotFound: except NotFound:
LOG.error(_LE('Snapshot %s was not found'), snapshot['id']) LOG.error('Snapshot %s was not found', snapshot['id'])
raise raise
ebs_vol = ebs_ss.create_volume(self._zone) ebs_vol = ebs_ss.create_volume(self._zone)

View File

@ -14,13 +14,11 @@
from oslo_log import log as logging from oslo_log import log as logging
from cinder.i18n import _translators
from cinder.volume.driver import BaseVD from cinder.volume.driver import BaseVD
from cinder.volume.drivers.gce import gceconf from cinder.volume.drivers.gce import gceconf
from cinder.volume.drivers.gce import gceutils from cinder.volume.drivers.gce import gceutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_LI = _translators.log_info
class GceDriver(BaseVD): class GceDriver(BaseVD):
@ -35,9 +33,8 @@ class GceDriver(BaseVD):
def do_setup(self, context): def do_setup(self, context):
self.gce_svc = gceutils.get_gce_service(self.gce_svc_key) self.gce_svc = gceutils.get_gce_service(self.gce_svc_key)
self.set_initialized() self.set_initialized()
LOG.info( LOG.info("Gce volume driver init with %s project, %s zone",
_LI("Gce volume driver init with %s project, %s zone") % (self.gce_project, self.gce_zone))
(self.gce_project, self.gce_zone))
def _gce_volume_name(self, volume): def _gce_volume_name(self, volume):
return 'vol-' + volume.id return 'vol-' + volume.id

View File

@ -18,12 +18,11 @@ from googleapiclient.discovery import build
from oauth2client.client import GoogleCredentials from oauth2client.client import GoogleCredentials
from oslo_log import log as logging from oslo_log import log as logging
from cinder.i18n import _translators, _ from cinder.i18n import _
from oslo_service import loopingcall from oslo_service import loopingcall
from oslo_utils import reflection from oslo_utils import reflection
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_LI = _translators.log_info
class GceOperationError(Exception): class GceOperationError(Exception):
@ -83,8 +82,7 @@ def wait_for_operation(compute, project, operation, interval=1, timeout=60):
def watch_operation(name, request): def watch_operation(name, request):
result = request.execute() result = request.execute()
if result['status'] == 'DONE': if result['status'] == 'DONE':
LOG.info( LOG.info("Operation %s status is %s", (name, result['status']))
_LI("Operation %s status is %s") % (name, result['status']))
if 'error' in result: if 'error' in result:
raise GceOperationError(result['error']) raise GceOperationError(result['error'])
raise loopingcall.LoopingCallDone() raise loopingcall.LoopingCallDone()

View File

@ -22,7 +22,7 @@ from ConfigParser import ConfigParser
from glance_store import capabilities from glance_store import capabilities
from glance_store import exceptions from glance_store import exceptions
from glance_store.i18n import _, _LE from glance_store.i18n import _
import glance_store.driver import glance_store.driver
import glance_store.location import glance_store.location

View File

@ -22,7 +22,7 @@ from oslo_log import log as logging
from oslo_utils import reflection from oslo_utils import reflection
from neutron_lib import exceptions as e from neutron_lib import exceptions as e
from neutron._i18n import _LI, _ from neutron._i18n import _
from oslo_service import loopingcall from oslo_service import loopingcall
from six.moves import urllib from six.moves import urllib
@ -118,8 +118,7 @@ def wait_for_operation(compute, project, operation, interval=1, timeout=60):
def watch_operation(name, request): def watch_operation(name, request):
result = request.execute() result = request.execute()
if result['status'] == 'DONE': if result['status'] == 'DONE':
LOG.info( LOG.info("Operation %s status is %s", (name, result['status']))
_LI("Operation %s status is %s") % (name, result['status']))
if 'error' in result: if 'error' in result:
raise GceOperationError(result['error']) raise GceOperationError(result['error'])
raise loopingcall.LoopingCallDone() raise loopingcall.LoopingCallDone()
@ -330,9 +329,8 @@ def assign_floatingip(compute, project, zone, fixedip, floatingip):
raise GceResourceNotFound(name='Instance with fixed IP', raise GceResourceNotFound(name='Instance with fixed IP',
identifier=fixedip) identifier=fixedip)
LOG.info( LOG.info('Assigning floating ip %s to instance %s',
_LI('Assigning floating ip %s to instance %s') % (floatingip, (floatingip, instance_name))
instance_name))
operation = compute.instances().addAccessConfig( operation = compute.instances().addAccessConfig(
project=project, zone=zone, instance=instance_name, project=project, zone=zone, instance=instance_name,
@ -358,9 +356,8 @@ def release_floatingip(compute, project, zone, floatingip):
items = urllib.parse.urlparse(user).path.strip('/').split('/') items = urllib.parse.urlparse(user).path.strip('/').split('/')
if len(items) < 4 or items[-2] != 'instances': if len(items) < 4 or items[-2] != 'instances':
LOG.warning( LOG.warning('Unknown referrer %s to GCE static IP %s',
_LI('Unknown referrer %s to GCE static IP %s') % (user, (user, floatingip))
floatingip))
continue continue
instance, zone = items[-1], items[-3] instance, zone = items[-1], items[-3]
@ -368,9 +365,8 @@ def release_floatingip(compute, project, zone, floatingip):
for interface in instance_info['networkInterfaces']: for interface in instance_info['networkInterfaces']:
for accessconfig in interface.get('accessConfigs', []): for accessconfig in interface.get('accessConfigs', []):
if accessconfig.get('natIP') == floatingip: if accessconfig.get('natIP') == floatingip:
LOG.info( LOG.info('Releasing %s from instance %s',
_LI('Releasing %s from instance %s') % (floatingip, (floatingip, instance))
instance))
operation = compute.instances().deleteAccessConfig( operation = compute.instances().deleteAccessConfig(
project=project, zone=zone, instance=instance, project=project, zone=zone, instance=instance,
accessConfig=accessconfig['name'], accessConfig=accessconfig['name'],

View File

@ -17,7 +17,7 @@ import random
from oslo_log import log from oslo_log import log
import ipaddr import ipaddr
from neutron._i18n import _LI, _ from neutron._i18n import _
from neutron.callbacks import events from neutron.callbacks import events
from neutron.callbacks import registry from neutron.callbacks import registry
from neutron.callbacks import resources from neutron.callbacks import resources
@ -52,9 +52,8 @@ class GceMechanismDriver(api.MechanismDriver):
def initialize(self): def initialize(self):
self.gce_svc = gceutils.get_gce_service(self.gce_svc_key) self.gce_svc = gceutils.get_gce_service(self.gce_svc_key)
LOG.info( LOG.info("GCE Mechanism driver init with %s project, %s region",
_LI("GCE Mechanism driver init with %s project, %s region") % (self.gce_project, self.gce_region))
(self.gce_project, self.gce_region))
self._subscribe_events() self._subscribe_events()
def _subscribe_events(self): def _subscribe_events(self):
@ -89,7 +88,7 @@ class GceMechanismDriver(api.MechanismDriver):
name = self._gce_network_name(context) name = self._gce_network_name(context)
operation = gceutils.create_network(compute, project, name) operation = gceutils.create_network(compute, project, name)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info(_LI('Created network on GCE %s') % name) LOG.info('Created network on GCE %s', name)
def update_network_precommit(self, context): def update_network_precommit(self, context):
pass pass
@ -105,7 +104,7 @@ class GceMechanismDriver(api.MechanismDriver):
name = self._gce_network_name(context) name = self._gce_network_name(context)
operation = gceutils.delete_network(compute, project, name) operation = gceutils.delete_network(compute, project, name)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info(_LI('Deleted network on GCE %s') % name) LOG.info('Deleted network on GCE %s', name)
def create_subnet_precommit(self, context): def create_subnet_precommit(self, context):
pass pass
@ -121,8 +120,7 @@ class GceMechanismDriver(api.MechanismDriver):
operation = gceutils.create_subnet(compute, project, region, name, operation = gceutils.create_subnet(compute, project, region, name,
cidr, network_link) cidr, network_link)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info( LOG.info("Created subnet %s in region %s on GCE", (name, region))
_LI("Created subnet %s in region %s on GCE") % (name, region))
def update_subnet_precommit(self, context): def update_subnet_precommit(self, context):
pass pass
@ -140,8 +138,7 @@ class GceMechanismDriver(api.MechanismDriver):
name = self._gce_subnet_name(context) name = self._gce_subnet_name(context)
operation = gceutils.delete_subnet(compute, project, region, name) operation = gceutils.delete_subnet(compute, project, region, name)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info( LOG.info("Deleted subnet %s in region %s on GCE",(name, region))
_LI("Deleted subnet %s in region %s on GCE") % (name, region))
def _gce_secgrp_id(self, openstack_id): def _gce_secgrp_id(self, openstack_id):
return "secgrp-" + openstack_id return "secgrp-" + openstack_id
@ -207,7 +204,7 @@ class GceMechanismDriver(api.MechanismDriver):
LOG.exception( LOG.exception(
"An error occured while creating security group: %s" % e) "An error occured while creating security group: %s" % e)
return return
LOG.info(_LI("Create GCE firewall rule %s") % gce_rule) LOG.info("Create GCE firewall rule %s", gce_rule)
operation = gceutils.create_firewall_rule(compute, project, gce_rule) operation = gceutils.create_firewall_rule(compute, project, gce_rule)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
@ -229,14 +226,14 @@ class GceMechanismDriver(api.MechanismDriver):
network_link = gce_firewall_info['network'] network_link = gce_firewall_info['network']
try: try:
gce_rule = self._convert_secgrp_rule_to_gce(rule, network_link) gce_rule = self._convert_secgrp_rule_to_gce(rule, network_link)
LOG.info(_LI("Update GCE firewall rule %s") % name) LOG.info("Update GCE firewall rule %s", name)
operation = gceutils.update_firewall_rule(compute, project, name, operation = gceutils.update_firewall_rule(compute, project, name,
gce_rule) gce_rule)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
except Exception as e: except Exception as e:
LOG.exception( LOG.exception("An error occurred while updating security "
_LI("An error occured while updating security group: %s") % e) "group: %s", e)
LOG.error(_LI("Deleting existing GCE firewall rule %s") % name) LOG.error("Deleting existing GCE firewall rule %s", name)
operation = gceutils.delete_firewall_rule(compute, project, name) operation = gceutils.delete_firewall_rule(compute, project, name)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
@ -244,9 +241,8 @@ class GceMechanismDriver(api.MechanismDriver):
name = self._gce_secgrp_id(rule_id) name = self._gce_secgrp_id(rule_id)
compute, project = self.gce_svc, self.gce_project compute, project = self.gce_svc, self.gce_project
try: try:
LOG.warn( LOG.warn("Delete existing GCE firewall rule %s,"
_LI("Delete existing GCE firewall rule %s," "as firewall rule update not GCE compatible.", name)
"as firewall rule update not GCE compatible.") % name)
operation = gceutils.delete_firewall_rule(compute, project, name) operation = gceutils.delete_firewall_rule(compute, project, name)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
except gceutils.HttpError: except gceutils.HttpError:
@ -325,5 +321,4 @@ class GceMechanismDriver(api.MechanismDriver):
if security_group_id: if security_group_id:
self._delete_secgrp(context, security_group_id) self._delete_secgrp(context, security_group_id)
else: else:
LOG.warn( LOG.warn("Security group ID not found in delete request")
_LI("Security group ID not found in delete request"))

View File

@ -26,7 +26,6 @@ from neutron.extensions import multiprovidernet as mpnet
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.extensions import providernet as provider from neutron.extensions import providernet as provider
from neutron.extensions import vlantransparent from neutron.extensions import vlantransparent
from neutron.i18n import _LE, _LI, _LW
from neutron.plugins.ml2.common import exceptions as ml2_exc from neutron.plugins.ml2.common import exceptions as ml2_exc
from neutron.plugins.ml2 import db from neutron.plugins.ml2 import db
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api
@ -46,12 +45,12 @@ class TypeManager(stevedore.named.NamedExtensionManager):
# Mapping from type name to DriverManager # Mapping from type name to DriverManager
self.drivers = {} self.drivers = {}
LOG.info(_LI("Configured type driver names: %s"), LOG.info("Configured type driver names: %s",
cfg.CONF.ml2.type_drivers) cfg.CONF.ml2.type_drivers)
super(TypeManager, self).__init__('neutron.ml2.type_drivers', super(TypeManager, self).__init__('neutron.ml2.type_drivers',
cfg.CONF.ml2.type_drivers, cfg.CONF.ml2.type_drivers,
invoke_on_load=True) invoke_on_load=True)
LOG.info(_LI("Loaded type driver names: %s"), self.names()) LOG.info("Loaded type driver names: %s", self.names())
self._register_types() self._register_types()
self._check_tenant_network_types(cfg.CONF.ml2.tenant_network_types) self._check_tenant_network_types(cfg.CONF.ml2.tenant_network_types)
self._check_external_network_type(cfg.CONF.ml2.external_network_type) self._check_external_network_type(cfg.CONF.ml2.external_network_type)
@ -60,15 +59,15 @@ class TypeManager(stevedore.named.NamedExtensionManager):
for ext in self: for ext in self:
network_type = ext.obj.get_type() network_type = ext.obj.get_type()
if network_type in self.drivers: if network_type in self.drivers:
LOG.error(_LE("Type driver '%(new_driver)s' ignored because" LOG.error("Type driver '%(new_driver)s' ignored because"
" type driver '%(old_driver)s' is already" " type driver '%(old_driver)s' is already"
" registered for type '%(type)s'"), " registered for type '%(type)s'",
{'new_driver': ext.name, {'new_driver': ext.name,
'old_driver': self.drivers[network_type].name, 'old_driver': self.drivers[network_type].name,
'type': network_type}) 'type': network_type})
else: else:
self.drivers[network_type] = ext self.drivers[network_type] = ext
LOG.info(_LI("Registered types: %s"), self.drivers.keys()) LOG.info("Registered types: %s", self.drivers.keys())
def _check_tenant_network_types(self, types): def _check_tenant_network_types(self, types):
self.tenant_network_types = [] self.tenant_network_types = []
@ -76,15 +75,15 @@ class TypeManager(stevedore.named.NamedExtensionManager):
if network_type in self.drivers: if network_type in self.drivers:
self.tenant_network_types.append(network_type) self.tenant_network_types.append(network_type)
else: else:
LOG.error(_LE("No type driver for tenant network_type: %s. " LOG.error("No type driver for tenant network_type: %s. "
"Service terminated!"), network_type) "Service terminated!", network_type)
raise SystemExit(1) raise SystemExit(1)
LOG.info(_LI("Tenant network_types: %s"), self.tenant_network_types) LOG.info("Tenant network_types: %s", self.tenant_network_types)
def _check_external_network_type(self, ext_network_type): def _check_external_network_type(self, ext_network_type):
if ext_network_type and ext_network_type not in self.drivers: if ext_network_type and ext_network_type not in self.drivers:
LOG.error(_LE("No type driver for external network_type: %s. " LOG.error("No type driver for external network_type: %s. "
"Service terminated!"), ext_network_type) "Service terminated!", ext_network_type)
raise SystemExit(1) raise SystemExit(1)
def _process_provider_segment(self, segment): def _process_provider_segment(self, segment):
@ -179,7 +178,7 @@ class TypeManager(stevedore.named.NamedExtensionManager):
def initialize(self): def initialize(self):
for network_type, driver in six.iteritems(self.drivers): for network_type, driver in six.iteritems(self.drivers):
LOG.info(_LI("Initializing driver for type '%s'"), network_type) LOG.info("Initializing driver for type '%s'", network_type)
driver.obj.initialize() driver.obj.initialize()
def _add_network_segment(self, session, network_id, segment, mtu, def _add_network_segment(self, session, network_id, segment, mtu,
@ -261,8 +260,8 @@ class TypeManager(stevedore.named.NamedExtensionManager):
if driver: if driver:
driver.obj.release_segment(session, segment) driver.obj.release_segment(session, segment)
else: else:
LOG.error(_LE("Failed to release segment '%s' because " LOG.error("Failed to release segment '%s' because "
"network type is not supported."), segment) "network type is not supported.", segment)
def allocate_dynamic_segment(self, session, network_id, segment): def allocate_dynamic_segment(self, session, network_id, segment):
"""Allocate a dynamic segment using a partial or full segment dict.""" """Allocate a dynamic segment using a partial or full segment dict."""
@ -288,8 +287,8 @@ class TypeManager(stevedore.named.NamedExtensionManager):
driver.obj.release_segment(session, segment) driver.obj.release_segment(session, segment)
db.delete_network_segment(session, segment_id) db.delete_network_segment(session, segment_id)
else: else:
LOG.error(_LE("Failed to release segment '%s' because " LOG.error("Failed to release segment '%s' because "
"network type is not supported."), segment) "network type is not supported.", segment)
else: else:
LOG.debug("No segment found with id %(segment_id)s", segment_id) LOG.debug("No segment found with id %(segment_id)s", segment_id)
@ -304,13 +303,13 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
# the order in which the drivers are called. # the order in which the drivers are called.
self.ordered_mech_drivers = [] self.ordered_mech_drivers = []
LOG.info(_LI("Configured mechanism driver names: %s"), LOG.info("Configured mechanism driver names: %s",
cfg.CONF.ml2.mechanism_drivers) cfg.CONF.ml2.mechanism_drivers)
super(MechanismManager, self).__init__('neutron.ml2.mechanism_drivers', super(MechanismManager, self).__init__('neutron.ml2.mechanism_drivers',
cfg.CONF.ml2.mechanism_drivers, cfg.CONF.ml2.mechanism_drivers,
invoke_on_load=True, invoke_on_load=True,
name_order=True) name_order=True)
LOG.info(_LI("Loaded mechanism driver names: %s"), self.names()) LOG.info("Loaded mechanism driver names: %s", self.names())
self._register_mechanisms() self._register_mechanisms()
def _register_mechanisms(self): def _register_mechanisms(self):
@ -322,7 +321,7 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
for ext in self: for ext in self:
self.mech_drivers[ext.name] = ext self.mech_drivers[ext.name] = ext
self.ordered_mech_drivers.append(ext) self.ordered_mech_drivers.append(ext)
LOG.info(_LI("Registered mechanism drivers: %s"), LOG.info("Registered mechanism drivers: %s",
[driver.name for driver in self.ordered_mech_drivers]) [driver.name for driver in self.ordered_mech_drivers])
@property @property
@ -344,19 +343,17 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
rule_types & set(driver_obj.supported_qos_rule_types) rule_types & set(driver_obj.supported_qos_rule_types)
dropped_rule_types = new_rule_types - rule_types dropped_rule_types = new_rule_types - rule_types
if dropped_rule_types: if dropped_rule_types:
LOG.info( LOG.info("%(rule_types)s rule types disabled for ml2 "
_LI("%(rule_types)s rule types disabled for ml2 " "because %(driver)s does not support them",
"because %(driver)s does not support them"), {'rule_types': ', '.join(dropped_rule_types),
{'rule_types': ', '.join(dropped_rule_types), 'driver': driver.name})
'driver': driver.name})
rule_types = new_rule_types rule_types = new_rule_types
else: else:
# at least one of drivers does not support QoS, meaning # at least one of drivers does not support QoS, meaning
# there are no rule types supported by all of them # there are no rule types supported by all of them
LOG.warn( LOG.warn("%s does not support QoS; "
_LW("%s does not support QoS; " "no rule types available",
"no rule types available"), driver.name)
driver.name)
return [] return []
if binding_driver_found: if binding_driver_found:
@ -369,7 +366,7 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
def initialize(self): def initialize(self):
for driver in self.ordered_mech_drivers: for driver in self.ordered_mech_drivers:
LOG.info(_LI("Initializing mechanism driver '%s'"), driver.name) LOG.info("Initializing mechanism driver '%s'", driver.name)
driver.obj.initialize() driver.obj.initialize()
def _check_vlan_transparency(self, context): def _check_vlan_transparency(self, context):
@ -404,17 +401,15 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
try: try:
getattr(driver.obj, method_name)(context) getattr(driver.obj, method_name)(context)
except exceptions.AwsException as aws_exception: except exceptions.AwsException as aws_exception:
LOG.exception( LOG.exception("Mechanism driver '%(name)s' failed in"
_LE("Mechanism driver '%(name)s' failed in %(method)s"), " %(method)s",
{'name': driver.name, 'method': method_name} {'name': driver.name, 'method': method_name})
)
if not continue_on_failure: if not continue_on_failure:
raise aws_exception raise aws_exception
except Exception: except Exception:
LOG.exception( LOG.exception("Mechanism driver '%(name)s' failed in "
_LE("Mechanism driver '%(name)s' failed in %(method)s"), "%(method)s",
{'name': driver.name, 'method': method_name} {'name': driver.name, 'method': method_name})
)
error = True error = True
if not continue_on_failure: if not continue_on_failure:
break break
@ -698,7 +693,7 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
if not self._bind_port_level(context, 0, if not self._bind_port_level(context, 0,
context.network.network_segments): context.network.network_segments):
binding.vif_type = portbindings.VIF_TYPE_BINDING_FAILED binding.vif_type = portbindings.VIF_TYPE_BINDING_FAILED
LOG.error(_LE("Failed to bind port %(port)s on host %(host)s"), LOG.error("Failed to bind port %(port)s on host %(host)s",
{'port': context.current['id'], {'port': context.current['id'],
'host': context.host}) 'host': context.host})
@ -713,8 +708,8 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
'segments': segments_to_bind}) 'segments': segments_to_bind})
if level == MAX_BINDING_LEVELS: if level == MAX_BINDING_LEVELS:
LOG.error(_LE("Exceeded maximum binding levels attempting to bind " LOG.error("Exceeded maximum binding levels attempting to bind "
"port %(port)s on host %(host)s"), "port %(port)s on host %(host)s",
{'port': context.current['id'], {'port': context.current['id'],
'host': context.host}) 'host': context.host})
return False return False
@ -756,10 +751,9 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
'binding_levels': context.binding_levels}) 'binding_levels': context.binding_levels})
return True return True
except Exception: except Exception:
LOG.exception(_LE("Mechanism driver %s failed in " LOG.exception("Mechanism driver %s failed in bind_port",
"bind_port"),
driver.name) driver.name)
LOG.error(_LE("Failed to bind port %(port)s on host %(host)s"), LOG.error("Failed to bind port %(port)s on host %(host)s",
{'port': context.current['id'], {'port': context.current['id'],
'host': binding.host}) 'host': binding.host})
@ -790,13 +784,13 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
# the order in which the drivers are called. # the order in which the drivers are called.
self.ordered_ext_drivers = [] self.ordered_ext_drivers = []
LOG.info(_LI("Configured extension driver names: %s"), LOG.info("Configured extension driver names: %s",
cfg.CONF.ml2.extension_drivers) cfg.CONF.ml2.extension_drivers)
super(ExtensionManager, self).__init__('neutron.ml2.extension_drivers', super(ExtensionManager, self).__init__('neutron.ml2.extension_drivers',
cfg.CONF.ml2.extension_drivers, cfg.CONF.ml2.extension_drivers,
invoke_on_load=True, invoke_on_load=True,
name_order=True) name_order=True)
LOG.info(_LI("Loaded extension driver names: %s"), self.names()) LOG.info("Loaded extension driver names: %s", self.names())
self._register_drivers() self._register_drivers()
def _register_drivers(self): def _register_drivers(self):
@ -807,13 +801,13 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
""" """
for ext in self: for ext in self:
self.ordered_ext_drivers.append(ext) self.ordered_ext_drivers.append(ext)
LOG.info(_LI("Registered extension drivers: %s"), LOG.info("Registered extension drivers: %s",
[driver.name for driver in self.ordered_ext_drivers]) [driver.name for driver in self.ordered_ext_drivers])
def initialize(self): def initialize(self):
# Initialize each driver in the list. # Initialize each driver in the list.
for driver in self.ordered_ext_drivers: for driver in self.ordered_ext_drivers:
LOG.info(_LI("Initializing extension driver '%s'"), driver.name) LOG.info("Initializing extension driver '%s'", driver.name)
driver.obj.initialize() driver.obj.initialize()
def extension_aliases(self): def extension_aliases(self):
@ -822,7 +816,7 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
alias = driver.obj.extension_alias alias = driver.obj.extension_alias
if alias: if alias:
exts.append(alias) exts.append(alias)
LOG.info(_LI("Got %(alias)s extension from driver '%(drv)s'"), LOG.info("Got %(alias)s extension from driver '%(drv)s'",
{'alias': alias, 'drv': driver.name}) {'alias': alias, 'drv': driver.name})
return exts return exts
@ -833,8 +827,8 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
getattr(driver.obj, method_name)(plugin_context, data, result) getattr(driver.obj, method_name)(plugin_context, data, result)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.info(_LI("Extension driver '%(name)s' failed in " LOG.info("Extension driver '%(name)s' failed in "
"%(method)s"), "%(method)s",
{'name': driver.name, 'method': method_name}) {'name': driver.name, 'method': method_name})
def process_create_network(self, plugin_context, data, result): def process_create_network(self, plugin_context, data, result):
@ -872,8 +866,8 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
try: try:
getattr(driver.obj, method_name)(session, base_model, result) getattr(driver.obj, method_name)(session, base_model, result)
except Exception: except Exception:
LOG.error(_LE("Extension driver '%(name)s' failed in " LOG.error("Extension driver '%(name)s' failed in "
"%(method)s"), "%(method)s",
{'name': driver.name, 'method': method_name}) {'name': driver.name, 'method': method_name})
raise ml2_exc.ExtensionDriverError(driver=driver.name) raise ml2_exc.ExtensionDriverError(driver=driver.name)

View File

@ -24,7 +24,6 @@ from neutron.db import l3_dvrscheduler_db
from neutron.db import l3_gwmode_db from neutron.db import l3_gwmode_db
from neutron.db import l3_hamode_db from neutron.db import l3_hamode_db
from neutron.db import l3_hascheduler_db from neutron.db import l3_hascheduler_db
from neutron._i18n import _LI
from neutron.plugins.common import constants from neutron.plugins.common import constants
from neutron.quota import resource_registry from neutron.quota import resource_registry
from neutron.services import service_base from neutron.services import service_base
@ -62,23 +61,22 @@ class GceRouterPlugin(
self.gce_project = gceconf.project_id self.gce_project = gceconf.project_id
self.gce_svc_key = gceconf.service_key_path self.gce_svc_key = gceconf.service_key_path
self.gce_svc = gceutils.get_gce_service(self.gce_svc_key) self.gce_svc = gceutils.get_gce_service(self.gce_svc_key)
LOG.info( LOG.info("GCE Router plugin init with %s project, %s region",
_LI("GCE Router plugin init with %s project, %s region") % (self.gce_project, self.gce_region))
(self.gce_project, self.gce_region))
def get_plugin_type(self): def get_plugin_type(self):
return constants.L3_ROUTER_NAT return constants.L3_ROUTER_NAT
def get_plugin_description(self): def get_plugin_description(self):
"""returns string description of the plugin.""" """returns string description of the plugin."""
return _LI("GCE L3 Router Service Plugin for basic L3 forwarding" return ("GCE L3 Router Service Plugin for basic L3 forwarding"
" between (L2) Neutron networks and access to external" " between (L2) Neutron networks and access to external"
" networks via a NAT gateway.") " networks via a NAT gateway.")
def _cleanup_floatingip(self, compute, project, region, floatingip): def _cleanup_floatingip(self, compute, project, region, floatingip):
gceutils.release_floatingip(compute, project, region, floatingip) gceutils.release_floatingip(compute, project, region, floatingip)
gceutils.delete_floatingip(compute, project, region, floatingip) gceutils.delete_floatingip(compute, project, region, floatingip)
LOG.info(_LI('Released GCE static IP %s') % floatingip) LOG.info('Released GCE static IP %s', floatingip)
def create_floatingip(self, context, floatingip): def create_floatingip(self, context, floatingip):
compute, project, region = self.gce_svc, self.gce_project, self.gce_region compute, project, region = self.gce_svc, self.gce_project, self.gce_region
@ -87,7 +85,7 @@ class GceRouterPlugin(
try: try:
public_ip_allocated = gceutils.allocate_floatingip( public_ip_allocated = gceutils.allocate_floatingip(
compute, project, region) compute, project, region)
LOG.info(_LI("Created GCE static IP %s") % public_ip_allocated) LOG.info("Created GCE static IP %s", public_ip_allocated)
floatingip_dict = floatingip['floatingip'] floatingip_dict = floatingip['floatingip']
@ -98,7 +96,7 @@ class GceRouterPlugin(
self._associate_floatingip_to_port( self._associate_floatingip_to_port(
context, public_ip_allocated, port_id) context, public_ip_allocated, port_id)
except Exception as e: except Exception as e:
LOG.exception(_LI("Error in Creation/Allocating floating IP")) LOG.exception("Error in Creation/Allocating floating IP")
if public_ip_allocated: if public_ip_allocated:
self._cleanup_floatingip(compute, project, region, self._cleanup_floatingip(compute, project, region,
public_ip_allocated) public_ip_allocated)
@ -109,7 +107,7 @@ class GceRouterPlugin(
context, floatingip, context, floatingip,
initial_status=n_const.FLOATINGIP_STATUS_DOWN) initial_status=n_const.FLOATINGIP_STATUS_DOWN)
except Exception as e: except Exception as e:
LOG.exception(_LI("Error in adding floating IP")) LOG.exception("Error in adding floating IP")
if public_ip_allocated: if public_ip_allocated:
self._cleanup_floatingip(compute, project, region, self._cleanup_floatingip(compute, project, region,
public_ip_allocated) public_ip_allocated)
@ -127,9 +125,8 @@ class GceRouterPlugin(
fixed_ip_address = fixed_ip['ip_address'] fixed_ip_address = fixed_ip['ip_address']
if fixed_ip_address: if fixed_ip_address:
LOG.info( LOG.info('Found fixed ip %s for port %s',
_LI('Found fixed ip %s for port %s') % (fixed_ip_address, (fixed_ip_address, port_id))
port_id))
gceutils.assign_floatingip(compute, project, zone, gceutils.assign_floatingip(compute, project, zone,
fixed_ip_address, floating_ip_address) fixed_ip_address, floating_ip_address)
else: else:
@ -160,27 +157,25 @@ class GceRouterPlugin(
return super(GceRouterPlugin, self).delete_floatingip(context, id) return super(GceRouterPlugin, self).delete_floatingip(context, id)
def create_router(self, context, router): def create_router(self, context, router):
LOG.info(_LI("Creating router %s") % router['router']['name']) LOG.info("Creating router %s", router['router']['name'])
return super(GceRouterPlugin, self).create_router(context, router) return super(GceRouterPlugin, self).create_router(context, router)
def delete_router(self, context, id): def delete_router(self, context, id):
LOG.info(_LI("Deleting router %s") % id) LOG.info("Deleting router %s", id)
return super(GceRouterPlugin, self).delete_router(context, id) return super(GceRouterPlugin, self).delete_router(context, id)
def update_router(self, context, id, router): def update_router(self, context, id, router):
LOG.info(_LI("Updating router %s") % id) LOG.info("Updating router %s", id)
return super(GceRouterPlugin, self).update_router(context, id, router) return super(GceRouterPlugin, self).update_router(context, id, router)
def add_router_interface(self, context, router_id, interface_info): def add_router_interface(self, context, router_id, interface_info):
LOG.info( LOG.info("Adding interface %s to router %s",
_LI("Adding interface %s to router %s") % (interface_info, (interface_info, router_id))
router_id))
return super(GceRouterPlugin, self).add_router_interface( return super(GceRouterPlugin, self).add_router_interface(
context, router_id, interface_info) context, router_id, interface_info)
def remove_router_interface(self, context, router_id, interface_info): def remove_router_interface(self, context, router_id, interface_info):
LOG.info( LOG.info("Deleting interface %s from router %s",
_LI("Deleting interface %s from router %s") % (interface_info, (interface_info, router_id))
router_id))
return super(GceRouterPlugin, self).remove_router_interface( return super(GceRouterPlugin, self).remove_router_interface(
context, router_id, interface_info) context, router_id, interface_info)

View File

@ -20,7 +20,6 @@ import time
import nova.conf import nova.conf
from nova import exception from nova import exception
from nova.image import glance from nova.image import glance
from nova.i18n import _LI
from nova.virt import driver, hardware from nova.virt import driver, hardware
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
@ -119,9 +118,8 @@ class GCEDriver(driver.ComputeDriver):
self.gce_svc = gceutils.get_gce_service(self.gce_svc_key) self.gce_svc = gceutils.get_gce_service(self.gce_svc_key)
self.gce_flavor_info = gceutils.get_machines_info( self.gce_flavor_info = gceutils.get_machines_info(
self.gce_svc, self.gce_project, self.gce_zone) self.gce_svc, self.gce_project, self.gce_zone)
LOG.info( LOG.info("GCE driver init with %s project, %s region",
_LI("GCE driver init with %s project, %s region") % (self.gce_project, self.gce_zone))
(self.gce_project, self.gce_zone))
if '_GCE_NODES' not in globals(): if '_GCE_NODES' not in globals():
set_nodes([CONF.host]) set_nodes([CONF.host])
@ -233,9 +231,8 @@ class GCEDriver(driver.ComputeDriver):
# GCE expects instance name in format "[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?" # GCE expects instance name in format "[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?"
# So we need to construct it for GCE from uuid # So we need to construct it for GCE from uuid
gce_instance_name = 'inst-' + instance.uuid gce_instance_name = 'inst-' + instance.uuid
LOG.info( LOG.info("Creating instance %s as %s on GCE.",
_LI("Creating instance %s as %s on GCE.") % (instance.display_name, (instance.display_name, gce_instance_name))
gce_instance_name))
# Image Info # Image Info
image_link = instance.system_metadata['image_gce_link'] image_link = instance.system_metadata['image_gce_link']
# Flavor Info # Flavor Info
@ -294,7 +291,7 @@ class GCEDriver(driver.ComputeDriver):
try: try:
gce_id = self._get_gce_id_from_instance(instance) gce_id = self._get_gce_id_from_instance(instance)
LOG.info(_LI("Taking snapshot of instance %s") % instance.uuid) LOG.info("Taking snapshot of instance %s", instance.uuid)
try: try:
boot_disk = gceutils.get_instance_boot_disk( boot_disk = gceutils.get_instance_boot_disk(
compute, project, zone, gce_id) compute, project, zone, gce_id)
@ -302,29 +299,26 @@ class GCEDriver(driver.ComputeDriver):
reason = "Unable to find boot disk from instance metadata %s" % instance.uuid reason = "Unable to find boot disk from instance metadata %s" % instance.uuid
raise exception.InvalidMetadata(reason=reason) raise exception.InvalidMetadata(reason=reason)
disk_name = boot_disk['name'] disk_name = boot_disk['name']
LOG.debug( LOG.debug("1. Found boot disk %s for instance %s",
_LI("1. Found boot disk %s for instance %s") % (disk_name, (disk_name, instance.uuid))
instance.uuid))
operation = gceutils.stop_instance(compute, project, zone, gce_id) operation = gceutils.stop_instance(compute, project, zone, gce_id)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
instance_stopped = True instance_stopped = True
LOG.debug( LOG.debug("2. Temporarily stopped instance %s", instance.uuid)
_LI("2. Temporarily stopped instance %s") % instance.uuid)
snapshot_name = 'nsnap-' + disk_name + time.strftime("%s") snapshot_name = 'nsnap-' + disk_name + time.strftime("%s")
operation = gceutils.snapshot_disk( operation = gceutils.snapshot_disk(
compute, project, zone, boot_disk['name'], snapshot_name) compute, project, zone, boot_disk['name'], snapshot_name)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
temp_disk_snapshot = True temp_disk_snapshot = True
LOG.debug(_LI("3. Created boot disk snapshot %s") % snapshot_name) LOG.debug("3. Created boot disk snapshot %s", snapshot_name)
operation = gceutils.start_instance(compute, project, zone, gce_id) operation = gceutils.start_instance(compute, project, zone, gce_id)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
instance_stopped = False instance_stopped = False
LOG.debug( LOG.debug("4. Restart instance after disk snapshot %s",
_LI("4. Restart instance after disk snapshot %s") % instance.uuid)
instance.uuid)
snapshot_disk_name = 'vol-' + snapshot_name snapshot_disk_name = 'vol-' + snapshot_name
operation = gceutils.create_disk_from_snapshot( operation = gceutils.create_disk_from_snapshot(
@ -333,9 +327,8 @@ class GCEDriver(driver.ComputeDriver):
snapshot_disk_info = gceutils.get_disk(compute, project, zone, snapshot_disk_info = gceutils.get_disk(compute, project, zone,
snapshot_disk_name) snapshot_disk_name)
temp_disk_from_snapshot = True temp_disk_from_snapshot = True
LOG.debug( LOG.debug("5. Created disk %s from snapshot %s",
_LI("5. Created disk %s from snapshot %s") % (snapshot_disk_name, snapshot_name))
(snapshot_disk_name, snapshot_name))
update_task_state(task_state=task_states.IMAGE_PENDING_UPLOAD) update_task_state(task_state=task_states.IMAGE_PENDING_UPLOAD)
image_api = glance.get_default_image_service() image_api = glance.get_default_image_service()
@ -346,12 +339,10 @@ class GCEDriver(driver.ComputeDriver):
gceutils.wait_for_operation(compute, project, operation, gceutils.wait_for_operation(compute, project, operation,
timeout=120) timeout=120)
image_created = True image_created = True
LOG.debug( LOG.debug("6. Created image %s from disk %s",
_LI("6. Created image %s from disk %s") % (name, (name, snapshot_disk_name))
snapshot_disk_name)) LOG.info("Created GCE image %s from instance %s",
LOG.info( (name, instance.uuid))
_LI("Created GCE image %s from instance %s") % (name,
instance.uuid))
update_task_state(task_state=task_states.IMAGE_UPLOADING, update_task_state(task_state=task_states.IMAGE_UPLOADING,
expected_state=task_states.IMAGE_PENDING_UPLOAD) expected_state=task_states.IMAGE_PENDING_UPLOAD)
@ -373,7 +364,7 @@ class GCEDriver(driver.ComputeDriver):
}, },
} }
image_api.update(context, image_id, image_metadata) image_api.update(context, image_id, image_metadata)
LOG.debug(_LI("7. Added image to glance %s") % name) LOG.debug("7. Added image to glance %s", name)
disk_operation = gceutils.delete_disk(compute, project, zone, disk_operation = gceutils.delete_disk(compute, project, zone,
snapshot_disk_name) snapshot_disk_name)
@ -381,13 +372,12 @@ class GCEDriver(driver.ComputeDriver):
snapshot_name) snapshot_name)
gceutils.wait_for_operation(compute, project, disk_operation) gceutils.wait_for_operation(compute, project, disk_operation)
temp_disk_from_snapshot = False temp_disk_from_snapshot = False
LOG.debug(_LI("8. Delete temporary disk %s") % snapshot_disk_name) LOG.debug("8. Delete temporary disk %s", snapshot_disk_name)
gceutils.wait_for_operation(compute, project, snap_operation) gceutils.wait_for_operation(compute, project, snap_operation)
temp_disk_snapshot = False temp_disk_snapshot = False
LOG.debug( LOG.debug("9. Delete temporary disk snapshot %s", snapshot_name)
_LI("9. Delete temporary disk snapshot %s") % snapshot_name) LOG.info("Completed snapshot for instance %s", instance.uuid)
LOG.info(_LI("Completed snapshot for instance %s") % instance.uuid)
except Exception as e: except Exception as e:
LOG.exception("An error occured during image creation: %s" % e) LOG.exception("An error occured during image creation: %s" % e)
@ -395,29 +385,25 @@ class GCEDriver(driver.ComputeDriver):
operation = gceutils.start_instance(compute, project, zone, operation = gceutils.start_instance(compute, project, zone,
gce_id) gce_id)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.debug( LOG.debug("Restart instance after disk snapshot %s",
_LI("Restart instance after disk snapshot %s") % instance.uuid)
instance.uuid)
if image_created: if image_created:
LOG.info( LOG.info("Rollback snapshot for instance %s, deleting image "
_LI("Rollback snapshot for instance %s, deleting image %s from GCE" "%s from GCE", (instance.uuid, name))
) % (instance.uuid, name))
operation = gceutils.delete_image(compute, project, name) operation = gceutils.delete_image(compute, project, name)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
if temp_disk_from_snapshot: if temp_disk_from_snapshot:
disk_operation = gceutils.delete_disk(compute, project, zone, disk_operation = gceutils.delete_disk(compute, project, zone,
snapshot_disk_name) snapshot_disk_name)
gceutils.wait_for_operation(compute, project, disk_operation) gceutils.wait_for_operation(compute, project, disk_operation)
LOG.debug( LOG.debug("Rollback snapshot for instace %s, delete temporary"
_LI("Rollback snapshot for instace %s, delete temporary disk %s" " disk %s", (instance.uuid, snapshot_disk_name))
) % (instance.uuid, snapshot_disk_name))
if temp_disk_snapshot: if temp_disk_snapshot:
snap_operation = gceutils.delete_snapshot( snap_operation = gceutils.delete_snapshot(
compute, project, snapshot_name) compute, project, snapshot_name)
gceutils.wait_for_operation(compute, project, snap_operation) gceutils.wait_for_operation(compute, project, snap_operation)
LOG.debug( LOG.debug("Rollback snapshot for instance %s, delete temporary"
_LI("Rollback snapshot for instance %s, delete temporary disk snapshot %s" " disk snapshot %s", (instance.uuid, snapshot_name))
) % (instance.uuid, snapshot_name))
raise e raise e
def reboot(self, context, instance, network_info, reboot_type, def reboot(self, context, instance, network_info, reboot_type,
@ -449,22 +435,22 @@ class GCEDriver(driver.ComputeDriver):
block_device_info=None): block_device_info=None):
compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone
gce_id = self._get_gce_id_from_instance(instance) gce_id = self._get_gce_id_from_instance(instance)
LOG.info(_LI('Stopping instance %s') % instance.uuid) LOG.info('Stopping instance %s', instance.uuid)
operation = gceutils.stop_instance(compute, project, zone, gce_id) operation = gceutils.stop_instance(compute, project, zone, gce_id)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info(_LI('Starting instance %s') % instance.uuid) LOG.info('Starting instance %s', instance.uuid)
operation = gceutils.start_instance(compute, project, zone, gce_id) operation = gceutils.start_instance(compute, project, zone, gce_id)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info(_LI('Soft Reboot Complete for instance %s') % instance.uuid) LOG.info('Soft Reboot Complete for instance %s', instance.uuid)
def _hard_reboot(self, context, instance, network_info, def _hard_reboot(self, context, instance, network_info,
block_device_info=None): block_device_info=None):
compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone
gce_id = self._get_gce_id_from_instance(instance) gce_id = self._get_gce_id_from_instance(instance)
LOG.info(_LI('Resetting instance %s') % instance.uuid) LOG.info('Resetting instance %s', instance.uuid)
operation = gceutils.reset_instance(compute, project, zone, gce_id) operation = gceutils.reset_instance(compute, project, zone, gce_id)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info(_LI('Hard Reboot Complete %s') % instance.uuid) LOG.info('Hard Reboot Complete %s', instance.uuid)
@staticmethod @staticmethod
def get_host_ip_addr(): def get_host_ip_addr():
@ -516,23 +502,23 @@ class GCEDriver(driver.ComputeDriver):
""" """
compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone
gce_id = self._get_gce_id_from_instance(instance) gce_id = self._get_gce_id_from_instance(instance)
LOG.info(_LI('Stopping instance %s') % instance.uuid) LOG.info('Stopping instance %s', instance.uuid)
operation = gceutils.stop_instance(compute, project, zone, gce_id) operation = gceutils.stop_instance(compute, project, zone, gce_id)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info(_LI('Power off complete %s') % instance.uuid) LOG.info('Power off complete %s', instance.uuid)
def power_on(self, context, instance, network_info, block_device_info): def power_on(self, context, instance, network_info, block_device_info):
"""Power on the specified instance.""" """Power on the specified instance."""
compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone
gce_id = self._get_gce_id_from_instance(instance) gce_id = self._get_gce_id_from_instance(instance)
LOG.info(_LI('Starting instance %s') % instance.uuid) LOG.info('Starting instance %s', instance.uuid)
operation = gceutils.start_instance(compute, project, zone, gce_id) operation = gceutils.start_instance(compute, project, zone, gce_id)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info(_LI("Power on Complete %s") % instance.uuid) LOG.info("Power on Complete %s", instance.uuid)
def soft_delete(self, instance): def soft_delete(self, instance):
"""Deleting the specified instance""" """Deleting the specified instance"""
LOG.info(_LI("Soft delete instance %s") % instance.uuid) LOG.info("Soft delete instance %s", instance.uuid)
self.destroy(instance) self.destroy(instance)
def restore(self, instance): def restore(self, instance):
@ -545,7 +531,7 @@ class GCEDriver(driver.ComputeDriver):
instance. instance.
:param instance: nova.objects.instance.Instance :param instance: nova.objects.instance.Instance
""" """
LOG.info(_LI("Pause instance %s") % instance.uuid) LOG.info("Pause instance %s", instance.uuid)
self.power_off(instance) self.power_off(instance)
def unpause(self, instance): def unpause(self, instance):
@ -555,7 +541,7 @@ class GCEDriver(driver.ComputeDriver):
instance. and powering on such an instance in this method. instance. and powering on such an instance in this method.
:param instance: nova.objects.instance.Instance :param instance: nova.objects.instance.Instance
""" """
LOG.info(_LI("Unpause instance %s") % instance.uuid) LOG.info("Unpause instance %s", instance.uuid)
self.power_on(context=None, instance=instance, network_info=None, self.power_on(context=None, instance=instance, network_info=None,
block_device_info=None) block_device_info=None)
@ -566,7 +552,7 @@ class GCEDriver(driver.ComputeDriver):
instance. instance.
:param instance: nova.objects.instance.Instance :param instance: nova.objects.instance.Instance
""" """
LOG.info(_LI("Suspending instance %s") % instance.uuid) LOG.info("Suspending instance %s", instance.uuid)
self.power_off(instance) self.power_off(instance)
def resume(self, context, instance, network_info, block_device_info=None): def resume(self, context, instance, network_info, block_device_info=None):
@ -576,7 +562,7 @@ class GCEDriver(driver.ComputeDriver):
instance. instance.
:param instance: nova.objects.instance.Instance :param instance: nova.objects.instance.Instance
""" """
LOG.info(_LI("Resuming instance %s") % instance.uuid) LOG.info("Resuming instance %s", instance.uuid)
self.power_on(context, instance, network_info, block_device_info) self.power_on(context, instance, network_info, block_device_info)
def destroy(self, context, instance, network_info, block_device_info=None, def destroy(self, context, instance, network_info, block_device_info=None,
@ -597,13 +583,12 @@ class GCEDriver(driver.ComputeDriver):
:param migrate_data: implementation specific params :param migrate_data: implementation specific params
""" """
compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone
LOG.info(_LI('Deleting instance %s') % instance.uuid) LOG.info('Deleting instance %s', instance.uuid)
try: try:
gce_id = self._get_gce_id_from_instance(instance) gce_id = self._get_gce_id_from_instance(instance)
except exception.InstanceNotFound: except exception.InstanceNotFound:
LOG.error( LOG.error("Unable to find GCE mapping for instance %s",
_LI("Unable to find GCE mapping for instance %s") % instance.uuid)
instance.uuid)
return return
try: try:
operation = gceutils.delete_instance(compute, project, zone, operation = gceutils.delete_instance(compute, project, zone,
@ -611,12 +596,11 @@ class GCEDriver(driver.ComputeDriver):
except HttpError: except HttpError:
# Sometimes instance may not exist in GCE, in that case we just # Sometimes instance may not exist in GCE, in that case we just
# allow deleting VM from openstack # allow deleting VM from openstack
LOG.error( LOG.error("Instance %s not found in GCE, removing from openstack.",
_LI("Instance %s not found in GCE, removing from openstack.") % instance.uuid)
instance.uuid)
return return
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info(_LI("Destroy Complete %s") % instance.uuid) LOG.info("Destroy Complete %s", instance.uuid)
def attach_volume(self, context, connection_info, instance, mountpoint, def attach_volume(self, context, connection_info, instance, mountpoint,
disk_bus=None, device_type=None, encryption=None): disk_bus=None, device_type=None, encryption=None):
@ -630,9 +614,8 @@ class GCEDriver(driver.ComputeDriver):
operation = gceutils.attach_disk(compute, project, zone, gce_id, operation = gceutils.attach_disk(compute, project, zone, gce_id,
disk_name, disk_link) disk_name, disk_link)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info( LOG.info("Volume %s attached to instace %s",
_LI("Volume %s attached to instace %s") % (disk_name, (disk_name, instance.uuid))
instance.uuid))
def detach_volume(self, connection_info, instance, mountpoint, def detach_volume(self, connection_info, instance, mountpoint,
encryption=None): encryption=None):
@ -645,9 +628,8 @@ class GCEDriver(driver.ComputeDriver):
operation = gceutils.detach_disk(compute, project, zone, gce_id, operation = gceutils.detach_disk(compute, project, zone, gce_id,
disk_name) disk_name)
gceutils.wait_for_operation(compute, project, operation) gceutils.wait_for_operation(compute, project, operation)
LOG.info( LOG.info("Volume %s detached from instace %s",
_LI("Volume %s detached from instace %s") % (disk_name, (disk_name, instance.uuid))
instance.uuid))
def swap_volume(self, old_connection_info, new_connection_info, instance, def swap_volume(self, old_connection_info, new_connection_info, instance,
mountpoint, resize_to): mountpoint, resize_to):

View File

@ -16,7 +16,7 @@ import time
import six import six
from oslo_log import log as logging from oslo_log import log as logging
from nova.i18n import _LI, _ from nova.i18n import _
from googleapiclient.discovery import build from googleapiclient.discovery import build
from oauth2client.client import GoogleCredentials from oauth2client.client import GoogleCredentials
from oslo_service import loopingcall from oslo_service import loopingcall
@ -181,9 +181,8 @@ def create_instance(compute, project, zone, name, image_link, machine_link,
:param image_link: url, GCE Image link for instance launch :param image_link: url, GCE Image link for instance launch
:param machine_link: url, GCE Machine link for instance launch :param machine_link: url, GCE Machine link for instance launch
""" """
LOG.info( LOG.info("Launching instance %s with image %s, machine %s and network %s",
_LI("Launching instance %s with image %s, machine %s and network %s") % (name, image_link, machine_link, network_interfaces))
(name, image_link, machine_link, network_interfaces))
config = { config = {
'kind': 'compute#instance', 'kind': 'compute#instance',
@ -270,8 +269,7 @@ def wait_for_operation(compute, project, operation, interval=1, timeout=60):
def watch_operation(name, request): def watch_operation(name, request):
result = request.execute() result = request.execute()
if result['status'] == 'DONE': if result['status'] == 'DONE':
LOG.info( LOG.info("Operation %s status is %s", (name, result['status']))
_LI("Operation %s status is %s") % (name, result['status']))
if 'error' in result: if 'error' in result:
raise GceOperationError(result['error']) raise GceOperationError(result['error'])
raise loopingcall.LoopingCallDone() raise loopingcall.LoopingCallDone()
@ -418,7 +416,7 @@ def get_instance_boot_disk(compute, project, zone, instance):
# Eg. projects/<project>/zones/<zone>/disks/<disk_name> # Eg. projects/<project>/zones/<zone>/disks/<disk_name>
items = urllib.parse.urlparse(disk_url).path.strip('/').split('/') items = urllib.parse.urlparse(disk_url).path.strip('/').split('/')
if len(items) < 4 or items[-2] != 'disks': if len(items) < 4 or items[-2] != 'disks':
LOG.error(_LI('Invalid disk URL %s') % (disk_url)) LOG.error('Invalid disk URL %s', (disk_url))
disk_name, zone = items[-1], items[-3] disk_name, zone = items[-1], items[-3]
disk_info = get_disk(compute, project, zone, disk_name) disk_info = get_disk(compute, project, zone, disk_name)
return disk_info return disk_info

21
omnitests/cinder.log Normal file
View File

@ -0,0 +1,21 @@
py27 create: /home/stack/openstack/omni/.tox/py27
py27 develop-inst: /home/stack/openstack/omni
ERROR: invocation failed (exit code 1), logfile: /home/stack/openstack/omni/.tox/py27/log/py27-2.log
ERROR: actionid: py27
msg: developpkg
cmdargs: ['/home/stack/openstack/omni/.tox/py27/bin/pip', 'install', '-e', '/home/stack/openstack/omni']
env: {'VIRTUAL_ENV': '/home/stack/openstack/omni/.tox/py27', 'SHLVL': '1', 'LANG': 'en_US.UTF-8', 'PATH': '/home/stack/openstack/omni/.tox/py27/bin:/home/stack/openstack/omni/.tox/py27/bin:/home/stack/bin:/home/stack/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'PWD': '/home/stack/openstack/omni', 'PYTHONHASHSEED': '908394477', '_': '/usr/local/bin/tox', 'LANGUAGE': 'en_US'}
Obtaining file:///home/stack/openstack/omni
Collecting google-api-python-client>=1.4.2 (from omni==0.0.1.dev35)
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f2bf53d6210>: Failed to establish a new connection: [Errno -5] No address associated with hostname',)': /simple/google-api-python-client/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f2bf53d6310>: Failed to establish a new connection: [Errno -5] No address associated with hostname',)': /simple/google-api-python-client/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f2bf53d6710>: Failed to establish a new connection: [Errno -5] No address associated with hostname',)': /simple/google-api-python-client/
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f2bf53d6c10>: Failed to establish a new connection: [Errno -5] No address associated with hostname',)': /simple/google-api-python-client/
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f2bf53d6f10>: Failed to establish a new connection: [Errno -5] No address associated with hostname',)': /simple/google-api-python-client/
Could not find a version that satisfies the requirement google-api-python-client>=1.4.2 (from omni==0.0.1.dev35) (from versions: )
No matching distribution found for google-api-python-client>=1.4.2 (from omni==0.0.1.dev35)
py27 installed:
___________________________________ summary ____________________________________
ERROR: py27: InvocationError: /home/stack/openstack/omni/.tox/py27/bin/pip install -e /home/stack/openstack/omni (see /home/stack/openstack/omni/.tox/py27/log/py27-2.log)

View File

@ -0,0 +1,25 @@
py27 create: /home/stack/openstack/omni/.tox/py27
ERROR: invocation failed (exit code 1), logfile: /home/stack/openstack/omni/.tox/py27/log/py27-1.log
ERROR: actionid: py27
msg: getenv
cmdargs: ['/usr/bin/python', '-m', 'virtualenv', '--python', '/usr/bin/python2.7', 'py27']
env: {'VIRTUAL_ENV': '/home/stack/openstack/omni/.tox/py27', 'SHLVL': '1', 'LANG': 'en_US.UTF-8', 'PATH': '/home/stack/openstack/omni/.tox/py27/bin:/home/stack/openstack/omni/.tox/py27/bin:/home/stack/bin:/home/stack/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'PWD': '/home/stack/openstack/omni', 'PYTHONHASHSEED': '3596095205', '_': '/usr/local/bin/tox', 'LANGUAGE': 'en_US'}
New python executable in /home/stack/openstack/omni/.tox/py27/bin/python2.7
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2328, in <module>
main()
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 713, in main
symlink=options.symlink)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 925, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1231, in install_python
shutil.copyfile(executable, py_executable)
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 26] Text file busy: '/home/stack/openstack/omni/.tox/py27/bin/python2.7'
Running virtualenv with interpreter /usr/bin/python2.7
ERROR: InvocationError: /usr/bin/python -m virtualenv --python /usr/bin/python2.7 py27 (see /home/stack/openstack/omni/.tox/py27/log/py27-1.log)
___________________________________ summary ____________________________________
ERROR: py27: InvocationError: /usr/bin/python -m virtualenv --python /usr/bin/python2.7 py27 (see /home/stack/openstack/omni/.tox/py27/log/py27-1.log)

11
omnitests/neutron.log Normal file
View File

@ -0,0 +1,11 @@
py27 recreate: /home/stack/openstack/omni/.tox/py27
ERROR: invocation failed (exit code 3), logfile: /home/stack/openstack/omni/.tox/py27/log/py27-0.log
ERROR: actionid: py27
msg: getenv
cmdargs: ['/usr/bin/python', '-m', 'virtualenv', '--python', '/usr/bin/python2.7', 'py27']
env: {'VIRTUAL_ENV': '/home/stack/openstack/omni/.tox/py27', 'SHLVL': '1', 'LANG': 'en_US.UTF-8', 'PATH': '/home/stack/openstack/omni/.tox/py27/bin:/home/stack/openstack/omni/.tox/py27/bin:/home/stack/bin:/home/stack/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'PWD': '/home/stack/openstack/omni', 'PYTHONHASHSEED': '756525180', '_': '/usr/local/bin/tox', 'LANGUAGE': 'en_US'}
ERROR: InvocationError: /usr/bin/python -m virtualenv --python /home/stack/openstack/omni/.tox/py27/bin/python2.7 py27 (see /home/stack/openstack/omni/.tox/py27/log/py27-0.log)
___________________________________ summary ____________________________________
ERROR: py27: InvocationError: /usr/bin/python -m virtualenv --python /home/stack/openstack/omni/.tox/py27/bin/python2.7 py27 (see /home/stack/openstack/omni/.tox/py27/log/py27-0.log)

25
omnitests/nova.log Normal file
View File

@ -0,0 +1,25 @@
py27 create: /home/stack/openstack/omni/.tox/py27
ERROR: invocation failed (exit code 1), logfile: /home/stack/openstack/omni/.tox/py27/log/py27-0.log
ERROR: actionid: py27
msg: getenv
cmdargs: ['/usr/bin/python', '-m', 'virtualenv', '--python', '/usr/bin/python2.7', 'py27']
env: {'VIRTUAL_ENV': '/home/stack/openstack/omni/.tox/py27', 'SHLVL': '1', 'LANG': 'en_US.UTF-8', 'PATH': '/home/stack/openstack/omni/.tox/py27/bin:/home/stack/openstack/omni/.tox/py27/bin:/home/stack/bin:/home/stack/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'PWD': '/home/stack/openstack/omni', 'PYTHONHASHSEED': '756525180', '_': '/usr/local/bin/tox', 'LANGUAGE': 'en_US'}
New python executable in /home/stack/openstack/omni/.tox/py27/bin/python2.7
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2328, in <module>
main()
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 713, in main
symlink=options.symlink)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 925, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1231, in install_python
shutil.copyfile(executable, py_executable)
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 26] Text file busy: '/home/stack/openstack/omni/.tox/py27/bin/python2.7'
Running virtualenv with interpreter /usr/bin/python2.7
ERROR: InvocationError: /usr/bin/python -m virtualenv --python /usr/bin/python2.7 py27 (see /home/stack/openstack/omni/.tox/py27/log/py27-0.log)
___________________________________ summary ____________________________________
ERROR: py27: InvocationError: /usr/bin/python -m virtualenv --python /usr/bin/python2.7 py27 (see /home/stack/openstack/omni/.tox/py27/log/py27-0.log)

17
requirements.txt Normal file
View File

@ -0,0 +1,17 @@
google-api-python-client>=1.4.2 # Apache-2.0
moto
boto>=2.32.1 # MIT
ipaddr
google_compute_enginegoogle-api-python-client>=1.4.2 # Apache-2.0
moto
boto>=2.32.1 # MIT
ipaddr
google_compute_enginegoogle-api-python-client>=1.4.2 # Apache-2.0
moto
boto>=2.32.1 # MIT
ipaddr
google_compute_enginegoogle-api-python-client>=1.4.2 # Apache-2.0
moto
boto>=2.32.1 # MIT
ipaddr
google_compute_engine