-
Notifications
You must be signed in to change notification settings - Fork 896
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 VM specific customisations to vApp orchestration #12273
Add VM specific customisations to vApp orchestration #12273
Conversation
:name => "vdc_network-#{vm_id}", | ||
:label => "Network", | ||
:data_type => "string", | ||
:default_value => "(default)", |
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 am still not sure whether I should be using i18n here or not. Other templates will output whatever there is in the template itself, but this is a special case and I believe we could use 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.
If it will show up on the UI I'd put _()
around the string to be safe
return "(default)" if cloud_networks.empty? | ||
|
||
# Get network names. | ||
vdc_network_names = cloud_networks.collect(&: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.
Here I am only collecting names of the networks, however I'd rather see if I could create key,value
pairs. The list of names is used here and converted into the actual dialog field in OrchestrationTemplateDialogService
class.
What I am thinking is if it would be possible to change the code so that it would allow setting up key, value
and the corresponding code would use keys if they exist, otherwise it would use the same logic as today.
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.
@agrare currently I can only return the names of the VDC networks that are to be displayed in the dropdown. The logic that will create the actual request to the VMware API I'll need to find the IDs of these networks so I thought that the dropdown would have the ability to set these from the code, i.e. {nil => (default), id1 => VDC net 1, ...}
.
If we just pass ["(default)", "VDC net 1", ...]
, the code would work exactly as it does 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.
@agrare this class is what I am referring to in my previous comments. This class receives values from the form shown in the above screenshot and uses those values to construct provider-specific options struct.
Currently, this class uses only those parameters in "Options". In this class I'd like to get IDs (ems_id
), instead of network names so that I don't need to lookup in the database for these IDs.
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 am ok to change OrchestrationParameterAllowed
to be a hash rather than an array. We may accept both formats for backward comparability purpose.
expect(orchestration_template.content.include?('ovf:Envelope')).to be_truthy | ||
end | ||
|
||
it "is parsed using MmeiqXml" do |
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.
Ooops :-). The typo will be fixed.
8f5e4f2
to
1b2aef5
Compare
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
e4000aa
to
c2c2eb3
Compare
c2c2eb3
to
edce1c1
Compare
3c05d8c
to
507408b
Compare
} | ||
options[:vdc_id] = @dialog_options['dialog_availability_zone'] if @dialog_options.key?("dialog_availability_zone") && !@dialog_options["dialog_availability_zone"].nil? && !@dialog_options["dialog_availability_zone"].empty? |
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 be simplified as
options[:vdc_id] = @dialog_options['dialog_availability_zone'] unless @dialog_options['dialog_availability_zone'].blank?
network_config = {} | ||
source_vms = [] | ||
|
||
vm_params.each do |vm_id, vm_opts| |
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.
prefer source_vms = vm_params.collect
end | ||
|
||
# Create options suitable for VMware vCloud provider. | ||
custom_opts = { |
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.
The hash key naming is very confusing all over this class. Why a mix with CamelCase, camelCase, and snack_case?
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.
It's how fog library that is used to connect to vCloud names these parameters. I had the same issues, but in the end I wanted to make minimal changes to fog.
next if param_match.nil? | ||
|
||
vm_id = param_match.captures.first | ||
vm_params[vm_id] = {} unless vm_params.key?(vm_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.
seems to me that you always want to initialize vm_params[vm_id] = {}
and in next line set [param]
conditionally
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.
@bzweil can you explain a bit more? Line 72 creates new empty object in vm_params
with vm_id
as its key, but only if it wasn't created before. The next line will store specific parameter value for this 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.
@gberginc You're right. I misinterpreted it. But this line can be simplified as vm_params[vm_id] ||= {}
507408b
to
17659d6
Compare
@bzwei All comments addressed, apart from the one on the hash key names due to the external requirement from the fog library. |
17659d6
to
19bdbee
Compare
} unless network_config.key?(network_id) | ||
|
||
# Add network configuration to the source VM. | ||
src_vm[:networks] = [ |
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.
should it be an array []
or hash {}
?
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.
It has to be an array of objects. Since all elements are :key => value
, this implicitly creates an object. Would you prefer that I do it explicitly, so that I create it like
src_vm[:networks] = [
{
:networkName => network_id,
:IsConnected => true,
:IpAddressAllocationMode => "DHCP"
}
]
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.
Your original code is OK. Just want to make sure it is according to design.
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 mean the API takes multiple networks for a single VM but your application limits it to one?
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.
We are trying to mimic vCloud Director UI, where users seem to be able to only specify a single network.
network_id = vm_opts["vdc_network"] | ||
unless network_id.nil? | ||
# Create new network config if it hasn't been created before. | ||
network_config[network_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.
network_config[network_id] ||= {
and no need for unless
check.
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 really appreciate these kind of comments! I will wait for the comment about explicitly storing the object in the array above and then resubmit.
Previously users were only allowed to modify the name of the provisioned vApp and parameters that control the power state of the vApp. With this change we are adding support for changing the name of the instances that are deployed as part of the vApp as well as the ability to select a different VDC network to which instances may be connected. Similarly to the vCloud Director, each instance may be connected to a different network. Signed-off-by: Gregor Berginc <gregor.berginc@xlab.si>
19bdbee
to
20b9aa3
Compare
Checked commit xlab-si@20b9aa3 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 app/models/manageiq/providers/vmware/cloud_manager/orchestration_service_option_converter.rb
app/models/manageiq/providers/vmware/cloud_manager/orchestration_template.rb
spec/models/manageiq/providers/vmware/cloud_manager/orchestration_template_spec.rb
|
LGTM 👍 |
Hi @agrare, it looks like a nice enhancement to the provider. Should it not be backported? |
@sergio-ocon generally speaking enhancements aren't backported, if we have a BZ and it gets all ack's for a z-stream clone we'll backport it. |
Previously users were only allowed to modify the name of the provisioned vApp and parameters that control the power state of the vApp.
With this change we are adding support for changing the name of the instance as well as the ability to select a different VDC network to which instances may be connected.
Currently we are focusing on the UI part of the changes. I am also adding the spec file for these kinds of tests (it's not complete yet as more different cases are needed). The spec file was previously not used because I was mainly following other orchestration templates.
@miq-bot add_label providers/vmware/cloud, enhancement, ui, wip