fix the neutron-powervc utility broken issue

The neutron-powervc is a debug utility for powervc-driver's neutron rpc
service. It's broken with neutron kilo level code

Close-Bug: #1457752
Change-Id: I57101bcdccaa470fea01c8a4abacc1f694abca9b
This commit is contained in:
terryyao 2015-05-22 14:24:28 +08:00
parent d43d07acbc
commit 4f2035dfe2
2 changed files with 32 additions and 38 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright 2013 IBM Corp.
# Copyright 2015 IBM Corp.
import sys
import traceback
@ -23,7 +23,7 @@ from oslo.config import cfg
from neutron import context
from neutron.common import config as logging_config
from neutron.openstack.common import log as logging
from oslo_log import log as logging
from powervc.neutron.api.client_rpc import RpcClient
@ -64,7 +64,7 @@ def main():
usage()
argv = [sys.argv[0]]
config.parse_power_config(argv, 'powervc-neutron')
config.parse_power_config(argv, 'neutron')
# logging_config.setup_logging(cfg.CONF)
LOG.debug(_('Create RPC interface'))

View File

@ -1,4 +1,4 @@
# Copyright 2013 IBM Corp.
# Copyright 2015 IBM Corp.
from prettytable import PrettyTable
@ -6,8 +6,8 @@ from powervc.common import config
from oslo.config import cfg
from neutron.common.rpc import RpcProxy
from neutron.common import rpc
import oslo_messaging
from oslo_log import log as logging
from powervc.common.gettextutils import _
@ -17,7 +17,7 @@ LIST_COLUMNS = ['status', 'local_id', 'pvc_id', 'sync_key']
# RPC client
class RpcClient(RpcProxy):
class RpcClient(object):
BASE_RPC_API_VERSION = '1.0'
@ -27,8 +27,8 @@ class RpcClient(RpcProxy):
self.context = context
self.host = cfg.CONF.host
rpc.init(config.AMQP_OPENSTACK_CONF)
super(RpcClient, self).__init__(
topic=self.topic, default_version=self.BASE_RPC_API_VERSION)
target = oslo_messaging.Target(topic=self.topic, version=self.BASE_RPC_API_VERSION)
self.client = rpc.get_client(target)
def _print_table(self, result):
if result and len(result) > 0:
@ -54,66 +54,60 @@ class RpcClient(RpcProxy):
def get_local_network_uuid(self, network_id):
LOG.debug(_('get_local_network_uuid'))
result = self.call(self.context,
self.make_msg('get_local_network_uuid',
network_id=network_id),
topic=self.topic)
result = self.client.call(self.context,
'get_local_network_uuid',
network_id=network_id)
print 'Result from RPC call:', result
def get_pvc_network_uuid(self, network_id):
LOG.debug(_('get_pvc_network_uuid'))
result = self.call(self.context,
self.make_msg('get_pvc_network_uuid',
network_id=network_id),
topic=self.topic)
result = self.client.call(self.context,
'get_pvc_network_uuid',
network_id=network_id)
print 'Result from RPC call:', result
def get_pvc_port_uuid(self, port_id):
LOG.debug(_('get_pvc_port_uuid'))
result = self.call(self.context,
self.make_msg('get_pvc_port_uuid',
port_id=port_id),
topic=self.topic)
result = self.client.call(self.context,
'get_pvc_port_uuid',
port_id=port_id)
print 'Result from RPC call:', result
def get_network(self, opt):
LOG.debug(_('get_network: %s'), opt)
result = self.call(self.context,
self.make_msg('get_network', sync_key=opt),
topic=self.topic)
result = self.client.call(self.context,
'get_network',
sync_key=opt)
self._print_object(result)
def get_networks(self):
LOG.debug(_('get_networks'))
result = self.call(self.context,
self.make_msg('get_networks'),
topic=self.topic)
result = self.client.call(self.context,
'get_networks')
self._print_table(result)
def get_subnet(self, opt):
LOG.debug(_('get_subnet: %s'), opt)
result = self.call(self.context,
self.make_msg('get_subnet', sync_key=opt),
topic=self.topic)
result = self.client.call(self.context,
'get_subnet',
sync_key=opt)
self._print_object(result)
def get_subnets(self):
LOG.debug(_('get_subnets'))
result = self.call(self.context,
self.make_msg('get_subnets'),
topic=self.topic)
result = self.client.call(self.context,
'get_subnets')
self._print_table(result)
def get_port(self, opt):
LOG.debug(_('get_port: %s'), opt)
result = self.call(self.context,
self.make_msg('get_port', sync_key=opt),
topic=self.topic)
result = self.client.call(self.context,
'get_port',
sync_key=opt)
self._print_object(result)
def get_ports(self):
LOG.debug(_('get_ports'))
result = self.call(self.context,
self.make_msg('get_ports'),
topic=self.topic)
result = self.client.call(self.context,
'get_ports')
self._print_table(result)