From 50437684060e2e4ab5adb9b33c82cd5567fcd8d7 Mon Sep 17 00:00:00 2001 From: ernjvr Date: Wed, 8 Aug 2018 08:37:04 +0200 Subject: [PATCH] ui: add ipaddress input field to 'Add network to VM' form (#2782) On the 'NICs' tab, when a user clicks the 'Add network to VM' button to add a network to a VM, the 'Add network to VM' popup screen does not have an IP Address input field to allow a user to define a specific IP Address for a NIC. A user can specify the IP address for the first NIC when creating a VM instance, but cannot do that for subsequent NICs when adding a network to a VM. To Reproduce: Go to the 'Instances' screen by clicking the 'Instances' tab on the lefthand side. On the 'Instances' screen click on a specific VM instance name. This will open the 'Details' tab for the specific VM instance. Click on the 'NICs' tab and then click on the 'Add network to VM' button to add a network to a VM. The 'Add network to VM' popup screen will display. Actual Behaviour: The 'Add network to VM' popup screen does not have an IP Address input field to allow a user to define a specific IP Address for a NIC. Expected behaviour: The 'Add network to VM' popup screen must have an IP Address input field to allow a user to define a specific IP Address for a NIC. Since the addNicToVirtualMachine API's ipaddress field is not required, the IP Address input field is also not a required field. The IP Address input field must be validated for a valid IPv4 formatted value if the user enters anything into the field. The valid user-specified IPv4 IP Address value must be allocated to the NIC if it is within the acceptable IP range for the chosen Network. --- ui/scripts/instances.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index 4e89cdb1d80..1a2a6409cca 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -2642,16 +2642,29 @@ } }); } + }, + ipaddress: { + label: 'label.ip.address', + validation: { + required: false, + ipv4: true + } } } }, action: function(args) { + var dataObj = { + virtualmachineid: args.context.instances[0].id, + networkid: args.data.networkid, + }; + + if (args.data.ipaddress) { + dataObj.ipaddress = args.data.ipaddress; + } + $.ajax({ url: createURL('addNicToVirtualMachine'), - data: { - virtualmachineid: args.context.instances[0].id, - networkid: args.data.networkid - }, + data: dataObj, success: function(json) { args.response.success({ _custom: {