Class: Kontena::Plugin::Cloud::Platform::ImportGridCommand
- Inherits:
-
Command
- Object
- Clamp::Command
- Command
- Kontena::Plugin::Cloud::Platform::ImportGridCommand
- Includes:
- Cli::Common
- Defined in:
- lib/kontena/plugin/cloud/platform/import_grid_command.rb
Constant Summary
Constants included from CloudCommand
CloudCommand::PLATFORM_NOT_SELECTED_ERROR
Instance Method Summary collapse
Methods included from CloudCommand
#verify_current_grid, #verify_current_master, #verify_current_master_token
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kontena/plugin/cloud/platform/import_grid_command.rb', line 14 def execute self.organization = prompt_organization unless self.organization master = config.find_server(self.master) if master.nil? exit_with_error "Could not resolve master by name '#{self.master}'." + "\nFor a list of known masters please run: kontena master list" else config.current_master = master['name'] end config.current_master.grid = self.grid grid = client.get("/v1/grids/#{self.grid}") attributes = { 'name' => self.platform, 'grid' => self.grid, 'url' => current_master.url, 'initial-size' => grid['initial_size'] } spinner "Migrating #{self.master}/#{self.grid} (#{current_master.url}) to Kontena Cloud organization #{organization}" do cloud_client.post("/organizations/#{organization}/platforms/migrate", { data: { attributes: attributes } }) end end |
#prompt_organization ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/kontena/plugin/cloud/platform/import_grid_command.rb', line 38 def prompt_organization organizations = cloud_client.get('/organizations')['data'] prompt.select("Choose organization:") do || .choice "#{config.current_account.username} (you)", config.current_account.username organizations.each do |o| .choice o.dig('attributes', 'name') end end end |