Commit 6c9a7148 by Szabolcs Gelencser Committed by Szabolcs Gelencsér

Mitaka compatibility: must have network on vm creation

parent d8b13d06
......@@ -616,3 +616,5 @@ DEFAULT_LEASE_SUSPEND_SECONDS = 3600
DEFAULT_LEASE_DELETE_SECONDS = 7200
SESSIONHOOK_SHARED_SECRET = "verysecretmuchsecure"
IS_NET_OMISSION_SUPPORTED = False # in mitaka you must specify network at vm creation
......@@ -10,7 +10,9 @@
{{ form.name|as_crispy_field }}
{{ form.image|as_crispy_field }}
{{ form.flavor|as_crispy_field }}
{% if IS_NET_OMISSION_SUPPORTED %}
{{ form.internet_access|as_crispy_field }}
{% endif %}
<button class="btn btn-success btn-xs vm-create-start pull-right text-right" type="submit">
<i class="fa fa-play"></i> {% trans "Start" %}
</button>
......
......@@ -1113,13 +1113,14 @@ class VmPlainImageCreate(LoginRequiredMixin, TemplateView):
context = self.get_context_data(**kwargs)
context.update({
'form': VmFromPlainImageForm(request),
'IS_NET_OMISSION_SUPPORTED': settings.IS_NET_OMISSION_SUPPORTED,
})
return self.render_to_response(context)
def post(self, request, *args, **kwargs):
server_created = None
if request.POST.get("internet_access"):
if request.POST.get("internet_access") or not settings.IS_NET_OMISSION_SUPPORTED:
default_public_routed_net_id = DefaultPublicRoutedNet.get_id(request)
server_created = openstack_api.nova.server_create(
request,
......@@ -1198,12 +1199,25 @@ class VmCreate(LoginRequiredMixin, TemplateView):
return self.render_to_response(context)
def __create_normal(self, request, template, *args, **kwargs):
# TODO: create networks, interfaces, disks of template
if settings.IS_NET_OMISSION_SUPPORTED:
server_created = openstack_api.nova.server_create(
request,
template.name,
template.image_id,
template.flavor_id,
)
else:
default_public_routed_net_id = DefaultPublicRoutedNet.get_id(request)
server_created = openstack_api.nova.server_create(
request,
template.name,
template.image_id,
template.flavor_id,
nics=({
'net-id': default_public_routed_net_id,
},)
)
from dashboard.templatetags.instance_tags import get_absolute_url
messages.success(request, _("VM successfully created."))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment