Module: Knife::Clc::Base

Included in:
Chef::Knife::ClcServerCreate
Defined in:
lib/knife-clc/base.rb,
lib/knife-clc/base/config_options.rb

Defined Under Namespace

Classes: ConfigOptions

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(command_class) ⇒ Object



10
11
12
# File 'lib/knife-clc/base.rb', line 10

def self.included(command_class)
  ConfigOptions.attach(command_class)
end

Instance Method Details

#connectionObject



14
15
16
17
18
19
20
21
# File 'lib/knife-clc/base.rb', line 14

def connection
  @connection ||= ::Clc::Client.new(
    :username => config[:clc_username],
    :password => config[:clc_password],
    :endpoint => config[:clc_endpoint],
    :verbosity => config[:verbosity]
  )
end

#contextObject



23
24
25
# File 'lib/knife-clc/base.rb', line 23

def context
  @context ||= {}
end

#errorsObject



47
48
49
# File 'lib/knife-clc/base.rb', line 47

def errors
  @errors ||= []
end

#executeObject



44
45
# File 'lib/knife-clc/base.rb', line 44

def execute
end

#parse_and_validate_parametersObject



41
42
# File 'lib/knife-clc/base.rb', line 41

def parse_and_validate_parameters
end

#runObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/knife-clc/base.rb', line 27

def run
  $stdout.sync = true

  parse_and_validate_parameters

  if errors.any?
    show_errors
    show_usage
    exit 1
  else
    execute
  end
end

#show_errorsObject



51
52
53
# File 'lib/knife-clc/base.rb', line 51

def show_errors
  errors.each { |message| ui.error message }
end