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 support for custom VMware attributes #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/beaker/hypervisor/vcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,22 @@ def enable_root(host)

def create_clone_spec(host)
# Add VM annotation
additionalExtraConfig = if host['extraConfig']
host['extraConfig'].map do |key, value|
{ key: key, value: value }
end
else
[]
end
extraConfig = [{ key: 'guestinfo.hostname', value: host['vmhostname'] }] + additionalExtraConfig
Comment on lines +76 to +83
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 easier to read?

Suggested change
additionalExtraConfig = if host['extraConfig']
host['extraConfig'].map do |key, value|
{ key: key, value: value }
end
else
[]
end
extraConfig = [{ key: 'guestinfo.hostname', value: host['vmhostname'] }] + additionalExtraConfig
extraConfig = [{ key: 'guestinfo.hostname', value: host['vmhostname'] }]
if host['extraConfig']
extraConfig += host['extraConfig'].map do |key, value|
{ key: key, value: value }
end
end

I also wonder what happens if guestinfo.hostname is in host['extraConfig'].

Makes me tempted to write:

extraConfig = { 'guestinfo.hostname' => host['vmhostname'] }
extraConfig.merge(host['extraConfig']) if host['extraConfig']

And later:

extraConfig: extraConfig.map { |k, v| { key: k, value: v } }

@logger.debug("#{host['vmhostname']}: extraConfig is: #{extraConfig}")
configSpec = RbVmomi::VIM.VirtualMachineConfigSpec(
annotation: 'Base template: ' + host['template'] + "\n" +
'Creation time: ' + Time.now.strftime('%Y-%m-%d %H:%M') + "\n\n" +
'CI build link: ' + (ENV['BUILD_URL'] || 'Deployed independently of CI') +
'department: ' + @options[:department] +
'project: ' + @options[:project],
extraConfig: [
{ key: 'guestinfo.hostname',
value: host['vmhostname'], },
],
extraConfig: extraConfig,
)

# Are we using a customization spec?
Expand Down