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

Add guest customization field to service catalog order form #215

Merged

Conversation

gasper-vrhovsek
Copy link
Contributor

Added guest customization field to service catalog order
form, also added spec tests for the new field.

@gasper-vrhovsek gasper-vrhovsek force-pushed the feature/guest_customization_field branch from fc42425 to c033f47 Compare March 22, 2018 10:39
@gasper-vrhovsek
Copy link
Contributor Author

Hi @miha-plesko @gberginc I think this is ready to be reviewed.

Copy link
Contributor

@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 @gasper-vrhovsek generally looks great, few minor comments then we're good to go. May I also ask you to test this on a vApp template with RHEL VM? I know for sure that provisioning fails there if guest customization is enabled and would like to make sure it works is case user unchecks this checkbox.

vm.cores_per_socket = int(el, vm_xpaths(:cores_per_socket), :default => vm.num_cores)
vm.memory_mb = int(el, vm_xpaths(:memory_mb), :default => 1024)
vm.guest_customization = text(el, vm_xpaths(:guest_customization), :default => false)
vm.guest_customization = vm.guest_customization == 'true'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you introduce auxilary method flag() for this instead using text()?

@@ -130,6 +132,8 @@ def vm_xpaths(key)
"./vcloud:GuestCustomizationSection/vcloud:ComputerName"
when :nics
'.//vcloud:NetworkConnection'
when :guest_customization
"./vcloud:GuestCustomizationSection/vcloud:Enabled"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use single quotes '

'dialog_param_memory_mb-0' => 8192,
'dialog_param_admin_password-0' => 'admin-password',
'dialog_param_admin_reset-0' => 't',
'dialog_param_guest_customization-0' => 't',
Copy link
Contributor

Choose a reason for hiding this comment

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

So you've introduced this here in the input (which is BTW a simultaion what we get throught POST request when user orders provisioning). Can you please set it to 'f' in at least one case and check later in this test (L101 or L129)?

:default_value => vm.guest_customization,
:constraints => [
OrchestrationTemplate::OrchestrationParameterBoolean.new
]
Copy link
Contributor

Choose a reason for hiding this comment

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

May I suggest we put this new checkbox above admin_password field? I think it makes more sense there, since admin password will NOT be set if we uncheck this box.

