Merge "Remove load references"
This commit is contained in:
@@ -433,8 +433,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
data_port_avail_status = state.get('data_ports_avail', None)
|
||||
host_action = (host_data.get('ihost_action') or "")
|
||||
host_action = host_action.rstrip('-')
|
||||
software_load = host_data['software_load']
|
||||
target_load = host_data['target_load']
|
||||
sw_version = host_data.get("sw_version")
|
||||
device_image_update = host_data['device_image_update']
|
||||
|
||||
future.work(sysinv.get_host_labels, self._platform_token,
|
||||
@@ -467,8 +466,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
avail_status,
|
||||
host_action,
|
||||
host_data['uptime'],
|
||||
software_load,
|
||||
target_load,
|
||||
sw_version,
|
||||
device_image_update,
|
||||
openstack_compute,
|
||||
openstack_control,
|
||||
@@ -570,8 +568,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
data_port_oper_state = state.get('data_ports_oper', None)
|
||||
data_port_avail_status = state.get('data_ports_avail', None)
|
||||
host_action = (host_data.get('ihost_action') or "").rstrip('-')
|
||||
software_load = host_data['software_load']
|
||||
target_load = host_data['target_load']
|
||||
sw_version = host_data.get("sw_version")
|
||||
device_image_update = host_data['device_image_update']
|
||||
|
||||
admin_state, oper_state, avail_status, nfvi_data \
|
||||
@@ -603,8 +600,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
avail_status,
|
||||
host_action,
|
||||
host_data['uptime'],
|
||||
software_load,
|
||||
target_load,
|
||||
sw_version,
|
||||
device_image_update,
|
||||
openstack_compute,
|
||||
openstack_control,
|
||||
@@ -3185,8 +3181,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
data_port_oper_state = state.get('data_ports_oper', None)
|
||||
data_port_avail_status = state.get('data_ports_avail', None)
|
||||
host_action = (host_data.get('ihost_action') or "").rstrip('-')
|
||||
software_load = host_data['software_load']
|
||||
target_load = host_data['target_load']
|
||||
sw_version = host_data.get("sw_version")
|
||||
device_image_update = host_data['device_image_update']
|
||||
|
||||
admin_state, oper_state, avail_status, nfvi_data \
|
||||
@@ -3218,8 +3213,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
avail_status,
|
||||
host_action,
|
||||
host_data['uptime'],
|
||||
software_load,
|
||||
target_load,
|
||||
sw_version,
|
||||
device_image_update,
|
||||
openstack_compute,
|
||||
openstack_control,
|
||||
@@ -3305,8 +3299,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
data_port_oper_state = state.get('data_ports_oper', None)
|
||||
data_port_avail_status = state.get('data_ports_avail', None)
|
||||
host_action = (host_data.get('ihost_action') or "").rstrip('-')
|
||||
software_load = host_data['software_load']
|
||||
target_load = host_data['target_load']
|
||||
sw_version = host_data.get("sw_version")
|
||||
device_image_update = host_data['device_image_update']
|
||||
|
||||
admin_state, oper_state, avail_status, nfvi_data \
|
||||
@@ -3338,8 +3331,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
avail_status,
|
||||
host_action,
|
||||
host_data['uptime'],
|
||||
software_load,
|
||||
target_load,
|
||||
sw_version,
|
||||
device_image_update,
|
||||
openstack_compute,
|
||||
openstack_control,
|
||||
@@ -3424,8 +3416,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
sub_function_avail_status = state.get('subfunction_avail', None)
|
||||
data_port_oper_state = state.get('data_ports_oper', None)
|
||||
data_port_avail_status = state.get('data_ports_avail', None)
|
||||
software_load = host_data['software_load']
|
||||
target_load = host_data['target_load']
|
||||
sw_version = host_data.get("sw_version")
|
||||
device_image_update = host_data['device_image_update']
|
||||
|
||||
admin_state, oper_state, avail_status, nfvi_data \
|
||||
@@ -3457,8 +3448,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
avail_status,
|
||||
host_data['ihost_action'],
|
||||
host_data['uptime'],
|
||||
software_load,
|
||||
target_load,
|
||||
sw_version,
|
||||
device_image_update,
|
||||
openstack_compute,
|
||||
openstack_control,
|
||||
@@ -3542,8 +3532,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
sub_function_avail_status = state.get('subfunction_avail', None)
|
||||
data_port_oper_state = state.get('data_ports_oper', None)
|
||||
data_port_avail_status = state.get('data_ports_avail', None)
|
||||
software_load = host_data['software_load']
|
||||
target_load = host_data['target_load']
|
||||
sw_version = host_data.get("sw_version")
|
||||
device_image_update = host_data['device_image_update']
|
||||
|
||||
admin_state, oper_state, avail_status, nfvi_data \
|
||||
@@ -3575,8 +3564,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
avail_status,
|
||||
host_data['ihost_action'],
|
||||
host_data['uptime'],
|
||||
software_load,
|
||||
target_load,
|
||||
sw_version,
|
||||
device_image_update,
|
||||
openstack_compute,
|
||||
openstack_control,
|
||||
@@ -3713,8 +3701,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
sub_function_avail_status = state.get('subfunction_avail', None)
|
||||
data_port_oper_state = state.get('data_ports_oper', None)
|
||||
data_port_avail_status = state.get('data_ports_avail', None)
|
||||
software_load = host_data['software_load']
|
||||
target_load = host_data['target_load']
|
||||
sw_version = host_data.get("sw_version")
|
||||
device_image_update = host_data['device_image_update']
|
||||
|
||||
admin_state, oper_state, avail_status, nfvi_data \
|
||||
@@ -3746,8 +3733,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
avail_status,
|
||||
host_data['ihost_action'],
|
||||
host_data['uptime'],
|
||||
software_load,
|
||||
target_load,
|
||||
sw_version,
|
||||
device_image_update,
|
||||
openstack_compute,
|
||||
openstack_control,
|
||||
|
File diff suppressed because one or more lines are too long
@@ -285,8 +285,7 @@ class SwUpdateStrategyTestCase(testcase.NFVTestCase):
|
||||
admin_state=nfvi.objects.v1.HOST_ADMIN_STATE.UNLOCKED,
|
||||
oper_state=nfvi.objects.v1.HOST_OPER_STATE.ENABLED,
|
||||
avail_status=nfvi.objects.v1.HOST_AVAIL_STATUS.AVAILABLE,
|
||||
software_load='12.01',
|
||||
target_load='12.01',
|
||||
sw_version='12.01',
|
||||
openstack_installed=True):
|
||||
"""
|
||||
Create a host
|
||||
@@ -321,8 +320,7 @@ class SwUpdateStrategyTestCase(testcase.NFVTestCase):
|
||||
oper_state=oper_state,
|
||||
avail_status=avail_status,
|
||||
action=nfvi.objects.v1.HOST_ACTION.NONE,
|
||||
software_load=software_load,
|
||||
target_load=target_load,
|
||||
sw_version=sw_version,
|
||||
openstack_compute=openstack_compute,
|
||||
openstack_control=openstack_control,
|
||||
remote_storage=False,
|
||||
|
@@ -34,22 +34,22 @@ class TestNFVDatabaseUpgrade(testcase.NFVTestCase):
|
||||
config = dict()
|
||||
config['database_dir'] = self.db_dir
|
||||
database.database_initialize(config)
|
||||
data_input = "%s/nfv_vim_db_stx_19.12" % root_dir
|
||||
data_output = "%s/nfv_vim_db_stx_19.12.dump" % root_dir
|
||||
data_input = "%s/nfv_vim_db_stx_25.09" % root_dir
|
||||
data_output = "%s/nfv_vim_db_stx_25.09.dump" % root_dir
|
||||
database.database_load_data(data_input)
|
||||
database.database_dump_data(data_output)
|
||||
database.database_finalize()
|
||||
|
||||
def test_nfv_vim_database_upgrade_from_19_12(self):
|
||||
def test_nfv_vim_database_upgrade_from_25_09(self):
|
||||
"""
|
||||
Test VIM database upgrades from stx 19_12
|
||||
Test VIM database upgrades from stx 25_09
|
||||
"""
|
||||
root_dir = os.environ['VIRTUAL_ENV']
|
||||
# stage some old data
|
||||
devnull = open(os.devnull, 'w')
|
||||
try:
|
||||
vim_cmd = ("nfv-vim-manage db-load-data -d %s "
|
||||
"-f %s/nfv_vim_db_stx_19.12" % (self.db_dir, root_dir))
|
||||
"-f %s/nfv_vim_db_stx_25.09" % (self.db_dir, root_dir))
|
||||
|
||||
subprocess.check_call([vim_cmd], shell=True, stderr=devnull)
|
||||
except subprocess.CalledProcessError:
|
||||
|
@@ -188,8 +188,7 @@ class TestInstance(testcase.NFVTestCase):
|
||||
def create_host(self, host_name,
|
||||
cpe=False,
|
||||
admin_state=nfvi.objects.v1.HOST_ADMIN_STATE.UNLOCKED,
|
||||
software_load='12.01',
|
||||
target_load='12.01'):
|
||||
sw_version='12.01'):
|
||||
"""
|
||||
Create a host
|
||||
"""
|
||||
@@ -213,8 +212,7 @@ class TestInstance(testcase.NFVTestCase):
|
||||
oper_state=nfvi.objects.v1.HOST_OPER_STATE.ENABLED,
|
||||
avail_status=nfvi.objects.v1.HOST_AVAIL_STATUS.AVAILABLE,
|
||||
action=nfvi.objects.v1.HOST_ACTION.NONE,
|
||||
software_load=software_load,
|
||||
target_load=target_load,
|
||||
sw_version=sw_version,
|
||||
openstack_compute=False,
|
||||
openstack_control=False,
|
||||
remote_storage=False,
|
||||
|
@@ -64,10 +64,10 @@ def database_host_add(host_obj):
|
||||
"""
|
||||
db = database_get()
|
||||
session = db.session()
|
||||
query = session.query(model.Host_v7).filter(model.Host_v7.name == host_obj.name)
|
||||
query = session.query(model.Host_v8).filter(model.Host_v8.name == host_obj.name)
|
||||
host = query.first()
|
||||
if not host:
|
||||
host = model.Host_v7()
|
||||
host = model.Host_v8()
|
||||
host.uuid = host_obj.uuid
|
||||
host.name = host_obj.name
|
||||
host.personality = host_obj.personality
|
||||
@@ -98,8 +98,8 @@ def database_host_delete(host_name):
|
||||
"""
|
||||
db = database_get()
|
||||
session = db.session()
|
||||
query = session.query(model.Host_v7)
|
||||
query.filter(model.Host_v7.name == host_name).delete()
|
||||
query = session.query(model.Host_v8)
|
||||
query.filter(model.Host_v8.name == host_name).delete()
|
||||
session.commit()
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ def database_host_get_list():
|
||||
"""
|
||||
db = database_get()
|
||||
session = db.session()
|
||||
query = session.query(model.Host_v7)
|
||||
query = session.query(model.Host_v8)
|
||||
|
||||
host_objs = list()
|
||||
for host in query.all():
|
||||
@@ -122,8 +122,7 @@ def database_host_get_list():
|
||||
nfvi_host_data['avail_status'],
|
||||
nfvi_host_data['action'],
|
||||
nfvi_host_data['uptime'],
|
||||
nfvi_host_data['software_load'],
|
||||
nfvi_host_data['target_load'],
|
||||
nfvi_host_data['sw_version'],
|
||||
nfvi_host_data['device_image_update'],
|
||||
nfvi_host_data['openstack_compute'],
|
||||
nfvi_host_data['openstack_control'],
|
||||
|
@@ -12,6 +12,22 @@ from nfv_common import debug
|
||||
DLOG = debug.debug_get_logger('nfv_vim.database')
|
||||
|
||||
|
||||
def _migrate_hosts_v7_to_v8(session, hosts_v7, hosts_v8):
|
||||
"""
|
||||
Replace software_load, target_load with sw_version
|
||||
"""
|
||||
if 0 == len(hosts_v8):
|
||||
for host_v7 in hosts_v7:
|
||||
host_v8 = model.Host_v8()
|
||||
host_v8.data = host_v7.data
|
||||
nfvi_host_data = json.loads(host_v7.nfvi_host_data)
|
||||
nfvi_host_data['sw_version'] = None
|
||||
nfvi_host_data.pop('software_load', None)
|
||||
nfvi_host_data.pop('target_load', None)
|
||||
host_v8.nfvi_host_data = json.dumps(nfvi_host_data)
|
||||
session.add(host_v8)
|
||||
|
||||
|
||||
def _migrate_hosts_v6_to_v7(session, hosts_v6, hosts_v7):
|
||||
"""
|
||||
Migrate host_v6 table to host_v7 table
|
||||
@@ -37,3 +53,10 @@ def migrate_tables(session, table_names):
|
||||
hosts_v7 = hosts_v7_query.all()
|
||||
_migrate_hosts_v6_to_v7(session, hosts_v6, hosts_v7)
|
||||
hosts_v6_query.delete()
|
||||
if 'hosts_v7' in table_names and 'hosts_v8' in table_names:
|
||||
hosts_v7_query = session.query(model.Host_v7)
|
||||
hosts_v7 = hosts_v7_query.all()
|
||||
hosts_v8_query = session.query(model.Host_v8)
|
||||
hosts_v8 = hosts_v8_query.all()
|
||||
_migrate_hosts_v7_to_v8(session, hosts_v7, hosts_v8)
|
||||
hosts_v7_query.delete()
|
||||
|
@@ -7,6 +7,7 @@ from nfv_vim.database.model._base import Base # noqa: F401
|
||||
from nfv_vim.database.model._base import lookup_class_by_table # noqa: F401
|
||||
from nfv_vim.database.model._host import Host_v6 # noqa: F401
|
||||
from nfv_vim.database.model._host import Host_v7 # noqa: F401
|
||||
from nfv_vim.database.model._host import Host_v8 # noqa: F401
|
||||
from nfv_vim.database.model._host_aggregate import HostAggregate # noqa: F401
|
||||
from nfv_vim.database.model._host_group import HostGroup # noqa: F401
|
||||
from nfv_vim.database.model._hypervisor import Hypervisor # noqa: F401
|
||||
|
@@ -11,6 +11,31 @@ from nfv_vim.database.model._base import AsDictMixin
|
||||
from nfv_vim.database.model._base import Base
|
||||
|
||||
|
||||
class Host_v8(AsDictMixin, Base):
|
||||
"""
|
||||
Host Database Table Entry
|
||||
Note: Changes are only in nfvi_host_data to replace software_load and target_load with sw_version.
|
||||
"""
|
||||
__tablename__ = 'hosts_v8'
|
||||
|
||||
uuid = Column(String(64), nullable=False, primary_key=True)
|
||||
name = Column(String(64), nullable=False)
|
||||
personality = Column(String(64), nullable=False)
|
||||
state = Column(String(64), nullable=False)
|
||||
action = Column(String(64), nullable=False)
|
||||
upgrade_inprogress = Column(Boolean, nullable=False)
|
||||
recover_instances = Column(Boolean, nullable=False)
|
||||
uptime = Column(String(64), nullable=False)
|
||||
elapsed_time_in_state = Column(String(64), nullable=False)
|
||||
host_services_locked = Column(Boolean, nullable=False)
|
||||
nfvi_host_data = Column(String(2048), nullable=False)
|
||||
|
||||
def __repr__(self):
|
||||
return "<Host(%r, %r, %r, %r, %r %r)>" % (self.uuid, self.name,
|
||||
self.personality, self.state,
|
||||
self.action, self.uptime)
|
||||
|
||||
|
||||
class Host_v7(AsDictMixin, Base):
|
||||
"""
|
||||
Host Database Table Entry
|
||||
|
@@ -106,7 +106,7 @@ class Host(ObjectData):
|
||||
NFVI Host Object
|
||||
"""
|
||||
def __init__(self, uuid, name, personality, admin_state, oper_state,
|
||||
avail_status, action, uptime, software_load, target_load,
|
||||
avail_status, action, uptime, sw_version,
|
||||
device_image_update=None,
|
||||
openstack_compute=False,
|
||||
openstack_control=False,
|
||||
@@ -119,8 +119,7 @@ class Host(ObjectData):
|
||||
avail_status=avail_status,
|
||||
action=action,
|
||||
uptime=uptime,
|
||||
software_load=software_load,
|
||||
target_load=target_load,
|
||||
sw_version=sw_version,
|
||||
device_image_update=device_image_update,
|
||||
openstack_compute=openstack_compute,
|
||||
openstack_control=openstack_control,
|
||||
|
@@ -274,18 +274,11 @@ class Host(ObjectData):
|
||||
return self._upgrade_inprogress
|
||||
|
||||
@property
|
||||
def software_load(self):
|
||||
def sw_version(self):
|
||||
"""
|
||||
Returns software_load running on this host
|
||||
Returns sw_version running on this host
|
||||
"""
|
||||
return self._nfvi_host.software_load
|
||||
|
||||
@property
|
||||
def target_load(self):
|
||||
"""
|
||||
Returns target_load for this host
|
||||
"""
|
||||
return self._nfvi_host.target_load
|
||||
return self._nfvi_host.sw_version
|
||||
|
||||
@property
|
||||
def openstack_compute(self):
|
||||
|
@@ -133,7 +133,7 @@ deps = {[nfv]deps}
|
||||
stestr
|
||||
testtools
|
||||
setenv = PYTHONDONTWRITEBYTECODE=True
|
||||
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_19.12 {envdir}/
|
||||
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_25.09 {envdir}/
|
||||
stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}'
|
||||
stestr slowest
|
||||
|
||||
@@ -147,7 +147,7 @@ deps = {[nfv]deps}
|
||||
setenv =
|
||||
PYTHON=coverage run --parallel-mode
|
||||
PYTHONDONTWRITEBYTECODE=True
|
||||
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_19.12 {envdir}/
|
||||
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_25.09 {envdir}/
|
||||
coverage erase
|
||||
stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}'
|
||||
coverage combine
|
||||
|
Reference in New Issue
Block a user