Class: AvstCloud::CloudServer
- Inherits:
-
Object
- Object
- AvstCloud::CloudServer
- Includes:
- Logging
- Defined in:
- lib/avst-cloud/cloud_server.rb
Direct Known Subclasses
Constant Summary collapse
- UNIMPLEMENTED =
Abstract classes to be implemented per provider
"Unimplemented..."
Instance Attribute Summary collapse
-
#access_password ⇒ Object
Returns the value of attribute access_password.
-
#access_user ⇒ Object
Returns the value of attribute access_user.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#server ⇒ Object
Returns the value of attribute server.
-
#server_name ⇒ Object
Returns the value of attribute server_name.
Instance Method Summary collapse
- #bootstrap(pre_upload_commands, custom_file_uploads, post_upload_commands, remote_server_debug, debug_structured_log, enable_sudo = "false") ⇒ Object
- #destroy ⇒ Object
-
#initialize(server, server_name, ip_address, access_user, access_password) ⇒ CloudServer
constructor
A new instance of CloudServer.
- #post_provisioning_commands(custom_commands, os, remote_server_debug, server_tmp_folder, run_cleanup = true) ⇒ Object
- #provision(git, branch, server_tmp_folder, reference, custom_provisioning_commands, puppet_runner, puppet_runner_prepare, destination_folder, avst_cloud_config_dir, download_dependencies_command) ⇒ Object
- #run_tasks(tasks) ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
- #wait_for_state(&cond) ⇒ Object
Methods included from Logging
included, logger, #logger, logger=, mask_message, show_passwords=
Constructor Details
#initialize(server, server_name, ip_address, access_user, access_password) ⇒ CloudServer
Returns a new instance of CloudServer.
23 24 25 26 27 28 29 |
# File 'lib/avst-cloud/cloud_server.rb', line 23 def initialize(server, server_name, ip_address, access_user, access_password) @server = server @ip_address = ip_address @server_name = server_name @access_user = access_user @access_password = access_password end |
Instance Attribute Details
#access_password ⇒ Object
Returns the value of attribute access_password.
21 22 23 |
# File 'lib/avst-cloud/cloud_server.rb', line 21 def access_password @access_password end |
#access_user ⇒ Object
Returns the value of attribute access_user.
21 22 23 |
# File 'lib/avst-cloud/cloud_server.rb', line 21 def access_user @access_user end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
21 22 23 |
# File 'lib/avst-cloud/cloud_server.rb', line 21 def ip_address @ip_address end |
#server ⇒ Object
Returns the value of attribute server.
21 22 23 |
# File 'lib/avst-cloud/cloud_server.rb', line 21 def server @server end |
#server_name ⇒ Object
Returns the value of attribute server_name.
21 22 23 |
# File 'lib/avst-cloud/cloud_server.rb', line 21 def server_name @server_name end |
Instance Method Details
#bootstrap(pre_upload_commands, custom_file_uploads, post_upload_commands, remote_server_debug, debug_structured_log, enable_sudo = "false") ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/avst-cloud/cloud_server.rb', line 31 def bootstrap(pre_upload_commands, custom_file_uploads, post_upload_commands, remote_server_debug, debug_structured_log, enable_sudo="false") logger.debug "Bootstrapping #{server_name}...".green run_tasks([AvstCloud::WaitUntilReady.new]) disable_tty_task = AvstCloud::DisableRequireTty.new(@access_user, @access_password, enable_sudo) pre_upload_commands_tasks = AvstCloud::SshCommandTask.new(pre_upload_commands, remote_server_debug, debug_structured_log) custom_file_uploads_tasks = AvstCloud::ScpTask.new(custom_file_uploads) post_upload_commands_tasks = AvstCloud::SshCommandTask.new(post_upload_commands, remote_server_debug, debug_structured_log) run_tasks([disable_tty_task, pre_upload_commands_tasks, custom_file_uploads_tasks, post_upload_commands_tasks]) logger.debug "Bootstrap done. You can connect to server as #{@access_user} on #{@ip_address}" end |
#destroy ⇒ Object
87 88 89 |
# File 'lib/avst-cloud/cloud_server.rb', line 87 def destroy raise UNIMPLEMENTED end |
#post_provisioning_commands(custom_commands, os, remote_server_debug, server_tmp_folder, run_cleanup = true) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/avst-cloud/cloud_server.rb', line 49 def post_provisioning_commands(custom_commands, os, remote_server_debug, server_tmp_folder, run_cleanup=true) logger.debug "Running post provision cleanup and custom commands on #{server_name}..." custom_post_provision_commands = AvstCloud::SshCommandTask.new(custom_commands, remote_server_debug, true) commands = [AvstCloud::WaitUntilReady.new, custom_post_provision_commands] commands << AvstCloud::PostProvisionCleanup.new(os, remote_server_debug, server_tmp_folder) if run_cleanup run_tasks(commands) logger.debug "Post provisioning cleanup and custom commands done. You can connect to server as #{@access_user} on #{@ip_address}" end |
#provision(git, branch, server_tmp_folder, reference, custom_provisioning_commands, puppet_runner, puppet_runner_prepare, destination_folder, avst_cloud_config_dir, download_dependencies_command) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/avst-cloud/cloud_server.rb', line 42 def provision(git, branch, server_tmp_folder, reference, custom_provisioning_commands, puppet_runner, puppet_runner_prepare, destination_folder, avst_cloud_config_dir, download_dependencies_command) logger.debug "Provisioning #{@server_name}..." provision_task = AvstCloud::CapistranoDeploymentTask.new(git, branch, server_tmp_folder, reference, custom_provisioning_commands, puppet_runner, puppet_runner_prepare, destination_folder, avst_cloud_config_dir, download_dependencies_command) run_tasks([AvstCloud::WaitUntilReady.new, provision_task]) logger.debug "Provisioning done. You can connect to server on #{@ip_address}" end |
#run_tasks(tasks) ⇒ Object
58 59 60 61 62 |
# File 'lib/avst-cloud/cloud_server.rb', line 58 def run_tasks(tasks) Array(tasks).each do |task| task.execute self end end |
#start ⇒ Object
83 84 85 |
# File 'lib/avst-cloud/cloud_server.rb', line 83 def start raise UNIMPLEMENTED end |
#status ⇒ Object
64 65 66 |
# File 'lib/avst-cloud/cloud_server.rb', line 64 def status @server.state end |
#stop ⇒ Object
79 80 81 |
# File 'lib/avst-cloud/cloud_server.rb', line 79 def stop raise UNIMPLEMENTED end |
#wait_for_state(&cond) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/avst-cloud/cloud_server.rb', line 68 def wait_for_state(&cond) logger.debug "Waiting for state change...".yellow @server.wait_for(600, 5) do print "." STDOUT.flush cond.call(self) end end |