From a82ccdb3e64b5a6039de08336e19e8985b48f424 Mon Sep 17 00:00:00 2001 From: Pino de Candia <32303022+pinodeca@users.noreply.github.com> Date: Wed, 14 Feb 2018 23:06:55 -0600 Subject: [PATCH] Added panels for Tatu PATs and SSH Host info. --- tatudashboard/dashboards/tatu/host/panel.py | 2 +- .../dashboards/tatu/host_cert/__init__.py | 0 .../dashboards/tatu/host_cert/panel.py | 25 ++++ .../dashboards/tatu/host_cert/urls.py | 21 ++++ .../dashboards/tatu/host_cert/views.py | 19 +++ tatudashboard/dashboards/tatu/pat/__init__.py | 0 tatudashboard/dashboards/tatu/pat/panel.py | 25 ++++ tatudashboard/dashboards/tatu/pat/urls.py | 21 ++++ tatudashboard/dashboards/tatu/pat/views.py | 19 +++ tatudashboard/enabled/_3984_tatu_pat_panel.py | 26 ++++ .../enabled/_3985_tatu_host_cert_panel.py | 26 ++++ .../static/tatudashboard/host_cert.html | 4 + tatudashboard/static/tatudashboard/pat.html | 4 + .../os-tatu-host-cert/api.service.js | 86 +++++++++++++ .../os-tatu-host-cert.module.js | 114 ++++++++++++++++++ .../resources/os-tatu-host/api.service.js | 4 +- .../os-tatu-host/os-tatu-host.module.js | 37 ++---- .../resources/os-tatu-pat/api.service.js | 68 +++++++++++ .../os-tatu-pat/os-tatu-pat.module.js | 97 +++++++++++++++ .../os-tatu-user/os-tatu-user.module.js | 2 +- .../resources/resources.module.js | 4 +- .../tatudashboard/tatudashboard.module.js | 6 + 22 files changed, 575 insertions(+), 35 deletions(-) create mode 100644 tatudashboard/dashboards/tatu/host_cert/__init__.py create mode 100644 tatudashboard/dashboards/tatu/host_cert/panel.py create mode 100644 tatudashboard/dashboards/tatu/host_cert/urls.py create mode 100644 tatudashboard/dashboards/tatu/host_cert/views.py create mode 100644 tatudashboard/dashboards/tatu/pat/__init__.py create mode 100644 tatudashboard/dashboards/tatu/pat/panel.py create mode 100644 tatudashboard/dashboards/tatu/pat/urls.py create mode 100644 tatudashboard/dashboards/tatu/pat/views.py create mode 100644 tatudashboard/enabled/_3984_tatu_pat_panel.py create mode 100644 tatudashboard/enabled/_3985_tatu_host_cert_panel.py create mode 100644 tatudashboard/static/tatudashboard/host_cert.html create mode 100644 tatudashboard/static/tatudashboard/pat.html create mode 100644 tatudashboard/static/tatudashboard/resources/os-tatu-host-cert/api.service.js create mode 100644 tatudashboard/static/tatudashboard/resources/os-tatu-host-cert/os-tatu-host-cert.module.js create mode 100644 tatudashboard/static/tatudashboard/resources/os-tatu-pat/api.service.js create mode 100644 tatudashboard/static/tatudashboard/resources/os-tatu-pat/os-tatu-pat.module.js diff --git a/tatudashboard/dashboards/tatu/host/panel.py b/tatudashboard/dashboards/tatu/host/panel.py index 2fb1532..518cd17 100644 --- a/tatudashboard/dashboards/tatu/host/panel.py +++ b/tatudashboard/dashboards/tatu/host/panel.py @@ -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) diff --git a/tatudashboard/dashboards/tatu/host_cert/__init__.py b/tatudashboard/dashboards/tatu/host_cert/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tatudashboard/dashboards/tatu/host_cert/panel.py b/tatudashboard/dashboards/tatu/host_cert/panel.py new file mode 100644 index 0000000..0d651c8 --- /dev/null +++ b/tatudashboard/dashboards/tatu/host_cert/panel.py @@ -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) diff --git a/tatudashboard/dashboards/tatu/host_cert/urls.py b/tatudashboard/dashboards/tatu/host_cert/urls.py new file mode 100644 index 0000000..ebf95d4 --- /dev/null +++ b/tatudashboard/dashboards/tatu/host_cert/urls.py @@ -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'), +] diff --git a/tatudashboard/dashboards/tatu/host_cert/views.py b/tatudashboard/dashboards/tatu/host_cert/views.py new file mode 100644 index 0000000..aa7edc8 --- /dev/null +++ b/tatudashboard/dashboards/tatu/host_cert/views.py @@ -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' diff --git a/tatudashboard/dashboards/tatu/pat/__init__.py b/tatudashboard/dashboards/tatu/pat/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tatudashboard/dashboards/tatu/pat/panel.py b/tatudashboard/dashboards/tatu/pat/panel.py new file mode 100644 index 0000000..21ec6a1 --- /dev/null +++ b/tatudashboard/dashboards/tatu/pat/panel.py @@ -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) diff --git a/tatudashboard/dashboards/tatu/pat/urls.py b/tatudashboard/dashboards/tatu/pat/urls.py new file mode 100644 index 0000000..ebf95d4 --- /dev/null +++ b/tatudashboard/dashboards/tatu/pat/urls.py @@ -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'), +] diff --git a/tatudashboard/dashboards/tatu/pat/views.py b/tatudashboard/dashboards/tatu/pat/views.py new file mode 100644 index 0000000..aa7edc8 --- /dev/null +++ b/tatudashboard/dashboards/tatu/pat/views.py @@ -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' diff --git a/tatudashboard/enabled/_3984_tatu_pat_panel.py b/tatudashboard/enabled/_3984_tatu_pat_panel.py new file mode 100644 index 0000000..7b5d847 --- /dev/null +++ b/tatudashboard/enabled/_3984_tatu_pat_panel.py @@ -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 diff --git a/tatudashboard/enabled/_3985_tatu_host_cert_panel.py b/tatudashboard/enabled/_3985_tatu_host_cert_panel.py new file mode 100644 index 0000000..1d0391c --- /dev/null +++ b/tatudashboard/enabled/_3985_tatu_host_cert_panel.py @@ -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 diff --git a/tatudashboard/static/tatudashboard/host_cert.html b/tatudashboard/static/tatudashboard/host_cert.html new file mode 100644 index 0000000..38ad7df --- /dev/null +++ b/tatudashboard/static/tatudashboard/host_cert.html @@ -0,0 +1,4 @@ + + + diff --git a/tatudashboard/static/tatudashboard/pat.html b/tatudashboard/static/tatudashboard/pat.html new file mode 100644 index 0000000..9fe14dc --- /dev/null +++ b/tatudashboard/static/tatudashboard/pat.html @@ -0,0 +1,4 @@ + + + diff --git a/tatudashboard/static/tatudashboard/resources/os-tatu-host-cert/api.service.js b/tatudashboard/static/tatudashboard/resources/os-tatu-host-cert/api.service.js new file mode 100644 index 0000000..dbe8bbe --- /dev/null +++ b/tatudashboard/static/tatudashboard/resources/os-tatu-host-cert/api.service.js @@ -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.')); + }); + } + + } +}()); diff --git a/tatudashboard/static/tatudashboard/resources/os-tatu-host-cert/os-tatu-host-cert.module.js b/tatudashboard/static/tatudashboard/resources/os-tatu-host-cert/os-tatu-host-cert.module.js new file mode 100644 index 0000000..c71baf4 --- /dev/null +++ b/tatudashboard/static/tatudashboard/resources/os-tatu-host-cert/os-tatu-host-cert.module.js @@ -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; + }); + } + } + +})(); diff --git a/tatudashboard/static/tatudashboard/resources/os-tatu-host/api.service.js b/tatudashboard/static/tatudashboard/resources/os-tatu-host/api.service.js index 33d0cbf..a1c1988 100644 --- a/tatudashboard/static/tatudashboard/resources/os-tatu-host/api.service.js +++ b/tatudashboard/static/tatudashboard/resources/os-tatu-host/api.service.js @@ -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.')); }); diff --git a/tatudashboard/static/tatudashboard/resources/os-tatu-host/os-tatu-host.module.js b/tatudashboard/static/tatudashboard/resources/os-tatu-host/os-tatu-host.module.js index 23f2295..73ece43 100644 --- a/tatudashboard/static/tatudashboard/resources/os-tatu-host/os-tatu-host.module.js +++ b/tatudashboard/static/tatudashboard/resources/os-tatu-host/os-tatu-host.module.js @@ -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; diff --git a/tatudashboard/static/tatudashboard/resources/os-tatu-pat/api.service.js b/tatudashboard/static/tatudashboard/resources/os-tatu-pat/api.service.js new file mode 100644 index 0000000..078c585 --- /dev/null +++ b/tatudashboard/static/tatudashboard/resources/os-tatu-pat/api.service.js @@ -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.')); + }); + } + } +}()); diff --git a/tatudashboard/static/tatudashboard/resources/os-tatu-pat/os-tatu-pat.module.js b/tatudashboard/static/tatudashboard/resources/os-tatu-pat/os-tatu-pat.module.js new file mode 100644 index 0000000..8441b09 --- /dev/null +++ b/tatudashboard/static/tatudashboard/resources/os-tatu-pat/os-tatu-pat.module.js @@ -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; + }); + } + } + +})(); diff --git a/tatudashboard/static/tatudashboard/resources/os-tatu-user/os-tatu-user.module.js b/tatudashboard/static/tatudashboard/resources/os-tatu-user/os-tatu-user.module.js index e37a046..f3cde6f 100644 --- a/tatudashboard/static/tatudashboard/resources/os-tatu-user/os-tatu-user.module.js +++ b/tatudashboard/static/tatudashboard/resources/os-tatu-user/os-tatu-user.module.js @@ -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'); diff --git a/tatudashboard/static/tatudashboard/resources/resources.module.js b/tatudashboard/static/tatudashboard/resources/resources.module.js index dd1d27e..2ea5b8a 100644 --- a/tatudashboard/static/tatudashboard/resources/resources.module.js +++ b/tatudashboard/static/tatudashboard/resources/resources.module.js @@ -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' ]); })(); diff --git a/tatudashboard/static/tatudashboard/tatudashboard.module.js b/tatudashboard/static/tatudashboard/tatudashboard.module.js index 84f61da..eef73f0 100644 --- a/tatudashboard/static/tatudashboard/tatudashboard.module.js +++ b/tatudashboard/static/tatudashboard/tatudashboard.module.js @@ -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' }); }