Added panels for Tatu PATs and SSH Host info.

This commit is contained in:
Pino de Candia 2018-02-14 23:06:55 -06:00
parent 841f4e57fe
commit a82ccdb3e6
22 changed files with 575 additions and 35 deletions

View File

@ -19,7 +19,7 @@ from openstack_dashboard.dashboards.project import dashboard
class Host(horizon.Panel):
name = _("Host Certificates")
name = _("Hosts")
slug = 'tatu_host'
dashboard.Project.register(Host)

View File

@ -0,0 +1,25 @@
# Copyright (c) 2016 Huawei, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import horizon
from django.utils.translation import ugettext_lazy as _
from openstack_dashboard.dashboards.project import dashboard
class HostCert(horizon.Panel):
name = _("Host Certificates")
slug = 'tatu_host_cert'
dashboard.Project.register(HostCert)

View File

@ -0,0 +1,21 @@
# Copyright (c) 2016 Huawei, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.conf.urls import url
from . import views
urlpatterns = [
url('', views.IndexView.as_view(), name='index'),
]

View File

@ -0,0 +1,19 @@
# Copyright (c) 2016 Huawei, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.views import generic
class IndexView(generic.TemplateView):
template_name = 'angular.html'

View File

@ -0,0 +1,25 @@
# Copyright (c) 2016 Huawei, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import horizon
from django.utils.translation import ugettext_lazy as _
from openstack_dashboard.dashboards.project import dashboard
class PAT(horizon.Panel):
name = _("PAT Gateways")
slug = 'tatu_pat'
dashboard.Project.register(PAT)

View File

@ -0,0 +1,21 @@
# Copyright (c) 2016 Huawei, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.conf.urls import url
from . import views
urlpatterns = [
url('', views.IndexView.as_view(), name='index'),
]

View File

@ -0,0 +1,19 @@
# Copyright (c) 2016 Huawei, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.views import generic
class IndexView(generic.TemplateView):
template_name = 'angular.html'

View File

@ -0,0 +1,26 @@
# Copyright (c) 2017 Huawei, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
PANEL = 'tatu_pat'
PANEL_GROUP = 'tatu'
PANEL_DASHBOARD = 'project'
# If set to True, this dashboard will not be added to the settings.
DISABLED = False
ADD_PANEL = 'tatudashboard.dashboards.tatu.pat.panel.PAT'
ADD_ANGULAR_MODULES = ['tatudashboard']
AUTO_DISCOVER_STATIC_FILES = True

View File

@ -0,0 +1,26 @@
# Copyright (c) 2017 Huawei, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
PANEL = 'tatu_host_cert'
PANEL_GROUP = 'tatu'
PANEL_DASHBOARD = 'project'
# If set to True, this dashboard will not be added to the settings.
DISABLED = False
ADD_PANEL = 'tatudashboard.dashboards.tatu.host.panel.HostCert'
ADD_ANGULAR_MODULES = ['tatudashboard']
AUTO_DISCOVER_STATIC_FILES = True

View File

@ -0,0 +1,4 @@
<hz-resource-panel resource-type-name="OS::Tatu::HostCert">
<hz-resource-table resource-type-name="OS::Tatu::HostCert"
track-by="_timestampId"></hz-resource-table>
</hz-resource-panel>

View File

@ -0,0 +1,4 @@
<hz-resource-panel resource-type-name="OS::Tatu::PAT">
<hz-resource-table resource-type-name="OS::Tatu::PAT"
track-by="_timestampId"></hz-resource-table>
</hz-resource-panel>

View File

@ -0,0 +1,86 @@
/**
* (c) Copyright 2016 Hewlett Packard Enterprise Development LP
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function () {
'use strict';
angular
.module('tatudashboard.resources.os-tatu-host-cert')
.factory('tatudashboard.resources.os-tatu-host-cert.api', apiService);
apiService.$inject = [
'tatudashboard.apiPassthroughUrl',
'horizon.framework.util.http.service',
'horizon.framework.widgets.toast.service'
];
/**
* @ngdoc service
* @param {Object} httpService
* @param {Object} toastService
* @name apiService
* @description Provides direct access to Tatu host certificate APIs.
* @returns {Object} The service
*/
function apiService(apiPassthroughUrl, httpService, toastService) {
var service = {
get: get,
list: list
};
return service;
///////////////
/**
* @name list
* @description
* Get a list of host certificates.
*
* The listing result is an object with property "items." Each item is
* a host certificate.
*
* @param {Object} params
* Query parameters. Optional.
*
* @returns {Object} The result of the API call
*/
function list(params) {
var config = params ? {'params': params} : {};
return httpService.get(apiPassthroughUrl + 'noauth/hostcerts/', config)
.error(function () {
toastService.add('error', gettext('Unable to retrieve the certificates.'));
});
}
/**
* @name get
* @description
* Get a single host certificate by ID.
*
* @param {string} id
* Specifies the id of the host certificate to request.
*
* @returns {Object} The result of the API call
*/
function get(id) {
return httpService.get(apiPassthroughUrl + 'noauth/hostcerts/' + id + '/')
.error(function () {
toastService.add('error', gettext('Unable to retrieve the certificate.'));
});
}
}
}());

