Browse Source

Remove pool group totally in zaqarclient

The path remove pool group totally in client
Implements: bp remove-pool-group-totally

Co-Authored-By: wanghao <sxmatch1986@gmail.com>

Change-Id: I0604ad8c55127027aa238a2e8388bb046a93e8a9
changes/39/629339/9
gecong1973 3 years ago
committed by Dirk Mueller
parent
commit
4504a6f97f
  1. 61
      zaqarclient/queues/v1/cli.py
  2. 6
      zaqarclient/queues/v1/flavor.py
  3. 8
      zaqarclient/queues/v1/pool.py
  4. 7
      zaqarclient/queues/v2/cli.py
  5. 56
      zaqarclient/tests/queues/flavor.py
  6. 5
      zaqarclient/tests/queues/pool.py

61
zaqarclient/queues/v1/cli.py

@ -376,9 +376,9 @@ class CreatePool(command.ShowOne):
metavar="<pool_weight>",
help="weight of the pool")
parser.add_argument(
"--pool_group",
metavar="<pool_group>",
help="Group of the pool")
"--flavor",
metavar="<flavor>",
help="Flavor of the pool")
parser.add_argument(
"--pool_options",
type=json.loads,
@ -397,8 +397,8 @@ class CreatePool(command.ShowOne):
'options': parsed_args.pool_options
}
if parsed_args.pool_group:
kw_arg.update({'group': parsed_args.pool_group})
if parsed_args.flavor:
kw_arg.update({'flavor': parsed_args.flavor})
data = client.pool(parsed_args.pool_name, **kw_arg)
@ -406,7 +406,7 @@ class CreatePool(command.ShowOne):
raise RuntimeError('Failed to create pool(%s).' %
parsed_args.pool_name)
columns = ('Name', 'Weight', 'URI', 'Group', 'Options')
columns = ('Name', 'Weight', 'URI', 'Flavor', 'Options')
return columns, utils.get_item_properties(data, columns)
@ -449,7 +449,7 @@ class ShowPool(command.ShowOne):
pool_data = client.pool(parsed_args.pool_name,
auto_create=False).get()
columns = ('Name', 'Weight', 'URI', 'Group', 'Options')
columns = ('Name', 'Weight', 'URI', 'Flavor', 'Options')
return columns, utils.get_dict_properties(pool_data, columns)
@ -494,9 +494,9 @@ class UpdatePool(command.ShowOne):
metavar="<pool_weight>",
help="Weight of the pool")
parser.add_argument(
"--pool_group",
metavar="<pool_group>",
help="Group of the pool")
"--flavor",
metavar="<flavor>",
help="Flavor of the pool")
parser.add_argument(
"--pool_options",
type=json.loads,
@ -513,15 +513,15 @@ class UpdatePool(command.ShowOne):
kw_arg["uri"] = parsed_args.pool_uri
if parsed_args.pool_weight:
kw_arg["weight"] = parsed_args.pool_weight
if parsed_args.pool_group:
kw_arg["group"] = parsed_args.pool_group
if parsed_args.flavor:
kw_arg["flavor"] = parsed_args.flavor
if parsed_args.pool_options:
kw_arg["options"] = parsed_args.pool_options
pool_obj = client.pool(parsed_args.pool_name, auto_create=False)
pool_obj.update(kw_arg)
pool_data = pool_obj.get()
columns = ('Name', 'Weight', 'URI', 'Group', 'Options')
columns = ('Name', 'Weight', 'URI', 'Flavor', 'Options')
return columns, utils.get_dict_properties(pool_data, columns)
@ -610,7 +610,7 @@ class ListPools(command.Lister):
client = _get_client(self, parsed_args)
kwargs = {}
columns = ["Name", "Weight", "URI", "Group"]
columns = ["Name", "Weight", "URI", "Flavor"]
if parsed_args.marker is not None:
kwargs["marker"] = parsed_args.marker
if parsed_args.limit is not None:
@ -657,9 +657,9 @@ class UpdateFlavor(command.ShowOne):
metavar="<flavor_name>",
help="Name of the flavor")
parser.add_argument(
"--pool_group",
metavar="<pool_group>",
help="Pool group the flavor sits on")
"--pool_list",
metavar="<pool_list>",
help="Pool list the flavor sits on")
parser.add_argument(
"--capabilities",
metavar="<capabilities>",
@ -671,13 +671,14 @@ class UpdateFlavor(command.ShowOne):
self.log.debug("take_action(%s)" % parsed_args)
client = self.app.client_manager.messaging
kwargs = {}
if parsed_args.pool_group:
kwargs['pool'] = parsed_args.pool_group
if parsed_args.pool_list:
pool_list = parsed_args.pool_list.split(',')
kwargs['pool_list'] = pool_list
if parsed_args.capabilities:
kwargs['capabilities'] = json.loads(parsed_args.capabilities)
flavor = client.flavor(parsed_args.flavor_name, auto_create=False)
columns = ('Name', 'Pool', 'Capabilities')
columns = ('Name', 'Pool_list', 'Capabilities')
flavor.update(kwargs)
flavor_data = flavor.get()
return columns, utils.get_dict_properties(flavor_data, columns)
@ -696,9 +697,9 @@ class CreateFlavor(command.ShowOne):
metavar="<flavor_name>",
help="Name of the flavor")
parser.add_argument(
"pool_group",
metavar="<pool_group>",
help="Pool group for flavor")
"--pool_list",
metavar="<pool_list>",
help="Pool list for flavor")
parser.add_argument(
"--capabilities",
metavar="<capabilities>",
@ -712,13 +713,12 @@ class CreateFlavor(command.ShowOne):
self.log.debug("take_action(%s)" % parsed_args)
client = self.app.client_manager.messaging
kwargs = {'capabilities': parsed_args.capabilities}
data = client.flavor(parsed_args.flavor_name,
pool_group=parsed_args.pool_group,
pool_list=parsed_args.pool_list,
**kwargs)
columns = ('Name', 'Pool Group', 'Capabilities')
columns = ('Name', 'Pool list', 'Capabilities')
return columns, utils.get_item_properties(data, columns)
@ -739,7 +739,7 @@ class DeleteFlavor(command.Command):
def take_action(self, parsed_args):
client = _get_client(self, parsed_args)
flavor_name = parsed_args.flavor_name
client.flavor(flavor_name).delete()
client.flavor(flavor_name, auto_create=False).delete()
class ShowFlavor(command.ShowOne):
@ -762,7 +762,7 @@ class ShowFlavor(command.ShowOne):
client = self.app.client_manager.messaging
flavor_data = client.flavor(parsed_args.flavor_name,
auto_create=False).get()
columns = ('Name', 'Pool Group', 'Capabilities')
columns = ('Name', 'Pool list', 'Capabilities')
return columns, utils.get_dict_properties(flavor_data, columns)
@ -798,11 +798,10 @@ class ListFlavors(command.Lister):
kwargs["marker"] = parsed_args.marker
if parsed_args.limit is not None:
kwargs["limit"] = parsed_args.limit
data = client.flavors(**kwargs)
columns = ("Name", 'Pool')
columns = ("Name", 'Pool list')
if parsed_args.detailed:
columns = ("Name", 'Pool', 'Capabilities')
columns = ("Name", 'Pool list', 'Capabilities')
return (columns,
(utils.get_item_properties(s, columns) for s in data))

6
zaqarclient/queues/v1/flavor.py

@ -19,12 +19,12 @@ from zaqarclient.queues.v1 import core
class Flavor(object):
def __init__(self, client, name,
pool_group=None, auto_create=True,
pool_list=None, auto_create=True,
**kwargs):
self.client = client
self.name = name
self.pool_group = pool_group
self.pool_list = pool_list
self.capabilities = kwargs.get('capabilities', {})
if auto_create:
@ -44,7 +44,7 @@ class Flavor(object):
# TBD(mdnadeem): Have to change this code when zaqar server
# behaviour change for PUT operation.
data = {'pool_group': self.pool_group}
data = {'pool_list': self.pool_list}
if self.client.api_version <= 1.1:
data['capabilities'] = self.capabilities

8
zaqarclient/queues/v1/pool.py

@ -20,13 +20,13 @@ class Pool(object):
def __init__(self, client, name,
weight=None, uri=None,
group=None, auto_create=True,
flavor=None, auto_create=True,
**kwargs):
self.client = client
self.uri = uri
self.name = name
self.weight = weight
self.group = group
self.flavor = flavor
self.options = kwargs.get("options", {})
if auto_create:
@ -50,8 +50,8 @@ class Pool(object):
'weight': self.weight,
'options': self.options}
if self.client.api_version >= 1.1 and self.group:
data['group'] = self.group
if self.client.api_version >= 1.1 and self.flavor:
data['flavor'] = self.flavor
req, trans = self.client._request_and_transport()
core.pool_create(trans, req, self.name, data)

