Sha256: 172af5b8115f226d17cf361702f48cc93f5611506f51a6c93c1b6c06967b77aa

Contents?: true

Size: 951 Bytes

Versions: 2

Compression:

Stored size: 951 Bytes

Contents

require 'chef/knife/profitbricks_base'

class Chef
  class Knife
    class ProfitbricksServerStart < Knife
      include Knife::ProfitbricksBase

      banner 'knife profitbricks server start SERVER_ID [SERVER_ID] (options)'

      option :datacenter_id,
             short: '-D DATACENTER_ID',
             long: '--datacenter-id DATACENTER_ID',
             description: 'ID of the data center',
             proc: proc { |datacenter_id| Chef::Config[:knife][:datacenter_id] = datacenter_id },
             required: true

      def run
        connection
        @name_args.each do |server_id|
          begin
            server = ProfitBricks::Server.get(config[:datacenter_id], server_id)
          rescue Excon::Errors::NotFound
            ui.error("Server ID #{server_id} not found. Skipping.")
            next
          end

          server.start
          ui.warn("Server #{server.id} is starting")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
knife-profitbricks-1.2.0 lib/chef/knife/profitbricks_server_start.rb
knife-profitbricks-1.1.2 lib/chef/knife/profitbricks_server_start.rb