Class: BuckKnife::Commands::Create

Inherits:
Struct
  • Object
show all
Includes:
Base
Defined in:
lib/buckknife/commands/create.rb

Direct Known Subclasses

EucaCreate, RackspaceCreate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#base_run_list, #build_run_list, #to_s

Instance Attribute Details

#nodeObject

Returns the value of attribute node

Returns:

  • (Object)

    the current value of node



3
4
5
# File 'lib/buckknife/commands/create.rb', line 3

def node
  @node
end

#projectObject

Returns the value of attribute project

Returns:

  • (Object)

    the current value of project



3
4
5
# File 'lib/buckknife/commands/create.rb', line 3

def project
  @project
end

Class Method Details

.[](provider) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/buckknife/commands/create.rb', line 6

def self.[](provider)
  case provider
  when "rackspace" then RackspaceCreate
  when "euca"      then EucaCreate
  else
    raise ArgumentError, "Buckknife doesn't know how to create for this provider"
  end
end

Instance Method Details

#chef_server_urlObject



36
37
38
# File 'lib/buckknife/commands/create.rb', line 36

def chef_server_url
  Chef::Config[:chef_server_url]
end

#commandObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/buckknife/commands/create.rb', line 15

def command
  Command.new('knife').tap do |c|
    c.arg project.provider, 'server', 'create'
    c.opt '-r', base_run_list
    c.opt '-f', flavor
    c.opt '-I', image_id
    c.opt '-d', project.distro
    c.opt '-s', chef_server_url
    c.opt '-N', node.name
    c.opt '-x', project.ssh_username if project.ssh_username
  end
end

#flavorObject



32
33
34
# File 'lib/buckknife/commands/create.rb', line 32

def flavor
  node.flavor
end

#image_idObject



28
29
30
# File 'lib/buckknife/commands/create.rb', line 28

def image_id
  node.image_id
end