Module: HammerCLIForeman::CommonHostUpdateOptions

Included in:
Host::CreateCommand, Host::UpdateCommand
Defined in:
lib/hammer_cli_foreman/host.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/hammer_cli_foreman/host.rb', line 9

def self.included(base)
  base.apipie_options :without => [:host_parameters_attributes, :environment_id, :architecture_id, :domain_id,
        :puppet_proxy_id, :operatingsystem_id,
        # - temporarily disabled params until we add support for boolean options to apipie -
        :build, :managed, :enabled, :start,
        # - temporarily disabled params until they are fixed in API
        :puppet_class_ids, #3884
        # - temporarily disabled params that will be removed from the api ------------------
        :provision_method, :capabilities, :flavour_ref, :image_ref, :start,
        :network, :cpus, :memory, :provider, :type, :tenant_id, :image_id,
        # ----------------------------------------------------------------------------------
        :compute_resource_id, :ptable_id] + base.declared_identifiers.keys

  base.option "--environment-id", "ENVIRONMENT_ID", " "
  base.option "--architecture-id", "ARCHITECTURE_ID", " "
  base.option "--domain-id", "DOMAIN_ID", " "
  base.option "--puppet-proxy-id", "PUPPET_PROXY_ID", " "
  base.option "--operatingsystem-id", "OPERATINGSYSTEM_ID", " "
  base.option "--partition-table-id", "PARTITION_TABLE_ID", " "
  base.option "--compute-resource-id", "COMPUTE_RESOURCE", " "
  base.option "--partition-table-id", "PARTITION_TABLE", " "
  base.option "--puppetclass-ids", "PUPPETCLASS_IDS", " ",
    :format => HammerCLI::Options::Normalizers::List.new

  bme_options = {}
  bme_options[:default] = 'true' if base.action.to_sym == :create

  bme_options[:format] = HammerCLI::Options::Normalizers::Bool.new
  base.option "--managed", "MANAGED", " ", bme_options
  bme_options[:format] = HammerCLI::Options::Normalizers::Bool.new
  base.option "--build", "BUILD", " ", bme_options
  bme_options[:format] = HammerCLI::Options::Normalizers::Bool.new
  base.option "--enabled", "ENABLED", " ",  bme_options

  base.option "--parameters", "PARAMS", "Host parameters.",
    :format => HammerCLI::Options::Normalizers::KeyValueList.new
  base.option "--compute-attributes", "COMPUTE_ATTRS", "Compute resource attributes.",
    :format => HammerCLI::Options::Normalizers::KeyValueList.new
  base.option "--volume", "VOLUME", "Volume parameters", :multivalued => true,
    :format => HammerCLI::Options::Normalizers::KeyValueList.new
  base.option "--interface", "INTERFACE", "Interface parameters.", :multivalued => true,
    :format => HammerCLI::Options::Normalizers::KeyValueList.new
end

Instance Method Details

#request_paramsObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/hammer_cli_foreman/host.rb', line 53

def request_params
  params = super

  params['host']['build'] = option_build unless option_build.nil?
  params['host']['managed'] = option_managed unless option_managed.nil?
  params['host']['enabled'] = option_enabled unless option_enabled.nil?

  params['host']['puppetclass_ids'] = option_puppetclass_ids unless option_puppetclass_ids.nil?

  params['host']['ptable_id'] = option_partition_table_id unless option_partition_table_id.nil?
  params['host']['compute_resource_id'] = option_compute_resource_id unless option_compute_resource_id.nil?
  params['host']['host_parameters_attributes'] = parameter_attributes
  params['host']['compute_attributes'] = option_compute_attributes || {}
  params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list)
  if option_compute_resource_id
    params['host']['compute_attributes']['interfaces_attributes'] = nested_attributes(option_interface_list)
    params['host']['compute_attributes']['nics_attributes'] = nested_attributes(option_interface_list)
  else
    params['host']['interfaces_attributes'] = nested_attributes(option_interface_list)
  end

  params
end