opennebula-provider 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opennebula-provider/action.rb +45 -3
- data/lib/opennebula-provider/action/create.rb +9 -1
- data/lib/opennebula-provider/action/destroy.rb +1 -1
- data/lib/opennebula-provider/action/messages.rb +48 -0
- data/lib/opennebula-provider/action/start.rb +26 -0
- data/lib/opennebula-provider/action/stop.rb +19 -0
- data/lib/opennebula-provider/helpers/rocci.rb +28 -11
- data/lib/opennebula-provider/version.rb +1 -1
- data/locales/en.yml +25 -2
- metadata +29 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 092426db2ef0d08775ed8a7cdd03981b43807e69
|
4
|
+
data.tar.gz: 3d59ec44e5a34b8760aafdde8959a937d83db42b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ee472688c017ef639fa7bbc8e068bc35de95890d1609138e7f42bd6f833f33876b898b8a7ea2dddc9a9acf9e2b9725c897b3fee27356ee1fcb6b8eca01e2f38
|
7
|
+
data.tar.gz: 87eff7f92549fa85da7f426ac3179e18f24bc5c763754d327cc3428c9aadbed1ba988c594b17ecd56ad0ac661e2d6145efae145adfcd2def457dcfa371006005
|
@@ -2,8 +2,11 @@ require_relative 'action/check_state'
|
|
2
2
|
require_relative 'action/connect_opennebula'
|
3
3
|
require_relative 'action/create'
|
4
4
|
require_relative 'action/destroy'
|
5
|
+
require_relative 'action/messages'
|
5
6
|
require_relative 'action/read_ssh_info'
|
6
7
|
require_relative 'action/sync_folders'
|
8
|
+
require_relative 'action/start'
|
9
|
+
require_relative 'action/stop'
|
7
10
|
|
8
11
|
module VagrantPlugins
|
9
12
|
module OpenNebulaProvider
|
@@ -17,8 +20,11 @@ module VagrantPlugins
|
|
17
20
|
b1.use ConnectOpenNebula
|
18
21
|
b1.use Call, CheckState do |env2, b2|
|
19
22
|
case env2[:machine_state]
|
20
|
-
when :active
|
23
|
+
when :active, :error, :suspended, :inactive
|
21
24
|
b2.use Destroy
|
25
|
+
b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
|
26
|
+
when :not_created
|
27
|
+
b2.use MessageAlreadyDestroyed
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -32,14 +38,50 @@ module VagrantPlugins
|
|
32
38
|
b.use Call, CheckState do |env, b1|
|
33
39
|
case env[:machine_state]
|
34
40
|
when :active
|
35
|
-
|
36
|
-
when :
|
41
|
+
b1.use MessageAlreadyCreated
|
42
|
+
when :suspended
|
43
|
+
b1.use Start
|
44
|
+
when :not_created, :inactive
|
37
45
|
b1.use Create
|
38
46
|
end
|
39
47
|
end
|
40
48
|
end
|
41
49
|
end
|
42
50
|
|
51
|
+
def self.halt
|
52
|
+
Vagrant::Action::Builder.new.tap do |b|
|
53
|
+
b.use ConfigValidate
|
54
|
+
b.use ConnectOpenNebula
|
55
|
+
b.use Call, CheckState do |env1, b1|
|
56
|
+
case env1[:machine_state]
|
57
|
+
when :active
|
58
|
+
b1.use Stop
|
59
|
+
when :suspended
|
60
|
+
b1.use MessageAlreadyHalted
|
61
|
+
when :not_created, :inactive
|
62
|
+
b1.use MessageNotCreated
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.reload
|
69
|
+
Vagrant::Action::Builder.new.tap do |b|
|
70
|
+
b.use ConfigValidate
|
71
|
+
b.use ConnectOpenNebula
|
72
|
+
b.use Call, CheckState do |env1, b1|
|
73
|
+
case env1[:machine_state]
|
74
|
+
when :not_created
|
75
|
+
b1.use MessageNotCreated
|
76
|
+
next
|
77
|
+
end
|
78
|
+
|
79
|
+
b1.use halt
|
80
|
+
b1.use up
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
43
85
|
def self.check_state
|
44
86
|
Vagrant::Action::Builder.new.tap do |b|
|
45
87
|
b.use ConfigValidate
|
@@ -10,8 +10,16 @@ module VagrantPlugins
|
|
10
10
|
def call(env)
|
11
11
|
@logger.info I18n.t('opennebula_provider.info.creating')
|
12
12
|
result = env[:rocci].compute
|
13
|
-
env[:rocci].wait_for_event(env, result)
|
14
13
|
env[:machine].id = result
|
14
|
+
env[:rocci].wait_for_state(env, 'active')
|
15
|
+
env[:ui].info I18n.t('opennebula_provider.info.waiting_for_sshd')
|
16
|
+
if !env[:interrupted]
|
17
|
+
while true
|
18
|
+
break if env[:interrupted]
|
19
|
+
break if env[:machine].communicate.ready?
|
20
|
+
sleep 2
|
21
|
+
end
|
22
|
+
end
|
15
23
|
@app.call(env)
|
16
24
|
end
|
17
25
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OpenNebulaProvider
|
3
|
+
module Action
|
4
|
+
class MessageAlreadyCreated
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env[:ui].info I18n.t('opennebula_provider.info.already_created')
|
11
|
+
@app.call(env)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class MessageAlreadyDestroyed
|
16
|
+
def initialize(app, env)
|
17
|
+
@app = app
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(env)
|
21
|
+
env[:ui].info I18n.t('opennebula_provider.info.already_destroyed')
|
22
|
+
@app.call(env)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class MessageAlreadyHalted
|
27
|
+
def initialize(app, env)
|
28
|
+
@app = app
|
29
|
+
end
|
30
|
+
|
31
|
+
def call(env)
|
32
|
+
env[:ui].info I18n.t('opennebula_provider.info.already_halted')
|
33
|
+
@app.call(env)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
class MessageNotCreated
|
37
|
+
def initialize(app, env)
|
38
|
+
@app = app
|
39
|
+
end
|
40
|
+
|
41
|
+
def call(env)
|
42
|
+
env[:ui].info I18n.t('opennebula_provider.info.not_created')
|
43
|
+
@app.call(env)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OpenNebulaProvider
|
3
|
+
module Action
|
4
|
+
class Start
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
@logger = Log4r::Logger.new('vagrant::provider::opennebula::start')
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
@logger.info I18n.t('opennebula_provider.info.start', machine: env[:machine].id)
|
12
|
+
env[:rocci].start(env[:machine].id)
|
13
|
+
env[:ui].info I18n.t('opennebula_provider.info.waiting_for_sshd')
|
14
|
+
if !env[:interrupted]
|
15
|
+
while true
|
16
|
+
break if env[:interrupted]
|
17
|
+
break if env[:machine].communicate.ready?
|
18
|
+
sleep 2
|
19
|
+
end
|
20
|
+
end
|
21
|
+
@app.call(env)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OpenNebulaProvider
|
3
|
+
module Action
|
4
|
+
class Stop
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
@logger = Log4r::Logger.new('vagrant::provider::opennebula::stop')
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
@logger.info I18n.t('opennebula_provider.info.stop', machine: env[:machine].id)
|
12
|
+
env[:rocci].stop(env[:machine].id)
|
13
|
+
env[:rocci].wait_for_state(env, 'suspended')
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -75,15 +75,21 @@ module VagrantPlugins
|
|
75
75
|
raise Errors::ComputeError, error: e
|
76
76
|
end
|
77
77
|
|
78
|
+
def stop(id)
|
79
|
+
@logger.info 'stop!'
|
80
|
+
@rocci.trigger id, action_instance(id, 'stop')
|
81
|
+
end
|
82
|
+
|
83
|
+
def start(id)
|
84
|
+
@logger.info 'start!'
|
85
|
+
@rocci.trigger id, action_instance(id, 'start')
|
86
|
+
end
|
87
|
+
|
78
88
|
def delete(id)
|
79
89
|
@logger.info 'delete!'
|
80
90
|
@rocci.delete id
|
81
91
|
end
|
82
92
|
|
83
|
-
def describe_resource(resource)
|
84
|
-
@rocci.describe resource
|
85
|
-
end
|
86
|
-
|
87
93
|
def machine_state(id)
|
88
94
|
if id
|
89
95
|
begin
|
@@ -110,18 +116,29 @@ module VagrantPlugins
|
|
110
116
|
networkinterface[:address]
|
111
117
|
end
|
112
118
|
|
113
|
-
def
|
114
|
-
retryable(tries:
|
115
|
-
# stop waiting if interrupted
|
119
|
+
def wait_for_state(env, state)
|
120
|
+
retryable(tries: 10, sleep: 6) do
|
116
121
|
next if env[:interrupted]
|
117
|
-
|
118
|
-
# check event status
|
119
|
-
result = machine_state(id)
|
122
|
+
result = machine_state(env[:machine].id)
|
120
123
|
|
121
124
|
yield result if block_given?
|
122
|
-
fail '
|
125
|
+
fail Errors::ComputeError, error: 'Not ready' if result != state
|
123
126
|
end
|
124
127
|
end
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
def action_instance(id, action)
|
132
|
+
desc = describe_resource(id)
|
133
|
+
action_ = desc.first.actions.map do |ai|
|
134
|
+
ai.term == action ? ai : nil
|
135
|
+
end.compact.first
|
136
|
+
Occi::Core::ActionInstance.new action_, nil
|
137
|
+
end
|
138
|
+
|
139
|
+
def describe_resource(resource)
|
140
|
+
@rocci.describe resource
|
141
|
+
end
|
125
142
|
end
|
126
143
|
end
|
127
144
|
end
|
data/locales/en.yml
CHANGED
@@ -7,10 +7,18 @@ en:
|
|
7
7
|
Creating a new instance...
|
8
8
|
not_created: |-
|
9
9
|
Instance is not created
|
10
|
+
already_created: |-
|
11
|
+
Instance already created
|
12
|
+
already_destroyed: |-
|
13
|
+
Instance already destroyed
|
14
|
+
already_halted: |-
|
15
|
+
Instance already halted
|
10
16
|
destroying: |-
|
11
|
-
|
17
|
+
Instance %{machine} is destroying...
|
12
18
|
state: |-
|
13
|
-
|
19
|
+
Instance state is %{state}
|
20
|
+
waiting_for_sshd: |-
|
21
|
+
Instance is active, waiting for sshd daemon startup...
|
14
22
|
rsyncing: |-
|
15
23
|
Rsyncing folder: %{hostpath} => %{guestpath}...
|
16
24
|
rsync_not_found_warning: |-
|
@@ -33,11 +41,26 @@ en:
|
|
33
41
|
long_active: |-
|
34
42
|
Instance is active
|
35
43
|
|
44
|
+
short_waiting: |-
|
45
|
+
waiting
|
46
|
+
long_waiting: |-
|
47
|
+
Instance is waiting to create or boot
|
48
|
+
|
36
49
|
short_running: |-
|
37
50
|
running
|
38
51
|
long_running: |-
|
39
52
|
The OpenNebula instance is running
|
40
53
|
|
54
|
+
short_error: |-
|
55
|
+
error
|
56
|
+
long_error: |-
|
57
|
+
The OpenNebula instance cannot be started
|
58
|
+
|
59
|
+
short_suspended: |-
|
60
|
+
suspended
|
61
|
+
long_suspended: |-
|
62
|
+
The OpenNebula instance is suspended or halted
|
63
|
+
|
41
64
|
config:
|
42
65
|
endpoint: |-
|
43
66
|
rOCCI-server endpoint is not set
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opennebula-provider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cherdancev Evgeni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: occi-api
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: OpenNebula provider for Vagrant
|
@@ -73,30 +73,33 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- ".gitignore"
|
77
|
-
- Gemfile
|
78
76
|
- LICENSE.txt
|
77
|
+
- locales/en.yml
|
79
78
|
- README.md
|
80
|
-
-
|
81
|
-
- boxes/dummy/README.md
|
79
|
+
- Gemfile
|
82
80
|
- boxes/dummy/dummy.box
|
83
81
|
- boxes/dummy/metadata.json
|
84
|
-
-
|
85
|
-
- lib/opennebula-provider/
|
82
|
+
- boxes/dummy/README.md
|
83
|
+
- lib/opennebula-provider/version.rb
|
84
|
+
- lib/opennebula-provider/errors.rb
|
85
|
+
- lib/opennebula-provider/plugin.rb
|
86
|
+
- lib/opennebula-provider/helpers/rocci.rb
|
87
|
+
- lib/opennebula-provider/action/stop.rb
|
88
|
+
- lib/opennebula-provider/action/destroy.rb
|
86
89
|
- lib/opennebula-provider/action/check_state.rb
|
90
|
+
- lib/opennebula-provider/action/read_ssh_info.rb
|
87
91
|
- lib/opennebula-provider/action/connect_opennebula.rb
|
92
|
+
- lib/opennebula-provider/action/messages.rb
|
88
93
|
- lib/opennebula-provider/action/create.rb
|
89
|
-
- lib/opennebula-provider/action/
|
90
|
-
- lib/opennebula-provider/action/read_ssh_info.rb
|
94
|
+
- lib/opennebula-provider/action/start.rb
|
91
95
|
- lib/opennebula-provider/action/sync_folders.rb
|
96
|
+
- lib/opennebula-provider/action.rb
|
92
97
|
- lib/opennebula-provider/config.rb
|
93
|
-
- lib/opennebula-provider/errors.rb
|
94
|
-
- lib/opennebula-provider/helpers/rocci.rb
|
95
|
-
- lib/opennebula-provider/plugin.rb
|
96
98
|
- lib/opennebula-provider/provider.rb
|
97
|
-
- lib/opennebula-provider
|
98
|
-
- locales/en.yml
|
99
|
+
- lib/opennebula-provider.rb
|
99
100
|
- opennebula-provider.gemspec
|
101
|
+
- Rakefile
|
102
|
+
- .gitignore
|
100
103
|
homepage: ''
|
101
104
|
licenses:
|
102
105
|
- MIT
|
@@ -107,17 +110,17 @@ require_paths:
|
|
107
110
|
- lib
|
108
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
112
|
requirements:
|
110
|
-
- -
|
113
|
+
- - '>='
|
111
114
|
- !ruby/object:Gem::Version
|
112
115
|
version: '0'
|
113
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
117
|
requirements:
|
115
|
-
- -
|
118
|
+
- - '>='
|
116
119
|
- !ruby/object:Gem::Version
|
117
120
|
version: '0'
|
118
121
|
requirements: []
|
119
122
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.1.11
|
121
124
|
signing_key:
|
122
125
|
specification_version: 4
|
123
126
|
summary: OpenNebula provider for Vagrant
|