Class: Cyoi::Cli::Addresses::AddressCliOpenstack

Inherits:
Object
  • Object
show all
Defined in:
lib/cyoi/cli/provider_addresses/address_cli_openstack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider_client, attributes, highline) ⇒ AddressCliOpenstack

Returns a new instance of AddressCliOpenstack.



7
8
9
10
11
12
# File 'lib/cyoi/cli/provider_addresses/address_cli_openstack.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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/cyoi/cli/provider_addresses/address_cli_openstack.rb', line 4

def attributes
  @attributes
end

#hlObject (readonly)

Returns the value of attribute hl.



5
6
7
# File 'lib/cyoi/cli/provider_addresses/address_cli_openstack.rb', line 5

def hl
  @hl
end

#provider_clientObject (readonly)

Returns the value of attribute provider_client.



3
4
5
# File 'lib/cyoi/cli/provider_addresses/address_cli_openstack.rb', line 3

def provider_client
  @provider_client
end

Instance Method Details

#display_confirmationObject



36
37
38
39
# File 'lib/cyoi/cli/provider_addresses/address_cli_openstack.rb', line 36

def display_confirmation
  puts "\n"
  puts "Confirming: Using address #{attributes.ip}"
end

#export_attributesObject

helper to export the complete nested attributes.



27
28
29
# File 'lib/cyoi/cli/provider_addresses/address_cli_openstack.rb', line 27

def export_attributes
  attributes.to_nested_hash
end

#perform_and_return_attributesObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cyoi/cli/provider_addresses/address_cli_openstack.rb', line 14

def perform_and_return_attributes
  unless valid_address?
    if networks?
      subnet = select_subnet
      choose_address_from_subnet(subnet)
    else
      provision_address
    end
  end
  export_attributes
end

#valid_address?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/cyoi/cli/provider_addresses/address_cli_openstack.rb', line 32

def valid_address?
  attributes["ip"]
end