View File

@ -0,0 +1,114 @@
/**
* (c) Copyright 2016 Hewlett Packard Enterprise Development LP
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
(function () {
'use strict';
/**
* @ngdoc overview
* @ngname tatudashboard.resources.os-tatu-host-cert
*
* @description
* Provides all of the services and widgets required
* to support and display SSH (Tatu) host certificate related content.
*/
angular
.module('tatudashboard.resources.os-tatu-host-cert', [
'ngRoute'
])
.constant(
'tatudashboard.resources.os-tatu-host-cert.resourceType', 'OS::Tatu::HostCert')
.config(config)
.run(run);
config.$inject = ['$provide', '$windowProvider'];
function config($provide, $windowProvider) {
var path = $windowProvider.$get().STATIC_URL + 'tatudashboard/resources/os-tatu-host-cert/';
$provide.constant('tatudashboard.resources.os-tatu-host-cert.basePath', path);
}
run.$inject = [
'horizon.framework.conf.resource-type-registry.service',
'tatudashboard.resources.os-tatu-host-cert.api',
'tatudashboard.resources.os-tatu-host-cert.resourceType',
'tatudashboard.resources.util',
'$filter'
];
function run(registry,
api,
resourceTypeString,
util,
$filter) {
var resourceType = registry.getResourceType(resourceTypeString);
resourceType
.setNames(gettext('Certificate'), gettext('Certificate'))
.setListFunction(listHostCerts)
.setProperty('host_id', {
label: gettext('Host ID')
})
.setProperty('hostname', {
label: gettext('Hostname')
})
.setProperty('fingerprint', {
label: gettext('Fingerprint')
})
.setProperty('auth_id', {
label: gettext('Project/CA ID')
})
.setProperty('cert', {
label: gettext('Host Certificate')
});
resourceType
.tableColumns
.append({
id: 'host_id',
priority: 1
})
.append({
id: 'hostname',
priority: 2
})
.append({
id: 'fingerprint',
priority: 2
})
.append({
id: 'auth_id',
priority: 2
})
.append({
id: 'cert',
priority: 2,
filters: [function(input){ return $filter('limitTo')(input, 50, 0); }]
})
function listHostCerts() {
return api.list().then(function onList(response) {
// listFunctions are expected to return data in "items"
response.data.items = response.data.certs;
util.addTimestampIds(response.data.items, 'host_id');
return response;
});
}
}
})();

View File

