diff --git a/app/network/forms.py b/app/network/forms.py index b91962afbf2da4b242a639fe39299f33a7d51936..cd89d472358acfe2a79be8066a611f3aba646a5d 100644 --- a/app/network/forms.py +++ b/app/network/forms.py @@ -230,11 +230,13 @@ class HostInterfaceForm(HostForm, InterfaceForm): class CreateVMForm(CSEntryForm): cores = SelectField("Cores", default=2, coerce=int) memory = SelectField("Memory (GB)", default=2, coerce=int) + disk = SelectField("Disk (GB)", default=15, coerce=int) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.cores.choices = utils.get_choices(current_app.config["VM_CORES_CHOICES"]) self.memory.choices = utils.get_choices(current_app.config["VM_MEMORY_CHOICES"]) + self.disk.choices = utils.get_choices(current_app.config["VM_DISK_CHOICES"]) class GenerateZTPConfigForm(CSEntryForm): diff --git a/app/network/views.py b/app/network/views.py index 2835a055854b954947d35f43248fcc1929c688bc..2a539d86557fb193e06b221813175faf7b4286fa 100644 --- a/app/network/views.py +++ b/app/network/views.py @@ -154,6 +154,9 @@ def view_host(name): form.memory.choices = utils.get_choices( current_app.config["VIOC_MEMORY_CHOICES"] ) + form.disk.choices = utils.get_choices( + current_app.config["VIOC_DISK_CHOICES"] + ) else: form = None if form is not None and form.validate_on_submit(): @@ -180,10 +183,11 @@ def view_host(name): flash(f"Only admin users are allowed to create a VM!", "info") return redirect(url_for("network.view_host", name=name)) else: - # Save the requested memory and cores as ansible variables + # Save the requested disk, memory and cores as ansible variables csentry_vars = { "csentry_vm_memory": int(form.memory.data) * 1024, "csentry_vm_cores": int(form.cores.data), + "proxmox_disk_space": int(form.disk.data), } try: host.ansible_vars.update(csentry_vars) diff --git a/app/settings.py b/app/settings.py index b4ac8f7f13683a7a72e26873676e1bdf20cb305e..f7fd21102a06988fcf5bee46ca8e84391493a6a6 100644 --- a/app/settings.py +++ b/app/settings.py @@ -100,8 +100,10 @@ AWX_VM_CREATION_ENABLED = False VM_CORES_CHOICES = [1, 2, 4, 6, 8, 24] VM_MEMORY_CHOICES = [2, 4, 8, 16, 32, 128] +VM_DISK_CHOICES = [15, 50, 100, 250] VIOC_CORES_CHOICES = [1, 3, 6] VIOC_MEMORY_CHOICES = [2, 4, 8] +VIOC_DISK_CHOICES = [15, 50, 100, 250] # Sentry integration CSENTRY_RELEASE = raven.fetch_git_sha(Path(__file__).parents[1]) diff --git a/app/templates/network/view_host.html b/app/templates/network/view_host.html index 4f16c2e0d9630027ef87dfb63a0c51d55a8f1a7e..544ab6e9c9f9a5c0cac6cfadc561713f475d1711 100644 --- a/app/templates/network/view_host.html +++ b/app/templates/network/view_host.html @@ -75,6 +75,7 @@ {{ form.hidden_tag() }} {{ render_field(form.cores, label_size='6', input_size='6') }} {{ render_field(form.memory, label_size='6', input_size='6') }} + {{ render_field(form.disk, label_size='6', input_size='6') }} {{ submit_button_with_confirmation('Create ' + vm_type, 'Do you really want to create the ' + vm_type + ' ' + host.name + '?') }} </form> </div>