Host Inventory Panel

Enable panel, forms (modal windows) and tabs inside
of the Host inventory panel

Depends-on: https://review.openstack.org/#/c/591103/

Change-Id: Ie91ca12223d745663cdf1ebff6d6b1798d630635
This commit is contained in:
Eddie Ramirez 2018-08-10 16:35:19 -07:00
parent a4512acaad
commit 0630690279
37 changed files with 480 additions and 438 deletions

View File

@ -21,7 +21,7 @@ from starlingx_dashboard.api import base
from starlingx_dashboard.api import dc_manager
from starlingx_dashboard.api import sysinv
from starlingx_dashboard.api import vim
#from starlingx_dashboard.api import patch
from starlingx_dashboard.api import patch
# TODO (ediardo): cleanup the imports below
__all__ = [

View File

@ -7,4 +7,53 @@
from openstack_dashboard.api.nova import *
def server_group_create(request, **kwargs):
return novaclient(request).server_groups.create(**kwargs)
return novaclient(request).server_groups.create(**kwargs)
# WRS: Nova extension for provider network.
def provider_network_get(request, providernet_id):
return wrs_providernets.ProviderNetsManager(novaclient(request)).get(
providernet_id)
# WRS: Nova extension for device usage
class DeviceUsage(base.APIResourceWrapper):
"""Wrapper for Inventory Device Usage
"""
_attrs = ['device_id', 'device_name', 'vendor_id',
'pci_vfs_configured', 'pci_vfs_used',
'pci_pfs_configured', 'pci_pfs_used']
def get_device_usage_list(request):
usages = wrs_pci.PciDevicesManager(novaclient(request)).list()
return [DeviceUsage(n) for n in usages]
def get_device_usage(request, device_id):
if device_id is None:
raise nova_exceptions.ResourceNotFound
usage = wrs_pci.PciDevicesManager(novaclient(request)).list(
device_id=device_id)
return DeviceUsage(usage[0])
# WRS: Nova extension for detail device usage
class DetailUsage(base.APIResourceWrapper):
"""Wrapper for Inventory Device Usage
"""
_attrs = ['host',
'pci_vfs_configured', 'pci_vfs_used',
'pci_pfs_configured', 'pci_pfs_used']
def get_detail_usage(request, device_id):
usages = wrs_pci.PciDevicesManager(novaclient(request)).get(
device_id)
return [DetailUsage(n) for n in usages]
def can_set_quotas():
features = getattr(settings, 'OPENSTACK_HYPERVISOR_FEATURES', {})
return features.get('enable_quotas', True)

View File

@ -14,8 +14,8 @@
# Copyright (c) 2014 Wind River Systems, Inc.
#
from openstack_dashboard.api.rest import dc_manager
from openstack_dashboard.api.rest import sysinv
from starlingx_dashboard.api.rest import dc_manager
from starlingx_dashboard.api.rest import sysinv
__all__ = [

View File

@ -17,9 +17,9 @@ import logging
from django.views import generic
from openstack_dashboard.api import dc_manager
from openstack_dashboard.api.rest import urls
from openstack_dashboard.api.rest import utils as rest_utils
from starlingx_dashboard.api import dc_manager
LOG = logging.getLogger(__name__)

View File

@ -18,7 +18,7 @@ from django.views import generic
from openstack_dashboard.api.rest import urls
from openstack_dashboard.api.rest import utils as rest_utils
from openstack_dashboard.api import sysinv
from starlingx_dashboard.api import sysinv
@urls.register

View File

@ -12,8 +12,8 @@ from django.utils.translation import ugettext_lazy as _
from horizon import tables
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.cpu_functions \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.cpu_functions \
import utils as cpufunctions_utils
LOG = logging.getLogger(__name__)
@ -45,7 +45,7 @@ class CreateCpuProfile(tables.LinkAction):
return reverse(self.url, args=(host_id,))
def allowed(self, request, cpufunction=None):
return not api.sysinv.is_system_mode_simplex(request)
return not stx_api.sysinv.is_system_mode_simplex(request)
def get_function_name(datum):

View File

@ -15,12 +15,12 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import forms
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.cpu_functions.forms \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.cpu_functions.forms \
import AddCpuProfile
from openstack_dashboard.dashboards.admin.inventory.cpu_functions.forms \
from starlingx_dashboard.dashboards.admin.inventory.cpu_functions.forms \
import UpdateCpuFunctions
from openstack_dashboard.dashboards.admin.inventory.cpu_functions \
from starlingx_dashboard.dashboards.admin.inventory.cpu_functions \
import utils as cpufunctions_utils
LOG = logging.getLogger(__name__)
@ -40,9 +40,9 @@ class UpdateCpuFunctionsView(forms.ModalFormView):
if not hasattr(self, "_object"):
host_id = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, host_id)
host.nodes = api.sysinv.host_node_list(self.request, host.uuid)
host.cpus = api.sysinv.host_cpu_list(self.request, host.uuid)
host = stx_api.sysinv.host_get(self.request, host_id)
host.nodes = stx_api.sysinv.host_node_list(self.request, host.uuid)
host.cpus = stx_api.sysinv.host_cpu_list(self.request, host.uuid)
icpu_utils.restructure_host_cpu_data(host)
self._object = host
self._object.host_id = host_id
@ -165,9 +165,9 @@ class AddCpuProfileView(forms.ModalFormView):
if not hasattr(self, "_host"):
host_id = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, host_id)
host.nodes = api.sysinv.host_node_list(self.request, host.uuid)
host.cpus = api.sysinv.host_cpu_list(self.request, host.uuid)
host = stx_api.sysinv.host_get(self.request, host_id)
host.nodes = stx_api.sysinv.host_node_list(self.request, host.uuid)
host.cpus = stx_api.sysinv.host_cpu_list(self.request, host.uuid)
icpu_utils.restructure_host_cpu_data(host)
except Exception:
redirect = reverse('horizon:admin:inventory:index')

View File