@@ -112,6 +112,15 @@ def vm_param_groups(template)
:constraints => [
OrchestrationTemplate::OrchestrationParameterBoolean.new
]
), OrchestrationTemplate::OrchestrationParameter.new(
:name => param_name('guest_customization', [vm_idx]),
:label => 'Guest customization',
Copy link
Contributor

Choose a reason for hiding this comment

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

Label should be "Enable Guest Customization"

), OrchestrationTemplate::OrchestrationParameter.new(
:name => param_name('guest_customization', [vm_idx]),
:label => 'Guest customization',
:description => 'Allow guest customization',
Copy link
Contributor

Choose a reason for hiding this comment

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

Description should be something more meaningful, please see how it's described on the vCD dashboard.

capture

@gasper-vrhovsek gasper-vrhovsek force-pushed the feature/guest_customization_field branch 2 times, most recently from e4207d0 to b00d6ce Compare March 26, 2018 09:19
@agrare agrare self-assigned this Mar 26, 2018
Copy link
Contributor

@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 @gasper-vrhovsek few more comments then I thinkg we're green to go.

vm.guest_customization = bool(el, vm_xpaths(:guest_customization))

# vm.guest_customization = text(el, vm_xpaths(:guest_customization), :default => false)
# vm.guest_customization = vm.guest_customization == 'true'
Copy link
Contributor

Choose a reason for hiding this comment

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

Whooops ^

@@ -98,6 +102,10 @@ def parse_vapp_networks(ovf)
end
end

def bool(el, xpath, default: false)
text(el, xpath) == 'true' ? true : default
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this really work as intended? If XML contains

<vcloud:Enabled>false</vcloud:Enabled>

and I call

bool(..., default: true)

then I'll get true which is wrong. The default parameter should only be returned when XML contains no entry for the xpath. So I'd rather go with:

def bool(el, xpath, default: false)
  (match = el.elements[xpath]) ? match.text.downcase == 'true' : default
end

:name => param_name('guest_customization', [vm_idx]),
:label => 'Guest customization',
:description => 'The computer name and network settings configured for this VM are applied to its Guest OS
when the VM is powered on. The following settings are only applied the 1st time the VM is
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we go with this, please:

Check this to apply Hostname and NIC configuration for this VM to its Guest OS
when the VM is powered on. Guest OS must support this feature otherwise
provisioning will fail.

Other features that are mentioned in full text are not (yet) customizable via Service Dialog so we'd only confuse user telling her about them.

@@ -65,6 +65,7 @@
:memory_mb => 2048,
:admin_password => nil,
:admin_reset => false,
:guest_customization => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering why rubocop didn't complain about => alignment. I'd align it anyway.

@gasper-vrhovsek gasper-vrhovsek force-pushed the feature/guest_customization_field branch 6 times, most recently from 696464a to 0b37900 Compare March 29, 2018 13:34
@agrare
Copy link
Member

agrare commented Apr 2, 2018

@miha-plesko how does this look to you now?

Copy link
Contributor

@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.

LGTM. Also, I've tested and it works like a charm, thanks @gasper-vrhovsek.

@agrare feel free to merge.

Added guest customization field to service catalog order
form, also added spec tests for the new field.
@gasper-vrhovsek gasper-vrhovsek force-pushed the feature/guest_customization_field branch from 0b37900 to e8cd22c Compare April 3, 2018 08:48
@miq-bot
Copy link
Member

miq-bot commented Apr 3, 2018

Checked commit gasper-vrhovsek@e8cd22c with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
5 files checked, 0 offenses detected
Everything looks fine. 🍪

@gasper-vrhovsek
Copy link
Contributor Author

@agrare @miha-plesko last commit is just a rebase on master.

@miha-plesko
Copy link
Contributor

miha-plesko commented Apr 3, 2018

@gasper-vrhovsek Travis is red because a new version of fog-vcloud-director was released which sets 5.5 as default (was 5.1 until now). Will be green once #219 gets merged

@agrare agrare closed this Apr 3, 2018
@agrare agrare reopened this Apr 3, 2018
agrare added a commit to agrare/manageiq-providers-vmware that referenced this pull request Apr 3, 2018
…stomization_field

Add guest customization field to service catalog order form
@agrare agrare merged commit e8cd22c into ManageIQ:master Apr 3, 2018
@agrare agrare added this to the Sprint 83 Ending Apr 9, 2018 milestone Apr 3, 2018
@miha-plesko
Copy link
Contributor

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1550909

@miq-bot add_label enhancement,gaprindashvili/yes

simaishi pushed a commit that referenced this pull request Apr 3, 2018
…ion_field

Add guest customization field to service catalog order form
(cherry picked from commit 74f06e8)

https://bugzilla.redhat.com/show_bug.cgi?id=1552842
@simaishi
Copy link
Contributor

simaishi commented Apr 3, 2018

Gaprindashvili backport details:

$ git log -1
commit 215c46debd5eae9e01a3c10fe34d10b1e5791a7d
Author: Adam Grare <agrare@redhat.com>
Date:   Tue Apr 3 09:07:06 2018 -0400

    Merge pull request #215 from gasper-vrhovsek/feature/guest_customization_field
    
    Add guest customization field to service catalog order form
    (cherry picked from commit 74f06e81252ac45b74b9ca234672250cf61e42d6)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1552842

agrare pushed a commit to agrare/manageiq-providers-vmware that referenced this pull request Apr 15, 2019
v2v: Storage mapping for mass migration
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.

5 participants