7
zaqarclient/queues/v2/cli.py

@ -396,11 +396,14 @@ class CreateFlavor(cli.CreateFlavor):
if parsed_args.capabilities != {}:
raise AttributeError("<--capabilities> option is only\
available in client api version < 2")
pool_list = None
if parsed_args.pool_list:
pool_list = parsed_args.pool_list.split(',')
data = client.flavor(parsed_args.flavor_name,
pool_group=parsed_args.pool_group,
pool_list=pool_list,
**kwargs)
columns = ('Name', 'Pool Group', 'Capabilities')
columns = ('Name', 'Pool list', 'Capabilities')
return columns, utils.get_item_properties(data, columns)

56
zaqarclient/tests/queues/flavor.py

@ -24,7 +24,8 @@ from zaqarclient.transport import response
class QueuesV1_1FlavorUnitTest(base.QueuesTestBase):
def test_flavor_create(self):
flavor_data = {'pool_group': 'stomach'}
pool_list = ['pool1', 'pool2']
flavor_data = {'pool_list': pool_list}
with mock.patch.object(self.transport, 'send',
autospec=True) as send_method:
@ -37,10 +38,9 @@ class QueuesV1_1FlavorUnitTest(base.QueuesTestBase):
# since auto_create's default is True
flavor = self.client.flavor('tasty', **flavor_data)
self.assertEqual('tasty', flavor.name)
self.assertEqual('stomach', flavor.pool_group)
def test_flavor_get(self):
flavor_data = {'name': 'test', 'pool_group': 'stomach'}
flavor_data = {'name': 'test'}
with mock.patch.object(self.transport, 'send',
autospec=True) as send_method:
@ -54,11 +54,12 @@ class QueuesV1_1FlavorUnitTest(base.QueuesTestBase):
flavor = self.client.flavor('test')
flavor1 = flavor.get()
self.assertEqual('test', flavor1['name'])
self.assertEqual('stomach', flavor1['pool_group'])
def test_flavor_update(self):
flavor_data = {'pool_group': 'stomach'}
updated_data = {'pool_group': 'belly'}
pool_list1 = ['pool1', 'pool2']
pool_list2 = ['pool3', 'pool4']
flavor_data = {'pool_list': pool_list1}
updated_data = {'pool_list': pool_list2}
with mock.patch.object(self.transport, 'send',
autospec=True) as send_method:
@ -66,8 +67,8 @@ class QueuesV1_1FlavorUnitTest(base.QueuesTestBase):
send_method.return_value = resp
flavor = self.client.flavor('tasty', **flavor_data)
flavor.update({'pool_group': 'belly'})
self.assertEqual('belly', flavor.pool_group)
flavor.update({'pool_list': pool_list2})
self.assertEqual(pool_list2, flavor.pool_list)
def test_flavor_list(self):
returned = {
@ -76,8 +77,7 @@ class QueuesV1_1FlavorUnitTest(base.QueuesTestBase):
'href': '/v1.1/flavors?marker=6244-244224-783'
}],
'flavors': [{
'name': 'tasty',
'pool_group': 'stomach'
'name': 'tasty'
}]
}
@ -92,7 +92,8 @@ class QueuesV1_1FlavorUnitTest(base.QueuesTestBase):
self.assertEqual(1, len(list(flavor_var)))
def test_flavor_delete(self):
flavor_data = {'pool_group': 'stomach'}
pool_list = ['pool1', 'pool2']
flavor_data = {'pool_list': pool_list}
with mock.patch.object(self.transport, 'send',
autospec=True) as send_method:
@ -116,57 +117,55 @@ class QueuesV1_1FlavorFunctionalTest(base.QueuesTestBase):
def test_flavor_create(self):
pool_data = {'uri': 'mongodb://127.0.0.1:27017',
'weight': 10,
'group': 'us'}
'flavor': 'tasty'}
pool = self.client.pool('stomach', **pool_data)
self.addCleanup(pool.delete)
flavor_data = {'pool_group': 'us'}
pool_list = ['stomach']
flavor_data = {'pool_list': pool_list}
flavor = self.client.flavor('tasty', **flavor_data)
self.addCleanup(flavor.delete)
self.assertEqual('tasty', flavor.name)
self.assertEqual('us', flavor.pool_group)
self.assertEqual(pool_list, flavor.pool_list)
def test_flavor_get(self):
pool_data = {'weight': 10,
'group': 'us',
'flavor': 'tasty',
'uri': 'mongodb://127.0.0.1:27017'}
pool = self.client.pool('stomach', **pool_data)
self.addCleanup(pool.delete)
flavor_data = {'pool_group': 'us'}
pool_list = ['stomach']
flavor_data = {'pool_list': pool_list}
flavor = self.client.flavor('tasty', **flavor_data)
resp_data = flavor.get()
self.addCleanup(flavor.delete)
self.assertEqual('tasty', resp_data['name'])
self.assertEqual('us', resp_data['pool_group'])
def test_flavor_update(self):
pool_data = {'weight': 10,
'uri': 'mongodb://127.0.0.1:27017',
'group': 'us'}
'flavor': 'tasty'}
pool = self.client.pool('stomach', **pool_data)
self.addCleanup(pool.delete)
flavor_data = {'pool_group': 'us'}
pool_list = ['stomach']
flavor_data = {'pool_list': pool_list}
flavor = self.client.flavor('tasty', **flavor_data)
self.addCleanup(flavor.delete)
pool.update({'group': 'belly'})
flavor.update({'pool_group': 'belly'})
self.assertEqual('belly', flavor.pool_group)
def test_flavor_list(self):
pool_data = {'uri': 'mongodb://127.0.0.1:27017',
'weight': 10,
'group': 'us'}
'flavor': 'test_flavor'}
pool = self.client.pool('stomach', **pool_data)
self.addCleanup(pool.delete)
flavor_data = {'pool_group': 'us'}
pool_list = ['stomach']
flavor_data = {'pool_list': pool_list}
flavor = self.client.flavor("test_flavor", **flavor_data)
self.addCleanup(flavor.delete)
@ -177,11 +176,12 @@ class QueuesV1_1FlavorFunctionalTest(base.QueuesTestBase):
def test_flavor_delete(self):
pool_data = {'uri': 'mongodb://127.0.0.1:27017',
'weight': 10,
'group': 'us'}
'flavor': 'tasty'}
pool = self.client.pool('stomach', **pool_data)
self.addCleanup(pool.delete)
flavor_data = {'pool_group': 'us'}
pool_list = ['stomach']
flavor_data = {'pool_list': pool_list}
flavor = self.client.flavor('tasty', **flavor_data)
flavor.delete()

