Class: Cyoi::Cli::Providers::ProviderCliOpenStack
- Inherits:
-
ProviderCli
- Object
- ProviderCli
- Cyoi::Cli::Providers::ProviderCliOpenStack
show all
- Defined in:
- lib/cyoi/cli/providers/provider_cli_openstack.rb
Instance Attribute Summary
Attributes inherited from ProviderCli
#attributes, #hl
Instance Method Summary
collapse
Methods inherited from ProviderCli
#export_attributes, #initialize, #say
Instance Method Details
#choose_region ⇒ Object
22
23
24
25
|
# File 'lib/cyoi/cli/providers/provider_cli_openstack.rb', line 22
def choose_region
puts "\n"
attributes["region"] = hl.ask("OpenStack Region (optional): ")
end
|
#display_confirmation ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/cyoi/cli/providers/provider_cli_openstack.rb', line 35
def display_confirmation
puts "\n"
if attributes.region.size > 0
puts "Confirming: Using OpenStack/#{attributes.region}"
else
puts "Confirming: Using OpenStack"
end
end
|
3
4
5
6
7
8
9
10
|
# File 'lib/cyoi/cli/providers/provider_cli_openstack.rb', line 3
def perform_and_return_attributes
unless valid_infrastructure?
puts "\nUsing provider OpenStack\n"
setup_credentials
choose_region
end
export_attributes
end
|
#setup_credentials ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/cyoi/cli/providers/provider_cli_openstack.rb', line 12
def setup_credentials
puts "\n"
attributes.set_default("credentials", {})
credentials = attributes.credentials
credentials["openstack_username"] = hl.ask("Username: ").to_s unless credentials.exists?("openstack_username")
credentials["openstack_api_key"] = hl.ask("Password: ").to_s unless credentials.exists?("openstack_api_key")
credentials["openstack_tenant"] = hl.ask("Tenant: ").to_s unless credentials.exists?("openstack_tenant")
credentials["openstack_auth_url"] = hl.ask("Authorization Token URL: ").to_s unless credentials.exists?("openstack_auth_url")
end
|
#valid_infrastructure? ⇒ Boolean
27
28
29
30
31
32
33
|
# File 'lib/cyoi/cli/providers/provider_cli_openstack.rb', line 27
def valid_infrastructure?
attributes.exists?("region") &&
attributes.exists?("credentials.openstack_username") &&
attributes.exists?("credentials.openstack_api_key") &&
attributes.exists?("credentials.openstack_tenant") &&
attributes.exists?("credentials.openstack_auth_url")
end
|