Merge "Fixing database instance launch workflow"
This commit is contained in:
commit
9d41eba993
@ -74,10 +74,16 @@ def instance_delete(request, instance_id):
|
||||
|
||||
def instance_create(request, name, volume, flavor, databases=None,
|
||||
users=None, restore_point=None):
|
||||
#TODO(dklyle): adding conditional to support trove without volume
|
||||
# support for now until API supports checking for volume support
|
||||
if volume > 0:
|
||||
volume_params = {'size': volume}
|
||||
else:
|
||||
volume_params = None
|
||||
return troveclient(request).instances.create(
|
||||
name,
|
||||
flavor,
|
||||
{'size': volume},
|
||||
volume=volume_params,
|
||||
databases=databases,
|
||||
users=users,
|
||||
restorePoint=restore_point)
|
||||
|
@ -1,53 +1,4 @@
|
||||
{% load i18n horizon humanize %}
|
||||
|
||||
<p>{% blocktrans %}Specify the details for launching an instance.{% endblocktrans %}</p>
|
||||
<p>{% blocktrans %}The chart below shows the resources used by this project in relation to the project's quotas.{% endblocktrans %}</p>
|
||||
|
||||
<h4>{% trans "Flavor Details" %}</h4>
|
||||
<table class="flavor_table table-striped">
|
||||
<tbody>
|
||||
<tr><td class="flavor_name">{% trans "Name" %}</td><td><span id="flavor_name"></span></td></tr>
|
||||
<tr><td class="flavor_name">{% trans "VCPUs" %}</td><td><span id="flavor_vcpus"></span></td></tr>
|
||||
<tr><td class="flavor_name">{% trans "Root Disk" %}</td><td><span id="flavor_disk"> </span> {% trans "GB" %}</td></tr>
|
||||
<tr><td class="flavor_name">{% trans "Ephemeral Disk" %}</td><td><span id="flavor_ephemeral"></span> {% trans "GB" %}</td></tr>
|
||||
<tr><td class="flavor_name">{% trans "Total Disk" %}</td><td><span id="flavor_disk_total"></span> {% trans "GB" %}</td></tr>
|
||||
<tr><td class="flavor_name">{% trans "RAM" %}</td><td><span id="flavor_ram"></span> {% trans "MB" %}</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="quota-dynamic">
|
||||
<h4>{% trans "Project Quotas" %}</h4>
|
||||
<div class="quota_title clearfix">
|
||||
<strong>{% trans "Number of Instances" %} <span>({{ usages.instances.used|intcomma }})</span></strong>
|
||||
<p>{{ usages.instances.available|quota|intcomma }}</p>
|
||||
</div>
|
||||
<div id="quota_instances" class="quota_bar" data-progress-indicator-flavor data-quota-limit="{{ usages.instances.quota }}" data-quota-used="{{ usages.instances.used }}">
|
||||
{% horizon_progress_bar usages.instances.used usages.instances.quota %}
|
||||
</div>
|
||||
|
||||
<div class="quota_title clearfix">
|
||||
<strong>{% trans "Number of VCPUs" %} <span>({{ usages.cores.used|intcomma }})</span></strong>
|
||||
<p>{{ usages.cores.available|quota|intcomma }}</p>
|
||||
</div>
|
||||
<div id="quota_vcpus" class="quota_bar" data-progress-indicator-flavor data-quota-limit="{{ usages.cores.quota }}" data-quota-used="{{ usages.cores.used }}">
|
||||
{% horizon_progress_bar usages.cores.used usages.cores.quota %}
|
||||
</div>
|
||||
|
||||
<div class="quota_title clearfix">
|
||||
<strong>{% trans "Total RAM" %} <span>({{ usages.ram.used|intcomma }} {% trans "MB" %})</span></strong>
|
||||
<p>{{ usages.ram.available|quota:"MB"|intcomma }}</p>
|
||||
</div>
|
||||
<div id="quota_ram" data-progress-indicator-flavor data-quota-limit="{{ usages.ram.quota }}" data-quota-used="{{ usages.ram.used }}" class="quota_bar">
|
||||
{% horizon_progress_bar usages.ram.used usages.ram.quota %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
if(typeof horizon.Quota !== 'undefined') {
|
||||
horizon.Quota.initWithFlavors({{ flavors|safe|default:"{}" }});
|
||||
} else {
|
||||
addHorizonLoadEvent(function() {
|
||||
horizon.Quota.initWithFlavors({{ flavors|safe|default:"{}" }});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<p>{% blocktrans %}<strong>Please note:</strong> The value specified in the Volume Size field should be greater than 0, however, some configurations do not support specifying volume size. If specifying the volume results in an error stating volume support is not enabled, enter 0.{% endblocktrans %}</p>
|
||||
|
@ -117,13 +117,10 @@ class DatabaseTests(test.TestCase):
|
||||
self.assertMessageCount(res, error=1)
|
||||
|
||||
@test.create_stubs({
|
||||
api.nova: ('tenant_absolute_limits',),
|
||||
api.trove: ('flavor_list', 'backup_list',)})
|
||||
def test_launch_instance(self):
|
||||
api.trove.flavor_list(IsA(http.HttpRequest))\
|
||||
.AndReturn(self.flavors.list())
|
||||
api.nova.tenant_absolute_limits(IsA(http.HttpRequest))\
|
||||
.AndReturn([])
|
||||
api.trove.backup_list(IsA(http.HttpRequest))\
|
||||
.AndReturn(self.database_backups.list())
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import simplejson as json
|
||||
|
||||
from django.conf import settings # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
@ -33,13 +32,13 @@ class SetInstanceDetailsAction(workflows.Action):
|
||||
flavor = forms.ChoiceField(label=_("Flavor"),
|
||||
help_text=_("Size of image to launch."))
|
||||
volume = forms.IntegerField(label=_("Volume Size"),
|
||||
min_value=1,
|
||||
min_value=0,
|
||||
initial=1,
|
||||
help_text=_("Size of the volume in GB."))
|
||||
|
||||
class Meta:
|
||||
name = _("Details")
|
||||
help_text_template = ("project/instances/_launch_details_help.html")
|
||||
help_text_template = ("project/databases/_launch_details_help.html")
|
||||
|
||||
def flavors(self, request):
|
||||
if not hasattr(self, '_flavors'):
|
||||
@ -54,18 +53,6 @@ class SetInstanceDetailsAction(workflows.Action):
|
||||
flavor_list = [(f.id, "%s" % f.name) for f in self.flavors(request)]
|
||||
return sorted(flavor_list)
|
||||
|
||||
def get_help_text(self):
|
||||
flavors = json.dumps([f._info for f in self.flavors(self.request)])
|
||||
extra = {'flavors': flavors}
|
||||
try:
|
||||
LOG.debug("Obtaining absolute tenant limits")
|
||||
extra['usages'] = api.nova.tenant_absolute_limits(self.request)
|
||||
extra['usages_json'] = json.dumps(extra['usages'])
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
_("Unable to retrieve quota information."))
|
||||
return super(SetInstanceDetailsAction, self).get_help_text(extra)
|
||||
|
||||
|
||||
TROVE_ADD_USER_PERMS = getattr(settings, 'TROVE_ADD_USER_PERMS', [])
|
||||
TROVE_ADD_DATABASE_PERMS = getattr(settings, 'TROVE_ADD_DATABASE_PERMS', [])
|
||||
|
Loading…
x
Reference in New Issue
Block a user