Fix rpc initialization of cinder-manager volume
VolumeCommands.rpc_client is a property, so when the oslo.config argparser introspect the class VolumeCommands at module loading time, it launch the method. But the method depends on a initialized oslo.config.cfg.CONF object, but this one is not yet initialized. So don't use python property, to initialize the rpc_client correctly. No test because of bug: #1398401 Change-Id: I2c2f0be6e7a9d0866f063d98e1f8213f62fb9f92 Closes-bug: #1398319
This commit is contained in:
parent
dd006ad496
commit
d496b78795
@ -252,13 +252,12 @@ class VolumeCommands(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._client = None
|
self._client = None
|
||||||
|
|
||||||
@property
|
|
||||||
def rpc_client(self):
|
def rpc_client(self):
|
||||||
|
if self._client is None:
|
||||||
if not rpc.initialized():
|
if not rpc.initialized():
|
||||||
rpc.init(CONF)
|
rpc.init(CONF)
|
||||||
target = messaging.Target(topic=CONF.volume_topic)
|
target = messaging.Target(topic=CONF.volume_topic)
|
||||||
self._client = rpc.get_client(target)
|
self._client = rpc.get_client(target)
|
||||||
|
|
||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
@args('volume_id',
|
@args('volume_id',
|
||||||
@ -282,7 +281,7 @@ class VolumeCommands(object):
|
|||||||
print(_("Detach volume from instance and then try again."))
|
print(_("Detach volume from instance and then try again."))
|
||||||
return
|
return
|
||||||
|
|
||||||
cctxt = self.rpc_client.prepare(server=host)
|
cctxt = self.rpc_client().prepare(server=host)
|
||||||
cctxt.cast(ctxt, "delete_volume", volume_id=volume['id'])
|
cctxt.cast(ctxt, "delete_volume", volume_id=volume['id'])
|
||||||
|
|
||||||
@args('--currenthost', required=True, help='Existing volume host name')
|
@args('--currenthost', required=True, help='Existing volume host name')
|
||||||
|
Loading…
Reference in New Issue
Block a user