Class: Bosh::Providers::Cli::OpenStackProviderCli
- Inherits:
-
ProviderCli
- Object
- ProviderCli
- Bosh::Providers::Cli::OpenStackProviderCli
- Defined in:
- lib/bosh/providers/cli/openstack_provider_cli.rb
Overview
Interactively prompt user for region & credential information for OpenStack
Primary use within inception is to pass settings.provider
hash run #perform to gather credentials, then export the credentials/attributes.
settings["provider"] = {}
provider = OpenStackProviderCli.new(settings.provider)
provider_client.perform
settings.provider = provider_cli.export_attributes
Instance Attribute Summary
Attributes inherited from ProviderCli
Instance Method Summary collapse
- #choose_region ⇒ Object
-
#export_attributes ⇒ Object
helper to export the complete nested attributes as a pure Hash.
- #openstack_constants ⇒ Object
- #perform ⇒ Object
- #setup_credentials ⇒ Object
Methods inherited from ProviderCli
Methods included from Inception::CliHelpers::Interactions
#bold, #clear, #cyan, #green, #hl, #red, #yellow
Constructor Details
This class inherits a constructor from Bosh::Providers::Cli::ProviderCli
Instance Method Details
#choose_region ⇒ Object
30 31 32 33 34 |
# File 'lib/bosh/providers/cli/openstack_provider_cli.rb', line 30 def choose_region attributes.region = hl.ask("OpenStack Region (optional): ") do |q| q.default = openstack_constants.no_region_code end end |
#export_attributes ⇒ Object
helper to export the complete nested attributes as a pure Hash
26 27 28 |
# File 'lib/bosh/providers/cli/openstack_provider_cli.rb', line 26 def export_attributes attributes.to_nested_hash end |
#openstack_constants ⇒ Object
44 45 46 |
# File 'lib/bosh/providers/cli/openstack_provider_cli.rb', line 44 def openstack_constants Bosh::Providers::Constants::OpenStackConstants end |
#perform ⇒ Object
19 20 21 22 23 |
# File 'lib/bosh/providers/cli/openstack_provider_cli.rb', line 19 def perform attributes.set("name", "openstack") # ensure this property is correct choose_region unless attributes.exists?("region") setup_credentials unless attributes.exists?("credentials.openstack_api_key") end |
#setup_credentials ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/bosh/providers/cli/openstack_provider_cli.rb', line 36 def setup_credentials attributes.set_default("credentials", {}) attributes.credentials["openstack_username"] = hl.ask("Username: ") attributes.credentials["openstack_api_key"] = hl.ask("Password: ") attributes.credentials["openstack_tenant"] = hl.ask("Tenant: ") attributes.credentials["openstack_auth_url"] = hl.ask("Authorization Token URL: ") end |