diff --git a/starlingx_dashboard/api/nova.py b/starlingx_dashboard/api/nova.py index 2a52a870..bc6e872c 100644 --- a/starlingx_dashboard/api/nova.py +++ b/starlingx_dashboard/api/nova.py @@ -7,6 +7,7 @@ from novaclient.v2 import wrs_pci from novaclient.v2 import wrs_providernets +from openstack_dashboard.api import base from openstack_dashboard.api.nova import * @@ -66,8 +67,3 @@ 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) diff --git a/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/forms.py b/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/forms.py index ba215e5c..1091ac58 100644 --- a/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/forms.py +++ b/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/forms.py @@ -16,7 +16,8 @@ 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.api import sysinv LOG = logging.getLogger(__name__) @@ -304,7 +305,7 @@ class UpdateCpuFunctions(forms.SelfHandlingForm): del data['host'] try: - host = api.sysinv.host_get(self.request, host_id) + host = sysinv.host_get(self.request, host_id) cpudata = {} sharedcpudata = {} platformcpudata = {} @@ -333,10 +334,10 @@ class UpdateCpuFunctions(forms.SelfHandlingForm): sharedcpudata['function'] = 'shared' platformcpudata['function'] = 'platform' - api.sysinv.host_cpus_modify(request, host.uuid, - platformcpudata, - cpudata, - sharedcpudata) + sysinv.host_cpus_modify(request, host.uuid, + platformcpudata, + cpudata, + sharedcpudata) msg = _('CPU Assignments were successfully updated.') LOG.debug(msg) messages.success(request, msg) @@ -376,7 +377,7 @@ class AddCpuProfile(forms.SelfHandlingForm): cpuProfileName = data['profilename'] try: - cpuProfile = api.sysinv.host_cpuprofile_create(request, **data) + cpuProfile = sysinv.host_cpuprofile_create(request, **data) msg = _( 'Cpu Profile "%s" was successfully created.') % cpuProfileName LOG.debug(msg) diff --git a/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/views.py b/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/views.py index b731929e..cc396639 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/views.py +++ b/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/views.py @@ -15,7 +15,8 @@ from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon import forms -from starlingx_dashboard import api as stx_api + +from starlingx_dashboard.api import sysinv from starlingx_dashboard.dashboards.admin.inventory.cpu_functions.forms \ import AddCpuProfile from starlingx_dashboard.dashboards.admin.inventory.cpu_functions.forms \ @@ -40,9 +41,9 @@ class UpdateCpuFunctionsView(forms.ModalFormView): if not hasattr(self, "_object"): host_id = self.kwargs['host_id'] try: - 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 = sysinv.host_get(self.request, host_id) + host.nodes = sysinv.host_node_list(self.request, host.uuid) + host.cpus = 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 +166,9 @@ class AddCpuProfileView(forms.ModalFormView): if not hasattr(self, "_host"): host_id = self.kwargs['host_id'] try: - 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 = sysinv.host_get(self.request, host_id) + host.nodes = sysinv.host_node_list(self.request, host.uuid) + host.cpus = sysinv.host_cpu_list(self.request, host.uuid) icpu_utils.restructure_host_cpu_data(host) except Exception: redirect = reverse('horizon:admin:inventory:index') diff --git a/starlingx_dashboard/dashboards/admin/inventory/devices/forms.py b/starlingx_dashboard/dashboards/admin/inventory/devices/forms.py index bd723a87..41b7aa57 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/devices/forms.py +++ b/starlingx_dashboard/dashboards/admin/inventory/devices/forms.py @@ -14,7 +14,8 @@ 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 LOG = logging.getLogger(__name__) @@ -63,7 +64,7 @@ class UpdateDevice(forms.SelfHandlingForm): p = {} p['name'] = name p['enabled'] = str(data['enabled']) - device = api.sysinv.host_device_update(request, uuid, **p) + device = stx_api.sysinv.host_device_update(request, uuid, **p) msg = _('device "%s" was successfully updated.') % name LOG.debug(msg) messages.success(request, msg) diff --git a/starlingx_dashboard/dashboards/admin/inventory/devices/tables.py b/starlingx_dashboard/dashboards/admin/inventory/devices/tables.py index 58698640..f3c0eac4 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/devices/tables.py +++ b/starlingx_dashboard/dashboards/admin/inventory/devices/tables.py @@ -14,7 +14,7 @@ from django.utils.translation import ugettext_lazy as _ from horizon import tables -from openstack_dashboard import api +from starlingx_dashboard import api as stx_api LOG = logging.getLogger(__name__) @@ -32,7 +32,7 @@ class EditDevice(tables.LinkAction): def allowed(self, request, datum): host = self.table.kwargs['host'] return (host._administrative == 'locked' and - api.sysinv.SUBFUNCTIONS_COMPUTE in host.subfunctions) + stx_api.sysinv.SUBFUNCTIONS_COMPUTE in host.subfunctions) def get_viewdevice_link_url(device): diff --git a/starlingx_dashboard/dashboards/admin/inventory/devices/views.py b/starlingx_dashboard/dashboards/admin/inventory/devices/views.py index f1c91060..7424e290 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/devices/views.py +++ b/starlingx_dashboard/dashboards/admin/inventory/devices/views.py @@ -16,7 +16,7 @@ from horizon import forms from horizon import tables from horizon.utils import memoized from horizon import views -from openstack_dashboard import api + from starlingx_dashboard import api as stx_api from starlingx_dashboard.dashboards.admin.inventory.devices.forms import \ UpdateDevice @@ -155,7 +155,7 @@ class UsageView(tables.MultiTableView): if not hasattr(self, "_usage_object"): dev_id = self.kwargs['device_id'] try: - _object = api.nova.get_device_usage(self.request, dev_id) + _object = stx_api.nova.get_device_usage(self.request, dev_id) self._usage_object = _object except Exception: self._handle_exception(dev_id) diff --git a/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/forms.py b/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/forms.py index b9d1320f..b19f92ba 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/forms.py +++ b/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/forms.py @@ -20,10 +20,12 @@ import logging from django.core.urlresolvers import reverse from django import shortcuts from django.utils.translation import ugettext_lazy as _ + import netaddr from horizon import forms from horizon import messages + from starlingx_dashboard import api as stx_api LOG = logging.getLogger(__name__) diff --git a/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/tables.py b/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/tables.py index 3a99b0cf..d8befd14 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/tables.py +++ b/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/tables.py @@ -20,6 +20,7 @@ from django.utils.translation import ungettext_lazy from horizon import exceptions from horizon import tables + from starlingx_dashboard import api as stx_api LOG = logging.getLogger(__name__) diff --git a/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py b/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py index 4dbca9d1..c6cd4437 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py +++ b/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py @@ -21,7 +21,9 @@ 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.api import neutron +from starlingx_dashboard.api import sysinv LOG = logging.getLogger(__name__) @@ -99,8 +101,8 @@ class AddInterfaceProfile(forms.SelfHandlingForm): host_id = data['host_id'] interfaceProfileName = data['profilename'] try: - interfaceProfile = api.sysinv.host_interfaceprofile_create(request, - **data) + interfaceProfile = sysinv.host_interfaceprofile_create(request, + **data) msg = _( 'Interface Profile "%s" was ' 'successfully created.') % interfaceProfileName @@ -391,7 +393,7 @@ class AddInterface(forms.SelfHandlingForm): current_interface = None if (type(self) is UpdateInterface): this_interface_id = kwargs['initial']['id'] - current_interface = api.sysinv.host_interface_get( + current_interface = sysinv.host_interface_get( self.request, this_interface_id) else: self.fields['providernetworks_sriov'].widget = \ @@ -406,13 +408,13 @@ class AddInterface(forms.SelfHandlingForm): sdn_l3_mode = kwargs['initial']['sdn_l3_mode_enabled'] # Populate Address Pool selections - pools = api.sysinv.address_pool_list(self.request) + pools = sysinv.address_pool_list(self.request) self.fields['ipv4_pool'].choices = _get_ipv4_pool_choices(pools) self.fields['ipv6_pool'].choices = _get_ipv6_pool_choices(pools) # Populate Provider Network Choices by querying Neutron self.extras = {} - interfaces = api.sysinv.host_interface_list(self.request, host_uuid) + interfaces = sysinv.host_interface_list(self.request, host_uuid) used_providernets = [] for i in interfaces: @@ -428,7 +430,7 @@ class AddInterface(forms.SelfHandlingForm): providernet_choices = [] providernet_filtered = [] providernet_flat = None - providernets = api.neutron.provider_network_list(self.request) + providernets = neutron.provider_network_list(self.request) for provider in providernets: label = "{} (mtu={})".format(provider.name, provider.mtu) providernet = (str(provider.name), label) @@ -460,14 +462,14 @@ class AddInterface(forms.SelfHandlingForm): if not current_interface.uses: # update default interfaces self.fields['uses'].widget = forms.widgets.HiddenInput() - avail_port_list = api.sysinv.host_port_list( + avail_port_list = sysinv.host_port_list( self.request, host_uuid) for p in avail_port_list: if p.interface_uuid == this_interface_id: self.fields['ports'].initial = p.uuid else: # update non default interfaces - avail_interface_list = api.sysinv.host_interface_list( + avail_interface_list = sysinv.host_interface_list( self.request, host_uuid) interface_tuple_list = [] for i in avail_interface_list: @@ -487,7 +489,7 @@ class AddInterface(forms.SelfHandlingForm): else: # add operation - avail_interface_list = api.sysinv.host_interface_list( + avail_interface_list = sysinv.host_interface_list( self.request, host_uuid) interface_tuple_list = [] for i in avail_interface_list: @@ -591,7 +593,7 @@ class AddInterface(forms.SelfHandlingForm): elif data['aemode'] == 'active_standby': del data['txhashpolicy'] - interface = api.sysinv.host_interface_create(request, **data) + interface = sysinv.host_interface_create(request, **data) msg = _('Interface "%s" was successfully' ' created.') % data['ifname'] LOG.debug(msg) @@ -685,7 +687,7 @@ class UpdateInterface(AddInterface): self.fields['aemode'].choices = self.AE_MODE_CHOICES # Populate Address Pool selections - pools = api.sysinv.address_pool_list(self.request) + pools = sysinv.address_pool_list(self.request) self.fields['ipv4_pool'].choices = _get_ipv4_pool_choices(pools) self.fields['ipv6_pool'].choices = _get_ipv6_pool_choices(pools) self.fields['ipv4_pool'].initial = kwargs['initial'].get('ipv4_pool') @@ -745,8 +747,8 @@ class UpdateInterface(AddInterface): self.fields['networktype'].initial = ('none', 'none') # Get the total possible number of VFs for SRIOV network type - port_list = api.sysinv.host_port_list(self.request, - host_uuid) + port_list = sysinv.host_port_list(self.request, + host_uuid) for p in port_list: if p.interface_uuid == this_interface_id: if p.sriov_totalvfs: @@ -801,9 +803,9 @@ class UpdateInterface(AddInterface): del data['txhashpolicy'] if 'none' in data['networktype']: - avail_port_list = api.sysinv.host_port_list( + avail_port_list = sysinv.host_port_list( self.request, host_uuid) - current_interface = api.sysinv.host_interface_get( + current_interface = sysinv.host_interface_get( self.request, interface_id) if data['iftype'] != 'ae' or data['iftype'] != 'vlan': for p in avail_port_list: @@ -826,7 +828,7 @@ class UpdateInterface(AddInterface): flatten(list(nt) for nt in self.fields['networktype'].choices) if 'pci-passthrough' in network_type or \ ('pci-sriov' in network_type and data['sriov_numvfs']): - current_interface = api.sysinv.host_interface_get( + current_interface = sysinv.host_interface_get( self.request, interface_id) if current_interface.iftype != 'ethernet': # Only ethernet interfaces can be pci-sriov @@ -847,8 +849,8 @@ class UpdateInterface(AddInterface): if data['networktype']: data['networktype'] = ",".join(data['networktype']) - interface = api.sysinv.host_interface_update(request, interface_id, - **data) + interface = sysinv.host_interface_update(request, interface_id, + **data) # FIXME: this should be done under # the interface update API of sysinv diff --git a/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/forms.py b/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/forms.py index faca8943..80b83091 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/forms.py +++ b/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/forms.py @@ -24,6 +24,7 @@ import netaddr from horizon import forms from horizon import messages + from starlingx_dashboard import api as stx_api LOG = logging.getLogger(__name__) diff --git a/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/tables.py b/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/tables.py index 13624236..7ae5e4c9 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/tables.py +++ b/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/tables.py @@ -20,6 +20,7 @@ from django.utils.translation import ungettext_lazy from horizon import exceptions from horizon import tables + from starlingx_dashboard import api as stx_api LOG = logging.getLogger(__name__) diff --git a/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/views.py b/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/views.py index 4af7c5ae..cb3f410b 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/views.py +++ b/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/views.py @@ -18,6 +18,7 @@ import logging from django.core.urlresolvers import reverse # noqa from horizon import forms + from starlingx_dashboard.dashboards.admin.inventory.interfaces.route import \ forms as route_forms diff --git a/starlingx_dashboard/dashboards/admin/inventory/interfaces/tables.py b/starlingx_dashboard/dashboards/admin/inventory/interfaces/tables.py index e6d89141..d396d724 100644 --- a/starlingx_dashboard/dashboards/admin/inventory/interfaces/tables.py +++ b/starlingx_dashboard/dashboards/admin/inventory/interfaces/tables.py @@ -13,7 +13,8 @@ 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__) @@ -45,7 +46,7 @@ class DeleteInterface(tables.DeleteAction): def delete(self, request, interface_id): host_id = self.table.kwargs['host_id'] try: - api.sysinv.host_interface_delete(request, interface_id) + stx_api.sysinv.host_interface_delete(request, interface_id) except Exception: msg = _('Failed to delete host %(hid)s interface %(iid)s') % { 'hid': host_id, 'iid': interface_id} @@ -66,7 +67,7 @@ class CreateInterfaceProfile(tables.LinkAction): return reverse(self.url, args=(host_id,)) def allowed(self, request, datum): - return not api.sysinv.is_system_mode_simplex(request) + return not stx_api.sysinv.is_system_mode_simplex(request) class CreateInterface(tables.LinkAction): diff --git a/starlingx_dashboard/dashboards/admin/inventory/lldp/views.py b/starlingx_dashboard/dashboards/admin/inventory/lldp/views.py index 6476cf45..93c9a96b 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/lldp/views.py +++ b/starlingx_dashboard/dashboards/admin/inventory/lldp/views.py @@ -14,7 +14,8 @@ from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon.utils import memoized from horizon import views -from openstack_dashboard import api + +from starlingx_dashboard import api as stx_api LOG = logging.getLogger(__name__) @@ -28,8 +29,8 @@ class DetailNeighbourView(views.HorizonTemplateView): neighbour_uuid = self.kwargs['neighbour_uuid'] try: self._object = \ - api.sysinv.host_lldpneighbour_get(self.request, - neighbour_uuid) + stx_api.sysinv.host_lldpneighbour_get(self.request, + neighbour_uuid) except Exception: redirect = reverse('horizon:admin:inventory:index') @@ -91,7 +92,7 @@ class DetailNeighbourView(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.') diff --git a/starlingx_dashboard/dashboards/admin/inventory/memories/forms.py b/starlingx_dashboard/dashboards/admin/inventory/memories/forms.py index f89a24ce..90e4ee1b 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/memories/forms.py +++ b/starlingx_dashboard/dashboards/admin/inventory/memories/forms.py @@ -16,7 +16,8 @@ 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__) @@ -287,8 +288,8 @@ class UpdateMemory(forms.SelfHandlingForm): new_data['vm_hugepages_nr_1G_pending'] = pages_1G[nd] if new_data: - api.sysinv.host_memory_update(request, m.uuid, - **new_data) + stx_api.sysinv.host_memory_update(request, m.uuid, + **new_data) else: msg = _('Failed to find %s') % nd @@ -338,7 +339,7 @@ class AddMemoryProfile(forms.SelfHandlingForm): memoryProfileName = data['profilename'] try: - memoryProfile = api.sysinv.host_memprofile_create(request, **data) + memoryProfile = stx_api.sysinv.host_memprofile_create(request, **data) msg = _('Memory Profile "%s" was successfully created.') % \ memoryProfileName LOG.debug(msg) diff --git a/starlingx_dashboard/dashboards/admin/inventory/memories/tables.py b/starlingx_dashboard/dashboards/admin/inventory/memories/tables.py index b8ee31af..1777f91a 100644 --- a/starlingx_dashboard/dashboards/admin/inventory/memories/tables.py +++ b/starlingx_dashboard/dashboards/admin/inventory/memories/tables.py @@ -11,7 +11,8 @@ from django import template from django.utils.translation import ugettext_lazy as _ from horizon import tables -from openstack_dashboard import api + +from starlingx_dashboard import api as stx_api LOG = logging.getLogger(__name__) @@ -48,7 +49,7 @@ class CreateMemoryProfile(tables.LinkAction): if host.subfunctions and 'compute' not in host.subfunctions: return False return (host.invprovision == 'provisioned' and - not api.sysinv.is_system_mode_simplex(request)) + not stx_api.sysinv.is_system_mode_simplex(request)) def get_processor_memory(memory): diff --git a/starlingx_dashboard/dashboards/admin/inventory/memories/views.py b/starlingx_dashboard/dashboards/admin/inventory/memories/views.py index 5976184d..9e0b5053 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/memories/views.py +++ b/starlingx_dashboard/dashboards/admin/inventory/memories/views.py @@ -13,6 +13,7 @@ from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon import forms + from starlingx_dashboard import api as stx_api from starlingx_dashboard.dashboards.admin.inventory.memories.forms import \ AddMemoryProfile diff --git a/starlingx_dashboard/dashboards/admin/inventory/ports/forms.py b/starlingx_dashboard/dashboards/admin/inventory/ports/forms.py index 69292502..025bdd27 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/ports/forms.py +++ b/starlingx_dashboard/dashboards/admin/inventory/ports/forms.py @@ -14,7 +14,8 @@ 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__) @@ -109,7 +110,7 @@ class UpdatePort(forms.SelfHandlingForm): del data['id'] try: - port = api.sysinv.host_port_update(request, port_id, **data) + port = stx_api.sysinv.host_port_update(request, port_id, **data) msg = _('Port "%s" was successfully updated.') % deviceName LOG.debug(msg) messages.success(request, msg) diff --git a/starlingx_dashboard/dashboards/admin/inventory/ports/views.py b/starlingx_dashboard/dashboards/admin/inventory/ports/views.py index d04e8df3..e88c85c0 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/ports/views.py +++ b/starlingx_dashboard/dashboards/admin/inventory/ports/views.py @@ -16,6 +16,7 @@ from horizon import exceptions from horizon import forms from horizon.utils import memoized from horizon import views + from starlingx_dashboard import api as stx_api from starlingx_dashboard.dashboards.admin.inventory.ports.forms import \ UpdatePort diff --git a/starlingx_dashboard/dashboards/admin/inventory/sensors/forms.py b/starlingx_dashboard/dashboards/admin/inventory/sensors/forms.py index 908487d7..9a17e3b6 100644 --- a/starlingx_dashboard/dashboards/admin/inventory/sensors/forms.py +++ b/starlingx_dashboard/dashboards/admin/inventory/sensors/forms.py @@ -9,6 +9,7 @@ import logging from cgtsclient import exc + from django.core.urlresolvers import reverse # noqa from django import shortcuts from django.utils.translation import ugettext_lazy as _ @@ -16,6 +17,7 @@ from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon import forms from horizon import messages + from starlingx_dashboard import api as stx_api LOG = logging.getLogger(__name__) diff --git a/starlingx_dashboard/dashboards/admin/inventory/sensors/tables.py b/starlingx_dashboard/dashboards/admin/inventory/sensors/tables.py index 0baae73d..bcb3fdfd 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/sensors/tables.py +++ b/starlingx_dashboard/dashboards/admin/inventory/sensors/tables.py @@ -7,7 +7,6 @@ import logging from django.core.urlresolvers import reverse # noqa -# from django.template import defaultfilters as filters from django import template from django.utils.translation import string_concat # noqa from django.utils.translation import ugettext_lazy as _ @@ -15,6 +14,7 @@ from django.utils.translation import ungettext_lazy from horizon import exceptions from horizon import tables + from starlingx_dashboard import api as stx_api from starlingx_dashboard.dashboards.admin.inventory import tables as itables diff --git a/starlingx_dashboard/dashboards/admin/inventory/sensors/views.py b/starlingx_dashboard/dashboards/admin/inventory/sensors/views.py index ad71b5db..6b7089d2 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/sensors/views.py +++ b/starlingx_dashboard/dashboards/admin/inventory/sensors/views.py @@ -15,13 +15,12 @@ from horizon import exceptions from horizon import forms from horizon.utils import memoized from horizon import views + from starlingx_dashboard import api as stx_api from starlingx_dashboard.dashboards.admin.inventory.sensors.forms import \ AddSensorGroup from starlingx_dashboard.dashboards.admin.inventory.sensors.forms import \ UpdateSensorGroup -# from openstack_dashboard.dashboards.admin.inventory.sensors.forms import \ -# AddSensor LOG = logging.getLogger(__name__) diff --git a/starlingx_dashboard/dashboards/admin/inventory/storages/forms.py b/starlingx_dashboard/dashboards/admin/inventory/storages/forms.py index e3144cbf..df46739d 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/storages/forms.py +++ b/starlingx_dashboard/dashboards/admin/inventory/storages/forms.py @@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon import forms from horizon import messages + from starlingx_dashboard import api as stx_api LOG = logging.getLogger(__name__) diff --git a/starlingx_dashboard/dashboards/admin/inventory/storages/lvg_params/forms.py b/starlingx_dashboard/dashboards/admin/inventory/storages/lvg_params/forms.py index 12e046fb..5aabb1d6 100644 --- a/starlingx_dashboard/dashboards/admin/inventory/storages/lvg_params/forms.py +++ b/starlingx_dashboard/dashboards/admin/inventory/storages/lvg_params/forms.py @@ -1,5 +1,3 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - # Copyright (c) 2015-2017 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 @@ -14,53 +12,55 @@ from django.utils.translation import ugettext_lazy as _ # noqa from horizon import exceptions from horizon import forms from horizon import messages -from starlingx_dashboard import api as stx_api + from oslo_serialization import jsonutils +from starlingx_dashboard.api import sysinv + LOG = logging.getLogger(__name__) NOVA_PARAMS_FIELD_MAP = { - 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, + 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, } CINDER_PARAMS_FIELD_MAP = { - stx_api.sysinv.LVG_CINDER_PARAM_LVM_TYPE: - stx_api.sysinv.LVG_CINDER_PARAM_LVM_TYPE, + sysinv.LVG_CINDER_PARAM_LVM_TYPE: + sysinv.LVG_CINDER_PARAM_LVM_TYPE, } NOVA_PARAMS_KEY_MAP = ( - (stx_api.sysinv.LVG_NOVA_PARAM_BACKING, + (sysinv.LVG_NOVA_PARAM_BACKING, _("Instance Backing")), - (stx_api.sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB, + (sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB, _("Instances LV Size [in MiB]")), - (stx_api.sysinv.LVG_NOVA_PARAM_DISK_OPS, + (sysinv.LVG_NOVA_PARAM_DISK_OPS, _("Concurrent Disk Operations")), ) CINDER_PARAMS_KEY_MAP = ( - (stx_api.sysinv.LVG_CINDER_PARAM_LVM_TYPE, + (sysinv.LVG_CINDER_PARAM_LVM_TYPE, _("LVM Provisioning Type")), ) PARAMS_HELP = { - stx_api.sysinv.LVG_NOVA_PARAM_BACKING: + 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', - stx_api.sysinv.LVG_NOVA_PARAM_DISK_OPS: + sysinv.LVG_NOVA_PARAM_DISK_OPS: 'Number of parallel disk I/O intensive operations (glance image downloads, \ image format conversions, etc.).', - stx_api.sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB: + 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.', - stx_api.sysinv.LVG_CINDER_PARAM_LVM_TYPE: + 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', @@ -75,14 +75,14 @@ CINDER_PARAMS_KEY_NAMES = dict(CINDER_PARAMS_KEY_MAP) CINDER_PARAMS_CHOICES = CINDER_PARAMS_KEY_MAP BACKING_CHOICES = ( - (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")), + (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")), ) LVM_TYPE_CHOICES = ( - (stx_api.sysinv.LVG_CINDER_LVM_TYPE_THICK, _("Thick Provisioning (default)")), - (stx_api.sysinv.LVG_CINDER_LVM_TYPE_THIN, _("Thin Provisioning (thin)")), + (sysinv.LVG_CINDER_LVM_TYPE_THICK, _("Thick Provisioning (default)")), + (sysinv.LVG_CINDER_LVM_TYPE_THIN, _("Thin Provisioning (thin)")), ) @@ -97,7 +97,7 @@ class ParamMixin(object): def _host_lvg_get(self, lvg_id): try: - return stx_api.sysinv.host_lvg_get(self.request, lvg_id) + return sysinv.host_lvg_get(self.request, lvg_id) except Exception: exceptions.handle( self.request, @@ -106,7 +106,7 @@ class ParamMixin(object): def _host_pv_list(self, host_id): try: - return stx_api.sysinv.host_pv_list(self.request, host_id) + return sysinv.host_pv_list(self.request, host_id) except Exception: exceptions.handle( self.request, @@ -115,7 +115,7 @@ class ParamMixin(object): def _host_pv_disk_get(self, pv): try: - return stx_api.sysinv.host_disk_get(self.request, pv.disk_or_part_uuid) + return sysinv.host_disk_get(self.request, pv.disk_or_part_uuid) except Exception: exceptions.handle( self.request, @@ -340,7 +340,7 @@ class EditParam(ParamForm): 'value': jsonutils.dumps(metadata), 'op': 'replace'}) - stx_api.sysinv.host_lvg_update(request, lvg_id, patch) + sysinv.host_lvg_update(request, lvg_id, patch) msg = _('Updated parameter "%s".') % data['key'] messages.success(request, msg) return True diff --git a/starlingx_dashboard/dashboards/admin/inventory/storages/lvg_params/views.py b/starlingx_dashboard/dashboards/admin/inventory/storages/lvg_params/views.py index 3f720691..4d15321c 100644 --- a/starlingx_dashboard/dashboards/admin/inventory/storages/lvg_params/views.py +++ b/starlingx_dashboard/dashboards/admin/inventory/storages/lvg_params/views.py @@ -12,6 +12,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa from horizon import exceptions from horizon import forms + from starlingx_dashboard import api as stx_api from starlingx_dashboard.dashboards.admin.inventory.storages.lvg_params \ import forms as project_forms diff --git a/starlingx_dashboard/dashboards/admin/inventory/storages/tables.py b/starlingx_dashboard/dashboards/admin/inventory/storages/tables.py index 66f598c8..528e47d0 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/storages/tables.py +++ b/starlingx_dashboard/dashboards/admin/inventory/storages/tables.py @@ -16,7 +16,8 @@ from django.utils.translation import ungettext_lazy from horizon import exceptions from horizon import tables -from starlingx_dashboard import api as stx_api + +from starlingx_dashboard.api import sysinv LOG = logging.getLogger(__name__) @@ -109,11 +110,11 @@ class DeletePartition(tables.DeleteAction): def allowed(self, request, partition=None): host = self.table.kwargs['host'] - PARTITION_IN_USE_STATUS = stx_api.sysinv.PARTITION_IN_USE_STATUS - PARTITION_STATUS_MSG = stx_api.sysinv.PARTITION_STATUS_MSG + PARTITION_IN_USE_STATUS = sysinv.PARTITION_IN_USE_STATUS + PARTITION_STATUS_MSG = sysinv.PARTITION_STATUS_MSG if partition: - if partition.type_guid != stx_api.sysinv.USER_PARTITION_PHYS_VOL: + if partition.type_guid != sysinv.USER_PARTITION_PHYS_VOL: return False if (partition.status == @@ -125,8 +126,8 @@ class DeletePartition(tables.DeleteAction): # Get all the partitions from the same disk. disk_partitions = \ - stx_api.sysinv.host_disk_partition_list(request, host.uuid, - partition.idisk_uuid) + sysinv.host_disk_partition_list(request, host.uuid, + partition.idisk_uuid) if partition.device_path: partition_number = re.match('.*?([0-9]+)$', @@ -142,7 +143,7 @@ class DeletePartition(tables.DeleteAction): def delete(self, request, partition_id): host_id = self.table.kwargs['host_id'] try: - stx_api.sysinv.host_disk_partition_delete(request, partition_id) + 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, @@ -167,19 +168,19 @@ class EditPartition(tables.LinkAction): def allowed(self, request, partition=None): host = self.table.kwargs['host'] - PARTITION_IN_USE_STATUS = stx_api.sysinv.PARTITION_IN_USE_STATUS - PARTITION_STATUS_MSG = stx_api.sysinv.PARTITION_STATUS_MSG + PARTITION_IN_USE_STATUS = sysinv.PARTITION_IN_USE_STATUS + PARTITION_STATUS_MSG = sysinv.PARTITION_STATUS_MSG if partition: pv = None - if partition.type_guid != stx_api.sysinv.USER_PARTITION_PHYS_VOL: + if partition.type_guid != sysinv.USER_PARTITION_PHYS_VOL: return False if partition.ipv_uuid: - pv = stx_api.sysinv.host_pv_get( + pv = sysinv.host_pv_get( request, partition.ipv_uuid) - if pv.lvm_vg_name == stx_api.sysinv.LVG_CINDER_VOLUMES: + if pv.lvm_vg_name == sysinv.LVG_CINDER_VOLUMES: if (host.personality == "Controller-Active" and host._administrative == 'unlocked'): return False @@ -189,14 +190,14 @@ class EditPartition(tables.LinkAction): if (partition.status == PARTITION_STATUS_MSG[PARTITION_IN_USE_STATUS]): if not (pv and - pv.lvm_vg_name == stx_api.sysinv.LVG_CINDER_VOLUMES): + pv.lvm_vg_name == sysinv.LVG_CINDER_VOLUMES): return False # Get all the partitions from the same disk. disk_partitions = \ - stx_api.sysinv.host_disk_partition_list(request, - host.uuid, - partition.idisk_uuid) + sysinv.host_disk_partition_list(request, + host.uuid, + partition.idisk_uuid) if partition.device_path: partition_number = re.match('.*?([0-9]+)$', @@ -286,8 +287,8 @@ class EditStor(tables.LinkAction): if stor and stor.function == 'osd': forihostuuid = self.table.kwargs['host'].uuid journal_stors = \ - stx_api.sysinv.host_stor_get_by_function(request, forihostuuid, - 'journal') + sysinv.host_stor_get_by_function(request, forihostuuid, + 'journal') if not journal_stors: self.classes = [c for c in self.classes] + ['disabled'] @@ -327,7 +328,7 @@ class DeleteStor(tables.DeleteAction): return stor.function == 'journal' def delete(self, request, obj_id): - stx_api.sysinv.host_stor_delete(request, obj_id) + sysinv.host_stor_delete(request, obj_id) class StorageVolumesTable(tables.DataTable): @@ -386,17 +387,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 = [stx_api.sysinv.LVG_ADD, stx_api.sysinv.LVG_PROV] - ilvg_list = stx_api.sysinv.host_lvg_list(request, host.uuid) + current_lvg_states = [sysinv.LVG_ADD, sysinv.LVG_PROV] + ilvg_list = 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 += [stx_api.sysinv.LVG_CINDER_VOLUMES] + compatible_lvgs += [sysinv.LVG_CINDER_VOLUMES] if 'compute' in host._subfunctions: - compatible_lvgs += [stx_api.sysinv.LVG_NOVA_LOCAL] + compatible_lvgs += [sysinv.LVG_NOVA_LOCAL] allowed_lvgs = set(compatible_lvgs) - set(current_lvgs) if not any(allowed_lvgs): @@ -427,22 +428,22 @@ class RemoveLocalVolumeGroup(tables.DeleteAction): def allowed(self, request, lvg=None): host = self.table.kwargs['host'] - cinder_backend = stx_api.sysinv.get_cinder_backend(request) + cinder_backend = sysinv.get_cinder_backend(request) - if lvg.lvm_vg_name == stx_api.sysinv.LVG_NOVA_LOCAL: + if lvg.lvm_vg_name == 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 == 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) + elif lvg.lvm_vg_name == sysinv.LVG_CINDER_VOLUMES: + return (sysinv.CINDER_BACKEND_LVM not in cinder_backend and + sysinv.LVG_ADD in lvg.vg_state) return False def delete(self, request, lvg_id): host_id = self.table.kwargs['host_id'] try: - stx_api.sysinv.host_lvg_delete(request, lvg_id) + sysinv.host_lvg_delete(request, lvg_id) except Exception as e: msg = _('Failed to delete host %(hid)s local ' 'volume group %(lvg)s ' @@ -506,7 +507,7 @@ class AddPhysicalVolume(tables.LinkAction): self.classes = classes # cgts-vg, cinder-volumes: Allow adding to any controller - if host._personality == stx_api.sysinv.PERSONALITY_CONTROLLER: + if host._personality == sysinv.PERSONALITY_CONTROLLER: return True # nova-local: Allow adding to any locked host with a compute @@ -520,7 +521,7 @@ class AddPhysicalVolume(tables.LinkAction): _("(Node Unlocked)")) elif "nova-local" not in [ lvg.lvm_vg_name for lvg in - stx_api.sysinv.host_lvg_list(request, host.uuid)]: + 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, ' ', @@ -548,22 +549,22 @@ class RemovePhysicalVolume(tables.DeleteAction): def allowed(self, request, pv=None): host = self.table.kwargs['host'] - cinder_backend = stx_api.sysinv.get_cinder_backend(request) + cinder_backend = sysinv.get_cinder_backend(request) - if pv.lvm_vg_name == stx_api.sysinv.LVG_NOVA_LOCAL: + if pv.lvm_vg_name == 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 == 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) + elif pv.lvm_vg_name == sysinv.LVG_CINDER_VOLUMES: + return (sysinv.CINDER_BACKEND_LVM not in cinder_backend and + sysinv.PV_ADD in pv.pv_state) return False def delete(self, request, pv_id): host_id = self.table.kwargs['host_id'] try: - stx_api.sysinv.host_pv_delete(request, pv_id) + 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} diff --git a/starlingx_dashboard/dashboards/admin/inventory/storages/views.py b/starlingx_dashboard/dashboards/admin/inventory/storages/views.py index 66360de7..4fe38834 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/storages/views.py +++ b/starlingx_dashboard/dashboards/admin/inventory/storages/views.py @@ -17,7 +17,7 @@ from horizon import tabs from horizon.utils import memoized from horizon import views -from starlingx_dashboard import api as stx_api +from starlingx_dashboard.api import sysinv from starlingx_dashboard.dashboards.admin.inventory.storages.forms import \ AddDiskProfile from starlingx_dashboard.dashboards.admin.inventory.storages.forms import \ @@ -61,7 +61,7 @@ class AddStorageVolumeView(forms.ModalFormView): initial = super(AddStorageVolumeView, self).get_initial() initial['host_id'] = self.kwargs['host_id'] try: - host = stx_api.sysinv.host_get(self.request, initial['host_id']) + host = sysinv.host_get(self.request, initial['host_id']) except Exception: exceptions.handle(self.request, _('Unable to retrieve host.')) initial['ihost_uuid'] = host.uuid @@ -85,8 +85,8 @@ class EditStorageVolumeView(forms.ModalFormView): LOG.debug("stor_id=%s kwargs=%s", stor_uuid, self.kwargs) try: - self._object = stx_api.sysinv.host_stor_get(self.request, - stor_uuid) + self._object = sysinv.host_stor_get(self.request, + stor_uuid) self._object.host_id = host_id except Exception: redirect = reverse("horizon:admin:inventory:detail", @@ -130,24 +130,24 @@ class AddDiskProfileView(forms.ModalFormView): if not hasattr(self, "_host"): host_id = self.kwargs['host_id'] try: - host = stx_api.sysinv.host_get(self.request, host_id) + host = sysinv.host_get(self.request, host_id) - all_disks = stx_api.sysinv.host_disk_list(self.request, host.uuid) + all_disks = 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 = stx_api.sysinv.host_disk_partition_list( + host.partitions = sysinv.host_disk_partition_list( self.request, host.uuid) - host.stors = stx_api.sysinv.host_stor_list(self.request, host.uuid) + host.stors = sysinv.host_stor_list(self.request, host.uuid) - all_lvgs = stx_api.sysinv.host_lvg_list(self.request, host.uuid) + all_lvgs = sysinv.host_lvg_list(self.request, host.uuid) host.lvgs = [l for l in all_lvgs if - l.lvm_vg_name == stx_api.sysinv.LVG_NOVA_LOCAL] + l.lvm_vg_name == sysinv.LVG_NOVA_LOCAL] - all_pvs = stx_api.sysinv.host_pv_list(self.request, host.uuid) + all_pvs = sysinv.host_pv_list(self.request, host.uuid) host.pvs = [p for p in all_pvs if - p.lvm_vg_name == stx_api.sysinv.LVG_NOVA_LOCAL] + p.lvm_vg_name == sysinv.LVG_NOVA_LOCAL] journals = {} count = 0 @@ -174,21 +174,21 @@ class AddDiskProfileView(forms.ModalFormView): for l in host.lvgs: l.instance_backing = l.capabilities.get( - stx_api.sysinv.LVG_NOVA_PARAM_BACKING) + sysinv.LVG_NOVA_PARAM_BACKING) l.concurrent_disk_operations = l.capabilities.get( - stx_api.sysinv.LVG_NOVA_PARAM_DISK_OPS) + sysinv.LVG_NOVA_PARAM_DISK_OPS) if (l.instance_backing and - l.instance_backing == stx_api.sysinv.LVG_NOVA_BACKING_LVM): + l.instance_backing == sysinv.LVG_NOVA_BACKING_LVM): l.instances_lv_size_mib = l.capabilities.get( - stx_api.sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB) + sysinv.LVG_NOVA_PARAM_INSTANCES_SIZE_MIB) l.lvm_type = l.capabilities.get( - stx_api.sysinv.LVG_CINDER_PARAM_LVM_TYPE) + 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 == stx_api.sysinv.LVG_NOVA_LOCAL] + p.lvm_vg_name == sysinv.LVG_NOVA_LOCAL] l.dev_paths = ", ".join(l.dev_paths) except Exception: @@ -211,7 +211,7 @@ class AddDiskProfileView(forms.ModalFormView): initial = super(AddDiskProfileView, self).get_initial() initial['host_id'] = self.kwargs['host_id'] try: - host = stx_api.sysinv.host_get(self.request, initial['host_id']) + host = sysinv.host_get(self.request, initial['host_id']) except Exception: exceptions.handle(self.request, _('Unable to retrieve host.')) initial['personality'] = host._personality @@ -242,7 +242,7 @@ class AddLocalVolumeGroupView(forms.ModalFormView): initial = super(AddLocalVolumeGroupView, self).get_initial() initial['host_id'] = self.kwargs['host_id'] try: - host = stx_api.sysinv.host_get(self.request, initial['host_id']) + host = sysinv.host_get(self.request, initial['host_id']) except Exception: exceptions.handle(self.request, _('Unable to retrieve host.')) initial['ihost_uuid'] = host.uuid @@ -273,7 +273,7 @@ class AddPhysicalVolumeView(forms.ModalFormView): initial = super(AddPhysicalVolumeView, self).get_initial() initial['host_id'] = self.kwargs['host_id'] try: - host = stx_api.sysinv.host_get(self.request, initial['host_id']) + host = sysinv.host_get(self.request, initial['host_id']) except Exception: exceptions.handle(self.request, _('Unable to retrieve host.')) initial['ihost_uuid'] = host.uuid @@ -305,7 +305,7 @@ class DetailPhysicalVolumeView(views.HorizonTemplateView): @memoized.memoized_method def get_hostname(self, host_uuid): try: - host = stx_api.sysinv.host_get(self.request, host_uuid) + host = sysinv.host_get(self.request, host_uuid) except Exception: host = {} msg = _('Unable to retrieve hostname details.') @@ -316,7 +316,7 @@ class DetailPhysicalVolumeView(views.HorizonTemplateView): if not hasattr(self, "_pv"): pv_id = self.kwargs['pv_id'] try: - pv = stx_api.sysinv.host_pv_get(self.request, pv_id) + pv = sysinv.host_pv_get(self.request, pv_id) except Exception: redirect = reverse('horizon:admin:inventory:index') exceptions.handle(self.request, @@ -354,7 +354,7 @@ class DetailLocalVolumeGroupView(tabs.TabbedTableView): if not hasattr(self, "_lvg"): lvg_id = self.kwargs['lvg_id'] try: - lvg = stx_api.sysinv.host_lvg_get(self.request, lvg_id) + lvg = sysinv.host_lvg_get(self.request, lvg_id) except Exception: redirect = reverse('horizon:admin:inventory:index') exceptions.handle(self.request, @@ -368,7 +368,7 @@ class DetailLocalVolumeGroupView(tabs.TabbedTableView): @memoized.memoized_method def get_hostname(self, host_uuid): try: - host = stx_api.sysinv.host_get(self.request, host_uuid) + host = sysinv.host_get(self.request, host_uuid) except Exception: host = {} msg = _('Unable to retrieve hostname details.') @@ -403,7 +403,7 @@ class CreatePartitionView(forms.ModalFormView): initial = super(CreatePartitionView, self).get_initial() initial['host_id'] = self.kwargs['host_id'] try: - host = stx_api.sysinv.host_get(self.request, initial['host_id']) + host = sysinv.host_get(self.request, initial['host_id']) except Exception: exceptions.handle(self.request, _('Unable to retrieve host.')) initial['ihost_uuid'] = host.uuid @@ -427,7 +427,7 @@ class EditPartitionView(forms.ModalFormView): LOG.debug("partition_id=%s kwargs=%s", partition_uuid, self.kwargs) try: - self._object = stx_api.sysinv.host_disk_partition_get( + self._object = sysinv.host_disk_partition_get( self.request, partition_uuid) self._object.host_id = host_id diff --git a/starlingx_dashboard/dashboards/admin/inventory/tables.py b/starlingx_dashboard/dashboards/admin/inventory/tables.py index 31e29845..b0401628 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/tables.py +++ b/starlingx_dashboard/dashboards/admin/inventory/tables.py @@ -4,6 +4,8 @@ # SPDX-License-Identifier: Apache-2.0 # + +import cgcs_patch.constants as patch_constants import logging from django.core.urlresolvers import reverse # noqa @@ -17,11 +19,11 @@ from horizon import exceptions from horizon import messages from horizon import tables from horizon.utils import 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 LOG = logging.getLogger(__name__) diff --git a/starlingx_dashboard/dashboards/admin/inventory/tabs.py b/starlingx_dashboard/dashboards/admin/inventory/tabs.py index 430f2e8d..0caa8831 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/tabs.py +++ b/starlingx_dashboard/dashboards/admin/inventory/tabs.py @@ -14,6 +14,7 @@ from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon import tabs + from starlingx_dashboard import api as stx_api from starlingx_dashboard.dashboards.admin.inventory.cpu_functions import \ tables as cpufunctions_tables diff --git a/starlingx_dashboard/dashboards/admin/inventory/views.py b/starlingx_dashboard/dashboards/admin/inventory/views.py index d2de0d3d..99dfd2fd 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/views.py +++ b/starlingx_dashboard/dashboards/admin/inventory/views.py @@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon import tabs from horizon import workflows + 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 diff --git a/starlingx_dashboard/dashboards/admin/inventory/workflows.py b/starlingx_dashboard/dashboards/admin/inventory/workflows.py index 408950c8..dcf3e1d4 100755 --- a/starlingx_dashboard/dashboards/admin/inventory/workflows.py +++ b/starlingx_dashboard/dashboards/admin/inventory/workflows.py @@ -12,6 +12,7 @@ import cpu_functions.utils as icpu_utils from cgtsclient.common import constants from cgtsclient import exc + from django.utils.translation import ugettext_lazy as _ # noqa from django.views.decorators.debug import sensitive_variables # noqa @@ -19,6 +20,7 @@ from horizon import exceptions from horizon import forms from horizon.utils import validators from horizon import workflows + from starlingx_dashboard import api as stx_api LOG = logging.getLogger(__name__)