Merge "remove use of dummy db"
This commit is contained in:
commit
a858f10d13
@ -139,12 +139,6 @@ tuskar-ui introduces one additional dependency - python-tuskarclient:
|
|||||||
|
|
||||||
pip install git+http://github.com/stackforge/python-tuskarclient.git
|
pip install git+http://github.com/stackforge/python-tuskarclient.git
|
||||||
|
|
||||||
Finally, synchronize your local database:
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
./manage.py syncdb
|
|
||||||
|
|
||||||
Starting the app
|
Starting the app
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
@ -398,16 +398,3 @@ OVERCLOUD_CREDS = {
|
|||||||
'tenant': 'admin',
|
'tenant': 'admin',
|
||||||
'auth_url': 'http://localhost:5000/v2.0/',
|
'auth_url': 'http://localhost:5000/v2.0/',
|
||||||
}
|
}
|
||||||
|
|
||||||
# FIXME: configuration for dummy data
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
|
||||||
'NAME': 'openstack_dashboard/dummydb.sqlite',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# FIXME: configuration for dummy data
|
|
||||||
FIXTURE_DIRS = (
|
|
||||||
'openstack_dashboard/dashboards/infrastructure/fixtures/',
|
|
||||||
)
|
|
||||||
|
@ -30,8 +30,6 @@ from tuskarclient.v1 import client as tuskar_client
|
|||||||
from openstack_dashboard.api import base
|
from openstack_dashboard.api import base
|
||||||
from openstack_dashboard.api import nova
|
from openstack_dashboard.api import nova
|
||||||
|
|
||||||
import tuskar_ui.infrastructure.models as dummymodels
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
TUSKAR_ENDPOINT_URL = getattr(django.conf.settings, 'TUSKAR_ENDPOINT_URL')
|
TUSKAR_ENDPOINT_URL = getattr(django.conf.settings, 'TUSKAR_ENDPOINT_URL')
|
||||||
@ -145,26 +143,6 @@ class Capacity(StringIdAPIResourceWrapper):
|
|||||||
"""
|
"""
|
||||||
_attrs = ['name', 'value', 'unit']
|
_attrs = ['name', 'value', 'unit']
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def create(cls, request, **kwargs):
|
|
||||||
c = dummymodels.Capacity(
|
|
||||||
content_object=kwargs['content_object'],
|
|
||||||
name=kwargs['name'],
|
|
||||||
value=kwargs['value'],
|
|
||||||
unit=kwargs['unit'])
|
|
||||||
c.save()
|
|
||||||
return Capacity(c)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def update(cls, request, **kwargs):
|
|
||||||
c = dummymodels.Capacity.objects.get(id=kwargs['capacity_id'])
|
|
||||||
c.content_object = kwargs['content_object']
|
|
||||||
c.name = kwargs['name']
|
|
||||||
c.value = kwargs['value']
|
|
||||||
c.unit = kwargs['unit']
|
|
||||||
c.save()
|
|
||||||
return cls(c)
|
|
||||||
|
|
||||||
# defines a random usage of capacity - API should probably be able to
|
# defines a random usage of capacity - API should probably be able to
|
||||||
# determine usage of capacity based on capacity value and obejct_id
|
# determine usage of capacity based on capacity value and obejct_id
|
||||||
@property
|
@property
|
||||||
@ -290,25 +268,6 @@ class Node(StringIdAPIResourceWrapper):
|
|||||||
LOG.debug(exceptions.error_color(msg))
|
LOG.debug(exceptions.error_color(msg))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
|
||||||
def vm_capacity(self):
|
|
||||||
if not hasattr(self, '_vm_capacity'):
|
|
||||||
try:
|
|
||||||
value = (
|
|
||||||
dummymodels.ResourceClassFlavor.objects
|
|
||||||
.filter(resource_class__rack__node=self._apiresource)
|
|
||||||
.aggregate(django.db.models.Max("max_vms"))
|
|
||||||
['max_vms__max']
|
|
||||||
)
|
|
||||||
except Exception:
|
|
||||||
value = _("Unable to retrieve vm capacity")
|
|
||||||
|
|
||||||
vm_capacity = dummymodels.Capacity(name=_("Max VMs"),
|
|
||||||
value=value,
|
|
||||||
unit=_("VMs"))
|
|
||||||
self._vm_capacity = Capacity(vm_capacity)
|
|
||||||
return self._vm_capacity
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
# FIXME: just mock implementation, add proper one
|
# FIXME: just mock implementation, add proper one
|
||||||
def running_instances(self):
|
def running_instances(self):
|
||||||
@ -327,10 +286,7 @@ class Node(StringIdAPIResourceWrapper):
|
|||||||
@property
|
@property
|
||||||
def alerts(self):
|
def alerts(self):
|
||||||
if not hasattr(self, '_alerts'):
|
if not hasattr(self, '_alerts'):
|
||||||
self._alerts = [Alert(a) for a in
|
self._alerts = []
|
||||||
dummymodels.Alert.objects
|
|
||||||
.filter(object_type='node')
|
|
||||||
.filter(object_id=str(self.id))]
|
|
||||||
return self._alerts
|
return self._alerts
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -470,10 +426,7 @@ class Rack(StringIdAPIResourceWrapper):
|
|||||||
@property
|
@property
|
||||||
def alerts(self):
|
def alerts(self):
|
||||||
if not hasattr(self, '_alerts'):
|
if not hasattr(self, '_alerts'):
|
||||||
self._alerts = [Alert(a) for a in
|
self._alerts = []
|
||||||
dummymodels.Alert.objects
|
|
||||||
.filter(object_type='rack')
|
|
||||||
.filter(object_id=int(self.id))]
|
|
||||||
return self._alerts
|
return self._alerts
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
[
|
|
||||||
{"pk": 1, "model": "infrastructure.alert", "fields": {"message": "Switch is not accessible.", "object_id": "1", "object_type": "rack", "time": "2011-09-01T13:20:30+03:00"}},
|
|
||||||
{"pk": 2, "model": "infrastructure.alert", "fields": {"message": "Nova service is not running.", "object_id": "1", "object_type": "node", "time": "2011-09-01T13:20:30+03:00"}},
|
|
||||||
{"pk": 3, "model": "infrastructure.alert", "fields": {"message": "Disk usage is over 90%.", "object_id": "1", "object_type": "node", "time": "2011-09-01T13:20:30+03:00"}}
|
|
||||||
]
|
|
@ -1,26 +0,0 @@
|
|||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# FIXME: configuration for dummy data
|
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
|
|
||||||
class Alert(models.Model):
|
|
||||||
class Meta:
|
|
||||||
db_table = 'infrastructure_alerts'
|
|
||||||
|
|
||||||
object_id = models.CharField(max_length=50)
|
|
||||||
object_type = models.CharField(max_length=20)
|
|
||||||
message = models.CharField(max_length=250)
|
|
||||||
time = models.DateTimeField()
|
|
@ -22,27 +22,3 @@
|
|||||||
{% endblock breadcrumbs %}
|
{% endblock breadcrumbs %}
|
||||||
|
|
||||||
{% block name %}{{ node.name }}{% endblock %}
|
{% block name %}{{ node.name }}{% endblock %}
|
||||||
|
|
||||||
{% block overall_usage %}
|
|
||||||
<table class="capacities overall_usage">
|
|
||||||
<tr>
|
|
||||||
<td class="capacity_label">{% trans "Usage" %}:</td>
|
|
||||||
<td>
|
|
||||||
{% if node.is_provisioned %}
|
|
||||||
<div id="node_usage"
|
|
||||||
class="capacity_bar"
|
|
||||||
data-chart-type="capacity_bar_chart"
|
|
||||||
data-capacity-limit="{{ node.vm_capacity.value }}"
|
|
||||||
data-capacity-used="{{ node.vm_capacity.usage }}"
|
|
||||||
data-average-capacity-used="{{ 4 }}">
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<div id="node_usage"
|
|
||||||
class="capacity_bar"
|
|
||||||
data-chart-type="capacity_bar_chart">
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
{% endblock %}
|
|
||||||
|
@ -440,7 +440,7 @@ class TuskarApiTests(test.APITestCase):
|
|||||||
|
|
||||||
for rack in rc.aggregated_alerts:
|
for rack in rc.aggregated_alerts:
|
||||||
self.assertIsInstance(rack, api.Rack)
|
self.assertIsInstance(rack, api.Rack)
|
||||||
self.assertEquals(1, len(rc.aggregated_alerts))
|
self.assertEquals(0, len(rc.aggregated_alerts))
|
||||||
|
|
||||||
def test_rack_list(self):
|
def test_rack_list(self):
|
||||||
racks = self.tuskarclient_racks.list()
|
racks = self.tuskarclient_racks.list()
|
||||||
@ -653,7 +653,7 @@ class TuskarApiTests(test.APITestCase):
|
|||||||
|
|
||||||
for node in rack.aggregated_alerts:
|
for node in rack.aggregated_alerts:
|
||||||
self.assertIsInstance(node, api.Node)
|
self.assertIsInstance(node, api.Node)
|
||||||
self.assertEquals(1, len(rack.aggregated_alerts))
|
self.assertEquals(0, len(rack.aggregated_alerts))
|
||||||
|
|
||||||
def test_flavor_create(self):
|
def test_flavor_create(self):
|
||||||
flavor = self.tuskarclient_flavors.first()
|
flavor = self.tuskarclient_flavors.first()
|
||||||
|
Loading…
Reference in New Issue
Block a user