lib/vagrant-arubacloud/action.rb in vagrant-arubacloud-0.0.4 vs lib/vagrant-arubacloud/action.rb in vagrant-arubacloud-0.0.5
- old
+ new
@@ -43,10 +43,24 @@
b1.use HaltServer
end
end
end
+ def self.action_start
+ Vagrant::Action::Builder.new.tap do |b|
+ b.use ConfigValidate
+ b.use Call, IsCreated do |env, b1|
+ unless env[:result]
+ b1.use MessageNotCreated
+ next
+ end
+ b1.use ConnectArubaCloud
+ b1.use StartServer
+ end
+ end
+ end
+
def self.action_provision
Vagrant::Action::Builder.new.tap do |b|
b.use ConfigValidate
b.use Call, IsCreated do |env, b2|
unless env[:result]
@@ -58,15 +72,43 @@
b2.use SyncedFolders
end
end
end
- #def self.action_reload
- #Vagrant::Action::Builder.new.tap do |b|
+ def self.action_reload
+ Vagrant::Action::Builder.new.tap do |b|
+ b.use ConfigValidate
+ b.use ConnectArubaCloud
- #end
- #end
+ b.use Call, IsCreated do |env, b2|
+ if !env[:result]
+ b2.use MessageNotCreated
+ next
+ end
+ b2.use action_halt
+ # if not stopped , signal and exit
+ b2.use Call, IsState, Fog::ArubaCloud::Compute::Server::STOPPED do |envr, br|
+ if !envr[:result]
+ br.use Message, ' The server not respond at power off request.'
+ next
+ end
+ end
+ # VM is power off ; now can be powered on
+ b2.use action_start
+ b2.use Call, IsCreated do |env3, b3|
+ unless env3[:result]
+ b3.use Message, ' The server not re-create or not started '
+ next
+ end
+ # Use our custom provisioning class
+ b3.use ConnectArubaCloud
+ b3.use WaitForCommunicator
+ b3.use SyncedFolders
+ end
+ end
+ end
+ end
def self.action_read_ssh_info
Vagrant::Action::Builder.new.tap do |b|
b.use ConfigValidate
b.use ConnectArubaCloud
@@ -118,15 +160,14 @@
b.use Call, IsCreated do |env, b2|
if env[:result]
b2.use MessageAlreadyCreated
next
end
-
b2.use ConnectArubaCloud
- # b2.use RunInitScript # temporarily removed
b2.use CreateServer
b2.use WaitForCommunicator
+ b2.use SyncedFolders
end
end
end
def self.action_list_servers
@@ -146,16 +187,16 @@
# The autoload farm
action_root = Pathname.new(File.expand_path('../action', __FILE__))
autoload :ConnectArubaCloud, action_root.join('connect_arubacloud')
autoload :CreateServer, action_root.join('create_server')
autoload :HaltServer, action_root.join('halt_server')
+ autoload :StartServer, action_root.join('start_server')
autoload :DeleteServer, action_root.join('delete_server')
autoload :IsCreated, action_root.join('is_created')
autoload :MessageNotCreated, action_root.join('message_not_created')
autoload :MessageAlreadyCreated, action_root.join('message_already_created')
autoload :ReadSSHInfo, action_root.join('read_ssh_info')
autoload :ReadState, action_root.join('read_state')
- # autoload :RunInitScript, action_root.join("run_init_script")
autoload :ListServers, action_root.join('list_servers')
autoload :ListTemplates, action_root.join('list_templates')
autoload :ArubaProvision, action_root.join('aruba_provision')
end
end