From 6b7d5ded67d6d1a2af13b5037bdd3119c623212d Mon Sep 17 00:00:00 2001 From: Cristian Mondo Date: Sun, 11 Jun 2023 23:08:30 -0300 Subject: [PATCH] Subcloud Name Reconfiguration This change adds the capability to rename the subcloud after bootstrap. The "name" field is enabled in Horizon subcloud update form, which allows to change the name of the subcloud. Depends-On: https://review.opendev.org/c/starlingx/distcloud/+/885832 Test Plan: PASS: Update subcloud name from UI PASS: Change and check Subcloud status from UI Story: 2010788 Task: 48218 Signed-off-by: Cristian Mondo Change-Id: Ibec87811c6355a623d15566efce3192719f819b9 --- .zuul.yaml | 1 + bindep.txt | 6 +++++ .../starlingx_dashboard/api/dc_manager.py | 2 +- .../cloud_overview/cloud_overview.module.js | 24 ++++++++++++++++++- .../table/subcloud_table.controller.js | 19 ++++++++------- 5 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 bindep.txt diff --git a/.zuul.yaml b/.zuul.yaml index 08bbff8d..b974c8cd 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -29,6 +29,7 @@ tox_constraints_file: '{{ ansible_user_dir }}/src/opendev.org/starlingx/root/build-tools/requirements/debian/upper-constraints.txt' # yamllint disable-line rule:line-length tox_environment: STX_DC_CLIENT: distcloud-client + bindep_profile: pylint required-projects: - starlingx/config - starlingx/distcloud-client diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 00000000..dafee19f --- /dev/null +++ b/bindep.txt @@ -0,0 +1,6 @@ +# This is a cross-platform list tracking distribution packages needed for install and tests; +# see https://docs.openstack.org/infra/bindep/ for additional information. + +libsasl2-dev [pylint platform:dpkg] +libldap2-dev [pylint platform:dpkg] +libssl-dev [pylint platform:dpkg] diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/dc_manager.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/dc_manager.py index 7a95e8f1..9371a24b 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/dc_manager.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/dc_manager.py @@ -55,7 +55,7 @@ class Subcloud(base.APIResourceWrapper): 'management_start_ip', 'management_end_ip', 'management_gateway_ip', 'systemcontroller_gateway_ip', 'created_at', 'updated_at', 'group_id', 'sync_status', - 'endpoint_sync_status', ] + 'endpoint_sync_status', 'region_name', ] def subcloud_list(request): diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/static/dashboard/dc_admin/cloud_overview/cloud_overview.module.js b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/static/dashboard/dc_admin/cloud_overview/cloud_overview.module.js index 5bc599fb..75faaa1e 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/static/dashboard/dc_admin/cloud_overview/cloud_overview.module.js +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/static/dashboard/dc_admin/cloud_overview/cloud_overview.module.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 Wind River Systems, Inc. + * Copyright (c) 2017-2023 Wind River Systems, Inc. * * SPDX-License-Identifier: Apache-2.0 * @@ -18,8 +18,30 @@ */ angular .module('horizon.dashboard.dc_admin.cloud_overview', []) + .run(['$rootScope', '$cookies', '$location', run]) .config(config); + /* + Keeps the subcloud name updated in the menu, + instead of showing the region name. + */ + function run($rootScope, $cookies, $location) { + $rootScope.$on('$locationChangeSuccess', function() { + var services_region = $cookies.get('services_region'); + + //Finds the element where region name is displayed + var region_element = document.querySelector('span.context-region'); + + if (region_element) { + //Set the subcloud name only if it is a subcloud + if(services_region != 'RegionOne' && services_region != 'SystemController'){ + var subcloud_name = $cookies.get('subcloud_' + services_region); + region_element.textContent = subcloud_name; + } + } + }); + } + config.$inject = [ '$provide', '$windowProvider' diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/static/dashboard/dc_admin/cloud_overview/table/subcloud_table.controller.js b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/static/dashboard/dc_admin/cloud_overview/table/subcloud_table.controller.js index fd32059b..9519e493 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/static/dashboard/dc_admin/cloud_overview/table/subcloud_table.controller.js +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/static/dashboard/dc_admin/cloud_overview/table/subcloud_table.controller.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017-2021 Wind River Systems, Inc. + * Copyright (c) 2017-2023 Wind River Systems, Inc. * * SPDX-License-Identifier: Apache-2.0 * @@ -27,6 +27,7 @@ '$timeout', '$interval', '$window', + '$cookies', 'horizon.framework.widgets.toast.service', 'horizon.framework.util.i18n.gettext', 'horizon.framework.widgets.form.ModalFormService', @@ -42,6 +43,7 @@ $timeout, $interval, $window, + $cookies, toast, gettext, modalFormService, @@ -354,8 +356,7 @@ properties: { "name": { type: "string", - title: "Name", - readonly: true}, + title: "Name"}, "description": { type: "string", title: "Description"}, @@ -408,9 +409,10 @@ } keystone.getCurrentUserSession().success(function(session){ - session.available_services_regions.indexOf(cloud.name) - if (session.available_services_regions.indexOf(cloud.name) > -1) { - $window.location.href = "/auth/switch_services_region/"+ cloud.name + "/?next=/admin/active_alarms/"; + session.available_services_regions.indexOf(cloud.region_name) + if (session.available_services_regions.indexOf(cloud.region_name) > -1) { + $cookies.put("subcloud_" + cloud.region_name, cloud.name); + $window.location.href = "/auth/switch_services_region/"+ cloud.region_name + "/?next=/admin/active_alarms/"; } else { toast.add('error', ctrl.endpointErrorMsg); // TODO(tsmith) should we force a logout here with an reason message? @@ -435,8 +437,9 @@ } keystone.getCurrentUserSession().success(function(session){ - if (session.available_services_regions.indexOf(cloud.name) > -1) { - $window.location.href = "/auth/switch_services_region/"+ cloud.name + "/?next=/admin/"; + if (session.available_services_regions.indexOf(cloud.region_name) > -1) { + $cookies.put("subcloud_" + cloud.region_name, cloud.name); + $window.location.href = "/auth/switch_services_region/"+ cloud.region_name + "/?next=/admin/"; } else { toast.add('error', ctrl.endpointErrorMsg); }