knife-kvm 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/knife-kvm.gemspec +1 -1
- data/lib/chef/knife/kvm_base.rb +7 -7
- data/lib/chef/knife/kvm_vm_create.rb +6 -4
- data/lib/chef/knife/kvm_vm_list.rb +1 -1
- data/lib/knife-kvm/version.rb +1 -1
- metadata +12 -15
data/knife-kvm.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.add_dependency "fog", ">= 1.1.
|
19
|
+
s.add_dependency "fog", ">= 1.1.2"
|
20
20
|
s.add_dependency "terminal-table"
|
21
21
|
s.add_dependency "alchemist"
|
22
22
|
s.add_dependency "chef", ">= 0.10"
|
data/lib/chef/knife/kvm_base.rb
CHANGED
@@ -55,6 +55,11 @@ class Chef
|
|
55
55
|
:description => "Your KVM host address",
|
56
56
|
:default => "127.0.0.1",
|
57
57
|
:proc => Proc.new { |host| Chef::Config[:knife][:kvm_host] = host }
|
58
|
+
|
59
|
+
option :libvirt_protocol,
|
60
|
+
:long => "--libvirt-protocol PROTO",
|
61
|
+
:description => "Libvirt connection protocol (default SSH)",
|
62
|
+
:default => "ssh"
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
@@ -64,13 +69,8 @@ class Chef
|
|
64
69
|
host = Chef::Config[:knife][:kvm_host] || '127.0.0.1'
|
65
70
|
username = Chef::Config[:knife][:kvm_username]
|
66
71
|
password = Chef::Config[:knife][:kvm_password]
|
67
|
-
libvirt_uri =
|
68
|
-
|
69
|
-
libvirt_uri = "qemu+unix:///system"
|
70
|
-
else
|
71
|
-
libvirt_uri = "qemu+ssh://#{username}@#{host}/system"
|
72
|
-
end
|
73
|
-
ui.info "#{ui.color("Connecting to KVM host #{config[:kvm_host]}... ", :magenta)}"
|
72
|
+
libvirt_uri = "qemu+#{config[:libvirt_protocol]}://#{username}@#{host}/system"
|
73
|
+
ui.info "#{ui.color("Connecting to KVM host #{config[:kvm_host]} (#{config[:libvirt_protocol]})... ", :magenta)}"
|
74
74
|
@connection = ::Fog::Compute.new :provider => 'libvirt',
|
75
75
|
:libvirt_uri => libvirt_uri,
|
76
76
|
:libvirt_ip_command => "virt-cat -d $server_name /tmp/ip-info 2> /dev/null |grep -v 127.0.0.1"
|
@@ -26,6 +26,7 @@ class Chef
|
|
26
26
|
|
27
27
|
deps do
|
28
28
|
require 'readline'
|
29
|
+
require 'alchemist'
|
29
30
|
require 'chef/json_compat'
|
30
31
|
require 'chef/knife/bootstrap'
|
31
32
|
Chef::Knife::Bootstrap.load_deps
|
@@ -35,7 +36,7 @@ class Chef
|
|
35
36
|
|
36
37
|
option :vm_disk,
|
37
38
|
:long => "--vm-disk FILE",
|
38
|
-
:description => "The path to the
|
39
|
+
:description => "The path to the QCOW2 disk file"
|
39
40
|
|
40
41
|
option :vm_name,
|
41
42
|
:long => "--vm-name NAME",
|
@@ -142,12 +143,12 @@ class Chef
|
|
142
143
|
$stdout.sync = true
|
143
144
|
|
144
145
|
unless config[:vm_disk]
|
145
|
-
ui.error("You have not provided a valid
|
146
|
+
ui.error("You have not provided a valid QCOW2 file. (--vm-disk)")
|
146
147
|
exit 1
|
147
148
|
end
|
148
149
|
|
149
150
|
if not File.exist?(config[:vm_disk])
|
150
|
-
ui.error("Invalid
|
151
|
+
ui.error("Invalid QCOW2 disk file (--vm-disk)")
|
151
152
|
exit 1
|
152
153
|
end
|
153
154
|
|
@@ -173,6 +174,7 @@ class Chef
|
|
173
174
|
#:autostart => true, # Starting guest automatically
|
174
175
|
:volume_pool_name => pool,
|
175
176
|
:network_interface_type => net_type,
|
177
|
+
:memory_size => memory.to_i * 1024,
|
176
178
|
:network_bridge_name => net_if
|
177
179
|
|
178
180
|
puts "#{ui.color("Importing VM disk... ", :magenta)}"
|
@@ -180,7 +182,7 @@ class Chef
|
|
180
182
|
vm.start
|
181
183
|
|
182
184
|
puts "#{ui.color("VM Name", :cyan)}: #{vm.name}"
|
183
|
-
puts "#{ui.color("VM Memory", :cyan)}: #{
|
185
|
+
puts "#{ui.color("VM Memory", :cyan)}: #{vm.memory_size.to_i.kilobytes.to.megabytes.round} MB"
|
184
186
|
|
185
187
|
# wait for it to be ready to do stuff
|
186
188
|
print "\n#{ui.color("Waiting server... ", :magenta)}"
|
@@ -31,7 +31,7 @@ class Chef
|
|
31
31
|
vm_table = table do |t|
|
32
32
|
t.headings = %w{NAME STATE MAX_MEM CPUS OS_TYPE ARCH}
|
33
33
|
connection.servers.each do |vm|
|
34
|
-
t << [vm.name, vm.state, "#{vm.
|
34
|
+
t << [vm.name, vm.state, "#{vm.memory_size.to_i.kilobytes.to.megabytes.round} MB", vm.cpus, vm.os_type, vm.arch]
|
35
35
|
end
|
36
36
|
end
|
37
37
|
puts vm_table
|
data/lib/knife-kvm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-kvm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
16
|
-
requirement: &
|
16
|
+
requirement: &12118620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.1.
|
21
|
+
version: 1.1.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *12118620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: terminal-table
|
27
|
-
requirement: &
|
27
|
+
requirement: &12118200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *12118200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: alchemist
|
38
|
-
requirement: &
|
38
|
+
requirement: &12117740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *12117740
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: chef
|
49
|
-
requirement: &
|
49
|
+
requirement: &12117180 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0.10'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *12117180
|
58
58
|
description: KVM Support for Chef's Knife Command
|
59
59
|
email:
|
60
60
|
- rubiojr@frameos.org
|
@@ -100,7 +100,4 @@ rubygems_version: 1.8.10
|
|
100
100
|
signing_key:
|
101
101
|
specification_version: 3
|
102
102
|
summary: KVM Support for Chef's Knife Command
|
103
|
-
test_files:
|
104
|
-
- features/kvm.feature
|
105
|
-
- features/step_definitions/steps.rb
|
106
|
-
- features/support/env.rb
|
103
|
+
test_files: []
|