class HammerCLIForeman::ComputeAttribute::AddVolume

Using the Update command because adding a new volume is done by modifying existing compute_attribute

Public Instance Methods

request_params() click to toggle source
# File lib/hammer_cli_foreman/compute_attribute.rb, line 236
def request_params
  params = HammerCLIForeman::ComputeAttribute.get_params(options)
  raise ArgumentError, "Compute profile value to update does not exist yet; it needs to be created first" if !params['compute_attribute'].key?('id')
  volume_attr =  params['compute_attribute']['vm_attrs']['volumes_attributes'] || {}
  new_volume_id = (volume_attr.keys.max.to_i + 1 ).to_s if volume_attr.any?
  new_volume_id ||= "0"
  params['id'] = params['compute_attribute']['id']
  params['compute_attribute']['vm_attrs']['volumes_attributes'] ||= {}
  params['compute_attribute']['vm_attrs']['volumes_attributes'][new_volume_id] = option_volume
  params
end
validate_options() click to toggle source
Calls superclass method
# File lib/hammer_cli_foreman/compute_attribute.rb, line 230
def validate_options
  super
  validator.any(:option_compute_profile_id, :option_compute_profile_name).required
  validator.any(:option_compute_resource_id, :option_compute_resource_name).required
end