Skip to content
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

Merged
merged 1 commit into from
May 30, 2018

Conversation

miha-plesko
Copy link
Contributor

@miha-plesko miha-plesko commented May 22, 2018

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

@miha-plesko
Copy link
Contributor Author

Added some more tests, now I think it's ready for review.

['None'] + orchestration_stack.cloud_networks.map(&:name)
end

def available_adapter_names
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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)
Copy link
Member

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?

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

@miha-plesko miha-plesko left a 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)
Copy link
Contributor Author

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)
Copy link
Contributor Author

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)
Copy link
Contributor

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.

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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?

@miha-plesko miha-plesko force-pushed the network-reconfigure branch 2 times, most recently from 41548b1 to 35b5e6d Compare May 25, 2018 09:19
@miha-plesko
Copy link
Contributor Author

Thanks @agrare and @himdel for comment on 'None' network, just moved it to to UI and must say it really feels better. Kindly ask for another pass on the two PRs.

@miha-plesko miha-plesko force-pushed the network-reconfigure branch 2 times, most recently from 9f08cc3 to 732339c Compare May 25, 2018 11:01
@miha-plesko
Copy link
Contributor Author

@agrare looking forward to another pass of review on this one.

@miha-plesko miha-plesko changed the title Reconfigure VM network connectivity aka. NICs [WIP] Reconfigure VM network connectivity aka. NICs May 28, 2018
@miq-bot miq-bot added the wip label May 28, 2018
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>
@miq-bot
Copy link
Member

miq-bot commented May 28, 2018

Checked commit miha-plesko@aef06b5 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
6 files checked, 0 offenses detected
Everything looks fine. ⭐

@miha-plesko miha-plesko changed the title [WIP] Reconfigure VM network connectivity aka. NICs Reconfigure VM network connectivity aka. NICs May 28, 2018
@miq-bot miq-bot removed the wip label May 28, 2018
@@ -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)
Copy link
Member

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.

@agrare agrare merged commit aef06b5 into ManageIQ:master May 30, 2018
agrare added a commit that referenced this pull request May 30, 2018
Reconfigure VM network connectivity aka. NICs
@agrare agrare added this to the Sprint 87 Ending Jun 4, 2018 milestone May 30, 2018
simaishi pushed a commit that referenced this pull request Jun 1, 2018
@simaishi
Copy link
Contributor

simaishi commented Jun 1, 2018

Gaprindashvili backport details:

$ git log -1
commit 5359c57a195fa9d5555581d480cd55c0be09e8be
Author: Adam Grare <agrare@redhat.com>
Date:   Wed May 30 08:50:37 2018 -0400

    Merge pull request #272 from miha-plesko/network-reconfigure
    
    Reconfigure VM network connectivity aka. NICs
    (cherry picked from commit b1dfc85630c7894848f97bfadab26c9e15cf4333)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1584699

@miha-plesko miha-plesko deleted the network-reconfigure branch January 7, 2019 08:26
agrare pushed a commit to agrare/manageiq-providers-vmware that referenced this pull request Apr 15, 2019
Add changes for service, vm retire request approval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants