Class: Cyoi::Cli::KeyPair::KeyPairCliVsphere

Inherits:
Object
  • Object
show all
Defined in:
lib/cyoi/cli/provider_key_pair/key_pair_vsphere.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider_client, attributes, highline) ⇒ KeyPairCliVsphere

Returns a new instance of KeyPairCliVsphere.



7
8
9
10
11
12
13
# File 'lib/cyoi/cli/provider_key_pair/key_pair_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)
  raise "@attributes.name must be set" unless @attributes["name"]
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/cyoi/cli/provider_key_pair/key_pair_vsphere.rb', line 4

def attributes
  @attributes
end

#hlObject (readonly)

Returns the value of attribute hl.



5
6
7
# File 'lib/cyoi/cli/provider_key_pair/key_pair_vsphere.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_key_pair/key_pair_vsphere.rb', line 3

def provider_client
  @provider_client
end

Instance Method Details

#display_confirmationObject



33
34
35
36
# File 'lib/cyoi/cli/provider_key_pair/key_pair_vsphere.rb', line 33

def display_confirmation
  puts "\n"
  puts "Confirming: Using key pair #{key_pair_name}"
end

#export_attributesObject

helper to export the complete nested attributes.



24
25
26
# File 'lib/cyoi/cli/provider_key_pair/key_pair_vsphere.rb', line 24

def export_attributes
  attributes.to_nested_hash
end

#key_pair_nameObject



38
39
40
# File 'lib/cyoi/cli/provider_key_pair/key_pair_vsphere.rb', line 38

def key_pair_name
  attributes.name
end

#perform_and_return_attributesObject



15
16
17
18
19
20
21
# File 'lib/cyoi/cli/provider_key_pair/key_pair_vsphere.rb', line 15

def perform_and_return_attributes
  unless valid?
    #destroy_existing_key_pair
    provision_key_pair
  end
  export_attributes
end

#valid?Boolean

Returns:

  • (Boolean)


28
29
30
31
# File 'lib/cyoi/cli/provider_key_pair/key_pair_vsphere.rb', line 28

def valid?
  attributes["name"] && attributes["fingerprint"] && attributes["private_key"]
  #  provider_client.valid_key_pair_fingerprint?(key_pair_name, attributes.fingerprint)
end