Volumes info collecting added
OSWL utilities updated. Code that supports collecting volumes info added. This patch is dependent on [1]. [1]: https://review.openstack.org/#/c/156643/ Change-Id: Ifcb44bf990d46ce79cdcc67d533f598146710ec2 Implements: blueprint openstack-workload-statistics
This commit is contained in:
parent
f4487769f5
commit
f34c22ff04
|
@ -89,6 +89,7 @@ OSWL_COLLECTORS_POLLING_INTERVAL:
|
|||
vm: 300
|
||||
flavor: 300
|
||||
image: 300
|
||||
volume: 300
|
||||
|
||||
# Action log send records per request
|
||||
STATS_SEND_COUNT: 100
|
||||
|
@ -112,6 +113,7 @@ COLLECTOR_RESP_TIMEOUT: 5
|
|||
OPENSTACK_API_VERSION:
|
||||
nova: "2"
|
||||
keystone: "v2.0"
|
||||
cinder: "1"
|
||||
|
||||
# proxy port for OpenStack info collector
|
||||
OPENSTACK_INFO_COLLECTOR_PROXY_PORT: 8888
|
||||
|
|
|
@ -18,6 +18,7 @@ import six
|
|||
|
||||
from contextlib import contextmanager
|
||||
|
||||
from cinderclient import client as cinder_client
|
||||
from novaclient import client as nova_client
|
||||
|
||||
from nailgun import consts
|
||||
|
@ -63,6 +64,22 @@ collected_components_attrs = {
|
|||
},
|
||||
"resource_manager_path": ["nova", "images"]
|
||||
},
|
||||
"volume": {
|
||||
"attr_names": {
|
||||
"id": ["id"],
|
||||
"availability_zone": ["availability_zone"],
|
||||
"encrypted_flag": ["encrypted"],
|
||||
"bootable_flag": ["bootable"],
|
||||
"status": ["status"],
|
||||
"volume_type": ["volume_type"],
|
||||
"size": ["size"],
|
||||
"host": ["os-vol-host-attr:host"],
|
||||
"snapshot_id": ["snapshot_id"],
|
||||
"attachments": ["attachments"],
|
||||
"tenant_id": ["os-vol-tenant-attr:tenant_id"],
|
||||
},
|
||||
"resource_manager_path": ["cinder", "volumes"]
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,6 +91,7 @@ class ClientProvider(object):
|
|||
def __init__(self, cluster):
|
||||
self.cluster = cluster
|
||||
self._nova = None
|
||||
self._cinder = None
|
||||
self._credentials = None
|
||||
|
||||
@property
|
||||
|
@ -87,6 +105,16 @@ class ClientProvider(object):
|
|||
|
||||
return self._nova
|
||||
|
||||
@property
|
||||
def cinder(self):
|
||||
if self._cinder is None:
|
||||
self._cinder = cinder_client.Client(
|
||||
settings.OPENSTACK_API_VERSION["cinder"],
|
||||
*self.credentials
|
||||
)
|
||||
|
||||
return self._cinder
|
||||
|
||||
@property
|
||||
def credentials(self):
|
||||
if self._credentials is None:
|
||||
|
@ -142,7 +170,8 @@ def get_info_from_os_resource_manager(client_provider, resource_name):
|
|||
inst_details = {}
|
||||
|
||||
for attr_name, attr_path in six.iteritems(resource["attr_names"]):
|
||||
obj_dict = inst.to_dict()
|
||||
obj_dict = \
|
||||
inst.to_dict() if hasattr(inst, "to_dict") else inst.__dict__
|
||||
inst_details[attr_name] = _get_value_from_nested_dict(
|
||||
obj_dict, attr_path
|
||||
)
|
||||
|
|
|
@ -593,7 +593,22 @@ class TestOSWLCollectingUtils(BaseTestCase):
|
|||
"created": "some_date_of_creation",
|
||||
"updated": "some_date_of_update"
|
||||
},
|
||||
}
|
||||
},
|
||||
"cinder": {
|
||||
"volumes": {
|
||||
"id": 3,
|
||||
"availability_zone": "test_availability_zone",
|
||||
"encrypted": False,
|
||||
"bootable": False,
|
||||
"status": "available",
|
||||
"volume_type": "test_volume",
|
||||
"size": 1,
|
||||
"os-vol-host-attr:host": "test-node",
|
||||
"snapshot_id": None,
|
||||
"attachments": "test_attachments",
|
||||
"os-vol-tenant-attr:tenant_id": "test_tenant",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
expected = {
|
||||
|
@ -640,7 +655,25 @@ class TestOSWLCollectingUtils(BaseTestCase):
|
|||
"updated_at": "some_date_of_update"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"volumes": {
|
||||
"regard_resource": "volume",
|
||||
"data": [
|
||||
{
|
||||
"id": 3,
|
||||
"availability_zone": "test_availability_zone",
|
||||
"encrypted_flag": False,
|
||||
"bootable_flag": False,
|
||||
"status": "available",
|
||||
"volume_type": "test_volume",
|
||||
"size": 1,
|
||||
"host": "test-node",
|
||||
"snapshot_id": None,
|
||||
"attachments": "test_attachments",
|
||||
"tenant_id": "test_tenant",
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
get_proxy_path = ("nailgun.statistics.utils.get_proxy_for_cluster")
|
||||
|
|
|
@ -29,4 +29,5 @@ keystonemiddleware>=1.2.0
|
|||
# we might still need keystone command
|
||||
python-keystoneclient>=0.11
|
||||
python-novaclient>=2.17.0
|
||||
python-cinderclient>=1.0.7
|
||||
networkx>=1.8
|
||||
|
|
Loading…
Reference in New Issue