Backport for nodes meta data adding into statistics
Meta data added for building stat reports on nodes info. Change-Id: I7c1b63bea2b1dc28e1ba68fdc31609d4356a5322 Closes-Bug: #1466064
This commit is contained in:
parent
fa8dec50f3
commit
e668ad65e4
@ -12,6 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
|
||||
from nailgun.db.sqlalchemy.models import NeutronConfig
|
||||
from nailgun.db.sqlalchemy.models import NovaNetworkConfig
|
||||
from nailgun.objects import ClusterCollection
|
||||
@ -194,6 +196,28 @@ class InstallationInfo(object):
|
||||
pass
|
||||
return result_attrs
|
||||
|
||||
def get_node_meta(self, node):
|
||||
meta = node.meta if node.meta is not None else {}
|
||||
to_copy = ['cpu', 'memory', 'disks']
|
||||
result = {}
|
||||
|
||||
for param in to_copy:
|
||||
result[param] = meta.get(param)
|
||||
|
||||
system = copy.deepcopy(meta.get('system', {}))
|
||||
system.pop('fqdn', None)
|
||||
system.pop('serial', None)
|
||||
result['system'] = system
|
||||
|
||||
interfaces = copy.deepcopy(meta.get('interfaces', []))
|
||||
result['interfaces'] = []
|
||||
for interface in interfaces:
|
||||
data = copy.deepcopy(interface)
|
||||
data.pop('mac')
|
||||
result['interfaces'].append(data)
|
||||
|
||||
return result
|
||||
|
||||
def get_nodes_info(self, nodes):
|
||||
nodes_info = []
|
||||
for node in nodes:
|
||||
@ -209,6 +233,7 @@ class InstallationInfo(object):
|
||||
|
||||
'manufacturer': node.manufacturer,
|
||||
'platform_name': node.platform_name,
|
||||
'meta': self.get_node_meta(node),
|
||||
|
||||
'pending_addition': node.pending_addition,
|
||||
'pending_deletion': node.pending_deletion,
|
||||
|
@ -210,9 +210,13 @@ class TestInstallationInfo(BaseTestCase):
|
||||
},
|
||||
nodes_kwargs=[
|
||||
{'status': consts.NODE_STATUSES.discover,
|
||||
'roles': ['controller', 'compute']},
|
||||
'roles': ['controller', 'compute'],
|
||||
'meta': {}},
|
||||
{'roles': [],
|
||||
'pending_roles': ['compute']}
|
||||
'pending_roles': ['compute'],
|
||||
'meta': {'cpu': {},
|
||||
'interfaces': [{'mac': 'x', 'name': 'eth0'}],
|
||||
'disks': [{'name': 'a', 'disk': 'a'}]}}
|
||||
]
|
||||
)
|
||||
self.env.make_bond_via_api(
|
||||
@ -234,6 +238,12 @@ class TestInstallationInfo(BaseTestCase):
|
||||
self.assertEquals(node_info['manufacturer'], node.manufacturer)
|
||||
self.assertEquals(node_info['platform_name'], node.platform_name)
|
||||
|
||||
self.assertIn('meta', node_info)
|
||||
for iface in node_info['meta']['interfaces']:
|
||||
self.assertNotIn('mac', iface)
|
||||
self.assertNotIn('fqdn', node_info['meta']['system'])
|
||||
self.assertNotIn('serial', node_info['meta']['system'])
|
||||
|
||||
self.assertEquals(node_info['pending_addition'],
|
||||
node.pending_addition)
|
||||
self.assertEquals(node_info['pending_deletion'],
|
||||
|
Loading…
Reference in New Issue
Block a user