Merge "Migrate volume backend commands to SDK"
This commit is contained in:
commit
53e7d713f0
openstackclient
releasenotes/notes
@ -21,6 +21,8 @@ import uuid
|
|||||||
from cinderclient import api_versions
|
from cinderclient import api_versions
|
||||||
from openstack.block_storage.v2 import _proxy as block_storage_v2_proxy
|
from openstack.block_storage.v2 import _proxy as block_storage_v2_proxy
|
||||||
from openstack.block_storage.v3 import backup as _backup
|
from openstack.block_storage.v3 import backup as _backup
|
||||||
|
from openstack.block_storage.v3 import capabilities as _capabilities
|
||||||
|
from openstack.block_storage.v3 import stats as _stats
|
||||||
from openstack.block_storage.v3 import volume as _volume
|
from openstack.block_storage.v3 import volume as _volume
|
||||||
from openstack.image.v2 import _proxy as image_v2_proxy
|
from openstack.image.v2 import _proxy as image_v2_proxy
|
||||||
from osc_lib.cli import format_columns
|
from osc_lib.cli import format_columns
|
||||||
@ -301,7 +303,7 @@ def create_one_capability(attrs=None):
|
|||||||
# Overwrite default attributes if there are some attributes set
|
# Overwrite default attributes if there are some attributes set
|
||||||
capability_info.update(attrs or {})
|
capability_info.update(attrs or {})
|
||||||
|
|
||||||
capability = fakes.FakeResource(None, capability_info, loaded=True)
|
capability = _capabilities.Capabilities(**capability_info)
|
||||||
|
|
||||||
return capability
|
return capability
|
||||||
|
|
||||||
@ -317,19 +319,21 @@ def create_one_pool(attrs=None):
|
|||||||
# Set default attribute
|
# Set default attribute
|
||||||
pool_info = {
|
pool_info = {
|
||||||
'name': 'host@lvmdriver-1#lvmdriver-1',
|
'name': 'host@lvmdriver-1#lvmdriver-1',
|
||||||
'storage_protocol': 'iSCSI',
|
'capabilities': {
|
||||||
'thick_provisioning_support': False,
|
'storage_protocol': 'iSCSI',
|
||||||
'thin_provisioning_support': True,
|
'thick_provisioning_support': False,
|
||||||
'total_volumes': 99,
|
'thin_provisioning_support': True,
|
||||||
'total_capacity_gb': 1000.00,
|
'total_volumes': 99,
|
||||||
'allocated_capacity_gb': 100,
|
'total_capacity_gb': 1000.00,
|
||||||
'max_over_subscription_ratio': 200.0,
|
'allocated_capacity_gb': 100,
|
||||||
|
'max_over_subscription_ratio': 200.0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
# Overwrite default attributes if there are some attributes set
|
# Overwrite default attributes if there are some attributes set
|
||||||
pool_info.update(attrs or {})
|
pool_info.update(attrs or {})
|
||||||
|
|
||||||
pool = fakes.FakeResource(None, pool_info, loaded=True)
|
pool = _stats.Pools(**pool_info)
|
||||||
|
|
||||||
return pool
|
return pool
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from osc_lib.cli import format_columns
|
||||||
|
|
||||||
from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
|
from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
|
||||||
from openstackclient.volume.v2 import volume_backend
|
from openstackclient.volume.v2 import volume_backend
|
||||||
|
|
||||||
@ -25,9 +27,8 @@ class TestShowVolumeCapability(volume_fakes.TestVolume):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
# Get a shortcut to the capability Mock
|
# Assign return value to capabilities mock
|
||||||
self.capability_mock = self.volume_client.capabilities
|
self.volume_sdk_client.get_capabilities.return_value = self.capability
|
||||||
self.capability_mock.get.return_value = self.capability
|
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = volume_backend.ShowCapability(self.app, None)
|
self.cmd = volume_backend.ShowCapability(self.app, None)
|
||||||
@ -68,7 +69,7 @@ class TestShowVolumeCapability(volume_fakes.TestVolume):
|
|||||||
self.assertIn(cap[0], capabilities)
|
self.assertIn(cap[0], capabilities)
|
||||||
|
|
||||||
# checking if proper call was made to get capabilities
|
# checking if proper call was made to get capabilities
|
||||||
self.capability_mock.get.assert_called_with(
|
self.volume_sdk_client.get_capabilities.assert_called_with(
|
||||||
'fake',
|
'fake',
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -82,8 +83,7 @@ class TestListVolumePool(volume_fakes.TestVolume):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.pool_mock = self.volume_client.pools
|
self.volume_sdk_client.backend_pools.return_value = [self.pools]
|
||||||
self.pool_mock.list.return_value = [self.pools]
|
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = volume_backend.ListPool(self.app, None)
|
self.cmd = volume_backend.ListPool(self.app, None)
|
||||||
@ -111,7 +111,7 @@ class TestListVolumePool(volume_fakes.TestVolume):
|
|||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
# checking if proper call was made to list pools
|
# checking if proper call was made to list pools
|
||||||
self.pool_mock.list.assert_called_with(
|
self.volume_sdk_client.backend_pools.assert_called_with(
|
||||||
detailed=False,
|
detailed=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -131,13 +131,7 @@ class TestListVolumePool(volume_fakes.TestVolume):
|
|||||||
|
|
||||||
expected_columns = [
|
expected_columns = [
|
||||||
'Name',
|
'Name',
|
||||||
'Protocol',
|
'Capabilities',
|
||||||
'Thick',
|
|
||||||
'Thin',
|
|
||||||
'Volumes',
|
|
||||||
'Capacity',
|
|
||||||
'Allocated',
|
|
||||||
'Max Over Ratio',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# confirming if all expected columns are present in the result.
|
# confirming if all expected columns are present in the result.
|
||||||
@ -146,19 +140,13 @@ class TestListVolumePool(volume_fakes.TestVolume):
|
|||||||
datalist = (
|
datalist = (
|
||||||
(
|
(
|
||||||
self.pools.name,
|
self.pools.name,
|
||||||
self.pools.storage_protocol,
|
format_columns.DictColumn(self.pools.capabilities),
|
||||||
self.pools.thick_provisioning_support,
|
|
||||||
self.pools.thin_provisioning_support,
|
|
||||||
self.pools.total_volumes,
|
|
||||||
self.pools.total_capacity_gb,
|
|
||||||
self.pools.allocated_capacity_gb,
|
|
||||||
self.pools.max_over_subscription_ratio,
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# confirming if all expected values are present in the result.
|
# confirming if all expected values are present in the result.
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
self.pool_mock.list.assert_called_with(
|
self.volume_sdk_client.backend_pools.assert_called_with(
|
||||||
detailed=True,
|
detailed=True,
|
||||||
)
|
)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
"""Storage backend action implementations"""
|
"""Storage backend action implementations"""
|
||||||
|
|
||||||
|
from osc_lib.cli import format_columns
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ class ShowCapability(command.Lister):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
volume_client = self.app.client_manager.volume
|
volume_client = self.app.client_manager.sdk_connection.volume
|
||||||
|
|
||||||
columns = [
|
columns = [
|
||||||
'Title',
|
'Title',
|
||||||
@ -42,7 +43,7 @@ class ShowCapability(command.Lister):
|
|||||||
'Description',
|
'Description',
|
||||||
]
|
]
|
||||||
|
|
||||||
data = volume_client.capabilities.get(parsed_args.host)
|
data = volume_client.get_capabilities(parsed_args.host)
|
||||||
|
|
||||||
# The get capabilities API is... interesting. We only want the names of
|
# The get capabilities API is... interesting. We only want the names of
|
||||||
# the capabilities that can set for a backend through extra specs, so
|
# the capabilities that can set for a backend through extra specs, so
|
||||||
@ -83,28 +84,17 @@ class ListPool(command.Lister):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
volume_client = self.app.client_manager.volume
|
volume_client = self.app.client_manager.sdk_connection.volume
|
||||||
|
|
||||||
if parsed_args.long:
|
if parsed_args.long:
|
||||||
columns = [
|
columns = [
|
||||||
'name',
|
'name',
|
||||||
'storage_protocol',
|
'capabilities',
|
||||||
'thick_provisioning_support',
|
|
||||||
'thin_provisioning_support',
|
|
||||||
'total_volumes',
|
|
||||||
'total_capacity_gb',
|
|
||||||
'allocated_capacity_gb',
|
|
||||||
'max_over_subscription_ratio',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
headers = [
|
headers = [
|
||||||
'Name',
|
'Name',
|
||||||
'Protocol',
|
'Capabilities',
|
||||||
'Thick',
|
|
||||||
'Thin',
|
|
||||||
'Volumes',
|
|
||||||
'Capacity',
|
|
||||||
'Allocated',
|
|
||||||
'Max Over Ratio',
|
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
columns = [
|
columns = [
|
||||||
@ -112,13 +102,15 @@ class ListPool(command.Lister):
|
|||||||
]
|
]
|
||||||
headers = columns
|
headers = columns
|
||||||
|
|
||||||
data = volume_client.pools.list(detailed=parsed_args.long)
|
data = volume_client.backend_pools(detailed=parsed_args.long)
|
||||||
|
formatters = {'capabilities': format_columns.DictColumn}
|
||||||
return (
|
return (
|
||||||
headers,
|
headers,
|
||||||
(
|
(
|
||||||
utils.get_item_properties(
|
utils.get_item_properties(
|
||||||
s,
|
s,
|
||||||
columns,
|
columns,
|
||||||
|
formatters=formatters,
|
||||||
)
|
)
|
||||||
for s in data
|
for s in data
|
||||||
),
|
),
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Migrated following volume backends commands to SDK.
|
||||||
|
|
||||||
|
* Capability Show
|
||||||
|
* Pool List
|
Loading…
x
Reference in New Issue
Block a user