Sha256: 361bcc3ebc7ab35dbc71aa2626b44f4823c31843d64c50f10aa8f95ce2c7b611

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 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 }

      def run
        connection
        @name_args.each do |server_id|
          begin
            server = ProfitBricks::Server.get(Chef::Config[:knife][: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

1 entries across 1 versions & 1 rubygems

Version Path
knife-profitbricks-2.0.1 lib/chef/knife/profitbricks_server_start.rb