@ -17,9 +17,10 @@ from horizon import tables
from horizon.utils import memoized
from horizon import views
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.devices.forms import \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.devices.forms import \
UpdateDevice
from openstack_dashboard.dashboards.admin.inventory.devices.tables import \
from starlingx_dashboard.dashboards.admin.inventory.devices.tables import \
UsageTable
LOG = logging.getLogger(__name__)
@ -40,7 +41,7 @@ class UpdateView(forms.ModalFormView):
device_uuid = self.kwargs['device_uuid']
host_id = self.kwargs['host_id']
try:
self._object = api.sysinv.host_device_get(self.request,
self._object = stx_api.sysinv.host_device_get(self.request,
device_uuid)
self._object.host_id = host_id
except Exception:
@ -83,7 +84,7 @@ class DetailView(views.HorizonTemplateView):
device_uuid = self.kwargs['device_uuid']
host_id = self.kwargs['host_id']
try:
self._object = api.sysinv.host_device_get(self.request,
self._object = stx_apl.sysinv.host_device_get(self.request,
device_uuid)
self._object.host_id = host_id
@ -98,7 +99,7 @@ class DetailView(views.HorizonTemplateView):
@memoized.memoized_method
def get_hostname(self, host_uuid):
try:
host = api.sysinv.host_get(self.request, host_uuid)
host = stx_apl.sysinv.host_get(self.request, host_uuid)
except Exception:
host = {}
msg = _('Unable to retrieve hostname details.')
@ -137,7 +138,7 @@ class UsageView(tables.MultiTableView):
if not hasattr(self, "_detail_object"):
dev_id = self.kwargs['device_id']
try:
_object = api.nova.get_detail_usage(self.request, dev_id)
_object = stx_apl.nova.get_detail_usage(self.request, dev_id)
_object.sort(key=lambda f: (f.host))
id = 0
for u in _object:

View File

@ -24,7 +24,7 @@ import netaddr
from horizon import forms
from horizon import messages
from openstack_dashboard import api
from starlingx_dashboard import api as stx_api
LOG = logging.getLogger(__name__)
@ -50,7 +50,7 @@ class CreateAddress(forms.SelfHandlingForm):
body = {'interface_uuid': data['interface_id'],
'address': str(ip_address.ip),
'prefix': ip_address.prefixlen}
address = api.sysinv.address_create(request, **body)
address = stx_api.sysinv.address_create(request, **body)
msg = (_('Address %(address)s/%(prefix)s was '
'successfully created') % body)
messages.success(request, msg)

View File

@ -20,7 +20,7 @@ from django.utils.translation import ungettext_lazy
from horizon import exceptions
from horizon import tables
from openstack_dashboard import api
from starlingx_dashboard import api as stx_api
LOG = logging.getLogger(__name__)
@ -52,7 +52,7 @@ class DeleteAddress(tables.DeleteAction):
def delete(self, request, obj_id):
try:
api.sysinv.address_delete(request, obj_id)
stx_api.sysinv.address_delete(request, obj_id)
except Exception:
exceptions.handle(request, redirect=self.get_redirect_url())
@ -115,7 +115,7 @@ class AddressTable(tables.DataTable):
if not hasattr(self, "_interface"):
try:
interface_id = self.kwargs["interface_id"]
self._interface = api.sysinv.host_interface_get(
self._interface = stx_api.sysinv.host_interface_get(
self.request, interface_id)
except Exception:
redirect = reverse(self.failure_url,

View File

@ -18,7 +18,7 @@ import logging
from django.core.urlresolvers import reverse # noqa
from horizon import forms
from openstack_dashboard.dashboards.admin.inventory.interfaces.address import \
from starlingx_dashboard.dashboards.admin.inventory.interfaces.address import \
forms as address_forms
LOG = logging.getLogger(__name__)

View File

@ -24,7 +24,7 @@ import netaddr
from horizon import forms
from horizon import messages
from openstack_dashboard import api
from starlingx_dashboard import api as stx_api
LOG = logging.getLogger(__name__)
@ -67,7 +67,7 @@ class CreateRoute(forms.SelfHandlingForm):
'prefix': ip_network.prefixlen,
'gateway': data['gateway'],
'metric': data['metric']}
route = api.sysinv.route_create(request, **body)
route = stx_api.sysinv.route_create(request, **body)
msg = (_('Route to %(network)s/%(prefix)s via %(gateway)s was '
'successfully created') % body)
messages.success(request, msg)

View File

@ -20,7 +20,7 @@ from django.utils.translation import ungettext_lazy
from horizon import exceptions
from horizon import tables
from openstack_dashboard import api
from starlingx_dashboard import api as stx_api
LOG = logging.getLogger(__name__)
@ -50,7 +50,7 @@ class DeleteRoute(tables.DeleteAction):
def delete(self, request, obj_id):
try:
api.sysinv.route_delete(request, obj_id)
stx_api.sysinv.route_delete(request, obj_id)
except Exception:
exceptions.handle(request, redirect=self.get_redirect_url())
@ -113,7 +113,7 @@ class RouteTable(tables.DataTable):
if not hasattr(self, "_interface"):
try:
interface_id = self.kwargs["interface_id"]
self._interface = api.sysinv.host_interface_get(
self._interface = stx_api.sysinv.host_interface_get(
self.request, interface_id)
except Exception:
redirect = reverse(self.failure_url,

View File

@ -18,7 +18,7 @@ import logging
from django.core.urlresolvers import reverse # noqa
from horizon import forms
from openstack_dashboard.dashboards.admin.inventory.interfaces.route import \
from starlingx_dashboard.dashboards.admin.inventory.interfaces.route import \
forms as route_forms
LOG = logging.getLogger(__name__)

View File

@ -17,16 +17,16 @@ from horizon import forms
from horizon import tables
from horizon.utils import memoized
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.interfaces.address import \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.interfaces.address import \
tables as address_tables
from openstack_dashboard.dashboards.admin.inventory.interfaces.forms import \
from starlingx_dashboard.dashboards.admin.inventory.interfaces.forms import \
AddInterface
from openstack_dashboard.dashboards.admin.inventory.interfaces.forms import \
from starlingx_dashboard.dashboards.admin.inventory.interfaces.forms import \
AddInterfaceProfile
from openstack_dashboard.dashboards.admin.inventory.interfaces.forms import \
from starlingx_dashboard.dashboards.admin.inventory.interfaces.forms import \
UpdateInterface
from openstack_dashboard.dashboards.admin.inventory.interfaces.route import \
from starlingx_dashboard.dashboards.admin.inventory.interfaces.route import \
tables as route_tables
LOG = logging.getLogger(__name__)
@ -40,22 +40,22 @@ def get_port_data(request, host_id, interface=None):
if not interface:
# Create case, host id is not UUID. Need to get the UUID in order
# to retrieve the ports for this host
host = api.sysinv.host_get(request, host_id)
host = stx_api.sysinv.host_get(request, host_id)
host_id = host.uuid
else:
if not interface.uses:
show_all_ports = False
port_list = \
api.sysinv.host_port_list(request, host_id)
stx_api.sysinv.host_port_list(request, host_id)
if show_all_ports:
# This is either a create or edit non-default interface
# operation. Get the list of available ports and their
# neighbours
neighbour_list = \
api.sysinv.host_lldpneighbour_list(request, host_id)
interface_list = api.sysinv.host_interface_list(request, host_id)
stx_api.sysinv.host_lldpneighbour_list(request, host_id)
interface_list = stx_api.sysinv.host_interface_list(request, host_id)
for p in port_list:
port_info = "%s (%s, %s, " % (p.get_port_display_name(),
@ -100,7 +100,7 @@ def get_port_data(request, host_id, interface=None):
port_info += " - bootif"
# Retrieve the neighbours for the port
neighbours = \
api.sysinv.port_lldpneighbour_list(request, p.uuid)
stx_api.sysinv.port_lldpneighbour_list(request, p.uuid)
neighbour_info = []
if neighbours:
for n in neighbours:
@ -146,7 +146,7 @@ class AddInterfaceView(forms.ModalFormView):
initial = super(AddInterfaceView, self).get_initial()
initial['host_id'] = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, initial['host_id'])
host = stx_api.sysinv.host_get(self.request, initial['host_id'])
except Exception:
exceptions.handle(self.request, _('Unable to retrieve host.'))
initial['ihost_uuid'] = host.uuid
@ -154,8 +154,8 @@ class AddInterfaceView(forms.ModalFormView):
# get SDN configuration status
try:
sdn_enabled = api.sysinv.get_sdn_enabled(self.request)
sdn_l3_mode = api.sysinv.get_sdn_l3_mode_enabled(self.request)
sdn_enabled = stx_api.sysinv.get_sdn_enabled(self.request)
sdn_l3_mode = stx_api.sysinv.get_sdn_l3_mode_enabled(self.request)
except Exception:
exceptions.handle(self.request,
_('Unable to retrieve SDN configuration.'))
@ -182,14 +182,14 @@ class AddInterfaceProfileView(forms.ModalFormView):
if not hasattr(self, "_host"):
host_id = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, host_id)
host = stx_api.sysinv.host_get(self.request, host_id)
all_ports = api.sysinv.host_port_list(self.request, host.uuid)
all_ports = stx_api.sysinv.host_port_list(self.request, host.uuid)
host.ports = [p for p in all_ports if p.interface_uuid]
for p in host.ports:
p.namedisplay = p.get_port_display_name()
host.interfaces = api.sysinv.host_interface_list(self.request,
host.interfaces = stx_api.sysinv.host_interface_list(self.request,
host.uuid)
for i in host.interfaces:
i.ports = [p.get_port_display_name()
@ -234,7 +234,7 @@ class UpdateView(forms.ModalFormView):
interface_id = self.kwargs['interface_id']
host_id = self.kwargs['host_id']
try:
self._object = api.sysinv.host_interface_get(self.request,
self._object = stx_api.sysinv.host_interface_get(self.request,
interface_id)
self._object.host_id = host_id
@ -267,15 +267,15 @@ class UpdateView(forms.ModalFormView):
for pn in interface.providernetworks.split(","):
providernetworks.append(str(pn))
try:
host = api.sysinv.host_get(self.request, interface.host_id)
host = stx_api.sysinv.host_get(self.request, interface.host_id)
except Exception:
exceptions.handle(self.request, _('Unable to retrieve host.'))
# get SDN configuration status
try:
sdn_enabled, sdn_l3_mode = False, False
sdn_enabled = api.sysinv.get_sdn_enabled(self.request)
sdn_l3_mode = api.sysinv.get_sdn_l3_mode_enabled(self.request)
sdn_enabled = stx_api.sysinv.get_sdn_enabled(self.request)
sdn_l3_mode = stx_api.sysinv.get_sdn_l3_mode_enabled(self.request)
except Exception:
exceptions.handle(self.request,
_('Unable to retrieve SDN configuration.'))
@ -315,7 +315,7 @@ class DetailView(tables.MultiTableView):
def get_addresses_data(self):
try:
interface_id = self.kwargs['interface_id']
addresses = api.sysinv.address_list_by_interface(
addresses = stx_api.sysinv.address_list_by_interface(
self.request, interface_id=interface_id)
addresses.sort(key=lambda f: (f.address, f.prefix))
except Exception:
@ -327,7 +327,7 @@ class DetailView(tables.MultiTableView):
def get_routes_data(self):
try:
interface_id = self.kwargs['interface_id']
routes = api.sysinv.route_list_by_interface(
routes = stx_api.sysinv.route_list_by_interface(
self.request, interface_id=interface_id)
routes.sort(key=lambda f: (f.network, f.prefix))
except Exception:
@ -337,7 +337,7 @@ class DetailView(tables.MultiTableView):
return routes
def _get_address_pools(self):
pools = api.sysinv.address_pool_list(self.request)
pools = stx_api.sysinv.address_pool_list(self.request)
return {p.uuid: p for p in pools}
def _add_pool_names(self, interface):
@ -354,7 +354,7 @@ class DetailView(tables.MultiTableView):
interface_id = self.kwargs['interface_id']
host_id = self.kwargs['host_id']
try:
self._object = api.sysinv.host_interface_get(self.request,
self._object = stx_api.sysinv.host_interface_get(self.request,
interface_id)
self._object.host_id = host_id
self._object = self._add_pool_names(self._object)
@ -369,7 +369,7 @@ class DetailView(tables.MultiTableView):
@memoized.memoized_method
def get_hostname(self, host_uuid):
try:
host = api.sysinv.host_get(self.request, host_uuid)
host = stx_api.sysinv.host_get(self.request, host_uuid)
except Exception:
host = {}
msg = _('Unable to retrieve hostname details.')

View File

@ -13,10 +13,10 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import forms
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.memorys.forms import \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.memorys.forms import \
AddMemoryProfile
from openstack_dashboard.dashboards.admin.inventory.memorys.forms import \
from starlingx_dashboard.dashboards.admin.inventory.memorys.forms import \
UpdateMemory
LOG = logging.getLogger(__name__)
@ -36,11 +36,11 @@ class UpdateMemoryView(forms.ModalFormView):
if not hasattr(self, "_object"):
host_id = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, host_id)
host.memorys = api.sysinv.host_memory_list(self.request,
host = stx_api.sysinv.host_get(self.request, host_id)
host.memorys = stx_api.sysinv.host_memory_list(self.request,
host.uuid)
host.nodes = \
api.sysinv.host_node_list(self.request, host.uuid)
stx_api.sysinv.host_node_list(self.request, host.uuid)
self._object = host
self._object.host_id = host_id
except Exception as e:
@ -83,14 +83,14 @@ class AddMemoryProfileView(forms.ModalFormView):
if not hasattr(self, "_host"):
host_id = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, host_id)
host.nodes = api.sysinv.host_node_list(self.request, host.uuid)
host = stx_api.sysinv.host_get(self.request, host_id)
host.nodes = stx_api.sysinv.host_node_list(self.request, host.uuid)
host.memory = \
api.sysinv.host_memory_list(self.request, host.uuid)
stx_api.sysinv.host_memory_list(self.request, host.uuid)
numa_node_tuple_list = []
for m in host.memory:
node = api.sysinv.host_node_get(self.request, m.inode_uuid)
node = stx_api.sysinv.host_node_get(self.request, m.inode_uuid)
numa_node_tuple_list.append((node.numa_node, m))
host.numa_nodes = numa_node_tuple_list

View File

@ -16,8 +16,8 @@ from horizon import exceptions
from horizon import forms
from horizon.utils import memoized
from horizon import views
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.ports.forms import \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.ports.forms import \
UpdatePort
LOG = logging.getLogger(__name__)
@ -38,7 +38,7 @@ class UpdateView(forms.ModalFormView):
port_id = self.kwargs['port_id']
host_id = self.kwargs['host_id']
try:
self._object = api.sysinv.host_port_get(self.request, port_id)
self._object = stx_api.sysinv.host_port_get(self.request, port_id)
self._object.host_id = host_id
except Exception:
redirect = reverse("horizon:project:networks:detail",
@ -85,7 +85,7 @@ class DetailView(views.HorizonTemplateView):
port_id = self.kwargs['port_id']
host_id = self.kwargs['host_id']
try:
self._object = api.sysinv.host_port_get(self.request,
self._object = stx_api.sysinv.host_port_get(self.request,
port_id)
self._object.host_id = host_id
@ -100,7 +100,7 @@ class DetailView(views.HorizonTemplateView):
@memoized.memoized_method
def get_hostname(self, host_uuid):
try:
host = api.sysinv.host_get(self.request, host_uuid)
host = stx_api.sysinv.host_get(self.request, host_uuid)
except Exception:
host = {}
msg = _('Unable to retrieve hostname details.')

View File

@ -16,7 +16,7 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import forms
from horizon import messages
from openstack_dashboard import api
from starlingx_dashboard import api as stx_api
LOG = logging.getLogger(__name__)
@ -73,7 +73,7 @@ class AddSensorGroup(forms.SelfHandlingForm):
del data['hostname']
# The REST API takes care of creating the sensorgroup and assoc
sensorgroup = api.sysinv.host_sensorgroup_create(request, **data)
sensorgroup = stx_api.sysinv.host_sensorgroup_create(request, **data)
msg = _('Sensor group was successfully created.')
LOG.debug(msg)
@ -153,7 +153,7 @@ class UpdateSensorGroup(forms.SelfHandlingForm):
def __init__(self, *args, **kwargs):
super(UpdateSensorGroup, self).__init__(*args, **kwargs)
sensorgroup = api.sysinv.host_sensorgroup_get(
sensorgroup = stx_api.sysinv.host_sensorgroup_get(
self.request, kwargs['initial']['uuid'])
self.fields['actions_critical_group'].choices = \
@ -206,7 +206,7 @@ class UpdateSensorGroup(forms.SelfHandlingForm):
mysensorgroupname = data.pop('sensorgroupname', None)
try:
sensorgroup = api.sysinv.host_sensorgroup_update(request,
sensorgroup = stx_api.sysinv.host_sensorgroup_update(request,
sensorgroup_id,
**data)

View File

@ -15,8 +15,8 @@ from django.utils.translation import ungettext_lazy
from horizon import exceptions
from horizon import tables
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory import tables as itables
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory import tables as itables
LOG = logging.getLogger(__name__)
@ -56,7 +56,7 @@ class RemoveSensorGroup(tables.DeleteAction):
def delete(self, request, sensorgroup_id):
host_id = self.table.kwargs['host_id']
try:
api.sysinv.host_sensorgroup_delete(request, sensorgroup_id)
stx_api.sysinv.host_sensorgroup_delete(request, sensorgroup_id)
except Exception:
msg = _('Failed to delete host %(hid)s '
'sensor group %(sensorgroup)s') % \
@ -127,7 +127,7 @@ class SuppressSensorGroup(tables.BatchAction):
return not sensorgroup_suppressed(sensorgroup)
def action(self, request, sensorgroup_id):
api.sysinv.host_sensorgroup_suppress(request, sensorgroup_id)
stx_api.sysinv.host_sensorgroup_suppress(request, sensorgroup_id)
def handle(self, table, request, obj_ids):
return itables.handle_sysinv(self, table, request, obj_ids)
@ -157,7 +157,7 @@ class UnSuppressSensorGroup(tables.BatchAction):
return sensorgroup_suppressed(sensorgroup)
def action(self, request, sensorgroup_id):
api.sysinv.host_sensorgroup_unsuppress(request, sensorgroup_id)
stx_api.sysinv.host_sensorgroup_unsuppress(request, sensorgroup_id)
def handle(self, table, request, obj_ids):
return itables.handle_sysinv(self, table, request, obj_ids)
@ -209,7 +209,7 @@ class RelearnSensorModel(tables.Action):
def single(self, table, request, obj_ids):
LOG.debug("requesting relearn of sensor model for host "
"%s", table.kwargs['host'].uuid)
api.sysinv.host_sensorgroup_relearn(request, table.kwargs['host'].uuid)
stx_api.sysinv.host_sensorgroup_relearn(request, table.kwargs['host'].uuid)
class SensorGroupsTable(tables.DataTable):
@ -312,7 +312,7 @@ class SuppressSensor(tables.BatchAction):
return not sensor_suppressed(sensor)
def action(self, request, sensor_id):
api.sysinv.host_sensor_suppress(request, sensor_id)
stx_api.sysinv.host_sensor_suppress(request, sensor_id)
def handle(self, table, request, obj_ids):
return itables.handle_sysinv(self, table, request, obj_ids)
@ -342,7 +342,7 @@ class UnSuppressSensor(tables.BatchAction):
return sensor_suppressed(sensor)
def action(self, request, sensor_id):
api.sysinv.host_sensor_unsuppress(request, sensor_id)
stx_api.sysinv.host_sensor_unsuppress(request, sensor_id)
def handle(self, table, request, obj_ids):
return itables.handle_sysinv(self, table, request, obj_ids)

View File

@ -15,10 +15,10 @@ from horizon import exceptions
from horizon import forms
from horizon.utils import memoized
from horizon import views
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.sensors.forms import \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.sensors.forms import \
AddSensorGroup
from openstack_dashboard.dashboards.admin.inventory.sensors.forms import \
from starlingx_dashboard.dashboards.admin.inventory.sensors.forms import \
UpdateSensorGroup
# from openstack_dashboard.dashboards.admin.inventory.sensors.forms import \
# AddSensor
@ -51,7 +51,7 @@ class AddSensorGroupView(forms.ModalFormView):
initial = super(AddSensorGroupView, self).get_initial()
initial['host_id'] = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, initial['host_id'])
host = stx_api.sysinv.host_get(self.request, initial['host_id'])
except Exception:
exceptions.handle(self.request, _('Unable to retrieve host.'))
initial['host_uuid'] = host.uuid
@ -75,7 +75,7 @@ class UpdateSensorGroupView(forms.ModalFormView):
LOG.debug("sensorgroup_id=%s kwargs=%s",
sensorgroup_id, self.kwargs)
try:
self._object = api.sysinv.host_sensorgroup_get(self.request,
self._object = stx_api.sysinv.host_sensorgroup_get(self.request,
sensorgroup_id)
self._object.host_id = host_id
@ -97,7 +97,7 @@ class UpdateSensorGroupView(forms.ModalFormView):
def get_initial(self):
sensorgroup = self._get_object()
# try:
# host = api.sysinv.host_get(self.request, sensorgroup.host_uuid)
# host = stx_api.sysinv.host_get(self.request, sensorgroup.host_uuid)
# except Exception:
# exceptions.handle(self.request, _('Unable to retrieve host.'))
# this is how we can do the analog vs discrete
@ -145,7 +145,7 @@ class DetailSensorView(views.HorizonTemplateView):
@memoized.memoized_method
def get_hostname(self, host_uuid):
try:
host = api.sysinv.host_get(self.request, host_uuid)
host = stx_api.sysinv.host_get(self.request, host_uuid)
except Exception:
host = {}
msg = _('Unable to retrieve hostname details.')
@ -156,7 +156,7 @@ class DetailSensorView(views.HorizonTemplateView):
if not hasattr(self, "_sensor"):
sensor_id = self.kwargs['sensor_id']
try:
sensor = api.sysinv.host_sensor_get(self.request, sensor_id)
sensor = stx_api.sysinv.host_sensor_get(self.request, sensor_id)
except Exception:
redirect = reverse('horizon:admin:inventory:index')
exceptions.handle(self.request,
@ -192,7 +192,7 @@ class DetailSensorGroupView(views.HorizonTemplateView):
@memoized.memoized_method
def get_hostname(self, host_uuid):
try:
host = api.sysinv.host_get(self.request, host_uuid)
host = stx_api.sysinv.host_get(self.request, host_uuid)
except Exception:
host = {}
msg = _('Unable to retrieve hostname details.')
@ -203,7 +203,7 @@ class DetailSensorGroupView(views.HorizonTemplateView):
if not hasattr(self, "_sensorgroup"):
sensorgroup_id = self.kwargs['sensorgroup_id']
try:
sensorgroup = api.sysinv.host_sensorgroup_get(self.request,
sensorgroup = stx_api.sysinv.host_sensorgroup_get(self.request,
sensorgroup_id)
except Exception:
redirect = reverse('horizon:admin:inventory:index')

View File

@ -16,8 +16,7 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import forms
from horizon import messages
from openstack_dashboard import api
from openstack_dashboard.api import sysinv
from starlingx_dashboard import api as stx_api
LOG = logging.getLogger(__name__)
@ -40,7 +39,7 @@ class AddDiskProfile(forms.SelfHandlingForm):
def handle(self, request, data):
diskProfileName = data['profilename']
try:
diskProfile = api.sysinv.host_diskprofile_create(request, **data)
diskProfile = stx_api.sysinv.host_diskprofile_create(request, **data)
msg = _('Storage Profile "%s" was successfully created.') \
% diskProfileName
@ -74,7 +73,7 @@ class EditStorageVolume(forms.SelfHandlingForm):
journal_size_mib = forms.CharField(label=_("Journal Size MiB"),
required=False,
initial=sysinv.JOURNAL_DEFAULT_SIZE,
initial=stx_api.sysinv.JOURNAL_DEFAULT_SIZE,
widget=forms.TextInput(attrs={
'data-slug': 'journal_size_mib'}),
help_text=_("Journal's size for the "
@ -85,7 +84,7 @@ class EditStorageVolume(forms.SelfHandlingForm):
def __init__(self, request, *args, **kwargs):
super(EditStorageVolume, self).__init__(request, *args, **kwargs)
stor = api.sysinv.host_stor_get(
stor = stx_api.sysinv.host_stor_get(
self.request, kwargs['initial']['uuid'])
initial_journal_location = kwargs['initial']['journal_location']
@ -93,7 +92,7 @@ class EditStorageVolume(forms.SelfHandlingForm):
# Populate available journal choices. If no journal is available,
# then the journal is collocated.
avail_journal_list = api.sysinv.host_stor_get_by_function(
avail_journal_list = stx_api.sysinv.host_stor_get_by_function(
self.request,
host_uuid,
'journal')
@ -127,13 +126,13 @@ class EditStorageVolume(forms.SelfHandlingForm):
data['journal_location'] = journal
else:
data['journal_location'] = None
data['journal_size_mib'] = sysinv.JOURNAL_DEFAULT_SIZE
data['journal_size_mib'] = stx_api.sysinv.JOURNAL_DEFAULT_SIZE
del data['journal_locations']
del data['id']
# The REST API takes care of updating the stor journal information.
stor = api.sysinv.host_stor_update(request, stor_id, **data)
stor = stx_api.sysinv.host_stor_update(request, stor_id, **data)
msg = _('Storage volume was successfully updated.')
LOG.debug(msg)
@ -217,7 +216,7 @@ class AddStorageVolume(forms.SelfHandlingForm):
journal_size_mib = forms.CharField(label=_("Journal Size MiB"),
required=False,
initial=sysinv.JOURNAL_DEFAULT_SIZE,
initial=stx_api.sysinv.JOURNAL_DEFAULT_SIZE,
widget=forms.TextInput(attrs={
'class': 'switched',
'data-switch-on': 'function',
@ -244,11 +243,11 @@ class AddStorageVolume(forms.SelfHandlingForm):
this_stor_uuid = 0
host_uuid = kwargs['initial']['ihost_uuid']
ihost = api.sysinv.host_get(self.request, host_uuid)
ihost = stx_api.sysinv.host_get(self.request, host_uuid)
ceph_caching = ((ihost.capabilities.get('pers_subtype') ==
sysinv.PERSONALITY_SUBTYPE_CEPH_CACHING))
stx_api.sysinv.PERSONALITY_SUBTYPE_CEPH_CACHING))
avail_disk_list = api.sysinv.host_disk_list(self.request, host_uuid)
avail_disk_list = stx_api.sysinv.host_disk_list(self.request, host_uuid)
disk_tuple_list = []
for d in avail_disk_list:
if d.istor_uuid and d.istor_uuid != this_stor_uuid:
@ -273,11 +272,11 @@ class AddStorageVolume(forms.SelfHandlingForm):
d.device_type)))
# Get the cluster
cluster_list = api.sysinv.cluster_list(self.request)
cluster_list = stx_api.sysinv.cluster_list(self.request)
cluster_uuid = cluster_list[0].uuid
# Populate the available tiers for OSD assignment
avail_tier_list = api.sysinv.storage_tier_list(self.request,
avail_tier_list = stx_api.sysinv.storage_tier_list(self.request,
cluster_uuid)
tier_tuple_list = [(t.uuid, t.name) for t in avail_tier_list]
@ -286,7 +285,7 @@ class AddStorageVolume(forms.SelfHandlingForm):
if ceph_caching:
avail_journal_list = []
else:
avail_journal_list = api.sysinv.host_stor_get_by_function(
avail_journal_list = stx_api.sysinv.host_stor_get_by_function(
self.request,
host_uuid,
'journal')
@ -336,7 +335,7 @@ class AddStorageVolume(forms.SelfHandlingForm):
data['journal_location'] = journal
else:
data['journal_location'] = None
data['journal_size_mib'] = sysinv.JOURNAL_DEFAULT_SIZE
data['journal_size_mib'] = stx_api.sysinv.JOURNAL_DEFAULT_SIZE
try:
del data['host_id']
@ -347,7 +346,7 @@ class AddStorageVolume(forms.SelfHandlingForm):
# The REST API takes care of creating the stor
# and updating disk.foristorid
stor = api.sysinv.host_stor_create(request, **data)
stor = stx_api.sysinv.host_stor_create(request, **data)
msg = _('Storage volume was successfully created.')
LOG.debug(msg)
@ -405,23 +404,23 @@ class AddLocalVolumeGroup(forms.SelfHandlingForm):
host_uuid = kwargs['initial']['ihost_uuid']
host_id = kwargs['initial']['host_id']
host = api.sysinv.host_get(self.request, host_id)
host = stx_api.sysinv.host_get(self.request, host_id)
subfunctions = host.subfunctions
# LVGs that are considered as "present" in the system are those
# in an adding or provisioned state.
ilvg_list = api.sysinv.host_lvg_list(self.request, host_uuid)
current_lvg_states = [api.sysinv.LVG_ADD, api.sysinv.LVG_PROV]
ilvg_list = stx_api.sysinv.host_lvg_list(self.request, host_uuid)
current_lvg_states = [stx_api.sysinv.LVG_ADD, stx_api.sysinv.LVG_PROV]
current_lvgs = [lvg.lvm_vg_name for lvg in ilvg_list
if lvg.vg_state in current_lvg_states]
compatible_lvgs = []
if host.personality.lower().startswith(
api.sysinv.PERSONALITY_CONTROLLER):
compatible_lvgs += [api.sysinv.LVG_CINDER_VOLUMES]
stx_api.sysinv.PERSONALITY_CONTROLLER):
compatible_lvgs += [stx_api.sysinv.LVG_CINDER_VOLUMES]
if api.sysinv.SUBFUNCTIONS_COMPUTE in subfunctions:
compatible_lvgs += [api.sysinv.LVG_NOVA_LOCAL]
if stx_api.sysinv.SUBFUNCTIONS_COMPUTE in subfunctions:
compatible_lvgs += [stx_api.sysinv.LVG_NOVA_LOCAL]
allowed_lvgs = set(compatible_lvgs) - set(current_lvgs)
@ -444,7 +443,7 @@ class AddLocalVolumeGroup(forms.SelfHandlingForm):
# The REST API takes care of creating the stor
# and updating disk.foristorid
lvg = api.sysinv.host_lvg_create(request, **data)
lvg = stx_api.sysinv.host_lvg_create(request, **data)
msg = _('Local volume group was successfully created.')
LOG.debug(msg)
@ -545,35 +544,35 @@ class AddPhysicalVolume(forms.SelfHandlingForm):
host_uuid = kwargs['initial']['ihost_uuid']
host_id = kwargs['initial']['host_id']
host = api.sysinv.host_get(self.request, host_id)
host = stx_api.sysinv.host_get(self.request, host_id)
subfunctions = host.subfunctions
compatible_lvgs = []
if host.personality.lower().startswith(
api.sysinv.PERSONALITY_CONTROLLER):
compatible_lvgs += [api.sysinv.LVG_CGTS_VG,
api.sysinv.LVG_CINDER_VOLUMES]
stx_api.sysinv.PERSONALITY_CONTROLLER):
compatible_lvgs += [stx_api.sysinv.LVG_CGTS_VG,
stx_api.sysinv.LVG_CINDER_VOLUMES]
if api.sysinv.SUBFUNCTIONS_COMPUTE in subfunctions:
compatible_lvgs += [api.sysinv.LVG_NOVA_LOCAL]
if stx_api.sysinv.SUBFUNCTIONS_COMPUTE in subfunctions:
compatible_lvgs += [stx_api.sysinv.LVG_NOVA_LOCAL]
avail_disk_list = api.sysinv.host_disk_list(self.request, host_uuid)
ilvg_list = api.sysinv.host_lvg_list(self.request, host_uuid)
partitions = api.sysinv.host_disk_partition_list(self.request,
avail_disk_list = stx_api.sysinv.host_disk_list(self.request, host_uuid)
ilvg_list = stx_api.sysinv.host_lvg_list(self.request, host_uuid)
partitions = stx_api.sysinv.host_disk_partition_list(self.request,
host_uuid)
ipv_list = api.sysinv.host_pv_list(self.request, host_uuid)
ipv_list = stx_api.sysinv.host_pv_list(self.request, host_uuid)
disk_tuple_list = []
partitions_tuple_list = []
ilvg_tuple_list = []
pv_cinder_volumes = next(
(pv for pv in ipv_list
if pv.lvm_vg_name == api.sysinv.LVG_CINDER_VOLUMES), None)
if pv.lvm_vg_name == stx_api.sysinv.LVG_CINDER_VOLUMES), None)
for lvg in ilvg_list:
if (lvg.lvm_vg_name in compatible_lvgs and
lvg.vg_state in [api.sysinv.LVG_ADD, api.sysinv.LVG_PROV]):
if (lvg.lvm_vg_name == api.sysinv.LVG_CINDER_VOLUMES and
lvg.vg_state in [stx_api.sysinv.LVG_ADD, stx_api.sysinv.LVG_PROV]):
if (lvg.lvm_vg_name == stx_api.sysinv.LVG_CINDER_VOLUMES and
pv_cinder_volumes):
continue
ilvg_tuple_list.append((lvg.uuid, lvg.lvm_vg_name))
@ -619,17 +618,17 @@ class AddPhysicalVolume(forms.SelfHandlingForm):
disk_model)))
for p in partitions:
if p.type_guid != api.sysinv.USER_PARTITION_PHYS_VOL:
if p.type_guid != stx_api.sysinv.USER_PARTITION_PHYS_VOL:
continue
if p.ipv_uuid:
continue
if p.status == api.sysinv.PARTITION_IN_USE_STATUS:
if p.status == stx_api.sysinv.PARTITION_IN_USE_STATUS:
# If partition is in use, but the PV it is attached to
# is in a "removing" state, we should allow the partition
# to be listed as a possible option.
for pv in ipv_list:
if (pv.disk_or_part_device_path == p.device_path and
pv.pv_state == api.sysinv.PV_DEL):
pv.pv_state == stx_api.sysinv.PV_DEL):
break
else:
continue
@ -667,7 +666,7 @@ class AddPhysicalVolume(forms.SelfHandlingForm):
del data['lvg']
del data['partitions']
stor = api.sysinv.host_pv_create(request, **data)
stor = stx_api.sysinv.host_pv_create(request, **data)
msg = _('Physical volume was successfully created.')
messages.success(request, msg)
@ -717,7 +716,7 @@ class EditPartition(forms.SelfHandlingForm):
try:
del data['id']
# The REST API takes care of updating the partition information.
partition = api.sysinv.host_disk_partition_update(
partition = stx_api.sysinv.host_disk_partition_update(
request, partition_id, **data)
msg = _('Partition was successfully updated.')
@ -789,7 +788,7 @@ class CreatePartition(forms.SelfHandlingForm):
# Populate disk choices.
host_uuid = kwargs['initial']['ihost_uuid']
avail_disk_list = api.sysinv.host_disk_list(self.request, host_uuid)
avail_disk_list = stx_api.sysinv.host_disk_list(self.request, host_uuid)
disk_tuple_list = []
for d in avail_disk_list:
disk_model = d.get_model_num()
@ -820,9 +819,9 @@ class CreatePartition(forms.SelfHandlingForm):
del data['host_id']
del data['disks']
del data['hostname']
data['type_guid'] = sysinv.USER_PARTITION_PHYS_VOL
data['type_guid'] = stx_api.sysinv.USER_PARTITION_PHYS_VOL
# The REST API takes care of creating the partition.
partition = api.sysinv.host_disk_partition_create(request, **data)
partition = stx_api.sysinv.host_disk_partition_create(request, **data)
msg = _('Partition was successfully created.')
LOG.debug(msg)

View File

@ -14,54 +14,53 @@ from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import exceptions
from horizon import forms
from horizon import messages
from openstack_dashboard import api
from starlingx_dashboard import api as stx_api
from oslo_serialization import jsonutils
from openstack_dashboard.api import sysinv
LOG = logging.getLogger(__name__)
NOVA_PARAMS_FIELD_MAP = {
sysinv.LVG_NOVA_PARAM_BACKING:
sysinv.LVG_NOVA_PARAM_BACKING,
sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB:
sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB,
sysinv.LVG_NOVA_PARAM_DISK_OPS:
sysinv.LVG_NOVA_PARAM_DISK_OPS,
stx_api.sysinv.LVG_NOVA_PARAM_BACKING:
stx_api.sysinv.LVG_NOVA_PARAM_BACKING,
stx_api.sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB:
stx_api.sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB,
stx_api.sysinv.LVG_NOVA_PARAM_DISK_OPS:
stx_api.sysinv.LVG_NOVA_PARAM_DISK_OPS,
}
CINDER_PARAMS_FIELD_MAP = {
sysinv.LVG_CINDER_PARAM_LVM_TYPE:
sysinv.LVG_CINDER_PARAM_LVM_TYPE,
stx_api.sysinv.LVG_CINDER_PARAM_LVM_TYPE:
stx_api.sysinv.LVG_CINDER_PARAM_LVM_TYPE,
}
NOVA_PARAMS_KEY_MAP = (
(sysinv.LVG_NOVA_PARAM_BACKING,
(stx_api.sysinv.LVG_NOVA_PARAM_BACKING,
_("Instance Backing")),
(sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB,
(stx_api.sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB,
_("Instances LV Size [in MiB]")),
(sysinv.LVG_NOVA_PARAM_DISK_OPS,
(stx_api.sysinv.LVG_NOVA_PARAM_DISK_OPS,
_("Concurrent Disk Operations")),
)
CINDER_PARAMS_KEY_MAP = (
(sysinv.LVG_CINDER_PARAM_LVM_TYPE,
(stx_api.sysinv.LVG_CINDER_PARAM_LVM_TYPE,
_("LVM Provisioning Type")),
)
PARAMS_HELP = {
sysinv.LVG_NOVA_PARAM_BACKING:
stx_api.sysinv.LVG_NOVA_PARAM_BACKING:
'Determines the format and location of instance disks. Local CoW image \
file backed, local RAW LVM logical volume backed, or remote RAW Ceph \
storage backed',
sysinv.LVG_NOVA_PARAM_DISK_OPS:
stx_api.sysinv.LVG_NOVA_PARAM_DISK_OPS:
'Number of parallel disk I/O intensive operations (glance image downloads, \
image format conversions, etc.).',
sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB:
stx_api.sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB:
'An integer specifying the size (in MiB) of the instances logical volume. \
(.e.g. 10 GiB = 10240). Volume is created from nova-local and will be \
mounted at /etc/nova/instances.',
sysinv.LVG_CINDER_PARAM_LVM_TYPE:
stx_api.sysinv.LVG_CINDER_PARAM_LVM_TYPE:
'Cinder configuration setting which determines how the volume group is \
provisioned. Thick provisioning will be used if the value is set to: \
default. Thin provisioning will be used in the value is set to: thin',
@ -76,14 +75,14 @@ CINDER_PARAMS_KEY_NAMES = dict(CINDER_PARAMS_KEY_MAP)
CINDER_PARAMS_CHOICES = CINDER_PARAMS_KEY_MAP
BACKING_CHOICES = (
(sysinv.LVG_NOVA_BACKING_LVM, _("Local RAW LVM backed")),
(sysinv.LVG_NOVA_BACKING_IMAGE, _("Local CoW image backed")),
(sysinv.LVG_NOVA_BACKING_REMOTE, _("Remote RAW Ceph storage backed")),
(stx_api.sysinv.LVG_NOVA_BACKING_LVM, _("Local RAW LVM backed")),
(stx_api.sysinv.LVG_NOVA_BACKING_IMAGE, _("Local CoW image backed")),
(stx_api.sysinv.LVG_NOVA_BACKING_REMOTE, _("Remote RAW Ceph storage backed")),
)
LVM_TYPE_CHOICES = (
(sysinv.LVG_CINDER_LVM_TYPE_THICK, _("Thick Provisioning (default)")),
(sysinv.LVG_CINDER_LVM_TYPE_THIN, _("Thin Provisioning (thin)")),
(stx_api.sysinv.LVG_CINDER_LVM_TYPE_THICK, _("Thick Provisioning (default)")),
(stx_api.sysinv.LVG_CINDER_LVM_TYPE_THIN, _("Thin Provisioning (thin)")),
)
@ -98,7 +97,7 @@ class ParamMixin(object):
def _host_lvg_get(self, lvg_id):
try:
return api.sysinv.host_lvg_get(self.request, lvg_id)
return stx_api.sysinv.host_lvg_get(self.request, lvg_id)
except Exception:
exceptions.handle(
self.request,
@ -107,7 +106,7 @@ class ParamMixin(object):
def _host_pv_list(self, host_id):
try:
return api.sysinv.host_pv_list(self.request, host_id)
return stx_api.sysinv.host_pv_list(self.request, host_id)
except Exception:
exceptions.handle(
self.request,
@ -116,7 +115,7 @@ class ParamMixin(object):
def _host_pv_disk_get(self, pv):
try:
return api.sysinv.host_disk_get(self.request, pv.disk_or_part_uuid)
return stx_api.sysinv.host_disk_get(self.request, pv.disk_or_part_uuid)
except Exception:
exceptions.handle(
self.request,
@ -341,7 +340,7 @@ class EditParam(ParamForm):
'value': jsonutils.dumps(metadata),
'op': 'replace'})
api.sysinv.host_lvg_update(request, lvg_id, patch)
stx_api.sysinv.host_lvg_update(request, lvg_id, patch)
msg = _('Updated parameter "%s".') % data['key']
messages.success(request, msg)
return True

View File

@ -10,10 +10,10 @@ from django.template import defaultfilters as filters
from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import tables
from openstack_dashboard.dashboards.admin.inventory.storages.lvg_params \
from starlingx_dashboard.dashboards.admin.inventory.storages.lvg_params \
import forms
from openstack_dashboard.api import sysinv
from starlingx_dashboard import api as stx_api
class ParamEdit(tables.LinkAction):
@ -34,13 +34,13 @@ def get_parameters_name(datum):
def get_parameters_value(datum):
if datum is None or datum.value is None:
return None
if datum.key == sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB:
if datum.key == stx_api.sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB:
value = datum.value
if datum.key == sysinv.LVG_NOVA_PARAM_BACKING:
if datum.key == stx_api.sysinv.LVG_NOVA_PARAM_BACKING:
value = datum.value
if datum.key == sysinv.LVG_NOVA_PARAM_DISK_OPS:
if datum.key == stx_api.sysinv.LVG_NOVA_PARAM_DISK_OPS:
value = datum.value
if datum.key == sysinv.LVG_CINDER_PARAM_LVM_TYPE:
if datum.key == stx_api.sysinv.LVG_CINDER_PARAM_LVM_TYPE:
value = datum.value
return value

View File

@ -7,7 +7,7 @@
from django.conf.urls import url # noqa
from openstack_dashboard.dashboards.admin.inventory.storages.lvg_params \
from starlingx_dashboard.dashboards.admin.inventory.storages.lvg_params \
import views
urlpatterns = [

View File

@ -12,8 +12,8 @@ from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import exceptions
from horizon import forms
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.storages.lvg_params \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.storages.lvg_params \
import forms as project_forms
LOG = logging.getLogger(__name__)
@ -38,7 +38,7 @@ class EditView(forms.ModalFormView):
lvg_id = self.kwargs['lvg_id']
key = self.kwargs['key']
try:
params = api.sysinv.host_lvg_get_params(
params = stx_api.sysinv.host_lvg_get_params(
self.request, lvg_id, raw=True)
except Exception:
params = {}

View File

@ -16,14 +16,11 @@ from django.utils.translation import ungettext_lazy
from horizon import exceptions
from horizon import tables
from openstack_dashboard import api
from starlingx_dashboard import api as stx_api
LOG = logging.getLogger(__name__)
# ##########
# ACTIONS
# ##########
class CreateStorageVolume(tables.LinkAction):
name = "createstoragevolume"
verbose_name = ("Assign Storage Function")
@ -112,11 +109,11 @@ class DeletePartition(tables.DeleteAction):
def allowed(self, request, partition=None):
host = self.table.kwargs['host']
PARTITION_IN_USE_STATUS = api.sysinv.PARTITION_IN_USE_STATUS
PARTITION_STATUS_MSG = api.sysinv.PARTITION_STATUS_MSG
PARTITION_IN_USE_STATUS = stx_api.sysinv.PARTITION_IN_USE_STATUS
PARTITION_STATUS_MSG = stx_api.sysinv.PARTITION_STATUS_MSG
if partition:
if partition.type_guid != api.sysinv.USER_PARTITION_PHYS_VOL:
if partition.type_guid != stx_api.sysinv.USER_PARTITION_PHYS_VOL:
return False
if (partition.status ==
@ -128,7 +125,7 @@ class DeletePartition(tables.DeleteAction):
# Get all the partitions from the same disk.
disk_partitions = \
api.sysinv.host_disk_partition_list(request, host.uuid,
stx_api.sysinv.host_disk_partition_list(request, host.uuid,
partition.idisk_uuid)
if partition.device_path:
@ -145,7 +142,7 @@ class DeletePartition(tables.DeleteAction):
def delete(self, request, partition_id):
host_id = self.table.kwargs['host_id']
try:
api.sysinv.host_disk_partition_delete(request, partition_id)
stx_api.sysinv.host_disk_partition_delete(request, partition_id)
except Exception as e:
msg = _('Failed to delete host %(hid)s partition %(pv)s. '
'%(e_msg)s') % {'hid': host_id,
@ -170,19 +167,19 @@ class EditPartition(tables.LinkAction):
def allowed(self, request, partition=None):
host = self.table.kwargs['host']
PARTITION_IN_USE_STATUS = api.sysinv.PARTITION_IN_USE_STATUS
PARTITION_STATUS_MSG = api.sysinv.PARTITION_STATUS_MSG
PARTITION_IN_USE_STATUS = stx_api.sysinv.PARTITION_IN_USE_STATUS
PARTITION_STATUS_MSG = stx_api.sysinv.PARTITION_STATUS_MSG
if partition:
pv = None
if partition.type_guid != api.sysinv.USER_PARTITION_PHYS_VOL:
if partition.type_guid != stx_api.sysinv.USER_PARTITION_PHYS_VOL:
return False
if partition.ipv_uuid:
pv = api.sysinv.host_pv_get(
pv = stx_api.sysinv.host_pv_get(
request, partition.ipv_uuid)
if pv.lvm_vg_name == api.sysinv.LVG_CINDER_VOLUMES:
if pv.lvm_vg_name == stx_api.sysinv.LVG_CINDER_VOLUMES:
if (host.personality == "Controller-Active" and
host._administrative == 'unlocked'):
return False
@ -192,12 +189,12 @@ class EditPartition(tables.LinkAction):
if (partition.status ==
PARTITION_STATUS_MSG[PARTITION_IN_USE_STATUS]):
if not (pv and
pv.lvm_vg_name == api.sysinv.LVG_CINDER_VOLUMES):
pv.lvm_vg_name == stx_api.sysinv.LVG_CINDER_VOLUMES):
return False
# Get all the partitions from the same disk.
disk_partitions = \
api.sysinv.host_disk_partition_list(request,
stx_api.sysinv.host_disk_partition_list(request,
host.uuid,
partition.idisk_uuid)
@ -289,7 +286,7 @@ class EditStor(tables.LinkAction):
if stor and stor.function == 'osd':
forihostuuid = self.table.kwargs['host'].uuid
journal_stors = \
api.sysinv.host_stor_get_by_function(request, forihostuuid,
stx_api.sysinv.host_stor_get_by_function(request, forihostuuid,
'journal')
if not journal_stors:
@ -330,7 +327,7 @@ class DeleteStor(tables.DeleteAction):
return stor.function == 'journal'
def delete(self, request, obj_id):
api.sysinv.host_stor_delete(request, obj_id)
stx_api.sysinv.host_stor_delete(request, obj_id)
class StorageVolumesTable(tables.DataTable):
@ -389,17 +386,17 @@ class AddLocalVolumeGroup(tables.LinkAction):
# LVGs that are considered as "present" in the system are those
# in an adding or provisioned state.
current_lvg_states = [api.sysinv.LVG_ADD, api.sysinv.LVG_PROV]
ilvg_list = api.sysinv.host_lvg_list(request, host.uuid)
current_lvg_states = [stx_api.sysinv.LVG_ADD, stx_api.sysinv.LVG_PROV]
ilvg_list = stx_api.sysinv.host_lvg_list(request, host.uuid)
current_lvgs = [lvg.lvm_vg_name for lvg in ilvg_list
if lvg.vg_state in current_lvg_states]
compatible_lvgs = []
if host._personality == 'controller':
compatible_lvgs += [api.sysinv.LVG_CINDER_VOLUMES]
compatible_lvgs += [stx_api.sysinv.LVG_CINDER_VOLUMES]
if 'compute' in host._subfunctions:
compatible_lvgs += [api.sysinv.LVG_NOVA_LOCAL]
compatible_lvgs += [stx_api.sysinv.LVG_NOVA_LOCAL]
allowed_lvgs = set(compatible_lvgs) - set(current_lvgs)
if not any(allowed_lvgs):
@ -430,23 +427,23 @@ class RemoveLocalVolumeGroup(tables.DeleteAction):
def allowed(self, request, lvg=None):
host = self.table.kwargs['host']
cinder_backend = api.sysinv.get_cinder_backend(request)
cinder_backend = stx_api.sysinv.get_cinder_backend(request)
if lvg.lvm_vg_name == api.sysinv.LVG_NOVA_LOCAL:
if lvg.lvm_vg_name == stx_api.sysinv.LVG_NOVA_LOCAL:
return ((host._administrative == 'locked')
or
(('compute' in host._subfunctions) and
(host.compute_config_required is True)))
elif lvg.lvm_vg_name == api.sysinv.LVG_CINDER_VOLUMES:
return (api.sysinv.CINDER_BACKEND_LVM not in cinder_backend and
api.sysinv.LVG_ADD in lvg.vg_state)
elif lvg.lvm_vg_name == stx_api.sysinv.LVG_CINDER_VOLUMES:
return (stx_api.sysinv.CINDER_BACKEND_LVM not in cinder_backend and
stx_api.sysinv.LVG_ADD in lvg.vg_state)
return False
def delete(self, request, lvg_id):
host_id = self.table.kwargs['host_id']
try:
api.sysinv.host_lvg_delete(request, lvg_id)
stx_api.sysinv.host_lvg_delete(request, lvg_id)
except Exception as e:
msg = _('Failed to delete host %(hid)s local '
'volume group %(lvg)s '
@ -510,7 +507,7 @@ class AddPhysicalVolume(tables.LinkAction):
self.classes = classes
# cgts-vg, cinder-volumes: Allow adding to any controller
if host._personality == api.sysinv.PERSONALITY_CONTROLLER:
if host._personality == stx_api.sysinv.PERSONALITY_CONTROLLER:
return True
# nova-local: Allow adding to any locked host with a compute
@ -524,7 +521,7 @@ class AddPhysicalVolume(tables.LinkAction):
_("(Node Unlocked)"))
elif "nova-local" not in [
lvg.lvm_vg_name for lvg in
api.sysinv.host_lvg_list(request, host.uuid)]:
stx_api.sysinv.host_lvg_list(request, host.uuid)]:
if "disabled" not in self.classes:
self.classes = [c for c in self.classes] + ['disabled']
self.verbose_name = string_concat(self.verbose_name, ' ',
@ -552,23 +549,23 @@ class RemovePhysicalVolume(tables.DeleteAction):
def allowed(self, request, pv=None):
host = self.table.kwargs['host']
cinder_backend = api.sysinv.get_cinder_backend(request)
cinder_backend = stx_api.sysinv.get_cinder_backend(request)
if pv.lvm_vg_name == api.sysinv.LVG_NOVA_LOCAL:
if pv.lvm_vg_name == stx_api.sysinv.LVG_NOVA_LOCAL:
return ((host._administrative == 'locked')
or
(('compute' in host._subfunctions) and
(host.compute_config_required is True)))
elif pv.lvm_vg_name == api.sysinv.LVG_CINDER_VOLUMES:
return (api.sysinv.CINDER_BACKEND_LVM not in cinder_backend and
api.sysinv.PV_ADD in pv.pv_state)
elif pv.lvm_vg_name == stx_api.sysinv.LVG_CINDER_VOLUMES:
return (stx_api.sysinv.CINDER_BACKEND_LVM not in cinder_backend and
stx_api.sysinv.PV_ADD in pv.pv_state)
return False
def delete(self, request, pv_id):
host_id = self.table.kwargs['host_id']
try:
api.sysinv.host_pv_delete(request, pv_id)
stx_api.sysinv.host_pv_delete(request, pv_id)
except Exception as e:
msg = _('Failed to delete host %(hid)s physical volume %(pv)s. '
'%(e_msg)s') % {'hid': host_id, 'pv': pv_id, 'e_msg': e}

View File

@ -12,8 +12,8 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.storages.lvg_params \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.storages.lvg_params \
import tables as params_table
LOG = logging.getLogger(__name__)
@ -28,7 +28,7 @@ class LocalVolumeGroupOverviewTab(tabs.Tab):
def get_context_data(self, request):
lvg_id = self.tab_group.kwargs['lvg_id']
try:
lvg = api.sysinv.host_lvg_get(request, lvg_id)
lvg = stx_api.sysinv.host_lvg_get(request, lvg_id)
except Exception:
redirect = reverse('horizon:admin:storages:index')
exceptions.handle(self.request,
@ -47,7 +47,7 @@ class LocalVolumeGroupParametersTab(tabs.TableTab):
request = self.tab_group.request
lvg_id = self.tab_group.kwargs['lvg_id']
try:
params = api.sysinv.host_lvg_get_params(request, lvg_id)
params = stx_api.sysinv.host_lvg_get_params(request, lvg_id)
params.sort(key=lambda es: (es.key,))
except Exception:
params = []

View File

@ -8,7 +8,7 @@
from django.conf.urls import include # noqa
from django.conf.urls import url # noqa
from openstack_dashboard.dashboards.admin.inventory.storages.lvg_params \
from starlingx_dashboard.dashboards.admin.inventory.storages.lvg_params \
import urls as lvg_params_urls
urlpatterns = [

View File

@ -17,23 +17,22 @@ from horizon import tabs
from horizon.utils import memoized
from horizon import views
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.storages.forms import \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.storages.forms import \
AddDiskProfile
from openstack_dashboard.dashboards.admin.inventory.storages.forms import \
from starlingx_dashboard.dashboards.admin.inventory.storages.forms import \
AddLocalVolumeGroup
from openstack_dashboard.dashboards.admin.inventory.storages.forms import \
from starlingx_dashboard.dashboards.admin.inventory.storages.forms import \
AddPhysicalVolume
from openstack_dashboard.dashboards.admin.inventory.storages.forms import \
from starlingx_dashboard.dashboards.admin.inventory.storages.forms import \
AddStorageVolume
from openstack_dashboard.dashboards.admin.inventory.storages.forms import \
from starlingx_dashboard.dashboards.admin.inventory.storages.forms import \
CreatePartition
from openstack_dashboard.dashboards.admin.inventory.storages.forms import \
from starlingx_dashboard.dashboards.admin.inventory.storages.forms import \
EditPartition
from openstack_dashboard.dashboards.admin.inventory.storages.forms import \
from starlingx_dashboard.dashboards.admin.inventory.storages.forms import \
EditStorageVolume
from openstack_dashboard.dashboards.admin.inventory.storages.tabs \
from starlingx_dashboard.dashboards.admin.inventory.storages.tabs \
import LocalVolumeGroupDetailTabs
LOG = logging.getLogger(__name__)
@ -62,7 +61,7 @@ class AddStorageVolumeView(forms.ModalFormView):
initial = super(AddStorageVolumeView, self).get_initial()
initial['host_id'] = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, initial['host_id'])
host = stx_api.sysinv.host_get(self.request, initial['host_id'])
except Exception:
exceptions.handle(self.request, _('Unable to retrieve host.'))
initial['ihost_uuid'] = host.uuid
@ -86,7 +85,7 @@ class EditStorageVolumeView(forms.ModalFormView):
LOG.debug("stor_id=%s kwargs=%s",
stor_uuid, self.kwargs)
try:
self._object = api.sysinv.host_stor_get(self.request,
self._object = stx_api.sysinv.host_stor_get(self.request,
stor_uuid)
self._object.host_id = host_id
except Exception:
@ -131,24 +130,24 @@ class AddDiskProfileView(forms.ModalFormView):
if not hasattr(self, "_host"):
host_id = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, host_id)
host = stx_api.sysinv.host_get(self.request, host_id)
all_disks = api.sysinv.host_disk_list(self.request, host.uuid)
all_disks = stx_api.sysinv.host_disk_list(self.request, host.uuid)
host.disks = [d for d in all_disks if
(d.istor_uuid or d.ipv_uuid)]
host.partitions = api.sysinv.host_disk_partition_list(
host.partitions = stx_api.sysinv.host_disk_partition_list(
self.request, host.uuid)
host.stors = api.sysinv.host_stor_list(self.request, host.uuid)
host.stors = stx_api.sysinv.host_stor_list(self.request, host.uuid)
all_lvgs = api.sysinv.host_lvg_list(self.request, host.uuid)
all_lvgs = stx_api.sysinv.host_lvg_list(self.request, host.uuid)
host.lvgs = [l for l in all_lvgs if
l.lvm_vg_name == api.sysinv.LVG_NOVA_LOCAL]
l.lvm_vg_name == stx_api.sysinv.LVG_NOVA_LOCAL]
all_pvs = api.sysinv.host_pv_list(self.request, host.uuid)
all_pvs = stx_api.sysinv.host_pv_list(self.request, host.uuid)
host.pvs = [p for p in all_pvs if
p.lvm_vg_name == api.sysinv.LVG_NOVA_LOCAL]
p.lvm_vg_name == stx_api.sysinv.LVG_NOVA_LOCAL]
journals = {}
count = 0
@ -175,21 +174,21 @@ class AddDiskProfileView(forms.ModalFormView):
for l in host.lvgs:
l.instance_backing = l.capabilities.get(
api.sysinv.LVG_NOVA_PARAM_BACKING)
stx_api.sysinv.LVG_NOVA_PARAM_BACKING)
l.concurrent_disk_operations = l.capabilities.get(
api.sysinv.LVG_NOVA_PARAM_DISK_OPS)
stx_api.sysinv.LVG_NOVA_PARAM_DISK_OPS)
if (l.instance_backing and
l.instance_backing == api.sysinv.LVG_NOVA_BACKING_LVM):
l.instance_backing == stx_api.sysinv.LVG_NOVA_BACKING_LVM):
l.instances_lv_size_mib = l.capabilities.get(
api.sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB)
stx_api.sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB)
l.lvm_type = l.capabilities.get(
api.sysinv.LVG_CINDER_PARAM_LVM_TYPE)
stx_api.sysinv.LVG_CINDER_PARAM_LVM_TYPE)
l.dev_paths = [p.disk_or_part_device_path
for p in all_pvs if
p.lvm_vg_name and
p.lvm_vg_name == api.sysinv.LVG_NOVA_LOCAL]
p.lvm_vg_name == stx_api.sysinv.LVG_NOVA_LOCAL]
l.dev_paths = ", ".join(l.dev_paths)
except Exception:
@ -212,7 +211,7 @@ class AddDiskProfileView(forms.ModalFormView):
initial = super(AddDiskProfileView, self).get_initial()
initial['host_id'] = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, initial['host_id'])
host = stx_api.sysinv.host_get(self.request, initial['host_id'])
except Exception:
exceptions.handle(self.request, _('Unable to retrieve host.'))
initial['personality'] = host._personality
@ -243,7 +242,7 @@ class AddLocalVolumeGroupView(forms.ModalFormView):
initial = super(AddLocalVolumeGroupView, self).get_initial()
initial['host_id'] = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, initial['host_id'])
host = stx_api.sysinv.host_get(self.request, initial['host_id'])
except Exception:
exceptions.handle(self.request, _('Unable to retrieve host.'))
initial['ihost_uuid'] = host.uuid
@ -274,7 +273,7 @@ class AddPhysicalVolumeView(forms.ModalFormView):
initial = super(AddPhysicalVolumeView, self).get_initial()
initial['host_id'] = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, initial['host_id'])
host = stx_api.sysinv.host_get(self.request, initial['host_id'])
except Exception:
exceptions.handle(self.request, _('Unable to retrieve host.'))
initial['ihost_uuid'] = host.uuid
@ -306,7 +305,7 @@ class DetailPhysicalVolumeView(views.HorizonTemplateView):
@memoized.memoized_method
def get_hostname(self, host_uuid):
try:
host = api.sysinv.host_get(self.request, host_uuid)
host = stx_api.sysinv.host_get(self.request, host_uuid)
except Exception:
host = {}
msg = _('Unable to retrieve hostname details.')
@ -317,7 +316,7 @@ class DetailPhysicalVolumeView(views.HorizonTemplateView):
if not hasattr(self, "_pv"):
pv_id = self.kwargs['pv_id']
try:
pv = api.sysinv.host_pv_get(self.request, pv_id)
pv = stx_api.sysinv.host_pv_get(self.request, pv_id)
except Exception:
redirect = reverse('horizon:admin:inventory:index')
exceptions.handle(self.request,
@ -355,7 +354,7 @@ class DetailLocalVolumeGroupView(tabs.TabbedTableView):
if not hasattr(self, "_lvg"):
lvg_id = self.kwargs['lvg_id']
try:
lvg = api.sysinv.host_lvg_get(self.request, lvg_id)
lvg = stx_api.sysinv.host_lvg_get(self.request, lvg_id)
except Exception:
redirect = reverse('horizon:admin:inventory:index')
exceptions.handle(self.request,
@ -369,7 +368,7 @@ class DetailLocalVolumeGroupView(tabs.TabbedTableView):
@memoized.memoized_method
def get_hostname(self, host_uuid):
try:
host = api.sysinv.host_get(self.request, host_uuid)
host = stx_api.sysinv.host_get(self.request, host_uuid)
except Exception:
host = {}
msg = _('Unable to retrieve hostname details.')
@ -404,7 +403,7 @@ class CreatePartitionView(forms.ModalFormView):
initial = super(CreatePartitionView, self).get_initial()
initial['host_id'] = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, initial['host_id'])
host = stx_api.sysinv.host_get(self.request, initial['host_id'])
except Exception:
exceptions.handle(self.request, _('Unable to retrieve host.'))
initial['ihost_uuid'] = host.uuid
@ -428,7 +427,7 @@ class EditPartitionView(forms.ModalFormView):
LOG.debug("partition_id=%s kwargs=%s",
partition_uuid, self.kwargs)
try:
self._object = api.sysinv.host_disk_partition_get(
self._object = stx_api.sysinv.host_disk_partition_get(
self.request,
partition_uuid)
self._object.host_id = host_id

View File

@ -17,9 +17,8 @@ from horizon import exceptions
from horizon import messages
from horizon import tables
from horizon.utils import functions
from openstack_dashboard import api
from openstack_dashboard.api.sysinv import Host
from openstack_dashboard.dashboards.admin.inventory.cpu_functions \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.cpu_functions \
import utils as cpufunctions_utils
import cgcs_patch.constants as patch_constants
@ -42,7 +41,7 @@ def host_board_management(host=None):
def host_controller(host=None):
if not host:
return False
return host._personality == api.sysinv.PERSONALITY_CONTROLLER
return host._personality == stx_api.sysinv.PERSONALITY_CONTROLLER
def host_powered_off(host=None):
@ -119,7 +118,7 @@ class AddHost(tables.LinkAction):
ajax = True
def allowed(self, request, host=None):
return not api.sysinv.is_system_mode_simplex(request)
return not stx_api.sysinv.is_system_mode_simplex(request)
class EditHost(tables.LinkAction):
@ -150,7 +149,7 @@ class DeleteHost(tables.DeleteAction):
return host_locked(host)
def delete(self, request, host_id):
api.sysinv.host_delete(request, host_id)
stx_api.sysinv.host_delete(request, host_id)
def handle(self, table, request, obj_ids):
return handle_sysinv(self, table, request, obj_ids)
@ -182,7 +181,7 @@ class LockHost(tables.BatchAction):
return not host_locked(host)
def action(self, request, host_id):
api.sysinv.host_lock(request, host_id)
stx_api.sysinv.host_lock(request, host_id)
def handle(self, table, request, obj_ids):
return handle_sysinv(self, table, request, obj_ids)
@ -213,13 +212,13 @@ class ForceLockHost(tables.BatchAction):
return not host_locked(host)
def action(self, request, host_id):
api.sysinv.host_force_lock(request, host_id)
stx_api.sysinv.host_force_lock(request, host_id)
def handle(self, table, request, obj_ids):
return handle_sysinv(self, table, request, obj_ids)
def get_confirm_message(self, request, datum):
if datum._personality == api.sysinv.PERSONALITY_CONTROLLER:
if datum._personality == stx_api.sysinv.PERSONALITY_CONTROLLER:
return _(
"<b>WARNING</b>: This will cause an uncontrolled switch"
" of services on host '%s'.\n\n"
@ -230,7 +229,7 @@ class ForceLockHost(tables.BatchAction):
"unsuccessful and this host MUST be locked.\n\n"
"If you proceed, then this action will be logged"
" and cannot be undone.") % datum.hostname
elif datum._personality == api.sysinv.PERSONALITY_COMPUTE:
elif datum._personality == stx_api.sysinv.PERSONALITY_COMPUTE:
return _(
"<b>WARNING</b>: This will cause a service OUTAGE"
" for all VMs currently using resources on '%s'.\n\n"
@ -241,7 +240,7 @@ class ForceLockHost(tables.BatchAction):
" unsuccessful and this host MUST be locked.\n\n"
"If you proceed, then this action will be logged"
" and cannot be undone.") % datum.hostname
elif datum._personality == api.sysinv.PERSONALITY_STORAGE:
elif datum._personality == stx_api.sysinv.PERSONALITY_STORAGE:
return _(
"<b>WARNING</b>: This will cause an uncontrolled"
" loss of storage services on host '%s'.\n\n"
@ -282,7 +281,7 @@ class UnlockHost(tables.BatchAction):
return host_locked(host)
def action(self, request, host_id):
api.sysinv.host_unlock(request, host_id)
stx_api.sysinv.host_unlock(request, host_id)
def handle(self, table, request, obj_ids):
return handle_sysinv(self, table, request, obj_ids)
@ -314,7 +313,7 @@ class ForceUnlockHost(tables.BatchAction):
return host_locked(host)
def action(self, request, host_id):
api.sysinv.host_force_unlock(request, host_id)
stx_api.sysinv.host_force_unlock(request, host_id)
def handle(self, table, request, obj_ids):
return handle_sysinv(self, table, request, obj_ids)
@ -351,10 +350,10 @@ class PowerOnHost(tables.BatchAction):
def allowed(self, request, host=None):
return (host_board_management(host) and host_locked(host) and
not api.sysinv.is_system_mode_simplex(request))
not stx_api.sysinv.is_system_mode_simplex(request))
def action(self, request, host_id):
api.sysinv.host_power_on(request, host_id)
stx_api.sysinv.host_power_on(request, host_id)
def handle(self, table, request, obj_ids):
return handle_sysinv(self, table, request, obj_ids)
@ -383,10 +382,10 @@ class PowerOffHost(tables.BatchAction):
def allowed(self, request, host=None):
return (host_board_management(host) and host_locked(host) and
not host_powered_off(host) and
not api.sysinv.is_system_mode_simplex(request))
not stx_api.sysinv.is_system_mode_simplex(request))
def action(self, request, host_id):
api.sysinv.host_power_off(request, host_id)
stx_api.sysinv.host_power_off(request, host_id)
def handle(self, table, request, obj_ids):
return handle_sysinv(self, table, request, obj_ids)
@ -414,10 +413,10 @@ class ResetHost(tables.BatchAction):
def allowed(self, request, host=None):
return (host_board_management(host) and host_locked(host) and
not api.sysinv.is_system_mode_simplex(request))
not stx_api.sysinv.is_system_mode_simplex(request))
def action(self, request, host_id):
api.sysinv.host_reset(request, host_id)
stx_api.sysinv.host_reset(request, host_id)
def handle(self, table, request, obj_ids):
return handle_sysinv(self, table, request, obj_ids)
@ -447,7 +446,7 @@ class RebootHost(tables.BatchAction):
return host_locked(host)
def action(self, request, host_id):
api.sysinv.host_reboot(request, host_id)
stx_api.sysinv.host_reboot(request, host_id)
def handle(self, table, request, obj_ids):
return handle_sysinv(self, table, request, obj_ids)
@ -477,7 +476,7 @@ class ReinstallHost(tables.BatchAction):
return host_locked(host)
def action(self, request, host_id):
api.sysinv.host_reinstall(request, host_id)
stx_api.sysinv.host_reinstall(request, host_id)
def handle(self, table, request, obj_ids):
return handle_sysinv(self, table, request, obj_ids)
@ -505,10 +504,10 @@ class SwactHost(tables.BatchAction):
def allowed(self, request, host=None):
return (host_controller(host) and not host_locked(host) and
not api.sysinv.is_system_mode_simplex(request))
not stx_api.sysinv.is_system_mode_simplex(request))
def action(self, request, host_id):
api.sysinv.host_swact(request, host_id)
stx_api.sysinv.host_swact(request, host_id)
def handle(self, table, request, obj_ids):
return handle_sysinv(self, table, request, obj_ids)
@ -543,14 +542,14 @@ class PatchInstallAsync(tables.BatchAction):
for host_id in obj_ids:
try:
ihost = api.sysinv.host_get(request, host_id)
ihost = stx_api.sysinv.host_get(request, host_id)
except Exception:
exceptions.handle(request,
_('Unable to retrieve host.'))
try:
LOG.info("Installing patch for host %s ...", ihost.hostname)
api.patch.host_install_async(request, ihost.hostname)
stx_api.patch.host_install_async(request, ihost.hostname)
except Exception as ex:
messages.error(request, ex)
return
@ -562,9 +561,9 @@ class UpdateRow(tables.Row):
ajax = True
def get_data(self, request, host_id):
host = api.sysinv.host_get(request, host_id)
host = stx_api.sysinv.host_get(request, host_id)
phost = api.patch.get_host(request, host.hostname)
phost = stx_api.patch.get_host(request, host.hostname)
if phost is not None:
if phost.interim_state is True:
host.patch_current = "Pending"
@ -716,16 +715,16 @@ class Hosts(tables.DataTable):
personality = tables.Column(
"personality",
verbose_name=_("Personality"),
display_choices=Host.PERSONALITY_DISPLAY_CHOICES)
display_choices=stx_api.sysinv.Host.PERSONALITY_DISPLAY_CHOICES)
admin = tables.Column("administrative",
verbose_name=_("Admin State"),
display_choices=Host.ADMIN_DISPLAY_CHOICES)
display_choices=stx_api.sysinv.Host.ADMIN_DISPLAY_CHOICES)
oper = tables.Column("operational",
verbose_name=_("Operational State"),
display_choices=Host.OPER_DISPLAY_CHOICES)
display_choices=stx_api.sysinv.Host.OPER_DISPLAY_CHOICES)
avail = tables.Column("availability",
verbose_name=_("Availability State"),
display_choices=Host.AVAIL_DISPLAY_CHOICES)
display_choices=stx_api.sysinv.Host.AVAIL_DISPLAY_CHOICES)
uptime = tables.Column('boottime',
verbose_name=_('Uptime'),
filters=(timesince,),
@ -837,7 +836,7 @@ class DeleteInterfaceProfile(tables.DeleteAction):
def delete(self, request, interfaceprofile_id):
try:
api.sysinv.host_interfaceprofile_delete(request,
stx_api.sysinv.host_interfaceprofile_delete(request,
interfaceprofile_id)
except Exception:
msg = _(
@ -902,7 +901,7 @@ class DeleteCpuProfile(tables.DeleteAction):
def delete(self, request, cpuprofile_id):
try:
api.sysinv.host_cpuprofile_delete(request, cpuprofile_id)
stx_api.sysinv.host_cpuprofile_delete(request, cpuprofile_id)
except Exception:
msg = _('Failed to delete cpu profile %s') % cpuprofile_id
LOG.info(msg)
@ -958,7 +957,7 @@ class DeleteDiskProfile(tables.DeleteAction):
def delete(self, request, diskprofile_id):
try:
api.sysinv.host_diskprofile_delete(request, diskprofile_id)
stx_api.sysinv.host_diskprofile_delete(request, diskprofile_id)
except Exception as e:
msg = _('Failed to delete storage profile %s') % diskprofile_id
LOG.info(msg)
@ -1054,7 +1053,7 @@ class DeleteMemoryProfile(tables.DeleteAction):
def delete(self, request, memoryprofile_id):
try:
api.sysinv.host_memprofile_delete(request, memoryprofile_id)
stx_api.sysinv.host_memprofile_delete(request, memoryprofile_id)
except Exception as e:
msg = _('Failed to delete memory profile %s') % memoryprofile_id
LOG.info(msg)

View File

@ -14,24 +14,24 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.cpu_functions import \
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.cpu_functions import \
tables as cpufunctions_tables
from openstack_dashboard.dashboards.admin.inventory.devices import \
from starlingx_dashboard.dashboards.admin.inventory.devices import \
tables as device_tables
from openstack_dashboard.dashboards.admin.inventory.interfaces import \
from starlingx_dashboard.dashboards.admin.inventory.interfaces import \
tables as interface_tables
from openstack_dashboard.dashboards.admin.inventory.lldp import \
from starlingx_dashboard.dashboards.admin.inventory.lldp import \
tables as lldp_tables
from openstack_dashboard.dashboards.admin.inventory.memorys import \
from starlingx_dashboard.dashboards.admin.inventory.memorys import \
tables as memory_tables
from openstack_dashboard.dashboards.admin.inventory.ports import \
from starlingx_dashboard.dashboards.admin.inventory.ports import \
tables as port_tables
from openstack_dashboard.dashboards.admin.inventory.sensors import \
from starlingx_dashboard.dashboards.admin.inventory.sensors import \
tables as sensor_tables
from openstack_dashboard.dashboards.admin.inventory.storages import \
from starlingx_dashboard.dashboards.admin.inventory.storages import \
tables as storage_tables
from openstack_dashboard.dashboards.admin.inventory import \
from starlingx_dashboard.dashboards.admin.inventory import \
tables as toplevel_tables
LOG = logging.getLogger(__name__)
@ -55,13 +55,13 @@ class HostsTab(tabs.TableTab):
request = self.request
self.all_hosts = []
try:
self.all_hosts = api.sysinv.host_list(request)
self.all_hosts = stx_api.sysinv.host_list(request)
except Exception:
exceptions.handle(request,
_('Unable to retrieve host list.'))
self.all_phosts = []
try:
self.all_phosts = api.patch.get_hosts(request)
self.all_phosts = stx_api.patch.get_hosts(request)
except Exception:
exceptions.handle(request,
_('Unable to retrieve host list from'
@ -71,11 +71,11 @@ class HostsTab(tabs.TableTab):
hosts = self.all_hosts
phosts = self.all_phosts
if personality == api.sysinv.PERSONALITY_CONTROLLER:
if personality == stx_api.sysinv.PERSONALITY_CONTROLLER:
hosts = [h for h in hosts if h._personality and
h._personality.lower().startswith(
api.sysinv.PERSONALITY_CONTROLLER)]
elif personality == api.sysinv.PERSONALITY_UNKNOWN:
stx_api.sysinv.PERSONALITY_CONTROLLER)]
elif personality == stx_api.sysinv.PERSONALITY_UNKNOWN:
hosts = [h for h in hosts if not h._personality]
else:
hosts = [h for h in hosts if h._personality and
@ -100,22 +100,22 @@ class HostsTab(tabs.TableTab):
return hosts
def get_hostscontroller_data(self):
controllers = self.get_hosts_data(api.sysinv.PERSONALITY_CONTROLLER)
controllers = self.get_hosts_data(stx_api.sysinv.PERSONALITY_CONTROLLER)
return controllers
def get_hostsstorage_data(self):
storages = self.get_hosts_data(api.sysinv.PERSONALITY_STORAGE)
storages = self.get_hosts_data(stx_api.sysinv.PERSONALITY_STORAGE)
return storages
def get_hostscompute_data(self):
computes = self.get_hosts_data(api.sysinv.PERSONALITY_COMPUTE)
computes = self.get_hosts_data(stx_api.sysinv.PERSONALITY_COMPUTE)
return computes
def get_hostsunprovisioned_data(self):
unprovisioned = self.get_hosts_data(api.sysinv.PERSONALITY_UNKNOWN)
unprovisioned = self.get_hosts_data(stx_api.sysinv.PERSONALITY_UNKNOWN)
return unprovisioned
@ -209,7 +209,7 @@ class CpuProfilesTab(tabs.TableTab):
def get_cpuprofiles_data(self):
cpuprofiles = []
try:
cpuprofiles = api.sysinv.host_cpuprofile_list(self.request)
cpuprofiles = stx_api.sysinv.host_cpuprofile_list(self.request)
cpuprofiles.sort(key=lambda f: (f.profilename))
except Exception:
cpuprofiles = []
@ -218,7 +218,7 @@ class CpuProfilesTab(tabs.TableTab):
return cpuprofiles
def allowed(self, request, datum=None):
return not api.sysinv.is_system_mode_simplex(request)
return not stx_api.sysinv.is_system_mode_simplex(request)
class InterfaceProfilesTab(tabs.TableTab):
@ -231,7 +231,7 @@ class InterfaceProfilesTab(tabs.TableTab):
def get_interfaceprofiles_data(self):
interfaceprofiles = []
try:
interfaceprofiles = api.sysinv.host_interfaceprofile_list(
interfaceprofiles = stx_api.sysinv.host_interfaceprofile_list(
self.request)
except Exception:
exceptions.handle(self.request,
@ -240,7 +240,7 @@ class InterfaceProfilesTab(tabs.TableTab):
return interfaceprofiles
def allowed(self, request, dataum=None):
return not api.sysinv.is_system_mode_simplex(request)
return not stx_api.sysinv.is_system_mode_simplex(request)
class DiskProfilesTab(tabs.TableTab):
@ -253,7 +253,7 @@ class DiskProfilesTab(tabs.TableTab):
def get_diskprofiles_data(self):
diskprofiles = []
try:
diskprofiles = api.sysinv.host_diskprofile_list(self.request)
diskprofiles = stx_api.sysinv.host_diskprofile_list(self.request)
for diskprofile in diskprofiles:
journals = {}
@ -278,7 +278,7 @@ class DiskProfilesTab(tabs.TableTab):
return diskprofiles
def allowed(self, request, dataum=None):
return not api.sysinv.is_system_mode_simplex(request)
return not stx_api.sysinv.is_system_mode_simplex(request)
class MemoryProfilesTab(tabs.TableTab):
@ -291,7 +291,7 @@ class MemoryProfilesTab(tabs.TableTab):
def get_memoryprofiles_data(self):
memoryprofiles = []
try:
memoryprofiles = api.sysinv.host_memprofile_list(self.request)
memoryprofiles = stx_api.sysinv.host_memprofile_list(self.request)
except Exception:
exceptions.handle(self.request,
_('Unable to retrieve memory profile list.'))
@ -299,7 +299,7 @@ class MemoryProfilesTab(tabs.TableTab):
return memoryprofiles
def allowed(self, request, dataum=None):
return not api.sysinv.is_system_mode_simplex(request)
return not stx_api.sysinv.is_system_mode_simplex(request)
class DeviceUsageTab(tabs.TableTab):
@ -310,7 +310,7 @@ class DeviceUsageTab(tabs.TableTab):
preload = False
def get_sysinv_devices(self, request):
device_list = api.sysinv.device_list_all(request)
device_list = stx_api.sysinv.device_list_all(request)
return device_list
def get_device_description(self, usage, devices):
@ -328,7 +328,7 @@ class DeviceUsageTab(tabs.TableTab):
deviceusage = []
devices = []
try:
deviceusage = api.nova.get_device_usage_list(self.request)
deviceusage = stx_api.nova.get_device_usage_list(self.request)
devices = self.get_sysinv_devices(self.request)
for du in deviceusage:
du.description = self.get_device_description(du, devices)
@ -495,7 +495,7 @@ class StorageTab(tabs.TableTab):
_('Unable to retrieve inventory details.'),
redirect=redirect)
context['cinder_backend'] = api.sysinv.get_cinder_backend(request)
context['cinder_backend'] = stx_api.sysinv.get_cinder_backend(request)
return context

View File

@ -9,36 +9,35 @@
from django.conf.urls import include # noqa
from django.conf.urls import url
from openstack_dashboard.dashboards.admin.inventory.cpu_functions import \
from starlingx_dashboard.dashboards.admin.inventory.cpu_functions import \
views as cpu_functions_views
from openstack_dashboard.dashboards.admin.inventory.devices import \
from starlingx_dashboard.dashboards.admin.inventory.devices import \
views as device_views
from openstack_dashboard.dashboards.admin.inventory.interfaces.address import \
from starlingx_dashboard.dashboards.admin.inventory.interfaces.address import \
views as address_views
from openstack_dashboard.dashboards.admin.inventory.interfaces.route import \
from starlingx_dashboard.dashboards.admin.inventory.interfaces.route import \
views as route_views
from openstack_dashboard.dashboards.admin.inventory.interfaces import \
from starlingx_dashboard.dashboards.admin.inventory.interfaces import \
views as interface_views
from openstack_dashboard.dashboards.admin.inventory.lldp import \
from starlingx_dashboard.dashboards.admin.inventory.lldp import \
views as lldp_views
from openstack_dashboard.dashboards.admin.inventory.memorys import \
from starlingx_dashboard.dashboards.admin.inventory.memories import \
views as memory_views
from openstack_dashboard.dashboards.admin.inventory.ports import \
from starlingx_dashboard.dashboards.admin.inventory.ports import \
views as port_views
from openstack_dashboard.dashboards.admin.inventory.sensors import \
from starlingx_dashboard.dashboards.admin.inventory.sensors import \
views as sensor_views
from openstack_dashboard.dashboards.admin.inventory.storages import \
from starlingx_dashboard.dashboards.admin.inventory.storages import \
views as storage_views
from openstack_dashboard.dashboards.admin.inventory.views import \
from starlingx_dashboard.dashboards.admin.inventory.views import \
AddView
from openstack_dashboard.dashboards.admin.inventory.views import \
from starlingx_dashboard.dashboards.admin.inventory.views import \
DetailView
from openstack_dashboard.dashboards.admin.inventory.views import \
from starlingx_dashboard.dashboards.admin.inventory.views import \
IndexView
from openstack_dashboard.dashboards.admin.inventory.views import \
from starlingx_dashboard.dashboards.admin.inventory.views import \
UpdateView
from openstack_dashboard.dashboards.admin.inventory.storages \
from starlingx_dashboard.dashboards.admin.inventory.storages \
import urls as storages_urls

View File

@ -16,11 +16,11 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from horizon import workflows
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.inventory.tabs import HostDetailTabs
from openstack_dashboard.dashboards.admin.inventory.tabs import InventoryTabs
from openstack_dashboard.dashboards.admin.inventory.workflows import AddHost
from openstack_dashboard.dashboards.admin.inventory.workflows import UpdateHost
from starlingx_dashboard import api as stx_api
from starlingx_dashboard.dashboards.admin.inventory.tabs import HostDetailTabs
from starlingx_dashboard.dashboards.admin.inventory.tabs import InventoryTabs
from starlingx_dashboard.dashboards.admin.inventory.workflows import AddHost
from starlingx_dashboard.dashboards.admin.inventory.workflows import UpdateHost
LOG = logging.getLogger(__name__)
@ -46,7 +46,7 @@ class AddView(workflows.WorkflowView):
'personality': "",
'subfunctions': "",
'mgmt_mac': "",
'bm_type': api.sysinv.BM_TYPE_NULL,
'bm_type': stx_api.sysinv.BM_TYPE_NULL,
'bm_ip': "",
'bm_username': ""}
@ -63,7 +63,7 @@ class UpdateView(workflows.WorkflowView):
def get_initial(self):
try:
host = api.sysinv.host_get(self.request, self.kwargs['host_id'])
host = stx_api.sysinv.host_get(self.request, self.kwargs['host_id'])
except Exception:
exceptions.handle(self.request,
_("Unable to retrieve host data."))
@ -96,12 +96,12 @@ class DetailView(tabs.TabbedTableView):
# Make the LVG/PV state data clearer to the end user
def _adjust_state_data(self, state, name):
adjustment = ''
if state in [api.sysinv.PV_ADD, api.sysinv.PV_DEL]:
if name == api.sysinv.LVG_CGTS_VG:
if state in [stx_api.sysinv.PV_ADD, stx_api.sysinv.PV_DEL]:
if name == stx_api.sysinv.LVG_CGTS_VG:
adjustment = ' (now)'
elif name == api.sysinv.LVG_CINDER_VOLUMES:
elif name == stx_api.sysinv.LVG_CINDER_VOLUMES:
adjustment = ' (with backend)'
elif name == api.sysinv.LVG_NOVA_LOCAL:
elif name == stx_api.sysinv.LVG_NOVA_LOCAL:
adjustment = ' (on unlock)'
return state + adjustment
@ -109,13 +109,13 @@ class DetailView(tabs.TabbedTableView):
if not hasattr(self, "_host"):
host_id = self.kwargs['host_id']
try:
host = api.sysinv.host_get(self.request, host_id)
host = stx_api.sysinv.host_get(self.request, host_id)
host.nodes = api.sysinv.host_node_list(self.request, host.uuid)
host.cpus = api.sysinv.host_cpu_list(self.request, host.uuid)
host.nodes = stx_api.sysinv.host_node_list(self.request, host.uuid)
host.cpus = stx_api.sysinv.host_cpu_list(self.request, host.uuid)
icpu_utils.restructure_host_cpu_data(host)
host.memorys = api.sysinv.host_memory_list(self.request,
host.memorys = stx_api.sysinv.host_memory_list(self.request,
host.uuid)
for m in host.memorys:
for n in host.nodes:
@ -123,23 +123,23 @@ class DetailView(tabs.TabbedTableView):
m.numa_node = n.numa_node
break
host.ports = api.sysinv.host_port_list(self.request, host.uuid)
host.interfaces = api.sysinv.host_interface_list(self.request,
host.ports = stx_api.sysinv.host_port_list(self.request, host.uuid)
host.interfaces = stx_api.sysinv.host_interface_list(self.request,
host.uuid)
host.devices = api.sysinv.host_device_list(self.request,
host.devices = stx_api.sysinv.host_device_list(self.request,
host.uuid)
host.disks = api.sysinv.host_disk_list(self.request, host.uuid)
host.stors = api.sysinv.host_stor_list(self.request, host.uuid)
host.pvs = api.sysinv.host_pv_list(self.request, host.uuid)
host.partitions = api.sysinv.host_disk_partition_list(
host.disks = stx_api.sysinv.host_disk_list(self.request, host.uuid)
host.stors = stx_api.sysinv.host_stor_list(self.request, host.uuid)
host.pvs = stx_api.sysinv.host_pv_list(self.request, host.uuid)
host.partitions = stx_api.sysinv.host_disk_partition_list(
self.request, host.uuid)
# Translate partition state codes:
for p in host.partitions:
p.status = api.sysinv.PARTITION_STATUS_MSG[p.status]
p.status = stx_api.sysinv.PARTITION_STATUS_MSG[p.status]
host.lldpneighbours = \
api.sysinv.host_lldpneighbour_list(self.request, host.uuid)
stx_api.sysinv.host_lldpneighbour_list(self.request, host.uuid)
# Set the value for neighbours field for each port in the host.
# This will be referenced in Interfaces table
@ -153,7 +153,7 @@ class DetailView(tabs.TabbedTableView):
pv.pv_state = self._adjust_state_data(pv.pv_state,
pv.lvm_vg_name)
host.lvgs = api.sysinv.host_lvg_list(self.request, host.uuid,
host.lvgs = stx_api.sysinv.host_lvg_list(self.request, host.uuid,
get_params=True)
# Adjust lvg state to be more "user friendly"
@ -161,13 +161,13 @@ class DetailView(tabs.TabbedTableView):
lvg.vg_state = self._adjust_state_data(lvg.vg_state,
lvg.lvm_vg_name)
host.sensors = api.sysinv.host_sensor_list(self.request,
host.sensors = stx_api.sysinv.host_sensor_list(self.request,
host.uuid)
host.sensorgroups = api.sysinv.host_sensorgroup_list(
host.sensorgroups = stx_api.sysinv.host_sensorgroup_list(
self.request, host.uuid)
# Add patching status data to hosts
phost = api.patch.get_host(self.request, host.hostname)
phost = stx_api.patch.get_host(self.request, host.hostname)
if phost is not None:
if phost.interim_state is True:
host.patch_current = "Pending"

View File

@ -19,44 +19,44 @@ from horizon import exceptions
from horizon import forms
from horizon.utils import validators
from horizon import workflows
from openstack_dashboard import api
from starlingx_dashboard import api as stx_api
LOG = logging.getLogger(__name__)
PERSONALITY_CHOICES = (
(api.sysinv.PERSONALITY_COMPUTE, _("Compute")),
(api.sysinv.PERSONALITY_CONTROLLER, _("Controller")),
(api.sysinv.PERSONALITY_STORAGE, _("Storage")),
(stx_api.sysinv.PERSONALITY_COMPUTE, _("Compute")),
(stx_api.sysinv.PERSONALITY_CONTROLLER, _("Controller")),
(stx_api.sysinv.PERSONALITY_STORAGE, _("Storage")),
)
FIELD_LABEL_PERFORMANCE_PROFILE = _("Performance Profile")
PERFORMANCE_CHOICES = (
(api.sysinv.SUBFUNCTIONS_COMPUTE, _("Standard")),
(api.sysinv.SUBFUNCTIONS_COMPUTE + ','
+ api.sysinv.SUBFUNCTIONS_LOWLATENCY, _("Low Latency")),
(stx_api.sysinv.SUBFUNCTIONS_COMPUTE, _("Standard")),
(stx_api.sysinv.SUBFUNCTIONS_COMPUTE + ','
+ stx_api.sysinv.SUBFUNCTIONS_LOWLATENCY, _("Low Latency")),
)
PERSONALITY_CHOICES_WITHOUT_STORAGE = (
(api.sysinv.PERSONALITY_COMPUTE, _("Compute")),
(api.sysinv.PERSONALITY_CONTROLLER, _("Controller")),
(stx_api.sysinv.PERSONALITY_COMPUTE, _("Compute")),
(stx_api.sysinv.PERSONALITY_CONTROLLER, _("Controller")),
)
PERSONALITY_CHOICE_CONTROLLER = (
(api.sysinv.PERSONALITY_CONTROLLER, _("Controller")),
(stx_api.sysinv.PERSONALITY_CONTROLLER, _("Controller")),
)
BM_TYPES_CHOICES = (
(api.sysinv.BM_TYPE_NULL, _('No Board Management')),
(api.sysinv.BM_TYPE_GENERIC, _("Board Management Controller")),
(stx_api.sysinv.BM_TYPE_NULL, _('No Board Management')),
(stx_api.sysinv.BM_TYPE_GENERIC, _("Board Management Controller")),
)
def ifprofile_applicable(host, profile):
for interface in profile.interfaces:
if (api.sysinv.PERSONALITY_COMPUTE == host._personality and
if (stx_api.sysinv.PERSONALITY_COMPUTE == host._personality and
interface.networktype == 'oam'):
return False
if (api.sysinv.PERSONALITY_COMPUTE not in host._subfunctions and
if (stx_api.sysinv.PERSONALITY_COMPUTE not in host._subfunctions and
interface.networktype == 'data'):
return False
return True
@ -78,7 +78,7 @@ def diskprofile_applicable(host, diskprofile):
if not len(host.disks) >= len(diskprofile.disks):
return False
if api.sysinv.PERSONALITY_COMPUTE in host._subfunctions:
if stx_api.sysinv.PERSONALITY_COMPUTE in host._subfunctions:
if diskprofile.lvgs:
for lvg in diskprofile.lvgs:
if (hasattr(lvg, 'lvm_vg_name') and
@ -88,10 +88,10 @@ def diskprofile_applicable(host, diskprofile):
return False
else:
return False
elif api.sysinv.PERSONALITY_STORAGE in host._subfunctions:
elif stx_api.sysinv.PERSONALITY_STORAGE in host._subfunctions:
if diskprofile.stors:
if (host.capabilities.get('pers_subtype') ==
api.sysinv.PERSONALITY_SUBTYPE_CEPH_CACHING):
stx_api.sysinv.PERSONALITY_SUBTYPE_CEPH_CACHING):
for pstor in diskprofile.stors:
if pstor.function == 'journal':
return False
@ -114,10 +114,10 @@ def memoryprofile_applicable(host, personality, profile):
def profile_get_uuid(request, profilename):
ifprofiles = api.sysinv.host_interfaceprofile_list(request)
cpuprofiles = api.sysinv.host_cpuprofile_list(request)
storprofiles = api.sysinv.host_diskprofile_list(request)
memoryprofiles = api.sysinv.host_memprofile_list(request)
ifprofiles = stx_api.sysinv.host_interfaceprofile_list(request)
cpuprofiles = stx_api.sysinv.host_cpuprofile_list(request)
storprofiles = stx_api.sysinv.host_diskprofile_list(request)
memoryprofiles = stx_api.sysinv.host_memprofile_list(request)
profiles = ifprofiles + cpuprofiles + storprofiles + memoryprofiles
@ -149,7 +149,7 @@ class AddHostInfoAction(workflows.Action):
attrs={'class': 'switched',
'data-switch-on': 'personality',
'data-personality-' +
api.sysinv.PERSONALITY_COMPUTE: _(
stx_api.sysinv.PERSONALITY_COMPUTE: _(
"Personality Sub-Type")}))
hostname = forms.RegexField(label=FIELD_LABEL_HOSTNAME,
@ -165,7 +165,7 @@ class AddHostInfoAction(workflows.Action):
attrs={'class': 'switched',
'data-switch-on': 'personality',
'data-personality-' +
api.sysinv.PERSONALITY_COMPUTE:
stx_api.sysinv.PERSONALITY_COMPUTE:
FIELD_LABEL_HOSTNAME,
}))
@ -175,11 +175,11 @@ class AddHostInfoAction(workflows.Action):
attrs={'class': 'switched',
'data-switch-on': 'personality',
'data-personality-' +
api.sysinv.PERSONALITY_COMPUTE: FIELD_LABEL_MGMT_MAC,
stx_api.sysinv.PERSONALITY_COMPUTE: FIELD_LABEL_MGMT_MAC,
'data-personality-' +
api.sysinv.PERSONALITY_CONTROLLER: FIELD_LABEL_MGMT_MAC,
stx_api.sysinv.PERSONALITY_CONTROLLER: FIELD_LABEL_MGMT_MAC,
'data-personality-' +
api.sysinv.PERSONALITY_STORAGE: FIELD_LABEL_MGMT_MAC,
stx_api.sysinv.PERSONALITY_STORAGE: FIELD_LABEL_MGMT_MAC,
}))
class Meta(object):
@ -191,13 +191,13 @@ class AddHostInfoAction(workflows.Action):
super(AddHostInfoAction, self).__init__(request, *arg, **kwargs)
# pesonality cannot be storage if ceph is not configured
cinder_backend = api.sysinv.get_cinder_backend(request)
if api.sysinv.CINDER_BACKEND_CEPH not in cinder_backend:
cinder_backend = stx_api.sysinv.get_cinder_backend(request)
if stx_api.sysinv.CINDER_BACKEND_CEPH not in cinder_backend:
self.fields['personality'].choices = \
PERSONALITY_CHOICES_WITHOUT_STORAGE
# All-in-one system, personality can only be controller.
systems = api.sysinv.system_list(request)
systems = stx_api.sysinv.system_list(request)
system_type = systems[0].to_dict().get('system_type')
if system_type == constants.TS_AIO:
self.fields['personality'].choices = \
@ -225,17 +225,17 @@ class UpdateHostInfoAction(workflows.Action):
attrs={'class': 'switched',
'data-switch-on': 'personality',
'data-personality-' +
api.sysinv.PERSONALITY_COMPUTE: _(
stx_api.sysinv.PERSONALITY_COMPUTE: _(
"Performance Profile")}))
pers_subtype = forms.ChoiceField(
label=_("Personality Sub-Type"),
choices=api.sysinv.Host.SUBTYPE_CHOICES,
choices=stx_api.sysinv.Host.SUBTYPE_CHOICES,
widget=forms.Select(
attrs={'class': 'switched',
'data-switch-on': 'personality',
'data-personality-' +
api.sysinv.PERSONALITY_STORAGE: _(
stx_api.sysinv.PERSONALITY_STORAGE: _(
"Personality Sub-Type")}))
hostname = forms.RegexField(label=_("Host Name"),
@ -251,7 +251,7 @@ class UpdateHostInfoAction(workflows.Action):
attrs={'class': 'switched',
'data-switch-on': 'personality',
'data-personality-' +
api.sysinv.PERSONALITY_COMPUTE: _(
stx_api.sysinv.PERSONALITY_COMPUTE: _(
"Host Name")}))
location = forms.CharField(label=_("Location"),
@ -291,13 +291,13 @@ class UpdateHostInfoAction(workflows.Action):
super(UpdateHostInfoAction, self).__init__(request, *args, **kwargs)
# pesonality cannot be storage if ceph is not configured
cinder_backend = api.sysinv.get_cinder_backend(request)
if api.sysinv.CINDER_BACKEND_CEPH not in cinder_backend:
cinder_backend = stx_api.sysinv.get_cinder_backend(request)
if stx_api.sysinv.CINDER_BACKEND_CEPH not in cinder_backend:
self.fields['personality'].choices = \
PERSONALITY_CHOICES_WITHOUT_STORAGE
# All-in-one system, personality can only be controller.
systems = api.sysinv.system_list(request)
systems = stx_api.sysinv.system_list(request)
self.system_mode = systems[0].to_dict().get('system_mode')
self.system_type = systems[0].to_dict().get('system_type')
if self.system_type == constants.TS_AIO:
@ -319,7 +319,7 @@ class UpdateHostInfoAction(workflows.Action):
host_id = self.initial['host_id']
personality = self.initial['personality']
if (api.sysinv.CINDER_BACKEND_CEPH not in api.sysinv.get_cinder_backend(request)) \
if (stx_api.sysinv.CINDER_BACKEND_CEPH not in stx_api.sysinv.get_cinder_backend(request)) \
or personality:
self.fields['pers_subtype'].widget.attrs['disabled'] = 'disabled'
self.fields['pers_subtype'].required = False
@ -331,15 +331,15 @@ class UpdateHostInfoAction(workflows.Action):
self.fields['personality'].required = False
self._personality = personality
host = api.sysinv.host_get(self.request, host_id)
host.nodes = api.sysinv.host_node_list(self.request, host.uuid)
host.cpus = api.sysinv.host_cpu_list(self.request, host.uuid)
host.ports = api.sysinv.host_port_list(self.request, host.uuid)
host.disks = api.sysinv.host_disk_list(self.request, host.uuid)
host = stx_api.sysinv.host_get(self.request, host_id)
host.nodes = stx_api.sysinv.host_node_list(self.request, host.uuid)
host.cpus = stx_api.sysinv.host_cpu_list(self.request, host.uuid)
host.ports = stx_api.sysinv.host_port_list(self.request, host.uuid)
host.disks = stx_api.sysinv.host_disk_list(self.request, host.uuid)
if 'compute' in host.subfunctions:
mem_profile_configurable = True
host.memory = api.sysinv.host_memory_list(
host.memory = stx_api.sysinv.host_memory_list(
self.request, host.uuid)
else:
del self.fields['memoryProfile']
@ -347,7 +347,7 @@ class UpdateHostInfoAction(workflows.Action):
if host.nodes and host.cpus and host.ports:
# Populate Available Cpu Profile Choices
try:
avail_cpu_profile_list = api.sysinv.host_cpuprofile_list(
avail_cpu_profile_list = stx_api.sysinv.host_cpuprofile_list(
self.request)
host_profile = icpu_utils.HostCpuProfile(
@ -357,7 +357,7 @@ class UpdateHostInfoAction(workflows.Action):
cpu_profile_tuple_list = [
('', _("Copy from an available cpu profile."))]
for ip in avail_cpu_profile_list:
nodes = api.sysinv.host_node_list(self.request,
nodes = stx_api.sysinv.host_node_list(self.request,
ip.uuid)
cpu_profile = icpu_utils.CpuProfile(ip.cpus, nodes)
if host_profile.profile_applicable(cpu_profile):
@ -374,7 +374,7 @@ class UpdateHostInfoAction(workflows.Action):
# Populate Available Interface Profile Choices
try:
avail_interface_profile_list = \
api.sysinv.host_interfaceprofile_list(self.request)
stx_api.sysinv.host_interfaceprofile_list(self.request)
interface_profile_tuple_list = [
('', _("Copy from an available interface profile."))]
@ -402,7 +402,7 @@ class UpdateHostInfoAction(workflows.Action):
disk_profile_tuple_list = [
('', _("Copy from an available storage profile."))]
avail_disk_profile_list = \
api.sysinv.host_diskprofile_list(self.request)
stx_api.sysinv.host_diskprofile_list(self.request)
for dp in avail_disk_profile_list:
if diskprofile_applicable(host, dp):
disk_profile_tuple_list.append(
@ -422,7 +422,7 @@ class UpdateHostInfoAction(workflows.Action):
# Populate Available Memory Profile Choices
try:
avail_memory_profile_list = \
api.sysinv.host_memprofile_list(self.request)
stx_api.sysinv.host_memprofile_list(self.request)
memory_profile_tuple_list = [
('', _("Copy from an available memory profile."))]
for mp in avail_memory_profile_list:
@ -449,7 +449,7 @@ class UpdateHostInfoAction(workflows.Action):
def clean_location(self):
try:
host_id = self.cleaned_data['host_id']
host = api.sysinv.host_get(self.request, host_id)
host = stx_api.sysinv.host_get(self.request, host_id)
location = host._location
location['locn'] = self.cleaned_data.get('location')
return location
@ -466,17 +466,17 @@ class UpdateHostInfoAction(workflows.Action):
self._personality = 'controller'
cleaned_data['personality'] = self._personality
if cleaned_data['personality'] == api.sysinv.PERSONALITY_STORAGE:
self._subfunctions = api.sysinv.PERSONALITY_STORAGE
if cleaned_data['personality'] == stx_api.sysinv.PERSONALITY_STORAGE:
self._subfunctions = stx_api.sysinv.PERSONALITY_STORAGE
cleaned_data['subfunctions'] = self._subfunctions
elif cleaned_data['personality'] == api.sysinv.PERSONALITY_CONTROLLER:
elif cleaned_data['personality'] == stx_api.sysinv.PERSONALITY_CONTROLLER:
if self.system_type == constants.TS_AIO:
self._subfunctions = (api.sysinv.PERSONALITY_CONTROLLER + ','
+ api.sysinv.PERSONALITY_COMPUTE)
self._subfunctions = (stx_api.sysinv.PERSONALITY_CONTROLLER + ','
+ stx_api.sysinv.PERSONALITY_COMPUTE)
else:
self._subfunctions = api.sysinv.PERSONALITY_CONTROLLER
self._subfunctions = stx_api.sysinv.PERSONALITY_CONTROLLER
cleaned_data['subfunctions'] = self._subfunctions
elif cleaned_data['personality'] == api.sysinv.PERSONALITY_COMPUTE:
elif cleaned_data['personality'] == stx_api.sysinv.PERSONALITY_COMPUTE:
cleaned_data['pers_subtype'] = None
return cleaned_data
@ -507,8 +507,8 @@ class UpdateHostInfo(workflows.Step):
class UpdateInstallParamsAction(workflows.Action):
INSTALL_OUTPUT_CHOICES = (
(api.sysinv.INSTALL_OUTPUT_TEXT, _("text")),
(api.sysinv.INSTALL_OUTPUT_GRAPHICAL, _("graphical")),
(stx_api.sysinv.INSTALL_OUTPUT_TEXT, _("text")),
(stx_api.sysinv.INSTALL_OUTPUT_GRAPHICAL, _("graphical")),
)
boot_device = forms.RegexField(label=_("Boot Device"),
@ -552,7 +552,7 @@ class UpdateInstallParamsAction(workflows.Action):
**kwargs)
host_id = self.initial['host_id']
host = api.sysinv.host_get(self.request, host_id)
host = stx_api.sysinv.host_get(self.request, host_id)
self.fields['boot_device'].initial = host.boot_device
self.fields['rootfs_device'].initial = host.rootfs_device
@ -599,7 +599,7 @@ class BoardManagementAction(workflows.Action):
'class': 'switched',
'data-switch-on': 'bm_type',
'data-bm_type-' +
api.sysinv.BM_TYPE_GENERIC: FIELD_LABEL_BM_IP}))
stx_api.sysinv.BM_TYPE_GENERIC: FIELD_LABEL_BM_IP}))
bm_username = forms.CharField(
label=FIELD_LABEL_BM_USERNAME,
@ -609,7 +609,7 @@ class BoardManagementAction(workflows.Action):
'class': 'switched',
'data-switch-on': 'bm_type',
'data-bm_type-' +
api.sysinv.BM_TYPE_GENERIC: FIELD_LABEL_BM_USERNAME}))
stx_api.sysinv.BM_TYPE_GENERIC: FIELD_LABEL_BM_USERNAME}))
bm_password = forms.RegexField(
label=FIELD_LABEL_BM_PASSWORD,
@ -620,7 +620,7 @@ class BoardManagementAction(workflows.Action):
'class': 'switched',
'data-switch-on': 'bm_type',
'data-bm_type-' +
api.sysinv.BM_TYPE_GENERIC: FIELD_LABEL_BM_PASSWORD}),
stx_api.sysinv.BM_TYPE_GENERIC: FIELD_LABEL_BM_PASSWORD}),
regex=validators.password_validator(),
required=False,
error_messages={'invalid': validators.password_validator_msg()})
@ -634,7 +634,7 @@ class BoardManagementAction(workflows.Action):
'class': 'switched',
'data-switch-on': 'bm_type',
'data-bm_type-' +
api.sysinv.BM_TYPE_GENERIC: FIELD_LABEL_BM_CONFIRM_PASSWORD}),
stx_api.sysinv.BM_TYPE_GENERIC: FIELD_LABEL_BM_CONFIRM_PASSWORD}),
required=False)
def clean(self):
@ -730,7 +730,7 @@ class AddHost(workflows.Workflow):
self.mgmt_mac = data['mgmt_mac']
try:
host = api.sysinv.host_create(request, **data)
host = stx_api.sysinv.host_create(request, **data)
return True if host else False
except exc.ClientException as ce:
@ -768,18 +768,18 @@ class UpdateHost(workflows.Workflow):
self.hostname = data['hostname']
try:
host = api.sysinv.host_get(request, data['host_id'])
host = stx_api.sysinv.host_get(request, data['host_id'])
if data['cpuProfile']:
profile_uuid = profile_get_uuid(request, data['cpuProfile'])
api.sysinv.host_apply_profile(request, data['host_id'],
stx_api.sysinv.host_apply_profile(request, data['host_id'],
profile_uuid)
data.pop('cpuProfile')
if data['interfaceProfile']:
profile_uuid = profile_get_uuid(request,
data['interfaceProfile'])
api.sysinv.host_apply_profile(request, data['host_id'],
stx_api.sysinv.host_apply_profile(request, data['host_id'],
profile_uuid)
data.pop('interfaceProfile')
@ -788,13 +788,13 @@ class UpdateHost(workflows.Workflow):
if data['diskProfile']:
profile_uuid = profile_get_uuid(request, data['diskProfile'])
api.sysinv.host_apply_profile(request, data['host_id'],
stx_api.sysinv.host_apply_profile(request, data['host_id'],
profile_uuid)
data.pop('diskProfile')
if data['memoryProfile']:
profile_uuid = profile_get_uuid(request, data['memoryProfile'])
api.sysinv.host_apply_profile(request, data['host_id'],
stx_api.sysinv.host_apply_profile(request, data['host_id'],
profile_uuid)
data.pop('memoryProfile')
@ -822,7 +822,7 @@ class UpdateHost(workflows.Workflow):
if host._subfunctions and 'subfunctions' in data:
data.pop('subfunctions')
host = api.sysinv.host_update(request, **data)
host = stx_api.sysinv.host_update(request, **data)
return True if host else False
except exc.ClientException as ce: