From 9f36d93e407c73640a611ab4561a01a9e1a00e94 Mon Sep 17 00:00:00 2001 From: Omer Etrog Date: Wed, 30 Dec 2015 13:31:12 +0200 Subject: [PATCH] remove @ from the file Change-Id: Ia9852cc6e1815130c21e8bb24872c27aa6ecc8b3 --- README.rst | 26 +++++--- vitrageclient/api/__init__.py | 65 +++++++++++++++++++ vitrageclient/api/rest/__init__.py | 34 ++++++++++ vitrageclient/api/rest/vitrage.py | 41 ++++++++++++ vitrageclient/api/vitrage.py | 34 ++++++++++ .../openstack-service-api/vitrage.service.js | 15 ++--- .../project/layout/main/main.controller.js | 2 + .../services/vitrage_topology.service.js | 3 +- 8 files changed, 202 insertions(+), 18 deletions(-) create mode 100644 vitrageclient/api/__init__.py create mode 100644 vitrageclient/api/rest/__init__.py create mode 100644 vitrageclient/api/rest/vitrage.py create mode 100644 vitrageclient/api/vitrage.py diff --git a/README.rst b/README.rst index 0ce1b4c..a32b582 100644 --- a/README.rst +++ b/README.rst @@ -21,12 +21,20 @@ Project Resources How to use this package ----------------------- -git clone https://github.com/openstack/horizon.git -git clone https://github.com/openstack/vitrage-dashboard.git -cd horizon - ./run_tests.sh -f --docs - cp ./openstack_dashboard/local/local_settings.py.example ./openstack_dashboard/local/local_settings.py - pushd ../vitrage-dashboard - ../horizon/tools/with_venv.sh pip install --upgrade . - cp -a vitragedashboard/enabled/* ../horizon/openstack_dashboard/enabled/ - popd \ No newline at end of file +:: + git clone https://github.com/openstack/horizon.git + git clone https://github.com/openstack/vitrage-dashboard.git + git clone https://github.com/openstack/python-vitrageclient.git + + cd pyton-vitrageclient + sudo pip install -e. + ../horizon/tools/with_venv.sh pip install --upgrade . + + cd ../horizon + ./run_tests.sh -f --docs + cp ./openstack_dashboard/local/local_settings.py.example ./openstack_dashboard/local/local_settings.py + pushd ../vitrage-dashboard + ../horizon/tools/with_venv.sh pip install --upgrade . + cp -a vitragedashboard/enabled/* ../horizon/openstack_dashboard/enabled/ + cp -a vitrageclient/api/* ../horizon/openstack_dashboard/api/ + popd \ No newline at end of file diff --git a/vitrageclient/api/__init__.py b/vitrageclient/api/__init__.py new file mode 100644 index 0000000..dd2c867 --- /dev/null +++ b/vitrageclient/api/__init__.py @@ -0,0 +1,65 @@ +# Copyright 2012 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Copyright 2012 Nebula, Inc. +# Copyright 2013 Big Switch Networks +# +# 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. + +""" +Methods and interface objects used to interact with external APIs. + +API method calls return objects that are in many cases objects with +attributes that are direct maps to the data returned from the API http call. +Unfortunately, these objects are also often constructed dynamically, making +it difficult to know what data is available from the API object. Because of +this, all API calls should wrap their returned object in one defined here, +using only explicitly defined attributes and/or methods. + +In other words, Horizon developers not working on openstack_dashboard.api +shouldn't need to understand the finer details of APIs for +Keystone/Nova/Glance/Swift et. al. +""" +from openstack_dashboard.api import base +from openstack_dashboard.api import ceilometer +from openstack_dashboard.api import cinder +from openstack_dashboard.api import fwaas +from openstack_dashboard.api import glance +from openstack_dashboard.api import heat +from openstack_dashboard.api import keystone +from openstack_dashboard.api import lbaas +from openstack_dashboard.api import network +from openstack_dashboard.api import neutron +from openstack_dashboard.api import nova +from openstack_dashboard.api import swift +from openstack_dashboard.api import vitrage +from openstack_dashboard.api import vpn + + +__all__ = [ + "base", + "cinder", + "fwaas", + "glance", + "heat", + "keystone", + "lbaas", + "network", + "neutron", + "nova", + "swift", + "ceilometer", + "vpn", + "vitrage" +] diff --git a/vitrageclient/api/rest/__init__.py b/vitrageclient/api/rest/__init__.py new file mode 100644 index 0000000..5df3298 --- /dev/null +++ b/vitrageclient/api/rest/__init__.py @@ -0,0 +1,34 @@ +# Copyright 2014, Rackspace, US, 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. +"""This package holds the REST API that supports the Horizon dashboard +Javascript code. + +It is not intended to be used outside of Horizon, and makes no promises of +stability or fitness for purpose outside of that scope. + +It does not promise to adhere to the general OpenStack API Guidelines set out +in https://wiki.openstack.org/wiki/APIChangeGuidelines. +""" + +# import REST API modules here +from . import cinder #flake8: noqa +from . import config #flake8: noqa +from . import glance #flake8: noqa +from . import heat #flake8: noqa +from . import keystone #flake8: noqa +from . import network #flake8: noqa +from . import neutron #flake8: noqa +from . import nova #flake8: noqa +from . import policy #flake8: noqa +from . import vitrage #flake8: noqa diff --git a/vitrageclient/api/rest/vitrage.py b/vitrageclient/api/rest/vitrage.py new file mode 100644 index 0000000..31d0538 --- /dev/null +++ b/vitrageclient/api/rest/vitrage.py @@ -0,0 +1,41 @@ +# Copyright 2015 - Alcatel-Lucent +# +# 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 + +from openstack_dashboard import api +from openstack_dashboard.api.rest import utils as rest_utils + +from openstack_dashboard.api.rest import urls + + +@urls.register +class Topolgy(generic.View): + """API for vitrage topology.""" + + url_regex = r'vitrage/topology/$' + + @rest_utils.ajax() + def get(self, request): + """Get a single volume's details with the volume id. + + The following get parameters may be passed in the GET + + :param volume_id the id of the volume + + The result is a volume object. + """ + + return api.vitrage.topology(request) diff --git a/vitrageclient/api/vitrage.py b/vitrageclient/api/vitrage.py new file mode 100644 index 0000000..1778400 --- /dev/null +++ b/vitrageclient/api/vitrage.py @@ -0,0 +1,34 @@ +# Copyright 2015 - Alcatel-Lucent +# +# 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 horizon.utils.memoized import memoized # noqa +from keystoneauth1.identity.generic.token import Token +from keystoneauth1.session import Session +from openstack_dashboard.api import base +from vitrageclient import client as vitrage_client + + +@memoized +def vitrageclient(request, password=None): + endpoint = base.url_for(request, 'identity') + tokenId = request.user.token.id + tenentName = request.user.tenant_name + auth = Token(auth_url=endpoint, token=tokenId, project_name=tenentName) + session = Session(auth=auth, timeout=600) + return vitrage_client.Client('1', session) + + +def topology(request): + return vitrageclient(request).topology.get(graph_type='tree') diff --git a/vitragedashboard/static/app/core/openstack-service-api/vitrage.service.js b/vitragedashboard/static/app/core/openstack-service-api/vitrage.service.js index e995bfa..df8cfca 100644 --- a/vitragedashboard/static/app/core/openstack-service-api/vitrage.service.js +++ b/vitragedashboard/static/app/core/openstack-service-api/vitrage.service.js @@ -9,27 +9,26 @@ vitrageAPI.$inject = [ 'horizon.framework.util.http.service', 'horizon.framework.widgets.toast.service' + ]; function vitrageAPI(apiService, toastService) { - return { + var service = { getTopology: getTopology }; + return service; + /////////// - // Topology - function getTopology() { - console.log("**** getToplogy test ****"); - return apiService.get('/api/nova/keypairs/') + function getTopology(config) { + return apiService.get('/api/vitrage/topology', config) .error(function () { - toastService.add('error', gettext('Unable to get the Vitrage service Topology.')); + toastService.add('error', gettext('Unable to fetch the Vitrage Topology service.')); }); - } - } }()); diff --git a/vitragedashboard/static/dashboard/project/layout/main/main.controller.js b/vitragedashboard/static/dashboard/project/layout/main/main.controller.js index 9b2f2b2..b8c3193 100644 --- a/vitragedashboard/static/dashboard/project/layout/main/main.controller.js +++ b/vitragedashboard/static/dashboard/project/layout/main/main.controller.js @@ -9,7 +9,9 @@ function MainController($scope, vitrageTopologySrv) { $scope.STATIC_URL = STATIC_URL; + console.log("MainController"); var srv = vitrageTopologySrv; + console.log("***** srv ",srv); } })(); diff --git a/vitragedashboard/static/dashboard/project/services/vitrage_topology.service.js b/vitragedashboard/static/dashboard/project/services/vitrage_topology.service.js index 701e12d..5246fd2 100644 --- a/vitragedashboard/static/dashboard/project/services/vitrage_topology.service.js +++ b/vitragedashboard/static/dashboard/project/services/vitrage_topology.service.js @@ -16,7 +16,8 @@ if (vitrageAPI) { vitrageAPI.getTopology() .success(function (data) { - console.log("Success " + data); + console.log("Success " , data); + return data; }) .error(function (err) { console.error(err);