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 <cristian.mondo@windriver.com>
Change-Id: Ibec87811c6355a623d15566efce3192719f819b9
This commit is contained in:
Cristian Mondo 2023-06-11 23:08:30 -03:00
parent 54a0486661
commit 6b7d5ded67
5 changed files with 42 additions and 10 deletions

View File

@ -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

6
bindep.txt Normal file
View File

@ -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]

View File

@ -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):

View File

@ -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'

View File

@ -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);
}