Skip to content

Commit

Permalink
Fixes #6159 - move image_id to be under the compute_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
shiramax committed Jan 24, 2019
1 parent 00a03a9 commit 26577ec
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/hammer_cli_foreman/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class Host < HammerCLIForeman::Command

resource :hosts

def self.set_image_uuid(params, image_id)
image_uuid = HammerCLIForeman.record_to_common_format(
HammerCLIForeman.foreman_resource(:images).call(
:show, {'compute_resource_id' => params['host']['compute_resource_id'], 'id' => image_id,}
)["uuid"]
)
params['host']['compute_attributes']['image_id'] = image_uuid
params
end

def self.extend_cr_help(cr)
cr_help_extensions[cr.name] = cr.method(:host_create_help)
end
Expand Down Expand Up @@ -305,6 +315,13 @@ def validate_options
end
end

def request_params
params = super
if option_image_id
HammerCLIForeman::Host.set_image_uuid(params,option_image_id)
end
params
end
end

class UpdateCommand < HammerCLIForeman::UpdateCommand
Expand All @@ -313,6 +330,14 @@ class UpdateCommand < HammerCLIForeman::UpdateCommand

include HammerCLIForeman::Hosts::CommonUpdateOptions
include HammerCLIForeman::Hosts::CommonUpdateHelp

def request_params
params = super
if option_image_id
HammerCLIForeman::Host.set_image_uuid(params,option_image_id)
end
params
end
end


Expand Down

0 comments on commit 26577ec

Please sign in to comment.