Class: DaptivChefCI::VagrantDriver
- Inherits:
-
Object
- Object
- DaptivChefCI::VagrantDriver
- Defined in:
- lib/daptiv-chef-ci/vagrant_driver.rb
Overview
Drives Vagrant via the command shell
Instance Method Summary collapse
- #destroy(opts = {}) ⇒ Object
- #halt(opts = {}) ⇒ Object
-
#initialize(provider = :virtualbox, shell = nil) ⇒ VagrantDriver
constructor
Constructs a new Vagrant management instance.
- #provision(opts = {}) ⇒ Object
- #up(opts = {}) ⇒ Object
Constructor Details
#initialize(provider = :virtualbox, shell = nil) ⇒ VagrantDriver
Constructs a new Vagrant management instance
> virtualbox (default), vmware_fusion
13 14 15 16 17 |
# File 'lib/daptiv-chef-ci/vagrant_driver.rb', line 13 def initialize(provider = :virtualbox, shell = nil) @logger = Log4r::Logger.new('daptiv_chef_ci::vagrant') @shell = shell || DaptivChefCI::Shell.new @provider = provider end |
Instance Method Details
#destroy(opts = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/daptiv-chef-ci/vagrant_driver.rb', line 19 def destroy(opts = {}) opts = { cmd_timeout_in_seconds: 180, retry_attempts: 2, retry_wait_in_seconds: 20, continue_on_error: true }.merge(opts) exec_cmd_with_retry('vagrant destroy -f', opts) end |
#halt(opts = {}) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/daptiv-chef-ci/vagrant_driver.rb', line 29 def halt(opts = {}) opts = { cmd_timeout_in_seconds: 180, retry_attempts: 2, retry_wait_in_seconds: 20 }.merge(opts) exec_cmd_with_retry('vagrant halt', opts) end |
#provision(opts = {}) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/daptiv-chef-ci/vagrant_driver.rb', line 48 def provision(opts = {}) opts = { cmd_timeout_in_seconds: 7200, retry_attempts: 0 }.merge(opts) exec_cmd_with_retry('vagrant provision', opts) end |
#up(opts = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/daptiv-chef-ci/vagrant_driver.rb', line 38 def up(opts = {}) opts = { cmd_timeout_in_seconds: 7200, retry_attempts: 0 }.merge(opts) cmd = 'vagrant up' cmd += ' --provider=' + @provider.to_s exec_cmd_with_retry(cmd, opts) end |