-
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
Add guest customization field to service catalog order form #215
Add guest customization field to service catalog order form #215
Conversation
fc42425
to
c033f47
Compare
Hi @miha-plesko @gberginc I think this is ready to be reviewed. |
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 @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' |
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.
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" |
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.
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', |
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.
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 | ||
] |
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.
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', |
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.
Label should be "Enable Guest Customization"
), OrchestrationTemplate::OrchestrationParameter.new( | ||
:name => param_name('guest_customization', [vm_idx]), | ||
:label => 'Guest customization', | ||
:description => 'Allow guest customization', |
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.
e4207d0
to
b00d6ce
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 @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' |
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.
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 |
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.
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 |
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.
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, |
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'm wondering why rubocop didn't complain about =>
alignment. I'd align it anyway.
696464a
to
0b37900
Compare
@miha-plesko how does this look to you now? |
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.
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.
0b37900
to
e8cd22c
Compare
Checked commit gasper-vrhovsek@e8cd22c with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@agrare @miha-plesko last commit is just a rebase on master. |
@gasper-vrhovsek Travis is red because a new version of |
…stomization_field Add guest customization field to service catalog order form
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1550909 @miq-bot add_label enhancement,gaprindashvili/yes |
…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
Gaprindashvili backport details:
|
v2v: Storage mapping for mass migration
Added guest customization field to service catalog order
form, also added spec tests for the new field.