Fix neutron V2 No valid authentication is available problem
neutron v2 client need admin context, or it will cause the failure Change-Id: I3a7d1eee60dd513756755f1da29c131e543cebb0 Closes-Bug: #1469625
This commit is contained in:
parent
6d39c193f7
commit
b8cc4d3065
|
@ -95,6 +95,7 @@ class PowerVCCloudManager(manager.Manager):
|
||||||
orig_ctx = nova.context.get_admin_context()
|
orig_ctx = nova.context.get_admin_context()
|
||||||
orig_ctx.project_id = keystone.tenant_id
|
orig_ctx.project_id = keystone.tenant_id
|
||||||
orig_ctx.user_id = keystone.user_id
|
orig_ctx.user_id = keystone.user_id
|
||||||
|
self.admin_context = orig_ctx
|
||||||
|
|
||||||
ctx = ctx_delegate.context_dynamic_auth_token(orig_ctx, keystone)
|
ctx = ctx_delegate.context_dynamic_auth_token(orig_ctx, keystone)
|
||||||
self.project_id = CONF.powervc.admin_tenant_name
|
self.project_id = CONF.powervc.admin_tenant_name
|
||||||
|
@ -669,7 +670,8 @@ class PowerVCCloudManager(manager.Manager):
|
||||||
objects.Instance(),
|
objects.Instance(),
|
||||||
local_instance)
|
local_instance)
|
||||||
try:
|
try:
|
||||||
self.network_api.deallocate_for_instance(ctx, local_instance)
|
self.network_api.deallocate_for_instance(self.admin_context,
|
||||||
|
local_instance)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.warning(_("Deallocate_for_instance failed."))
|
LOG.warning(_("Deallocate_for_instance failed."))
|
||||||
|
|
||||||
|
@ -2003,18 +2005,19 @@ class PowerVCCloudManager(manager.Manager):
|
||||||
search_opts = {'device_id': instance['uuid'],
|
search_opts = {'device_id': instance['uuid'],
|
||||||
'tenant_id': instance['project_id']}
|
'tenant_id': instance['project_id']}
|
||||||
try:
|
try:
|
||||||
data = self.network_api.list_ports(context, **search_opts)
|
data = self.network_api.list_ports(self.admin_context,
|
||||||
|
**search_opts)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
LOG.error(_("_fix_instance_nw_info failed: %s") %
|
LOG.warning(_("_fix_instance_nw_info failed: %s") %
|
||||||
(e))
|
(e))
|
||||||
return
|
return
|
||||||
ports = data.get('ports', [])
|
ports = data.get('ports', [])
|
||||||
# If ports is not empty, should put that into network_info.
|
# If ports is not empty, should put that into network_info.
|
||||||
if ports:
|
if ports:
|
||||||
try:
|
try:
|
||||||
nets = self.network_api.get_all(context)
|
nets = self.network_api.get_all(self.admin_context)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
LOG.error(_("_fix_instance_nw_info failed: %s") %
|
LOG.warning(_("_fix_instance_nw_info failed: %s") %
|
||||||
(e))
|
(e))
|
||||||
return
|
return
|
||||||
# Call this will trigger info_cache update,
|
# Call this will trigger info_cache update,
|
||||||
|
@ -2025,14 +2028,15 @@ class PowerVCCloudManager(manager.Manager):
|
||||||
inst = instance_obj.Instance.get_by_uuid(context,
|
inst = instance_obj.Instance.get_by_uuid(context,
|
||||||
instance['uuid'])
|
instance['uuid'])
|
||||||
try:
|
try:
|
||||||
|
admin_ctx = self.admin_context
|
||||||
nw_info = \
|
nw_info = \
|
||||||
self.network_api.get_instance_nw_info(context,
|
self.network_api.get_instance_nw_info(admin_ctx,
|
||||||
inst,
|
inst,
|
||||||
nets,
|
nets,
|
||||||
port_ids)
|
port_ids)
|
||||||
LOG.info("_fix_instance_nw_info suc:" + str(nw_info))
|
LOG.info("_fix_instance_nw_info suc:" + str(nw_info))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
LOG.error(_("_fix_instance_nw_info failed: %s") %
|
LOG.warning(_("_fix_instance_nw_info failed: %s") %
|
||||||
(e))
|
(e))
|
||||||
|
|
||||||
def _get_instance_root_device_name(self, pvc_instance, db_instance):
|
def _get_instance_root_device_name(self, pvc_instance, db_instance):
|
||||||
|
|
Loading…
Reference in New Issue