vagrant-haipa 0.0.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +11 -0
- data/.gitignore +49 -16
- data/.rspec_status +5 -0
- data/.vscode/launch.json +13 -3
- data/Gemfile +6 -2
- data/Gemfile.lock +181 -0
- data/LICENSE +21 -373
- data/Rakefile +7 -16
- data/lib/vagrant-haipa/action/converge_machine.rb +44 -0
- data/lib/vagrant-haipa/{actions → action}/delete_machine.rb +3 -10
- data/lib/vagrant-haipa/action/is_created.rb +19 -0
- data/lib/vagrant-haipa/action/is_running.rb +20 -0
- data/lib/vagrant-haipa/{actions → action}/message_already_created.rb +1 -1
- data/lib/vagrant-haipa/{actions → action}/message_not_created.rb +1 -1
- data/lib/vagrant-haipa/{actions → action}/message_will_not_destroy.rb +1 -1
- data/lib/vagrant-haipa/action/read_state.rb +19 -0
- data/lib/vagrant-haipa/{actions → action}/set_name.rb +3 -6
- data/lib/vagrant-haipa/action/start_machine.rb +24 -0
- data/lib/vagrant-haipa/action/stop_machine.rb +25 -0
- data/lib/vagrant-haipa/{actions → action}/wait_for_ip_address.rb +4 -4
- data/lib/vagrant-haipa/{actions.rb → action.rb} +78 -106
- data/lib/vagrant-haipa/config.rb +17 -15
- data/lib/vagrant-haipa/driver.rb +139 -0
- data/lib/vagrant-haipa/errors.rb +4 -36
- data/lib/vagrant-haipa/plugin.rb +8 -7
- data/lib/vagrant-haipa/provider.rb +44 -63
- data/lib/vagrant-haipa/version.rb +2 -2
- data/lib/vagrant-haipa.rb +11 -7
- data/locales/en.yml +2 -70
- data/spec/spec_helper.rb +20 -0
- data/spec/unit/provider_spec.rb +38 -0
- data/test/Vagrantfile +23 -14
- data/test/console.key +27 -0
- data/vagrant +27 -27
- data/vagrant-haipa.gemspec +3 -4
- metadata +32 -53
- data/README.md +0 -111
- data/lib/vagrant-haipa/actions/check_state.rb +0 -19
- data/lib/vagrant-haipa/actions/connect_haipa.rb +0 -24
- data/lib/vagrant-haipa/actions/create_machine.rb +0 -56
- data/lib/vagrant-haipa/actions/is_created.rb +0 -18
- data/lib/vagrant-haipa/actions/is_stopped.rb +0 -18
- data/lib/vagrant-haipa/actions/modify_provision_path.rb +0 -38
- data/lib/vagrant-haipa/actions/shut_down.rb +0 -33
- data/lib/vagrant-haipa/actions/start_machine.rb +0 -34
- data/lib/vagrant-haipa/actions/stop_machine.rb +0 -33
- data/lib/vagrant-haipa/helpers/client.rb +0 -111
- data/lib/vagrant-haipa/helpers/result.rb +0 -40
- data/test/cookbooks/test/recipes/default.rb +0 -1
- data/test/scripts/provision.sh +0 -3
- data/test/test.sh +0 -13
- data/test/test_id_rsa +0 -27
- data/test/test_id_rsa.pub +0 -1
data/README.md
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
Haipa Vagrant Provider
|
2
|
-
=================================
|
3
|
-
|
4
|
-
|
5
|
-
`vagrant-haipa` is a Vagrant provider plugin that supports the management of Hyper-V virtual machines with [Haipa](http://www.haipa.io).
|
6
|
-
|
7
|
-
Features include:
|
8
|
-
- Create and destroy Haipa Machines
|
9
|
-
- Power on and off Haipa Machines
|
10
|
-
|
11
|
-
|
12
|
-
Install
|
13
|
-
-------
|
14
|
-
Install the provider plugin using the Vagrant command-line interface:
|
15
|
-
|
16
|
-
`vagrant plugin install vagrant-haipa`
|
17
|
-
|
18
|
-
|
19
|
-
Configure
|
20
|
-
---------
|
21
|
-
Once the provider has been installed, you will need to configure your project to use it. See the following example for a basic `Vagrantfile` implementation:
|
22
|
-
|
23
|
-
```ruby
|
24
|
-
config.vm.define :ubuntu do |ubuntu|
|
25
|
-
ubuntu.vm.provider :haipa do |provider|
|
26
|
-
provider.vm_config = {
|
27
|
-
'Memory' => {
|
28
|
-
'Startup' => 2048
|
29
|
-
},
|
30
|
-
'Disks' => [
|
31
|
-
{
|
32
|
-
"Template" => 'c:\hyperv-templates\ubuntu-xenial.vhdx',
|
33
|
-
"Size" => 20
|
34
|
-
}
|
35
|
-
],
|
36
|
-
'NetworkAdapters' => [
|
37
|
-
{
|
38
|
-
"Name" => "eth0",
|
39
|
-
"SwitchName" => "Default Switch",
|
40
|
-
}
|
41
|
-
]
|
42
|
-
}
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
```
|
47
|
-
|
48
|
-
|
49
|
-
**Supported Configuration Attributes**
|
50
|
-
|
51
|
-
The following attributes are available to further configure the provider:
|
52
|
-
- `provider.vm_config`
|
53
|
-
* A Hash with the Haipa vm configuration
|
54
|
-
- `provider.provision`
|
55
|
-
* A Hash with the Haipa provision configuration
|
56
|
-
|
57
|
-
Run
|
58
|
-
---
|
59
|
-
After creating your project's `Vagrantfile` with the required configuration
|
60
|
-
attributes described above, you may create a new Machine with the following
|
61
|
-
command:
|
62
|
-
|
63
|
-
$ vagrant up --provider=haipa
|
64
|
-
|
65
|
-
This command will create a new machine, setup your SSH key for authentication,
|
66
|
-
create a new user account, and run the provisioners you have configured.
|
67
|
-
|
68
|
-
**Supported Commands**
|
69
|
-
|
70
|
-
The provider supports the following Vagrant sub-commands:
|
71
|
-
- `vagrant destroy` - Destroys the machine instance.
|
72
|
-
- `vagrant ssh` - Logs into the machine instance using the configured user account.
|
73
|
-
- `vagrant halt` - Powers off the machine instance.
|
74
|
-
- `vagrant provision` - Runs the configured provisioners and rsyncs any specified `config.vm.synced_folder`.
|
75
|
-
- `vagrant status` - Outputs the status (active, off, not created) for the machine instance.
|
76
|
-
|
77
|
-
|
78
|
-
Troubleshooting
|
79
|
-
---------------
|
80
|
-
Before submitting a GitHub issue, please ensure both Vagrant and vagrant-haipa are fully up-to-date.
|
81
|
-
* For the latest Vagrant version, please visit the [Vagrant](https://www.vagrantup.com/) website
|
82
|
-
* To update Vagrant plugins, run the following command: `vagrant plugin update`
|
83
|
-
|
84
|
-
|
85
|
-
Contribute
|
86
|
-
----------
|
87
|
-
To contribute, fork then clone the repository, and then the following:
|
88
|
-
|
89
|
-
**Developing**
|
90
|
-
|
91
|
-
1. Install [Bundler](http://bundler.io/)
|
92
|
-
2. Currently the Bundler version is locked to 1.7.9, please install this version.
|
93
|
-
* `sudo gem install bundler -v '1.7.9'`
|
94
|
-
3. Then install vagrant-haipa dependencies:
|
95
|
-
* `bundle _1.7.9_ install`
|
96
|
-
4. Do your development and run a few commands, one to get started would be:
|
97
|
-
* `bundle _1.7.9_ exec vagrant haipa-list images`
|
98
|
-
5. You can then run a test:
|
99
|
-
* `bundle _1.7.9_ exec rake test`
|
100
|
-
6. Once you are satisfied with your changes, please submit a pull request.
|
101
|
-
|
102
|
-
**Testing**
|
103
|
-
|
104
|
-
1. Build and package your newly developed code:
|
105
|
-
* `rake gem:build`
|
106
|
-
2. Then install the packaged plugin:
|
107
|
-
* `vagrant plugin install pkg/vagrant-haipa-*.gem`
|
108
|
-
3. Once you're done testing, roll-back to the latest released version:
|
109
|
-
* `vagrant plugin uninstall vagrant-haipa`
|
110
|
-
* `vagrant plugin install vagrant-haipa`
|
111
|
-
4. Once you're satisfied developing and testing your new code, please submit a pull request for review.
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module Haipa
|
3
|
-
module Actions
|
4
|
-
class CheckState
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
@machine = env[:machine]
|
8
|
-
@logger = Log4r::Logger.new('vagrant::haipa::check_state')
|
9
|
-
end
|
10
|
-
|
11
|
-
def call(env)
|
12
|
-
env[:machine_state] = @machine.state.id
|
13
|
-
@logger.info "Machine state is '#{@machine.state.id}'"
|
14
|
-
@app.call(env)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'vagrant-haipa'
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module Haipa
|
5
|
-
module Actions
|
6
|
-
class ConnectHaipa
|
7
|
-
include Helpers::Client
|
8
|
-
|
9
|
-
def initialize(app, env)
|
10
|
-
@app = app
|
11
|
-
@machine = env[:machine]
|
12
|
-
@client = client
|
13
|
-
@logger = Log4r::Logger.new('vagrant::haipa::ConnectHaipa')
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(env)
|
17
|
-
@app.call(env)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'vagrant-haipa/helpers/client'
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module Haipa
|
5
|
-
module Actions
|
6
|
-
class CreateMachine
|
7
|
-
include Helpers::Client
|
8
|
-
include Vagrant::Util::Retryable
|
9
|
-
|
10
|
-
def initialize(app, env)
|
11
|
-
@app = app
|
12
|
-
@machine = env[:machine]
|
13
|
-
@client = client
|
14
|
-
@logger = Log4r::Logger.new('vagrant::haipa::create_machine')
|
15
|
-
end
|
16
|
-
|
17
|
-
def call(env)
|
18
|
-
ssh_key_id = [env[:ssh_key_id]]
|
19
|
-
|
20
|
-
# submit new machine request
|
21
|
-
result = @client.post('/odata/Machines', {
|
22
|
-
|
23
|
-
'Name' => env[:generated_name],
|
24
|
-
'VM' => @machine.provider_config.vm_config,
|
25
|
-
"Provisioning" => @machine.provider_config.provision
|
26
|
-
})
|
27
|
-
|
28
|
-
# wait for request to complete
|
29
|
-
env[:ui].info I18n.t('vagrant_haipa.info.creating')
|
30
|
-
@client.wait_for_event(env, result['Id'])
|
31
|
-
|
32
|
-
# assign the machine id for reference in other commands
|
33
|
-
operation_result = @client.request("odata/Operations(#{result['Id']})")
|
34
|
-
@machine.id = operation_result['MachineGuid'].to_s
|
35
|
-
|
36
|
-
@app.call(env)
|
37
|
-
end
|
38
|
-
|
39
|
-
# Both the recover and terminate are stolen almost verbatim from
|
40
|
-
# the Vagrant AWS provider up action
|
41
|
-
def recover(env)
|
42
|
-
return if env['vagrant.error'].is_a?(Vagrant::Errors::VagrantError)
|
43
|
-
terminate(env) if @machine.state.id != :not_created
|
44
|
-
end
|
45
|
-
|
46
|
-
def terminate(env)
|
47
|
-
destroy_env = env.dup
|
48
|
-
destroy_env.delete(:interrupted)
|
49
|
-
destroy_env[:config_validate] = false
|
50
|
-
destroy_env[:force_confirm_destroy] = true
|
51
|
-
env[:action_runner].run(Actions.action_destroy, destroy_env)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module Haipa
|
3
|
-
module Actions
|
4
|
-
class IsCreated
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
@machine = env[:machine]
|
8
|
-
@logger = Log4r::Logger.new('vagrant::haipa::is_created')
|
9
|
-
end
|
10
|
-
|
11
|
-
def call(env)
|
12
|
-
env[:result] = env[:machine].state.id != :not_created
|
13
|
-
@app.call(env)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module Haipa
|
3
|
-
module Actions
|
4
|
-
class IsStopped
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
@machine = env[:machine]
|
8
|
-
@logger = Log4r::Logger.new('vagrant::haipa::is_stopped')
|
9
|
-
end
|
10
|
-
|
11
|
-
def call(env)
|
12
|
-
env[:result] = env[:machine].state.id == :Stopped
|
13
|
-
@app.call(env)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module Haipa
|
3
|
-
module Actions
|
4
|
-
class ModifyProvisionPath
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
@machine = env[:machine]
|
8
|
-
@logger =
|
9
|
-
Log4r::Logger.new('vagrant::haipa::modify_provision_path')
|
10
|
-
end
|
11
|
-
|
12
|
-
def call(env)
|
13
|
-
# check if provisioning is enabled
|
14
|
-
enabled = true
|
15
|
-
enabled = env[:provision_enabled] if env.has_key?(:provision_enabled)
|
16
|
-
return @app.call(env) if !enabled
|
17
|
-
|
18
|
-
username = @machine.ssh_info()[:username]
|
19
|
-
|
20
|
-
# change ownership of the provisioning path recursively to the
|
21
|
-
# ssh user
|
22
|
-
#
|
23
|
-
# TODO submit patch to vagrant to set appropriate permissions
|
24
|
-
# based on ssh username
|
25
|
-
@machine.config.vm.provisioners.each do |provisioner|
|
26
|
-
cfg = provisioner.config
|
27
|
-
path = cfg.upload_path if cfg.respond_to? :upload_path
|
28
|
-
path = cfg.provisioning_path if cfg.respond_to? :provisioning_path
|
29
|
-
@machine.communicate.sudo("chown -R #{username} #{path}",
|
30
|
-
:error_check => false)
|
31
|
-
end
|
32
|
-
|
33
|
-
@app.call(env)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'vagrant-haipa'
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module Haipa
|
5
|
-
module Actions
|
6
|
-
class ShutDown
|
7
|
-
include Helpers::Client
|
8
|
-
|
9
|
-
def initialize(app, env)
|
10
|
-
@app = app
|
11
|
-
@machine = env[:machine]
|
12
|
-
@client = client
|
13
|
-
@logger = Log4r::Logger.new('vagrant::haipa::shut_down')
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(env)
|
17
|
-
# submit shutdown machine request
|
18
|
-
result = @client.post("/odata/Machines(#{@machine.id})/Stop")
|
19
|
-
|
20
|
-
# wait for request to complete
|
21
|
-
env[:ui].info I18n.t('vagrant_haipa.info.shutting_down')
|
22
|
-
@client.wait_for_event(env, result['Id'])
|
23
|
-
|
24
|
-
# refresh machine state with provider
|
25
|
-
Provider.haipa_machine(@machine, :refresh => true)
|
26
|
-
|
27
|
-
@app.call(env)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'vagrant-haipa'
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module Haipa
|
5
|
-
module Actions
|
6
|
-
class StartMachine
|
7
|
-
include Helpers::Client
|
8
|
-
|
9
|
-
def initialize(app, env)
|
10
|
-
@app = app
|
11
|
-
@machine = env[:machine]
|
12
|
-
@client = client
|
13
|
-
@logger = Log4r::Logger.new('vagrant::haipa::power_on')
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(env)
|
17
|
-
# submit power on machine request
|
18
|
-
result = @client.post("/odata/Machines(#{@machine.id})/Start")
|
19
|
-
|
20
|
-
# wait for request to complete
|
21
|
-
env[:ui].info I18n.t('vagrant_haipa.info.powering_on')
|
22
|
-
@client.wait_for_event(env, result['Id'])
|
23
|
-
|
24
|
-
# refresh machine state with provider
|
25
|
-
Provider.haipa_machine(@machine, :refresh => true)
|
26
|
-
|
27
|
-
@app.call(env)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'vagrant-haipa'
|
2
|
-
#TODO: --force
|
3
|
-
module VagrantPlugins
|
4
|
-
module Haipa
|
5
|
-
module Actions
|
6
|
-
class StopMachine
|
7
|
-
include Helpers::Client
|
8
|
-
|
9
|
-
def initialize(app, env)
|
10
|
-
@app = app
|
11
|
-
@machine = env[:machine]
|
12
|
-
@client = client
|
13
|
-
@logger = Log4r::Logger.new('vagrant::haipa::power_off')
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(env)
|
17
|
-
# submit power off machine request
|
18
|
-
result = @client.post("/odata/Machines(#{@machine.id})/Stop")
|
19
|
-
|
20
|
-
# wait for request to complete
|
21
|
-
env[:ui].info I18n.t('vagrant_haipa.info.powering_off')
|
22
|
-
@client.wait_for_event(env, result['Id'])
|
23
|
-
|
24
|
-
# refresh machine state with provider
|
25
|
-
Provider.haipa_machine(@machine, :refresh => true)
|
26
|
-
|
27
|
-
@app.call(env)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
@@ -1,111 +0,0 @@
|
|
1
|
-
require 'vagrant-haipa/helpers/result'
|
2
|
-
require 'faraday'
|
3
|
-
require 'json'
|
4
|
-
module VagrantPlugins
|
5
|
-
module Haipa
|
6
|
-
module Helpers
|
7
|
-
module Client
|
8
|
-
def client
|
9
|
-
@client ||= ApiClient.new(@machine)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class ApiClient
|
14
|
-
include Vagrant::Util::Retryable
|
15
|
-
|
16
|
-
def initialize(machine)
|
17
|
-
@logger = Log4r::Logger.new('vagrant::haipa::apiclient')
|
18
|
-
@config = machine.provider_config
|
19
|
-
@client = Faraday.new({
|
20
|
-
:url => 'http://localhost:62189/',
|
21
|
-
:ssl => {
|
22
|
-
:ca_file => @config.ca_path
|
23
|
-
}
|
24
|
-
})
|
25
|
-
end
|
26
|
-
|
27
|
-
def delete(path, params = {})
|
28
|
-
request(path, params, :delete)
|
29
|
-
end
|
30
|
-
|
31
|
-
def post(path, params = {})
|
32
|
-
@client.headers['Content-Type'] = 'application/json'
|
33
|
-
request(path, params, :post)
|
34
|
-
end
|
35
|
-
|
36
|
-
def request(path, params = {}, method = :get)
|
37
|
-
begin
|
38
|
-
@logger.info "Request: #{path}"
|
39
|
-
result = @client.send(method) do |req|
|
40
|
-
req.url path
|
41
|
-
req.body = params.to_json unless method == :get
|
42
|
-
req.params = params if method == :get
|
43
|
-
|
44
|
-
req.headers['Authorization'] = "Bearer #{@config.token}"
|
45
|
-
end
|
46
|
-
rescue Faraday::Error::ConnectionFailed => e
|
47
|
-
# TODO this is suspect but because farady wraps the exception
|
48
|
-
# in something generic there doesn't appear to be another
|
49
|
-
# way to distinguish different connection errors :(
|
50
|
-
if e.message =~ /certificate verify failed/
|
51
|
-
raise Errors::CertificateError
|
52
|
-
end
|
53
|
-
|
54
|
-
raise e
|
55
|
-
end
|
56
|
-
|
57
|
-
begin
|
58
|
-
body = JSON.parse(result.body)
|
59
|
-
body.delete_if { |key, _| key == '@odata.context' }
|
60
|
-
|
61
|
-
@logger.info "Response: #{body}"
|
62
|
-
rescue JSON::ParserError => e
|
63
|
-
raise(Errors::JSONError, {
|
64
|
-
:message => e.message,
|
65
|
-
:path => path,
|
66
|
-
:params => params,
|
67
|
-
:response => result.body
|
68
|
-
})
|
69
|
-
end
|
70
|
-
|
71
|
-
unless /^2\d\d$/ =~ result.status.to_s
|
72
|
-
raise(Errors::APIStatusError, {
|
73
|
-
:path => path,
|
74
|
-
:params => params,
|
75
|
-
:status => result.status,
|
76
|
-
:response => body.inspect
|
77
|
-
})
|
78
|
-
end
|
79
|
-
Result.new(body)
|
80
|
-
end
|
81
|
-
|
82
|
-
def wait_for_event(env, id)
|
83
|
-
timestamp = '2018-09-01T23:47:17.50094+02:00'
|
84
|
-
|
85
|
-
operation_error = nil
|
86
|
-
retryable(:tries => 20, :sleep => 5) do
|
87
|
-
# stop waiting if interrupted
|
88
|
-
next if env[:interrupted]
|
89
|
-
|
90
|
-
# check action status
|
91
|
-
result = request("odata/Operations(#{id})", '$expand' => "LogEntries($filter=Timestamp gt #{timestamp})")
|
92
|
-
|
93
|
-
result['LogEntries'].each do |entry|
|
94
|
-
env[:ui].info(entry['Message'])
|
95
|
-
|
96
|
-
timestamp = entry['Timestamp']
|
97
|
-
end
|
98
|
-
|
99
|
-
yield result if block_given?
|
100
|
-
|
101
|
-
raise 'Operation not completed' if result['Status'] == 'Running' || result['Status'] == 'Queued'
|
102
|
-
operation_error = result['StatusMessage'] if result['Status'] == 'Failed'
|
103
|
-
end
|
104
|
-
|
105
|
-
raise "Operation failed: #{operation_error}" if operation_error
|
106
|
-
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module Haipa
|
3
|
-
module Helpers
|
4
|
-
class Result
|
5
|
-
def initialize(body)
|
6
|
-
@result = body
|
7
|
-
end
|
8
|
-
|
9
|
-
def [](key)
|
10
|
-
@result[key.to_s]
|
11
|
-
end
|
12
|
-
|
13
|
-
def find_id(sub_obj, search) #:ssh_keys, {:name => 'ijin (vagrant)'}
|
14
|
-
find(sub_obj, search)['id']
|
15
|
-
end
|
16
|
-
|
17
|
-
def find(sub_obj, search)
|
18
|
-
key = search.keys.first #:slug
|
19
|
-
value = search[key].to_s #sfo1
|
20
|
-
key = key.to_s #slug
|
21
|
-
|
22
|
-
result = @result[sub_obj.to_s].inject(nil) do |result2, obj|
|
23
|
-
obj[key] == value ? obj : result2
|
24
|
-
end
|
25
|
-
|
26
|
-
result || error(sub_obj, key, value)
|
27
|
-
end
|
28
|
-
|
29
|
-
def error(sub_obj, key, value)
|
30
|
-
raise(Errors::ResultMatchError, {
|
31
|
-
:key => key,
|
32
|
-
:value => value,
|
33
|
-
:collection_name => sub_obj.to_s,
|
34
|
-
:sub_obj => @result[sub_obj.to_s]
|
35
|
-
})
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
log 'Testing 1 2 3!'
|
data/test/scripts/provision.sh
DELETED
data/test/test.sh
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# if ! bundle exec vagrant box list | grep haipa 1>/dev/null; then
|
2
|
-
# bundle exec vagrant box add haipa box/haipa.box
|
3
|
-
# fi
|
4
|
-
|
5
|
-
cd test
|
6
|
-
|
7
|
-
bundle exec vagrant up --provider=haipa
|
8
|
-
bundle exec vagrant up
|
9
|
-
bundle exec vagrant provision
|
10
|
-
bundle exec vagrant halt
|
11
|
-
bundle exec vagrant destroy
|
12
|
-
|
13
|
-
cd ..
|
data/test/test_id_rsa
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
-----BEGIN RSA PRIVATE KEY-----
|
2
|
-
MIIEowIBA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1XAaYg6NY4z1oU8Q9Ud0sY74tDI8TF165LStb3prf1TinwaMbOyuQ1wrNU4aMzekiwazeo6LtHMnfPjweIGP01PwjZ8WkYcRF6tt digital_ocean provider test key
|