@ -59,7 +59,7 @@
*/
function list(params) {
var config = params ? {'params': params} : {};
return httpService.get(apiPassthroughUrl + 'noauth/hostcerts/', config)
return httpService.get(apiPassthroughUrl + 'noauth/hosts/', config)
.error(function () {
toastService.add('error', gettext('Unable to retrieve the hosts.'));
});
@ -76,7 +76,7 @@
* @returns {Object} The result of the API call
*/
function get(id) {
return httpService.get(apiPassthroughUrl + 'noauth/hostcerts/' + id + '/')
return httpService.get(apiPassthroughUrl + 'noauth/hosts/' + id + '/')
.error(function () {
toastService.add('error', gettext('Unable to retrieve the host.'));
});

View File

@ -50,7 +50,7 @@
];
function run(registry,
hostApi,
api,
resourceTypeString,
util,
$filter) {
@ -58,21 +58,12 @@
resourceType
.setNames(gettext('SSH Host'), gettext('SSH Hosts'))
.setListFunction(listHosts)
.setProperty('host_id', {
.setProperty('id', {
label: gettext('Host ID')
})
.setProperty('hostname', {
.setProperty('name', {
label: gettext('Hostname')
})
.setProperty('fingerprint', {
label: gettext('Fingerprint')
})
.setProperty('auth_id', {
label: gettext('Project/CA ID')
})
.setProperty('cert', {
label: gettext('Host Certificate')
})
.setProperty('pat_bastions', {
label: gettext('PAT Bastions')
})
@ -83,19 +74,11 @@
resourceType
.tableColumns
.append({
id: 'host_id',
id: 'id',
priority: 1
})
.append({
id: 'hostname',
priority: 2
})
.append({
id: 'fingerprint',
priority: 2
})
.append({
id: 'auth_id',
id: 'name',
priority: 2
})
.append({
@ -106,16 +89,10 @@
id: 'pat_bastions',
priority: 2,
filters: ['noName']
})
.append({
id: 'cert',
priority: 2,
filters: [function(input){ return $filter('limitTo')(input, 50, 0); }]
})
});
function listHosts() {
return hostApi.list().then(function onList(response) {
return api.list().then(function onList(response) {
// listFunctions are expected to return data in "items"
response.data.items = response.data.hosts;

View File

@ -0,0 +1,68 @@
/**
* (c) Copyright 2016 Hewlett Packard Enterprise Development LP
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function () {
'use strict';
angular
.module('tatudashboard.resources.os-tatu-pat')
.factory('tatudashboard.resources.os-tatu-pat.api', apiService);
apiService.$inject = [
'tatudashboard.apiPassthroughUrl',
'horizon.framework.util.http.service',
'horizon.framework.widgets.toast.service'
];
/**
* @ngdoc service
* @param {Object} httpService
* @param {Object} toastService
* @name apiService
* @description Provides direct access to Tatu pat APIs.
* @returns {Object} The service
*/
function apiService(apiPassthroughUrl, httpService, toastService) {
var service = {
get: get,
list: list
};
return service;
///////////////
/**
* @name list
* @description
* Get a list of PAT gateways.
*
* The listing result is an object with property "items." Each item is
* a PAT gateway.
*
* @param {Object} params
* Query parameters. Optional.
*
* @returns {Object} The result of the API call
*/
function list(params) {
var config = params ? {'params': params} : {};
return httpService.get(apiPassthroughUrl + 'noauth/pats/', config)
.error(function () {
toastService.add('error', gettext('Unable to retrieve the PAT Gateways.'));
});
}
}
}());

View File

@ -0,0 +1,97 @@
/**
* (c) Copyright 2016 Hewlett Packard Enterprise Development LP
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
(function () {
'use strict';
/**
* @ngdoc overview
* @ngname tatudashboard.resources.os-tatu-host
*
* @description
* Provides all of the services and widgets required
* to support and display SSH (Tatu) host related content.
*/
angular
.module('tatudashboard.resources.os-tatu-pat', [
'ngRoute'
])
.constant(
'tatudashboard.resources.os-tatu-pat.resourceType', 'OS::Tatu::PAT')
.config(config)
.run(run);
config.$inject = ['$provide', '$windowProvider'];
function config($provide, $windowProvider) {
var path = $windowProvider.$get().STATIC_URL + 'tatudashboard/resources/os-tatu-pat/';
$provide.constant('tatudashboard.resources.os-tatu-pat.basePath', path);
}
run.$inject = [
'horizon.framework.conf.resource-type-registry.service',
'tatudashboard.resources.os-tatu-pat.api',
'tatudashboard.resources.os-tatu-pat.resourceType',
'tatudashboard.resources.util'
];
function run(registry,
api,
resourceTypeString,
util) {
var resourceType = registry.getResourceType(resourceTypeString);
resourceType
.setNames(gettext('SSH PAT Gateway'), gettext('SSH PAT Gateways'))
.setListFunction(listPATs)
.setProperty('ip', {
label: gettext('IP Address')
})
.setProperty('chassis', {
label: gettext('Assigned Compute Node')
})
.setProperty('lport', {
label: gettext('Neutron Port')
});
resourceType
.tableColumns
.append({
id: 'ip',
priority: 1
})
.append({
id: 'lport',
priority: 2
})
.append({
id: 'chassis',
priority: 2
});
function listPATs() {
return api.list().then(function onList(response) {
// listFunctions are expected to return data in "items"
response.data.items = response.data.pats;
util.addTimestampIds(response.data.items, 'lport');
return response;
});
}
}
})();

View File

@ -116,7 +116,7 @@
function listUsers() {
return userApi.list().then(function onList(response) {
// listFunctions are expected to return data in "items"
response.data.items = response.data.users;
response.data.items = response.data.certs;
util.addTimestampIds(response.data.items, 'user_id');

View File

@ -31,6 +31,8 @@
.module('tatudashboard.resources', [
'tatudashboard.resources.os-tatu-ca',
'tatudashboard.resources.os-tatu-user',
'tatudashboard.resources.os-tatu-host'
'tatudashboard.resources.os-tatu-host',
'tatudashboard.resources.os-tatu-host-cert',
'tatudashboard.resources.os-tatu-pat'
]);
})();

View File

@ -66,6 +66,12 @@
})
.when('/project/tatu_host/', {
templateUrl: path + 'host.html'
})
.when('/project/tatu_host_cert/', {
templateUrl: path + 'host_cert.html'
})
.when('/project/tatu_pat/', {
templateUrl: path + 'pat.html'
});
}