Class: Cyoi::Cli::Image
- Inherits:
-
Object
- Object
- Cyoi::Cli::Image
- Includes:
- Helpers
- Defined in:
- lib/cyoi/cli/image.rb,
lib/cyoi/cli/provider_image/image_cli_base.rb
Defined Under Namespace
Classes: ImageCliAws, ImageCliBase, ImageCliOpenStack
Class Method Summary collapse
Instance Method Summary collapse
-
#execute! ⇒ Object
TODO run Cyoi::Cli::Provider first if settings.provider.name missing.
-
#image_cli ⇒ Object
Continue the interactive session with the user specific to the infrastructure they have chosen.
-
#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Image
constructor
A new instance of Image.
- #perform_and_return_attributes ⇒ Object
Methods included from Helpers::Settings
#migrate_old_settings, #reload_settings!, #save_settings!, #settings, #settings_dir, #settings_path, #settings_ssh_dir, #show_settings
Methods included from Helpers::Provider
#fog_compute, #provider_client
Methods included from Helpers::Interactions
#bold, #clear, #cyan, #green, #hl, #red, #yellow
Constructor Details
#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Image
Returns a new instance of Image.
7 8 9 10 11 |
# File 'lib/cyoi/cli/image.rb', line 7 def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel) @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel @settings_dir = @argv.shift || "/tmp/provider_settings" @settings_dir = File.(@settings_dir) end |
Class Method Details
.image_cli(name) ⇒ Object
53 54 55 |
# File 'lib/cyoi/cli/image.rb', line 53 def self.image_cli(name) @image_clis[name] end |
.register_image_cli(name, klass) ⇒ Object
48 49 50 51 |
# File 'lib/cyoi/cli/image.rb', line 48 def self.register_image_cli(name, klass) @image_clis ||= {} @image_clis[name] = klass end |
Instance Method Details
#execute! ⇒ Object
TODO run Cyoi::Cli::Provider first if settings.provider.name missing
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cyoi/cli/image.rb', line 14 def execute! unless settings.exists?("provider.name") $stderr.puts("Please run 'cyoi provider' first") exit 1 end unless valid? settings["image"] = perform_and_return_attributes save_settings! end image_cli.display_confirmation end |
#image_cli ⇒ Object
Continue the interactive session with the user specific to the infrastructure they have chosen.
The returned object is a class from cyoi/cli/provider_image/provier_cli_INFRASTRUCTURE.rb The class loads itself into ‘@image_clis` via `register_image_cli`
Returns nil if settings.key_pair.name not set
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cyoi/cli/image.rb', line 33 def image_cli @image_cli ||= begin provider_name = settings.exists?("provider.name") return nil unless provider_name require "cyoi/cli/provider_image/image_cli_#{settings.provider.name}" settings["image"] ||= {} klass = self.class.image_cli(settings.provider.name) klass.new(provider_client, settings.image, hl) end end |
#perform_and_return_attributes ⇒ Object
44 45 46 |
# File 'lib/cyoi/cli/image.rb', line 44 def perform_and_return_attributes image_cli.perform_and_return_attributes end |