-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reconfigure VM network connectivity aka. NICs #272
Conversation
6860ad6
to
8e2b911
Compare
Added some more tests, now I think it's ready for review. |
['None'] + orchestration_stack.cloud_networks.map(&:name) | ||
end | ||
|
||
def available_adapter_names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are these two methods called? Is there a corresponding UI PR that is still pending?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thanks
end | ||
|
||
def available_adapter_names | ||
available = (0..4).to_a - network_ports.map { |nic| nic_idx(nic.name) }.map(&:to_i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a vCloud limitation? Can you only have 5 NICs on a VM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think vCloud supports unlimited number of NICs. MIQ UI, however, hard-codes a limit of 4 when reconfiguring. I'm not sure why such limit is enforced, but I'm also not sure why vCloud user would ever want to assign more than 4 NICs so I didn't really go into that.
Let me update this to offer user only 4 indeces (0..3) so it will match UI limitation even better. If UI limit gets removed in future, we can add more here if needed.
:shared => network.is_shared, | ||
:type => network_type, | ||
:cloud_subnets => [], | ||
:orchestration_stack_id => network.try(:vapp).try(:id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I don't think this is the right id, the orchestration_stack_id should be our database id and the id you get from the vapp is probably more akin to our ems_ref.
If so you can set this to something like :orchestration_stack_ref
and in the network_manager save_inventory in core you can pull that ref out, lookup the stack and put the ID there in the saver.
/cc @Ladas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, we should also have this tested in refresh spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refresh parser is a bit special in a way it actually iterates orchestration stacks from VMDB and fetches networking information for each of them. This happens in L54 like this:
@ems.orchestration_stacks.each do |stack|
# ...
end
So vapp.id
here is actually the VMDB id. Spec test is already in place and I've double tested in development environment prior opening PR and recording demo video 😇 But thanks for pointing out, renamed :vapp
attribute into :orchestration_stack
to make it less misleading.
8e2b911
to
c6b9dae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for review, I've pushed a slightly modified patch where I introduce additional change to the refresh parser. Currently, we inventory NIC name as
"{vm_name}#NIC#{nic_index}"
which is quite long and unusual. We now rather inventory it only as:
"NIC#{nic_index}"
@agrare if you think I should open a separate PR for parser changes just let me know. Thing is no one really used vCloud network inventory by now so I think we're safe to modify it just like this.
end | ||
|
||
def available_adapter_names | ||
available = (0..4).to_a - network_ports.map { |nic| nic_idx(nic.name) }.map(&:to_i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think vCloud supports unlimited number of NICs. MIQ UI, however, hard-codes a limit of 4 when reconfiguring. I'm not sure why such limit is enforced, but I'm also not sure why vCloud user would ever want to assign more than 4 NICs so I didn't really go into that.
Let me update this to offer user only 4 indeces (0..3) so it will match UI limitation even better. If UI limit gets removed in future, we can add more here if needed.
:shared => network.is_shared, | ||
:type => network_type, | ||
:cloud_subnets => [], | ||
:orchestration_stack_id => network.try(:vapp).try(:id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refresh parser is a bit special in a way it actually iterates orchestration stacks from VMDB and fetches networking information for each of them. This happens in L54 like this:
@ems.orchestration_stacks.each do |stack|
# ...
end
So vapp.id
here is actually the VMDB id. Spec test is already in place and I've double tested in development environment prior opening PR and recording demo video 😇 But thanks for pointing out, renamed :vapp
attribute into :orchestration_stack
to make it less misleading.
@@ -28,6 +28,15 @@ def disk_default_type | |||
'LSI Logic Parallel SCSI' | |||
end | |||
|
|||
def available_networks | |||
['None'] + orchestration_stack.cloud_networks.map(&:name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if 'None'
should not be added by the UI.
But if it is here, it needs to be _('None')
or N_('None')
so that we have a hope of translating it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@himdel yeah I agree adding None here seems like the wrong place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"None" is a special network name which we pass directly to vCloud API and vCloud understands it, so using _('None')
won't work unless we perform some kind of reverse transformation prior passing to vCloud.
My thinking to add "None" here was that other providers don't seem to support it so I wasn't sure how to do it on UI (another IF statement with another function here on provider e.g. supports_none?
). We can also make vLan field optional, but that would affect how reconfigure works for other providers.
That being said, please let me know if you'd still prefer to do it on UI and I'll try to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting, maybe make the network selection optional on the UI and set the network name to 'None'
if options[:network].nil?
41548b1
to
35b5e6d
Compare
9f08cc3
to
732339c
Compare
@agrare looking forward to another pass of review on this one. |
With this commit we support reconfiguration of VM's network adapters - since UI only supports add and remove operations, we focus on these as well. Turns out vCloud's cloud_networks (vApp networks) were not hooked to corresponding orchestration_stack (vApp) yet so we needed to update the parser. Also, we modify parser to omit `subnet-` prefix from cloud_subnet names because it looks strange on the reconfigure UI. Fog version is shifted to 0.2.2 since only this version supports NIC reconfiguration. BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1572086 Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
732339c
to
aef06b5
Compare
Checked commit miha-plesko@aef06b5 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@@ -28,6 +28,11 @@ def disk_default_type | |||
'LSI Logic Parallel SCSI' | |||
end | |||
|
|||
def available_adapter_names | |||
available = (0..3).to_a - network_ports.map { |nic| nic_idx(nic.name) }.map(&:to_i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to leave a comment here for the record that we believe 4 NICs is a current UI limitation, if this changes in the future we should come back to this.
Reconfigure VM network connectivity aka. NICs
Reconfigure VM network connectivity aka. NICs (cherry picked from commit b1dfc85) https://bugzilla.redhat.com/show_bug.cgi?id=1584699
Gaprindashvili backport details:
|
Add changes for service, vm retire request approval
With this commit we support reconfiguration of VM's network adapters - since UI only supports add and remove operations, we focus on these as well.
Turns out vCloud's cloud_networks (vApp networks) were not hooked to corresponding orchestration_stack (vApp) yet so we needed to update the parser. Also, we modify parser to omit
subnet-
prefix from cloud_subnet names because it looks strange on the reconfigure UI.Fog version is shifted to 0.2.2 since only this version supports NIC reconfiguration.
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1572086
Needed for: ManageIQ/manageiq-ui-classic#3972
Video: http://x.k00.fr/nicreconfigure
@miq-bot assign @agrare
@miq-bot add_label enhancement,gaprindashvili/yes