Class: Veewee::Command::Kvm

Inherits:
GroupBase show all
Defined in:
lib/veewee/command/kvm.rb

Instance Attribute Summary

Attributes inherited from GroupBase

#env

Instance Method Summary collapse

Methods inherited from GroupBase

#initialize, register

Methods included from Helpers

#initialize_environment

Constructor Details

This class inherits a constructor from Veewee::Command::GroupBase

Instance Method Details

#build(box_name) ⇒ Object



18
19
20
21
22
# File 'lib/veewee/command/kvm.rb', line 18

def build(box_name)
  venv=Veewee::Environment.new(options)
  venv.ui=env.ui
  venv.providers["kvm"].get_box(box_name).build(options)
end

#define(definition_name, template_name) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/veewee/command/kvm.rb', line 63

def define(definition_name, template_name)
  venv=Veewee::Environment.new(options)
  venv.ui=env.ui
  venv.definitions.define(definition_name,template_name,options)
  env.ui.info "The basebox '#{definition_name}' has been successfully created from the template '#{template_name}'"
  env.ui.info "You can now edit the definition files stored in definitions/#{definition_name} or build the box with:"
  env.ui.info "veewee kvm build '#{definition_name}'"
end

#destroy(box_name) ⇒ Object



28
29
30
31
32
# File 'lib/veewee/command/kvm.rb', line 28

def destroy(box_name)
  venv=Veewee::Environment.new(options)
  venv.ui=env.ui
  venv.providers["kvm"].get_box(box_name).destroy(options)
end

#halt(box_name) ⇒ Object



37
38
39
40
41
# File 'lib/veewee/command/kvm.rb', line 37

def halt(box_name)
  venv=Veewee::Environment.new(options)
  venv.ui=env.ui
  venv.providers["kvm"].get_box(box_name).halt(options)
end

#listObject



118
119
120
121
122
123
124
125
126
# File 'lib/veewee/command/kvm.rb', line 118

def list
  env.ui.info "The following local definitions are available:"
  venv=Veewee::Environment.new(options)
  venv.ui=env.ui
  venv.ui=env.ui
  venv.definitions.each do |name,definition|
    env.ui.info "- #{name}"
  end
end

#ostypesObject



97
98
99
100
101
102
103
# File 'lib/veewee/command/kvm.rb', line 97

def ostypes
  venv=Veewee::Environment.new(options)
  venv.ui=env.ui
  venv.ostypes.each do |name|
     env.ui.info "- #{name}"
  end
end

#ssh(box_name, command = nil) ⇒ Object



54
55
56
57
58
# File 'lib/veewee/command/kvm.rb', line 54

def ssh(box_name,command=nil)
  venv=Veewee::Environment.new(options)
  venv.ui=env.ui
  venv.providers["kvm"].get_box(box_name).issh(command)
end

#templatesObject



107
108
109
110
111
112
113
114
# File 'lib/veewee/command/kvm.rb', line 107

def templates
  env.ui.info "The following templates are available:"
  venv=Veewee::Environment.new(options)
  venv.ui=env.ui
  venv.templates.each do |name,template|
    env.ui.info "veewee kvm define '<box_name>' '#{name}'",:prefix => false
  end
end

#undefine(definition_name) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/veewee/command/kvm.rb', line 74

def undefine(definition_name)
  env.ui.info "Removing definition #{definition_name}"
  begin
    venv=Veewee::Environment.new(options)
    venv.ui=env.ui
    venv.definitions.undefine(definition_name,options)
  rescue Error => ex
    env.ui.error("#{ex}", :prefix=> false)
    exit -1
  end
end

#up(box_name) ⇒ Object



46
47
48
49
50
# File 'lib/veewee/command/kvm.rb', line 46

def up(box_name)
  venv=Veewee::Environment.new(options)
  venv.ui=env.ui
  venv.providers["kvm"].get_box(box_name).up(options)
end

#validate(box_name) ⇒ Object



89
90
91
92
93
# File 'lib/veewee/command/kvm.rb', line 89

def validate(box_name)
  venv=Veewee::Environment.new(options)
  venv.ui=env.ui
  venv.providers["kvm"].get_box(box_name).validate_kvm(options)
end