virtualmaster 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,16 @@ callback :demo do
10
10
  end
11
11
 
12
12
  after :shutdown do
13
- puts "That's all folks!"
13
+ puts "That's all for now"
14
14
  end
15
+
16
+ after :reboot do
17
+ puts "It's raining init 6"
18
+ end
19
+
20
+ before :destroy do
21
+ puts "It's all going to shambles"
22
+ end
23
+
15
24
  end
16
25
 
@@ -61,10 +61,10 @@ module VirtualMaster
61
61
  profile_list.first
62
62
  end
63
63
 
64
- def self.create_instance(name, image_id, profile_id, realm)
64
+ def self.create_instance(name, image_id, profile, realm)
65
65
  api = VirtualMaster::CLI.api
66
66
 
67
- api.create_instance(image_id, {:name => name, :hwp_id => profile_id, :realm_id => realm})
67
+ api.create_instance(image_id, {:name => name, :memory => profile[:memory], :storage => profile[:storage], :realm_id => realm})
68
68
  end
69
69
  end
70
70
  end
@@ -71,17 +71,14 @@ command :create do |c|
71
71
 
72
72
  abort "Image name '#{options.profile}' not recognized!" unless profile
73
73
 
74
- hwp = VirtualMaster::Helpers.get_hw_profile(profile[:memory], profile[:storage])
75
- abort "Internal error: hardware profile not available" unless hwp
76
-
77
74
  # before :create callbacks
78
75
  VirtualMaster::Callbacks.trigger_event(:create, :before, options.__hash__, nil)
79
76
 
80
77
  say "Creating '#{profile_name}' instance (#{profile[:memory]} MB memory/#{profile[:storage]/1024} GB storage)"
81
-
78
+
82
79
  realm = "#{options.zone}-#{options.level}"
83
-
84
- instance = VirtualMaster::Helpers.create_instance(name, image_id, hwp.id, realm) if options.interactive
80
+
81
+ instance = VirtualMaster::Helpers.create_instance(name, image_id, profile, realm) if options.interactive
85
82
 
86
83
  # TODO handle exceptions (invalid image/profile, limits, etc.)
87
84
 
@@ -104,7 +101,7 @@ command :create do |c|
104
101
 
105
102
  sleep(5)
106
103
  end
107
-
104
+
108
105
  puts
109
106
  puts "Instance ready."
110
107
 
@@ -139,14 +136,19 @@ command :list do |c|
139
136
  end
140
137
  end
141
138
 
142
- def instance_action(action, args)
139
+ def instance_action(action, options, args)
143
140
  name = args.shift || abort('server name required')
144
141
 
145
142
  instance = VirtualMaster::Helpers.get_instance(name)
146
-
143
+
147
144
  abort "Invalid instance name!" if instance.nil?
148
-
145
+
146
+ VirtualMaster::Callbacks.trigger_event(action.to_sym, :before, options.__hash__, instance)
147
+
149
148
  instance.send("#{action}!")
149
+
150
+ VirtualMaster::Callbacks.trigger_event(action.to_sym, :after, options.__hash__, instance)
151
+
150
152
  end
151
153
 
152
154
  %w{start reboot stop shutdown destroy}.each do |cmd|
@@ -166,8 +168,13 @@ end
166
168
  c.description = "Remove server"
167
169
  end
168
170
 
171
+ # generate options for callbacks
172
+ VirtualMaster::CLI.callbacks.each do |cb|
173
+ c.send :option, *(cb.to_option)
174
+ end
175
+
169
176
  c.action do |args, options|
170
- instance_action(c.name, args)
177
+ instance_action(c.name, options, args)
171
178
  end
172
179
  end
173
180
  end
@@ -1,3 +1,3 @@
1
1
  module VirtualMaster
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtualmaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-11 00:00:00.000000000 Z
12
+ date: 2012-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
16
- requirement: &70096844415120 !ruby/object:Gem::Requirement
16
+ requirement: &70352789585640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 4.1.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70096844415120
24
+ version_requirements: *70352789585640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: deltacloud-client
27
- requirement: &70096844414580 !ruby/object:Gem::Requirement
27
+ requirement: &70352789585100 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.5.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70096844414580
35
+ version_requirements: *70352789585100
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: terminal-table
38
- requirement: &70096844414100 !ruby/object:Gem::Requirement
38
+ requirement: &70352789584620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.4.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70096844414100
46
+ version_requirements: *70352789584620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: net-ssh
49
- requirement: &70096844413440 !ruby/object:Gem::Requirement
49
+ requirement: &70352789583960 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.3.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70096844413440
57
+ version_requirements: *70352789583960
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70096844412820 !ruby/object:Gem::Requirement
60
+ requirement: &70352789583320 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '2'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70096844412820
68
+ version_requirements: *70352789583320
69
69
  description: Command line interface to Virtualmaster. Control your virtual infrastructure.
70
70
  email:
71
71
  - radim@laststation.net