From a05a5e80e1c051ebe4228c7a6041388c0aff5a15 Mon Sep 17 00:00:00 2001 From: Eddie Ramirez Date: Thu, 4 Aug 2016 22:58:20 +0000 Subject: [PATCH] Added base methods and classes for API --- .gitignore | 1 + ChangeLog | 1 + MANIFEST.in | 3 + craton_dashboard/api/__init__.py | 1 + craton_dashboard/api/craton.py | 84 ++++++++++++++ craton_dashboard/api/rest/__init__.py | 1 + craton_dashboard/api/rest/craton.py | 106 ++++++++++++++++++ .../dashboards/project/fleet/__init__.py | 1 + .../project/fleet/taskflows/panel.py | 2 +- .../fleet/taskflows/templates/index.html | 1 - .../project/fleet/templates/index.html | 1 - .../dashboards/project/fleet/views.py | 14 +-- .../enabled/_1730_fleet_taskflows_panel.py | 3 +- craton_dashboard/templates/__init__.py | 0 .../templates/regions/__init__.py | 0 craton_dashboard/templates/regions/index.html | 12 ++ .../templates/workflows/__init__.py | 0 .../templates/workflows/index.html | 12 ++ craton_ui.egg-info/PKG-INFO | 2 +- craton_ui.egg-info/SOURCES.txt | 9 ++ craton_ui.egg-info/pbr.json | 2 +- 21 files changed, 238 insertions(+), 18 deletions(-) create mode 100644 MANIFEST.in create mode 100644 craton_dashboard/api/__init__.py create mode 100644 craton_dashboard/api/rest/__init__.py create mode 100644 craton_dashboard/api/rest/craton.py delete mode 100644 craton_dashboard/dashboards/project/fleet/taskflows/templates/index.html delete mode 100644 craton_dashboard/dashboards/project/fleet/templates/index.html create mode 100644 craton_dashboard/templates/__init__.py create mode 100644 craton_dashboard/templates/regions/__init__.py create mode 100644 craton_dashboard/templates/regions/index.html create mode 100644 craton_dashboard/templates/workflows/__init__.py create mode 100644 craton_dashboard/templates/workflows/index.html diff --git a/.gitignore b/.gitignore index 7841b13..cfcd38a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dist ChangeLog AUTHORS +craton_ui.egg-info/* diff --git a/ChangeLog b/ChangeLog index 01a0edf..f9b66a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ CHANGES ======= +* Added base .gitignore * Added regions panel * Initial Structure * Initial commit diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..bb2dec3 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include setup.py + +recursive-include craton_dashboard *.js *.html *.scss diff --git a/craton_dashboard/api/__init__.py b/craton_dashboard/api/__init__.py new file mode 100644 index 0000000..7914d13 --- /dev/null +++ b/craton_dashboard/api/__init__.py @@ -0,0 +1 @@ +from craton_dashboard.api import craton diff --git a/craton_dashboard/api/craton.py b/craton_dashboard/api/craton.py index ed044a7..cec1a82 100644 --- a/craton_dashboard/api/craton.py +++ b/craton_dashboard/api/craton.py @@ -11,3 +11,87 @@ # 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 six.moves.urllib import request +from django.conf import settings + +from horizon import exceptions +from openstack_dashboard.api import base + +def cratonclient(): + pass + +def project_create(request, **kwargs): + pass + +def project_delete(request, **kwargs): + pass + +def project_list(request, **kwargs): + pass + +def project_show(request, **kwargs): + pass + +def project_update(request, **kwargs): + pass + +def region_create(request, **kwargs): + pass + +def region_delete(request, **kwargs): + pass + +def region_list(request, **kwargs): + pass + +def region_show(request, **kwargs): + pass + +def region_update(request, **kwargs): + pass + +def cell_create(request, **kwargs): + pass + +def cell_delete(request, **kwargs): + pass + +def cell_list(request, **kwargs): + pass + +def cell_show(request, **kwargs): + pass + +def cell_update(request, **kwargs): + pass + +def device_create(request, **kwargs): + pass + +def device_delete(request, **kwargs): + pass + +def device_list(request, **kwargs): + pass + +def device_show(request, **kwargs): + pass + +def host_create(request, **kwargs): + pass + +def host_delete(request, **kwargs): + pass + +def host_list(request, **kwargs): + pass + +def host_show(request, **kwargs): + pass + +def host_update(request, **kwargs): + pass + +def user_list(request, **kwargs): + pass diff --git a/craton_dashboard/api/rest/__init__.py b/craton_dashboard/api/rest/__init__.py new file mode 100644 index 0000000..1389bfb --- /dev/null +++ b/craton_dashboard/api/rest/__init__.py @@ -0,0 +1 @@ +from craton_dashboard.api.rest import craton diff --git a/craton_dashboard/api/rest/craton.py b/craton_dashboard/api/rest/craton.py new file mode 100644 index 0000000..3985f0f --- /dev/null +++ b/craton_dashboard/api/rest/craton.py @@ -0,0 +1,106 @@ +# Copyright 2016 Intel Corporation +# +# 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 import settings +from django.views import generic + +from craton_dashboard.api import craton + + +from openstack_dashboard import api +from openstack_dashboard.api.rest import urls +from openstack_dashboard.api.rest import utils as rest_utils + +from six.moves.urllib import request + +@urls.register +class Regions(generic.View): + """API for craton""" + + url_regex = r'craton/regions/$' + + @rest_utils.ajax() + def get(self, request, **kwargs): + """Gets all Regions""" + regions = craton.region_list(request) + return {'items': regions} + + @rest_utils.ajax() + def post(self, request, **kwargs): + """Creates a new Region""" + return craton.region_create(request) + + @rest_utils.ajax() + def put(self, request, **kwargs): + """Updates a Region""" + return craton.region_update(request) + + @rest_utils.ajax() + def delete(self, request, **kwargs): + """Deletes a Region""" + return craton.region_delete(request) + + +@urls.register +class Cells(generic.View): + """API for craton""" + + url_regex = r'craton/cells/$' + + @rest_utils.ajax() + def get(self, request, **kwargs): + """Gets all Cells""" + return craton.cell_list(request) + + @rest_utils.ajax() + def post(self, request, **kwargs): + """Creates a new Cell""" + return craton.cell_create(request) + + @rest_utils.ajax() + def put(self, request, **kwargs): + """Updates a Cell""" + return craton.cell_update(request) + + @rest_utils.ajax() + def delete(self, request, **kwargs): + """Deletes a Cell""" + return craton.cell_delete(request) + +@urls.register +class Hosts(generic.View): + """API for craton""" + + url_regex = r'craton/hosts/$' + + @rest_utils.ajax() + def get(self, request, **kwargs): + """Gets all Hosts""" + return craton.host_list(request) + + @rest_utils.ajax() + def post(self, request, **kwargs): + """Creates a new Host""" + return craton.hosts_create(request) + + @rest_utils.ajax() + def put(self, request, **kwargs): + """Updates a Host""" + return craton.hosts_update(request) + + @rest_utils.ajax() + def delete(self, request, **kwargs): + """Deletes a Host""" + return craton.hosts_delete(request) + diff --git a/craton_dashboard/dashboards/project/fleet/__init__.py b/craton_dashboard/dashboards/project/fleet/__init__.py index e69de29..b3be5c1 100644 --- a/craton_dashboard/dashboards/project/fleet/__init__.py +++ b/craton_dashboard/dashboards/project/fleet/__init__.py @@ -0,0 +1 @@ +from craton_dashboard.api import rest diff --git a/craton_dashboard/dashboards/project/fleet/taskflows/panel.py b/craton_dashboard/dashboards/project/fleet/taskflows/panel.py index 6c35b9c..902ead3 100644 --- a/craton_dashboard/dashboards/project/fleet/taskflows/panel.py +++ b/craton_dashboard/dashboards/project/fleet/taskflows/panel.py @@ -16,6 +16,6 @@ from django.utils.translation import ugettext_lazy as _ import horizon -class Taskflow(horizon.Panel): +class Taskflows(horizon.Panel): name = _('Taskflows') slug = 'taskflow' diff --git a/craton_dashboard/dashboards/project/fleet/taskflows/templates/index.html b/craton_dashboard/dashboards/project/fleet/taskflows/templates/index.html deleted file mode 100644 index 6d1d244..0000000 --- a/craton_dashboard/dashboards/project/fleet/taskflows/templates/index.html +++ /dev/null @@ -1 +0,0 @@ -

Hello World!

diff --git a/craton_dashboard/dashboards/project/fleet/templates/index.html b/craton_dashboard/dashboards/project/fleet/templates/index.html deleted file mode 100644 index 986a4a1..0000000 --- a/craton_dashboard/dashboards/project/fleet/templates/index.html +++ /dev/null @@ -1 +0,0 @@ -

Hello

diff --git a/craton_dashboard/dashboards/project/fleet/views.py b/craton_dashboard/dashboards/project/fleet/views.py index 7bf7a4a..80fe833 100644 --- a/craton_dashboard/dashboards/project/fleet/views.py +++ b/craton_dashboard/dashboards/project/fleet/views.py @@ -16,17 +16,9 @@ from django.utils.translation import ugettext_lazy as _ from django.views import generic from horizon import exceptions -from horizon import forms -from horizon import tables -from horizon import views -class IndexView(tables.DataTableView): - template_name = 'project/fleet/index.hml' +class IndexView(generic.TemplateView): + + template_name = 'regions/index.html' page_title = _('Regions') - def __init__(self, *args, **kwargs): - super(IndexView, self).__init__(*args, **kwargs) - self._more = None - - def get_data(self): - return [] diff --git a/craton_dashboard/enabled/_1730_fleet_taskflows_panel.py b/craton_dashboard/enabled/_1730_fleet_taskflows_panel.py index c930764..d467f7c 100644 --- a/craton_dashboard/enabled/_1730_fleet_taskflows_panel.py +++ b/craton_dashboard/enabled/_1730_fleet_taskflows_panel.py @@ -20,5 +20,4 @@ PANEL_DASHBOARD = 'project' PANEL_GROUP = 'fleet_management' -ADD_PANEL = 'craton_dashboard.dashboards.project.fleeti.taksflows.panel.Taskflows' - +ADD_PANEL = 'craton_dashboard.dashboards.project.fleet.taskflows.panel.Taskflows' diff --git a/craton_dashboard/templates/__init__.py b/craton_dashboard/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/craton_dashboard/templates/regions/__init__.py b/craton_dashboard/templates/regions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/craton_dashboard/templates/regions/index.html b/craton_dashboard/templates/regions/index.html new file mode 100644 index 0000000..3a1a5b0 --- /dev/null +++ b/craton_dashboard/templates/regions/index.html @@ -0,0 +1,12 @@ +{% extends 'base.html' %} +{% load i18n %} +{% block title %}{% trans "Craton" %}{% endblock %} +{% block page_header %}{% endblock %} + +{% block ng_route_base %} + +{% endblock %} + +{% block main %} +
+{% endblock %} diff --git a/craton_dashboard/templates/workflows/__init__.py b/craton_dashboard/templates/workflows/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/craton_dashboard/templates/workflows/index.html b/craton_dashboard/templates/workflows/index.html new file mode 100644 index 0000000..3a1a5b0 --- /dev/null +++ b/craton_dashboard/templates/workflows/index.html @@ -0,0 +1,12 @@ +{% extends 'base.html' %} +{% load i18n %} +{% block title %}{% trans "Craton" %}{% endblock %} +{% block page_header %}{% endblock %} + +{% block ng_route_base %} + +{% endblock %} + +{% block main %} +
+{% endblock %} diff --git a/craton_ui.egg-info/PKG-INFO b/craton_ui.egg-info/PKG-INFO index df7d1a1..94f885a 100644 --- a/craton_ui.egg-info/PKG-INFO +++ b/craton_ui.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: craton-ui -Version: 0.0.1.dev2 +Version: 0.0.1.dev3 Summary: The Craton UI for Horizon Dashboard Home-page: http://www.openstack.org/ Author: OSIC diff --git a/craton_ui.egg-info/SOURCES.txt b/craton_ui.egg-info/SOURCES.txt index aa65932..33c9165 100644 --- a/craton_ui.egg-info/SOURCES.txt +++ b/craton_ui.egg-info/SOURCES.txt @@ -1,11 +1,15 @@ AUTHORS ChangeLog LICENSE +MANIFEST.in README.rst setup.cfg setup.py craton_dashboard/__init__.py +craton_dashboard/api/__init__.py craton_dashboard/api/craton.py +craton_dashboard/api/rest/__init__.py +craton_dashboard/api/rest/craton.py craton_dashboard/dashboards/__init__.py craton_dashboard/dashboards/project/__init__.py craton_dashboard/dashboards/project/fleet/__init__.py @@ -20,6 +24,11 @@ craton_dashboard/enabled/_1710_fleet_panel_group.py craton_dashboard/enabled/_1720_fleet_regions_panel.py craton_dashboard/enabled/_1730_fleet_taskflows_panel.py craton_dashboard/enabled/__init__.py +craton_dashboard/templates/__init__.py +craton_dashboard/templates/regions/__init__.py +craton_dashboard/templates/regions/index.html +craton_dashboard/templates/workflows/__init__.py +craton_dashboard/templates/workflows/index.html craton_ui.egg-info/PKG-INFO craton_ui.egg-info/SOURCES.txt craton_ui.egg-info/dependency_links.txt diff --git a/craton_ui.egg-info/pbr.json b/craton_ui.egg-info/pbr.json index 1af97c0..2c86137 100644 --- a/craton_ui.egg-info/pbr.json +++ b/craton_ui.egg-info/pbr.json @@ -1 +1 @@ -{"is_release": false, "git_version": "e263577"} \ No newline at end of file +{"is_release": false, "git_version": "19b1a51"} \ No newline at end of file