Module: HammerCLIForeman::Hosts::CommonUpdateOptions
- Defined in:
- lib/hammer_cli_foreman/hosts/common_update_options.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.ask_password ⇒ Object
62 63 64 65 |
# File 'lib/hammer_cli_foreman/hosts/common_update_options.rb', line 62 def self.ask_password prompt = _("Enter the root password for the host:") + " " HammerCLI.interactive_output.ask(prompt) { |q| q.echo = false } end |
.included(base) ⇒ Object
5 6 7 8 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 52 53 54 55 56 57 58 59 60 |
# File 'lib/hammer_cli_foreman/hosts/common_update_options.rb', line 5 def self.included(base) base.option "--owner", "OWNER_LOGIN", _("Login of the owner"), :attribute_name => :option_user_login base.option "--owner-id", "OWNER_ID", _("ID of the owner"), :attribute_name => :option_owner_id base.option "--root-password", "ROOT_PW", _("Required if host is managed and value is not inherited from host group or default password in settings") base.option "--ask-root-password", "ASK_ROOT_PW", " ", :format => HammerCLI::Options::Normalizers::Bool.new base.option '--puppet-proxy', 'PUPPET_PROXY_NAME', '', referenced_resource: 'puppet_proxy', aliased_resource: 'puppet_proxy' base.option '--puppet-ca-proxy', 'PUPPET_CA_PROXY_NAME', '', referenced_resource: 'puppet_ca_proxy', aliased_resource: 'puppet_ca_proxy' base.option_family( format: HammerCLI::Options::Normalizers::List.new, aliased_resource: 'puppet-class', description: 'Names/Ids of associated puppet classes' ) do parent '--puppet-class-ids', 'PUPPET_CLASS_IDS', '', attribute_name: :option_puppetclass_ids child '--puppet-classes', 'PUPPET_CLASS_NAMES', '', attribute_name: :option_puppetclass_names end = {} [:default] = 'true' if base.action.to_sym == :create [:format] = HammerCLI::Options::Normalizers::Bool.new base.option "--overwrite", "OVERWRITE", " ", base.option "--parameters", "PARAMS", _("Replaces with new host parameters"), :format => HammerCLI::Options::Normalizers::KeyValueList.new host_params = base.resource.action(base.action).params .find { |p| p.name == 'host' }.params .find { |p| p.name == 'host_parameters_attributes' } base.option "--typed-parameters", "TYPED_PARAMS", _("Replaces with new host parameters (with type support)"), :format => HammerCLI::Options::Normalizers::ListNested.new(host_params.params) 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 base. :without => [ # - temporarily disabled params that will be removed from the api ------------------ :capabilities, :flavour_ref, :image_ref, :start, :network, :cpus, :memory, :provider, :type, :tenant_id, :image_id, # ---------------------------------------------------------------------------------- :puppet_class_ids, :host_parameters_attributes, :interfaces_attributes, :root_pass] end |
Instance Method Details
#request_params ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/hammer_cli_foreman/hosts/common_update_options.rb', line 67 def request_params params = super owner_id = owner_id(option_user_login, params['host']['owner_type']) params['host']['owner_id'] ||= owner_id unless owner_id.nil? puppet_proxy_id = proxy_id(option_puppet_proxy) params['host']['puppet_proxy_id'] ||= puppet_proxy_id unless puppet_proxy_id.nil? puppet_ca_proxy_id = proxy_id(option_puppet_ca_proxy) params['host']['puppet_ca_proxy_id'] ||= puppet_ca_proxy_id unless puppet_ca_proxy_id.nil? if action == :create params['host']['build'] = true if option_build.nil? params['host']['managed'] = true if option_managed.nil? params['host']['enabled'] = true if option_enabled.nil? end params['host']['overwrite'] = option_overwrite unless option_overwrite.nil? params['host']['host_parameters_attributes'] = parameter_attributes unless option_parameters.nil? params['host']['host_parameters_attributes'] ||= option_typed_parameters unless option_typed_parameters.nil? if option_compute_attributes && !option_compute_attributes.empty? params['host']['compute_attributes'] = host_compute_attrs(option_compute_attributes) end if action == :update unless option_volume_list.empty? params['host']['compute_attributes'] ||= {} params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list) end params['host']['interfaces_attributes'] = interfaces_attributes unless option_interface_list.empty? if ['option_new_location_id'] params['host']['location_id'] = ['option_new_location_id'] else params['host'].delete('location_id') end if ['option_new_organization_id'] params['host']['organization_id'] = ['option_new_organization_id'] else params['host'].delete('organization_id') end else params['host']['compute_attributes'] ||= {} params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list) params['host']['interfaces_attributes'] = interfaces_attributes end if ['option_image_id'] if params['host']['compute_resource_id'] compute_resource_id = params['host']['compute_resource_id'] elsif params['id'] compute_resource_id = ::HammerCLIForeman::ComputeResources.get_host_compute_resource_id(params['id']) elsif params['host']['hostgroup_id'] compute_resource_id = ::HammerCLIForeman::ComputeResources.get_hostgroup_compute_resource_id(params['host']['hostgroup_id']) end raise ArgumentError, "Missing argument for 'compute_resource'" if compute_resource_id.nil? image_uuid = ::HammerCLIForeman::ComputeResources.get_image_uuid(compute_resource_id, ["option_image_id"]) params['host']['compute_attributes'] ||= {} params['host']['compute_attributes']['image_id'] = image_uuid end params['host']['root_pass'] = option_root_password unless option_root_password.nil? if option_ask_root_password params['host']['root_pass'] = HammerCLIForeman::Hosts::CommonUpdateOptions::ask_password end params end |