5
zaqarclient/tests/queues/pool.py

@ -129,7 +129,6 @@ class QueuesV1_1PoolFunctionalTest(base.QueuesTestBase):
def test_pool_get(self):
pool_data = {'weight': 10,
'group': 'us',
'uri': 'mongodb://127.0.0.1:27017'}
pool = self.client.pool('FuncTestPool', **pool_data)
@ -142,7 +141,6 @@ class QueuesV1_1PoolFunctionalTest(base.QueuesTestBase):
def test_pool_create(self):
pool_data = {'weight': 10,
'group': 'us',
'uri': 'mongodb://127.0.0.1:27017'}
pool = self.client.pool('FuncTestPool', **pool_data)
@ -152,7 +150,6 @@ class QueuesV1_1PoolFunctionalTest(base.QueuesTestBase):
def test_pool_update(self):
pool_data = {'weight': 10,
'group': 'us',
'uri': 'mongodb://127.0.0.1:27017'}
pool = self.client.pool('FuncTestPool', **pool_data)
@ -162,7 +159,6 @@ class QueuesV1_1PoolFunctionalTest(base.QueuesTestBase):
def test_pool_list(self):
pool_data = {'weight': 10,
'group': 'us',
'uri': 'mongodb://127.0.0.1:27017'}
pool = self.client.pool('FuncTestPool', **pool_data)
self.addCleanup(pool.delete)
@ -173,7 +169,6 @@ class QueuesV1_1PoolFunctionalTest(base.QueuesTestBase):
def test_pool_delete(self):
pool_data = {'weight': 10,
'group': 'us',
'uri': 'mongodb://127.0.0.1:27017'}
pool = self.client.pool('FuncTestPool', **pool_data)

Loading…
Cancel
Save