bd05f693f2
In the config project,"/sysinv/sysinv/sysinv/sysinv/objects/" directory has many files imported into the "log" but not used. At the same time,I built a system of simplex with the latest ISO of the community. When the system was built,the code was changed. The system worked well and the other functional modules were not affected.So I agree we should delete them. Change-Id: I35f35ffdf1b9b00a97c259b47420dee3f1e4d939 Partial-Bug: #1844095 Signed-off-by: Hang Li <lihang0166@fiberhome.com>
77 lines
1.8 KiB
Python
77 lines
1.8 KiB
Python
#
|
|
# Copyright (c) 2016-2017 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
# coding=utf-8
|
|
#
|
|
|
|
from sysinv.db import api as db_api
|
|
from sysinv.objects import base
|
|
from sysinv.objects import utils
|
|
|
|
|
|
def get_peer_values(field, db_object):
|
|
"""Retrieves the list of peers associated with the cluster."""
|
|
peers = []
|
|
for entry in getattr(db_object, 'peers', []):
|
|
hosts = []
|
|
for ientry in getattr(entry, 'hosts', []):
|
|
hosts.append(ientry.hostname)
|
|
|
|
val = {'name': entry.name,
|
|
'status': entry.status,
|
|
'hosts': hosts,
|
|
'uuid': entry.uuid}
|
|
|
|
peers.append(val)
|
|
|
|
return peers
|
|
|
|
|
|
def get_tier_values(field, db_object):
|
|
"""Retrieves the list of storage tiers associated with the cluster."""
|
|
tiers = []
|
|
for entry in getattr(db_object, 'tiers', []):
|
|
val = {'name': entry.name,
|
|
'status': entry.status,
|
|
'uuid': entry.uuid}
|
|
|
|
tiers.append(val)
|
|
|
|
return tiers
|
|
|
|
|
|
class Cluster(base.SysinvObject):
|
|
# VERSION 1.0: Initial version
|
|
VERSION = '1.0'
|
|
|
|
dbapi = db_api.get_instance()
|
|
|
|
fields = {
|
|
'id': int,
|
|
'uuid': utils.str_or_none,
|
|
'cluster_uuid': utils.str_or_none,
|
|
'system_id': utils.int_or_none,
|
|
'type': utils.str_or_none,
|
|
'name': utils.str_or_none,
|
|
'capabilities': utils.dict_or_none,
|
|
'peers': list,
|
|
'tiers': list,
|
|
}
|
|
|
|
_foreign_fields = {
|
|
'peers': get_peer_values,
|
|
'tiers': get_tier_values
|
|
}
|
|
|
|
@base.remotable_classmethod
|
|
def get_by_uuid(cls, context, uuid):
|
|
return cls.dbapi.cluster_get(uuid)
|
|
|
|
def save_changes(self, context, updates):
|
|
self.dbapi.cluster_update(self.uuid, # pylint: disable=no-member
|
|
updates)
|