mirror of
https://github.com/retspen/webvirtcloud
synced 2025-01-24 06:05:20 +00:00
Rearrange host resources variables and change variable names
This commit is contained in:
parent
828a271789
commit
d22aed5ef7
4 changed files with 23 additions and 18 deletions
|
@ -24,10 +24,10 @@
|
||||||
<label class="col-sm-4 control-label">{% trans "Network" %}</label>
|
<label class="col-sm-4 control-label">{% trans "Network" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<select class="form-control" name="add-net-network">
|
<select class="form-control" name="add-net-network">
|
||||||
{% for c_net in compute_networks %}
|
{% for c_net in networks_host %}
|
||||||
<option value="net:{{ c_net }}">Network {{ c_net }}</option>
|
<option value="net:{{ c_net }}">Network {{ c_net }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for c_iface in compute_interfaces %}
|
{% for c_iface in interfaces_host %}
|
||||||
<option value="iface:{{ c_iface }}">Interface {{ c_iface }}</option>
|
<option value="iface:{{ c_iface }}">Interface {{ c_iface }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<select class="form-control" name="add-net-nwfilter">
|
<select class="form-control" name="add-net-nwfilter">
|
||||||
<option value="">{% trans "None" %}</option>
|
<option value="">{% trans "None" %}</option>
|
||||||
{% for nwfilter in compute_nwfilters %}
|
{% for nwfilter in nwfilters_host %}
|
||||||
<option value="{{ nwfilter }}">{{ nwfilter }}</option>
|
<option value="{{ nwfilter }}">{{ nwfilter }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<label class="col-sm-3 control-label">{% trans "Storage" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Storage" %}</label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<select name="storage" class="form-control image-format">
|
<select name="storage" class="form-control image-format">
|
||||||
{% for storage in storages %}
|
{% for storage in storages_host %}
|
||||||
<option value="{{ storage }}">{{ storage }}</option>
|
<option value="{{ storage }}">{{ storage }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -873,10 +873,10 @@
|
||||||
<input class="form-control" type="text" value="{{ network.nic }}" readonly/>
|
<input class="form-control" type="text" value="{{ network.nic }}" readonly/>
|
||||||
<label class="control-label"><em>to</em></label>
|
<label class="control-label"><em>to</em></label>
|
||||||
<select class="form-control" name="net-source-{{ forloop.counter0 }}">
|
<select class="form-control" name="net-source-{{ forloop.counter0 }}">
|
||||||
{% for c_net in compute_networks %}
|
{% for c_net in networks_host %}
|
||||||
<option value="net:{{ c_net }}" {% ifequal c_net network.nic %} selected {% endifequal %}>{% trans 'Network' %} {{ c_net }}</option>
|
<option value="net:{{ c_net }}" {% ifequal c_net network.nic %} selected {% endifequal %}>{% trans 'Network' %} {{ c_net }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for c_iface in compute_interfaces %}
|
{% for c_iface in interfaces_host %}
|
||||||
<option value="iface:{{ c_iface }}" {% ifequal c_iface network.nic %} selected {% endifequal %}>{% trans 'Interface' %} {{ c_iface }}</option>
|
<option value="iface:{{ c_iface }}" {% ifequal c_iface network.nic %} selected {% endifequal %}>{% trans 'Interface' %} {{ c_iface }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
@ -887,7 +887,7 @@
|
||||||
<label class="control-label"><em>to</em></label>
|
<label class="control-label"><em>to</em></label>
|
||||||
<select class="form-control" name="net-nwfilter-{{ forloop.counter0 }}">
|
<select class="form-control" name="net-nwfilter-{{ forloop.counter0 }}">
|
||||||
<option value="">{% trans "None" %}</option>
|
<option value="">{% trans "None" %}</option>
|
||||||
{% for c_filters in compute_nwfilters %}
|
{% for c_filters in nwfilters_host %}
|
||||||
<option value="{{ c_filters }}" {% ifequal c_filters network.filterref %} selected {% endifequal %}>{{ c_filters }}</option>
|
<option value="{{ c_filters }}" {% ifequal c_filters network.filterref %} selected {% endifequal %}>{{ c_filters }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -101,11 +101,12 @@ def instances(request, compute_id):
|
||||||
def instance(request, compute_id, vname):
|
def instance(request, compute_id, vname):
|
||||||
"""
|
"""
|
||||||
:param request:
|
:param request:
|
||||||
|
:param compute_id:
|
||||||
|
:param vname:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
error_messages = []
|
error_messages = []
|
||||||
# messages = []
|
|
||||||
compute = get_object_or_404(Compute, pk=compute_id)
|
compute = get_object_or_404(Compute, pk=compute_id)
|
||||||
computes = Compute.objects.all().order_by('name')
|
computes = Compute.objects.all().order_by('name')
|
||||||
computes_count = computes.count()
|
computes_count = computes.count()
|
||||||
|
@ -258,9 +259,6 @@ def instance(request, compute_id, vname):
|
||||||
compute.password,
|
compute.password,
|
||||||
compute.type,
|
compute.type,
|
||||||
vname)
|
vname)
|
||||||
compute_networks = sorted(conn.get_networks())
|
|
||||||
compute_interfaces = sorted(conn.get_ifaces())
|
|
||||||
compute_nwfilters = conn.get_nwfilters()
|
|
||||||
status = conn.get_status()
|
status = conn.get_status()
|
||||||
autostart = conn.get_autostart()
|
autostart = conn.get_autostart()
|
||||||
bootmenu = conn.get_bootmenu()
|
bootmenu = conn.get_bootmenu()
|
||||||
|
@ -272,13 +270,13 @@ def instance(request, compute_id, vname):
|
||||||
cur_memory = conn.get_cur_memory()
|
cur_memory = conn.get_cur_memory()
|
||||||
title = conn.get_title()
|
title = conn.get_title()
|
||||||
description = conn.get_description()
|
description = conn.get_description()
|
||||||
|
networks = conn.get_net_device()
|
||||||
disks = conn.get_disk_devices()
|
disks = conn.get_disk_devices()
|
||||||
media = conn.get_media_devices()
|
media = conn.get_media_devices()
|
||||||
if len(media) != 0:
|
if len(media) != 0:
|
||||||
media_iso = sorted(conn.get_iso_media())
|
media_iso = sorted(conn.get_iso_media())
|
||||||
else:
|
else:
|
||||||
media_iso = []
|
media_iso = []
|
||||||
networks = conn.get_net_device()
|
|
||||||
|
|
||||||
vcpu_range = conn.get_max_cpus()
|
vcpu_range = conn.get_max_cpus()
|
||||||
memory_range = [256, 512, 768, 1024, 2048, 3072, 4096, 6144, 8192, 16384]
|
memory_range = [256, 512, 768, 1024, 2048, 3072, 4096, 6144, 8192, 16384]
|
||||||
|
@ -286,8 +284,6 @@ def instance(request, compute_id, vname):
|
||||||
insort(memory_range, memory)
|
insort(memory_range, memory)
|
||||||
if cur_memory not in memory_range:
|
if cur_memory not in memory_range:
|
||||||
insort(memory_range, cur_memory)
|
insort(memory_range, cur_memory)
|
||||||
memory_host = conn.get_max_memory()
|
|
||||||
vcpu_host = len(vcpu_range)
|
|
||||||
telnet_port = conn.get_telnet_port()
|
telnet_port = conn.get_telnet_port()
|
||||||
console_type = conn.get_console_type()
|
console_type = conn.get_console_type()
|
||||||
console_port = conn.get_console_port()
|
console_port = conn.get_console_port()
|
||||||
|
@ -299,18 +295,16 @@ def instance(request, compute_id, vname):
|
||||||
console_passwd = conn.get_console_passwd()
|
console_passwd = conn.get_console_passwd()
|
||||||
clone_free_names = get_clone_free_names()
|
clone_free_names = get_clone_free_names()
|
||||||
user_quota_msg = check_user_quota(0, 0, 0, 0)
|
user_quota_msg = check_user_quota(0, 0, 0, 0)
|
||||||
storages = sorted(conn.get_storages())
|
|
||||||
cache_modes = sorted(conn.get_cache_modes().items())
|
cache_modes = sorted(conn.get_cache_modes().items())
|
||||||
default_cache = settings.INSTANCE_VOLUME_DEFAULT_CACHE
|
default_cache = settings.INSTANCE_VOLUME_DEFAULT_CACHE
|
||||||
default_format = settings.INSTANCE_VOLUME_DEFAULT_FORMAT
|
default_format = settings.INSTANCE_VOLUME_DEFAULT_FORMAT
|
||||||
default_owner = settings.INSTANCE_VOLUME_DEFAULT_OWNER
|
default_owner = settings.INSTANCE_VOLUME_DEFAULT_OWNER
|
||||||
formats = conn.get_image_formats()
|
formats = conn.get_image_formats()
|
||||||
|
|
||||||
busses = conn.get_disk_bus_types()
|
|
||||||
default_bus = settings.INSTANCE_VOLUME_DEFAULT_BUS
|
|
||||||
show_access_root_password = settings.SHOW_ACCESS_ROOT_PASSWORD
|
show_access_root_password = settings.SHOW_ACCESS_ROOT_PASSWORD
|
||||||
show_access_ssh_keys = settings.SHOW_ACCESS_SSH_KEYS
|
show_access_ssh_keys = settings.SHOW_ACCESS_SSH_KEYS
|
||||||
clone_instance_auto_name = settings.CLONE_INSTANCE_AUTO_NAME
|
clone_instance_auto_name = settings.CLONE_INSTANCE_AUTO_NAME
|
||||||
|
default_bus = settings.INSTANCE_VOLUME_DEFAULT_BUS
|
||||||
|
|
||||||
try:
|
try:
|
||||||
instance = Instance.objects.get(compute_id=compute_id, name=vname)
|
instance = Instance.objects.get(compute_id=compute_id, name=vname)
|
||||||
|
@ -328,6 +322,15 @@ def instance(request, compute_id, vname):
|
||||||
userinstances = UserInstance.objects.filter(instance=instance).order_by('user__username')
|
userinstances = UserInstance.objects.filter(instance=instance).order_by('user__username')
|
||||||
allow_admin_or_not_template = request.user.is_superuser or request.user.is_staff or not instance.is_template
|
allow_admin_or_not_template = request.user.is_superuser or request.user.is_staff or not instance.is_template
|
||||||
|
|
||||||
|
# Host resources
|
||||||
|
vcpu_host = len(vcpu_range)
|
||||||
|
memory_host = conn.get_max_memory()
|
||||||
|
bus_host = conn.get_disk_bus_types()
|
||||||
|
networks_host = sorted(conn.get_networks())
|
||||||
|
interfaces_host = sorted(conn.get_ifaces())
|
||||||
|
nwfilters_host = conn.get_nwfilters()
|
||||||
|
storages_host = sorted(conn.get_storages(True))
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if 'poweron' in request.POST:
|
if 'poweron' in request.POST:
|
||||||
if instance.is_template:
|
if instance.is_template:
|
||||||
|
@ -502,7 +505,7 @@ def instance(request, compute_id, vname):
|
||||||
|
|
||||||
if 'resizevm_disk' in request.POST and (
|
if 'resizevm_disk' in request.POST and (
|
||||||
request.user.is_superuser or request.user.is_staff or userinstance.is_change):
|
request.user.is_superuser or request.user.is_staff or userinstance.is_change):
|
||||||
disks_new = []
|
disks_new = list()
|
||||||
for disk in disks:
|
for disk in disks:
|
||||||
input_disk_size = filesizefstr(request.POST.get('disk_size_' + disk['dev'], ''))
|
input_disk_size = filesizefstr(request.POST.get('disk_size_' + disk['dev'], ''))
|
||||||
if input_disk_size > disk['size'] + (64 << 20):
|
if input_disk_size > disk['size'] + (64 << 20):
|
||||||
|
@ -907,6 +910,8 @@ def instance(request, compute_id, vname):
|
||||||
def inst_status(request, compute_id, vname):
|
def inst_status(request, compute_id, vname):
|
||||||
"""
|
"""
|
||||||
:param request:
|
:param request:
|
||||||
|
:param compute_id:
|
||||||
|
:param vname:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue