class Cyoi::Cli::Addresses::AddressCliVsphere

Attributes

attributes[R]
hl[R]
provider_client[R]

Public Class Methods

new(provider_client, attributes, highline) click to toggle source
# File lib/cyoi/cli/provider_addresses/address_cli_vsphere.rb, line 7
def initialize(provider_client, attributes, highline)
  @provider_client = provider_client
  @hl = highline
  @attributes = attributes.is_a?(Hash) ? ReadWriteSettings.new(attributes) : attributes
  raise "@attributes must be ReadWriteSettings (or Hash)" unless @attributes.is_a?(ReadWriteSettings)
end

Public Instance Methods

display_confirmation() click to toggle source
# File lib/cyoi/cli/provider_addresses/address_cli_vsphere.rb, line 31
def display_confirmation
  puts "\n"
  puts "Confirming: Using address #{attributes.ip}"
end
export_attributes() click to toggle source

helper to export the complete nested attributes.

# File lib/cyoi/cli/provider_addresses/address_cli_vsphere.rb, line 22
def export_attributes
  attributes.to_nested_hash
end
perform_and_return_attributes() click to toggle source
# File lib/cyoi/cli/provider_addresses/address_cli_vsphere.rb, line 14
def perform_and_return_attributes
  unless valid_address?
    provision_address
  end
  export_attributes
end
valid_address?() click to toggle source
# File lib/cyoi/cli/provider_addresses/address_cli_vsphere.rb, line 27
def valid_address?
  attributes["ip"]
end

Protected Instance Methods

provision_address() click to toggle source
# File lib/cyoi/cli/provider_addresses/address_cli_vsphere.rb, line 37
def provision_address
  print "Please specify network settings... "
  attributes["ip"] = hl.ask("Public IP: ").to_s unless attributes.exists?("ip")
  puts attributes.ip
end