vagrant-delphix 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 67ad7ab5e0e32a4326ad316d819f0d8e323bdeec
4
+ data.tar.gz: e6b4a52526d958d0512b2608225dd35135ba5eca
5
+ SHA512:
6
+ metadata.gz: 7a1f50fcc864ba3b883fc0207916dd85cdedf24d3138e3220fa3df22196e52bb4db1ab78310e84afbf8d925202b57bf659ed8861ee7bbb4f2692eba701c70319
7
+ data.tar.gz: a2f6f85afc83211c7bc0ca8a1a903a35d95d5b71101f2e8c03407031b58a6e21534e28cbe1705054291a877591d1eedf16b8452fe3a72bce6778c2dc19a31a49
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg/
2
+ .vagrant
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ delphix_vagrant
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.4
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.8.1'
5
+ end
6
+
7
+ group :plugins do
8
+ gemspec
9
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,114 @@
1
+ GIT
2
+ remote: git://github.com/mitchellh/vagrant.git
3
+ revision: c1c00e2f3cf69c579a5aa6922d67bb838a2de9cd
4
+ tag: v1.8.1
5
+ specs:
6
+ vagrant (1.8.1)
7
+ bundler (>= 1.5.2, <= 1.10.6)
8
+ childprocess (~> 0.5.0)
9
+ erubis (~> 2.7.0)
10
+ hashicorp-checkpoint (~> 0.1.1)
11
+ i18n (>= 0.6.0, <= 0.8.0)
12
+ listen (~> 3.0.2)
13
+ log4r (~> 1.1.9, < 1.1.11)
14
+ net-scp (~> 1.1.0)
15
+ net-sftp (~> 2.1)
16
+ net-ssh (~> 3.0.1)
17
+ nokogiri (= 1.6.3.1)
18
+ rb-kqueue (~> 0.2.0)
19
+ rest-client (>= 1.6.0, < 2.0)
20
+ wdm (~> 0.1.0)
21
+ winrm (~> 1.3)
22
+ winrm-fs (~> 0.2.2)
23
+
24
+ PATH
25
+ remote: .
26
+ specs:
27
+ vagrant-delphix (0.1.0)
28
+ delphix_rb (~> 0.3)
29
+
30
+ GEM
31
+ remote: https://rubygems.org/
32
+ specs:
33
+ builder (3.2.2)
34
+ childprocess (0.5.9)
35
+ ffi (~> 1.0, >= 1.0.11)
36
+ delphix_rb (0.3.1)
37
+ excon (~> 0.45.4)
38
+ domain_name (0.5.25)
39
+ unf (>= 0.0.5, < 1.0.0)
40
+ erubis (2.7.0)
41
+ excon (0.45.4)
42
+ ffi (1.9.10)
43
+ gssapi (1.2.0)
44
+ ffi (>= 1.0.1)
45
+ gyoku (1.3.1)
46
+ builder (>= 2.1.2)
47
+ hashicorp-checkpoint (0.1.4)
48
+ http-cookie (1.0.2)
49
+ domain_name (~> 0.5)
50
+ httpclient (2.7.1)
51
+ i18n (0.7.0)
52
+ listen (3.0.5)
53
+ rb-fsevent (>= 0.9.3)
54
+ rb-inotify (>= 0.9)
55
+ little-plugger (1.1.4)
56
+ log4r (1.1.10)
57
+ logging (1.8.2)
58
+ little-plugger (>= 1.1.3)
59
+ multi_json (>= 1.8.4)
60
+ mime-types (2.99)
61
+ mini_portile (0.6.0)
62
+ multi_json (1.11.2)
63
+ net-scp (1.1.2)
64
+ net-ssh (>= 2.6.5)
65
+ net-sftp (2.1.2)
66
+ net-ssh (>= 2.6.5)
67
+ net-ssh (3.0.2)
68
+ netrc (0.11.0)
69
+ nokogiri (1.6.3.1)
70
+ mini_portile (= 0.6.0)
71
+ nori (2.6.0)
72
+ rake (10.5.0)
73
+ rb-fsevent (0.9.7)
74
+ rb-inotify (0.9.5)
75
+ ffi (>= 0.5.0)
76
+ rb-kqueue (0.2.4)
77
+ ffi (>= 0.5.0)
78
+ rest-client (1.8.0)
79
+ http-cookie (>= 1.0.2, < 2.0)
80
+ mime-types (>= 1.16, < 3.0)
81
+ netrc (~> 0.7)
82
+ rubyntlm (0.4.0)
83
+ rubyzip (1.1.7)
84
+ unf (0.1.4)
85
+ unf_ext
86
+ unf_ext (0.0.7.1)
87
+ uuidtools (2.1.5)
88
+ wdm (0.1.1)
89
+ winrm (1.3.6)
90
+ builder (>= 2.1.2)
91
+ gssapi (~> 1.2)
92
+ gyoku (~> 1.0)
93
+ httpclient (~> 2.2, >= 2.2.0.2)
94
+ logging (>= 1.6.1, < 3.0)
95
+ nori (~> 2.0)
96
+ rubyntlm (~> 0.4.0)
97
+ uuidtools (~> 2.1.2)
98
+ winrm-fs (0.2.3)
99
+ erubis (~> 2.7)
100
+ logging (~> 1.6, >= 1.6.1)
101
+ rubyzip (~> 1.1)
102
+ winrm (~> 1.3.0)
103
+
104
+ PLATFORMS
105
+ ruby
106
+
107
+ DEPENDENCIES
108
+ bundler (~> 1.3)
109
+ rake
110
+ vagrant!
111
+ vagrant-delphix!
112
+
113
+ BUNDLED WITH
114
+ 1.10.6
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # vagrant-delphix
2
+
3
+ `vagrant-delphix` is a Vagrant 1.1+ plugin that interacts with the Delphix Engine.
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+
2
+ require 'bundler/gem_helper'
3
+
4
+ # Change to the directory of this file.
5
+ Dir.chdir(File.expand_path("../", __FILE__))
6
+
7
+ namespace :gem do
8
+ Bundler::GemHelper.install_tasks
9
+ end
10
+
11
+ task :test => [:up, :halt, :destroy] do
12
+ end
13
+
14
+ task :up do
15
+ sh 'bash test/rake_test_up.sh'
16
+ end
17
+
18
+ task :halt do
19
+ sh 'bash test/rake_test_halt.sh'
20
+ end
21
+
22
+ task :destroy => [:halt] do
23
+ sh 'bash test/rake_test_destroy.sh'
24
+ end
@@ -0,0 +1,48 @@
1
+
2
+ require 'delphix'
3
+ require 'vagrant-delphix/util'
4
+
5
+ module VagrantPlugins
6
+ module DelphixEngine
7
+ module Action
8
+
9
+ class DestroyEnvironment
10
+ include VagrantPlugins::DelphixEngine::Util
11
+
12
+ def initialize(app, env)
13
+ @app = app
14
+ @machine = env[:machine]
15
+ @global_env = @machine.env
16
+ @provider = @machine.provider_name
17
+ @logger = Log4r::Logger.new('vagrant::delphix_engine::create_environment')
18
+
19
+ @config = get_config(@machine)
20
+
21
+ end
22
+
23
+ def call(env)
24
+ # skip if machine is not active on destroy action
25
+ #return @app.call(env) if !@machine.id && env[:machine_action] == :destroy
26
+
27
+ # set the DE url
28
+ Delphix.url = @config.engine_url
29
+ Delphix.debug = @config.trace
30
+
31
+ # authenticate the connection
32
+ Delphix.authenticate!(@config.engine_user,@config.engine_password)
33
+
34
+ # lookup the environment
35
+ environments = Delphix.environments
36
+ environment = environments.lookup_by_name @config.env_name
37
+
38
+ # delete the environment from Delphix
39
+ environment.delete if environment != nil
40
+
41
+ @app.call(env)
42
+ end
43
+
44
+ end # end class
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,47 @@
1
+
2
+ require 'delphix'
3
+ require 'vagrant-delphix/util'
4
+
5
+ module VagrantPlugins
6
+ module DelphixEngine
7
+ module Action
8
+
9
+ class DisableEnvironment
10
+ include VagrantPlugins::DelphixEngine::Util
11
+
12
+ def initialize(app, env)
13
+ @app = app
14
+ @machine = env[:machine]
15
+ @global_env = @machine.env
16
+ @provider = @machine.provider_name
17
+ @logger = Log4r::Logger.new('vagrant::delphix_engine::create_environment')
18
+
19
+ @config = get_config(@machine)
20
+ end
21
+
22
+ def call(env)
23
+ # skip if machine is not active on destroy action
24
+ #return @app.call(env) if !@machine.id && env[:machine_action] == :destroy
25
+
26
+ # set the DE url
27
+ Delphix.url = @config.engine_url
28
+ Delphix.debug = @config.trace
29
+
30
+ # authenticate the connection
31
+ Delphix.authenticate!(@config.engine_user,@config.engine_password)
32
+
33
+ # lookup the environment
34
+ environments = Delphix.environments
35
+ environment = environments.lookup_by_name @config.env_name
36
+
37
+ # delete the environment from Delphix
38
+ environment.disable if environment != nil
39
+
40
+ @app.call(env)
41
+ end
42
+
43
+ end # end class
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+
2
+ require 'delphix'
3
+ require 'vagrant-delphix/util'
4
+
5
+ module VagrantPlugins
6
+ module DelphixEngine
7
+ module Action
8
+
9
+ class EnableEnvironment
10
+ include VagrantPlugins::DelphixEngine::Util
11
+
12
+ def initialize(app, env)
13
+ @app = app
14
+ @machine = env[:machine]
15
+ @global_env = @machine.env
16
+ @provider = @machine.provider_name
17
+ @logger = Log4r::Logger.new('vagrant::delphix_engine::create_environment')
18
+
19
+ @config = get_config(@machine)
20
+ end
21
+
22
+ def call(env)
23
+ # skip if machine is not active on destroy action
24
+ #return @app.call(env) if !@machine.id && env[:machine_action] == :destroy
25
+
26
+ # set the DE url
27
+ Delphix.url = @config.engine_url
28
+ Delphix.debug = @config.trace
29
+
30
+ # authenticate the connection
31
+ Delphix.authenticate!(@config.engine_user,@config.engine_password)
32
+
33
+ # lookup the environment
34
+ environments = Delphix.environments
35
+ environment = environments.lookup_by_name @config.env_name
36
+
37
+ # delete the environment from Delphix
38
+ environment.enable if environment != nil
39
+
40
+ @app.call(env)
41
+ end
42
+
43
+ end # end class
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,36 @@
1
+
2
+ require 'vagrant-delphix/action/enable_environment'
3
+ require 'vagrant-delphix/action/disable_environment'
4
+ require 'vagrant-delphix/action/destroy_environment'
5
+
6
+ module VagrantPlugins
7
+ module DelphixEngine
8
+
9
+ module Action
10
+ include Vagrant::Action::Builtin
11
+
12
+ def self.enable_environment
13
+ Vagrant::Action::Builder.new.tap do |builder|
14
+ builder.use ConfigValidate
15
+ builder.use EnableEnvironment
16
+ end
17
+ end
18
+
19
+ def self.disable_environment
20
+ Vagrant::Action::Builder.new.tap do |builder|
21
+ builder.use ConfigValidate
22
+ builder.use DisableEnvironment
23
+ end
24
+ end
25
+
26
+ def self.destroy_environment
27
+ Vagrant::Action::Builder.new.tap do |builder|
28
+ builder.use ConfigValidate
29
+ builder.use DestroyEnvironment
30
+ end
31
+ end
32
+
33
+ end # end module Action
34
+
35
+ end
36
+ end
@@ -0,0 +1,222 @@
1
+
2
+ module VagrantPlugins
3
+
4
+ module DelphixEngine
5
+
6
+ class Config < Vagrant.plugin('2', :config)
7
+
8
+ attr_accessor :enabled
9
+ attr_accessor :trace
10
+
11
+ # engine access
12
+ attr_accessor :engine_url
13
+ attr_accessor :engine_user
14
+ attr_accessor :engine_password
15
+
16
+ # env definition
17
+ attr_accessor :env_name
18
+ attr_accessor :env_ip
19
+ attr_accessor :env_port
20
+ attr_accessor :user
21
+ attr_accessor :password
22
+ attr_accessor :toolkit_path
23
+ attr_accessor :staging
24
+
25
+ def initialize
26
+ @enabled = UNSET_VALUE
27
+ @engine_url = UNSET_VALUE
28
+ @engine_user = UNSET_VALUE
29
+ @engine_password = UNSET_VALUE
30
+ @env_name = UNSET_VALUE
31
+ @env_ip = UNSET_VALUE
32
+ @env_port = UNSET_VALUE
33
+ @user = UNSET_VALUE
34
+ @password = UNSET_VALUE
35
+ @toolkit_path = UNSET_VALUE
36
+ @staging = UNSET_VALUE
37
+ @trace = UNSET_VALUE
38
+ end
39
+
40
+ def finalize!
41
+ @enabled = false if @enabled == UNSET_VALUE
42
+ @engine_url = nil if @engine_url == UNSET_VALUE
43
+ @engine_user = nil if @engine_user == UNSET_VALUE
44
+ @engine_password = nil if @engine_password == UNSET_VALUE
45
+ @env_name = nil if @env_name == UNSET_VALUE
46
+ @env_ip = nil if @env_ip == UNSET_VALUE
47
+ @env_port = 22 if @env_port == UNSET_VALUE
48
+ @user = nil if @user == UNSET_VALUE
49
+ @password = nil if @password == UNSET_VALUE
50
+ @toolkit_path = nil if @toolkit_path == UNSET_VALUE
51
+ @staging = false if @staging == UNSET_VALUE
52
+ @trace = false if @trace == UNSET_VALUE
53
+ end
54
+
55
+ def validate(machine)
56
+
57
+ errors = []
58
+ errors << validate_bool('delphix.enabled', @enabled)
59
+
60
+ if @enabled
61
+
62
+ # check if all values are present and of the correct type
63
+
64
+ if machine.config.delphix.staging.nil?
65
+ errors << I18n.t('vagrant_delphix.config.not_defined', {
66
+ :config_key => 'delphix.staging',
67
+ })
68
+ else
69
+ v = validate_bool('delphix.staging', machine.config.delphix.staging)
70
+ errors << v if v != nil
71
+ end
72
+
73
+ if machine.config.delphix.user.nil?
74
+ errors << I18n.t('vagrant_delphix.config.not_defined', {
75
+ :config_key => 'delphix.user',
76
+ })
77
+ else
78
+ if !machine.config.delphix.user.nil? &&
79
+ !machine.config.delphix.user.kind_of?(String)
80
+ errors << I18n.t('vagrant_delphix.config.not_a_string', {
81
+ :config_key => 'delphix.user',
82
+ :is_class => user.class.to_s,
83
+ })
84
+ end
85
+ end
86
+
87
+ if machine.config.delphix.password.nil?
88
+ errors << I18n.t('vagrant_delphix.config.not_defined', {
89
+ :config_key => 'delphix.password',
90
+ })
91
+ else
92
+ if !machine.config.delphix.password.nil? &&
93
+ !machine.config.delphix.password.kind_of?(String)
94
+ errors << I18n.t('vagrant_delphix.config.not_a_string', {
95
+ :config_key => 'delphix.password',
96
+ :is_class => password.class.to_s,
97
+ })
98
+ end
99
+ end
100
+
101
+ if machine.config.delphix.toolkit_path.nil?
102
+ errors << I18n.t('vagrant_delphix.config.not_defined', {
103
+ :config_key => 'delphix.toolkit_path',
104
+ })
105
+ else
106
+ if !machine.config.delphix.toolkit_path.nil? &&
107
+ !machine.config.delphix.toolkit_path.kind_of?(String)
108
+ errors << I18n.t('vagrant_delphix.config.not_a_string', {
109
+ :config_key => 'delphix.toolkit_path',
110
+ :is_class => toolkit_path.class.to_s,
111
+ })
112
+ end
113
+ end
114
+
115
+ if machine.config.delphix.env_name.nil?
116
+ errors << I18n.t('vagrant_delphix.config.not_defined', {
117
+ :config_key => 'delphix.env_name',
118
+ })
119
+ else
120
+ if !machine.config.delphix.env_name.nil? &&
121
+ !machine.config.delphix.env_name.kind_of?(String)
122
+ errors << I18n.t('vagrant_delphix.config.not_a_string', {
123
+ :config_key => 'delphix.env_name',
124
+ :is_class => env_name.class.to_s,
125
+ })
126
+ end
127
+ end
128
+
129
+ if machine.config.delphix.env_ip.nil?
130
+ errors << I18n.t('vagrant_delphix.config.not_defined', {
131
+ :config_key => 'delphix.env_ip',
132
+ })
133
+ else
134
+ if !machine.config.delphix.env_ip.nil? &&
135
+ !machine.config.delphix.env_ip.kind_of?(String)
136
+ errors << I18n.t('vagrant_delphix.config.not_a_string', {
137
+ :config_key => 'delphix.env_ip',
138
+ :is_class => env_ip.class.to_s,
139
+ })
140
+ end
141
+ end
142
+
143
+ if machine.config.delphix.env_port.nil?
144
+ errors << I18n.t('vagrant_delphix.config.not_defined', {
145
+ :config_key => 'delphix.env_port',
146
+ })
147
+ else
148
+ if !machine.config.delphix.env_port.nil? &&
149
+ !machine.config.delphix.env_port.kind_of?(Fixnum)
150
+ errors << I18n.t('vagrant_delphix.config.not_a_number', {
151
+ :config_key => 'delphix.env_port',
152
+ :is_class => env_ip.class.to_s,
153
+ })
154
+ end
155
+ end
156
+
157
+ if machine.config.delphix.engine_url.nil?
158
+ errors << I18n.t('vagrant_delphix.config.not_defined', {
159
+ :config_key => 'delphix.engine_url',
160
+ })
161
+ else
162
+ if !machine.config.delphix.engine_url.nil? &&
163
+ !machine.config.delphix.engine_url.kind_of?(String)
164
+ errors << I18n.t('vagrant_delphix.config.not_a_string', {
165
+ :config_key => 'delphix.engine_url',
166
+ :is_class => engine_url.class.to_s,
167
+ })
168
+ end
169
+ end
170
+
171
+ if machine.config.delphix.engine_user.nil?
172
+ errors << I18n.t('vagrant_delphix.config.not_defined', {
173
+ :config_key => 'delphix.engine_user',
174
+ })
175
+ else
176
+ if !machine.config.delphix.engine_user.nil? &&
177
+ !machine.config.delphix.engine_user.kind_of?(String)
178
+ errors << I18n.t('vagrant_delphix.config.not_a_string', {
179
+ :config_key => 'delphix.engine_user',
180
+ :is_class => engine_user.class.to_s,
181
+ })
182
+ end
183
+ end
184
+
185
+ if machine.config.delphix.engine_password.nil?
186
+ errors << I18n.t('vagrant_delphix.config.not_defined', {
187
+ :config_key => 'delphix.engine_password',
188
+ })
189
+ else
190
+ if !machine.config.delphix.engine_password.kind_of?(String)
191
+ errors << I18n.t('vagrant_delphix.config.not_a_string', {
192
+ :config_key => 'delphix.engine_password',
193
+ :is_class => engine_password.class.to_s,
194
+ })
195
+ end
196
+ end
197
+
198
+ end
199
+
200
+ errors.compact!
201
+ { "Delphix configuration" => errors }
202
+ end
203
+
204
+ private
205
+
206
+ def validate_bool(key, value)
207
+ if ![TrueClass, FalseClass].include?(value.class) &&
208
+ value != UNSET_VALUE
209
+ I18n.t('vagrant_delphix.config.not_a_bool', {
210
+ :config_key => key,
211
+ :value => value.class.to_s
212
+ })
213
+ else
214
+ nil
215
+ end
216
+ end
217
+
218
+ end # class Config
219
+
220
+ end # module Delphix
221
+
222
+ end # module VagrantPlugins
@@ -0,0 +1,7 @@
1
+
2
+ module VagrantPlugins
3
+ module DelphixEngine
4
+ module Errors
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,53 @@
1
+
2
+ require 'delphix'
3
+ require 'vagrant-delphix/action'
4
+
5
+ module VagrantPlugins
6
+ module DelphixEngine
7
+
8
+ class Plugin < Vagrant.plugin('2')
9
+ name 'DelphixEngine'
10
+ description <<-DESC
11
+ This plugin manages Delphix Engine
12
+ DESC
13
+
14
+ config(:delphix) do
15
+ require_relative 'config'
16
+ Config
17
+ end
18
+
19
+ #action_hook(:delphix, :machine_action_up) do |hook|
20
+ #hook.after(Vagrant::Action::Builtin::Provision, Action.enable_environment)
21
+ #end
22
+
23
+ action_hook(:delphix, :machine_action_resume) do |hook|
24
+ hook.after(Vagrant::Action::Builtin::Provision, Action.enable_environment)
25
+ end
26
+
27
+ action_hook(:delphix, :machine_action_halt) do |hook|
28
+ hook.prepend(Action.disable_environment)
29
+ end
30
+
31
+ action_hook(:delphix, :machine_action_suspend) do |hook|
32
+ hook.prepend(Action.disable_environment)
33
+ end
34
+
35
+ action_hook(:delphix, :machine_action_destroy) do |hook|
36
+ hook.prepend(Action.destroy_environment)
37
+ end
38
+
39
+ provisioner(:delphix) do
40
+ require_relative 'provisioner'
41
+ Provisioner
42
+ end
43
+
44
+ # Work-around for vagrant >= 1.5
45
+ # It breaks without a provisioner config, so we provide a dummy one
46
+ config(:delphix, :provisioner) do
47
+ ::Vagrant::Config::V2::DummyConfig.new
48
+ end
49
+
50
+ end # end class Plugin
51
+
52
+ end
53
+ end
@@ -0,0 +1,44 @@
1
+
2
+ require 'delphix'
3
+ require 'vagrant-delphix/util'
4
+
5
+ module VagrantPlugins
6
+ module DelphixEngine
7
+
8
+ class Provisioner < Vagrant.plugin('2', :provisioner)
9
+ include VagrantPlugins::DelphixEngine::Util
10
+
11
+ def initialize(machine, config)
12
+ super(machine, config)
13
+
14
+ @config = get_config(machine)
15
+
16
+ end
17
+
18
+ def provision
19
+
20
+ # set the DE url
21
+ Delphix.url = @config.engine_url
22
+ Delphix.debug = @config.trace
23
+
24
+ # authenticate the connection
25
+ Delphix.authenticate!(@config.engine_user,@config.engine_password)
26
+
27
+ # lookup the environment
28
+ environments = Delphix.environments
29
+ environment = environments.lookup_by_name @config.env_name
30
+
31
+ if environment == nil
32
+ # ceate a new environment
33
+ environment = Delphix::Environment.create @config.env_name, @config.env_ip, @config.env_port, @config.toolkit_path, @config.user, @config.password
34
+ else
35
+ # enable the environment
36
+ environment.enable
37
+ end
38
+
39
+ end
40
+
41
+ end # end Class
42
+
43
+ end
44
+ end
@@ -0,0 +1,16 @@
1
+
2
+ module VagrantPlugins
3
+ module DelphixEngine
4
+
5
+ module Util
6
+
7
+ def get_config(machine)
8
+ config = machine.config.delphix
9
+ config.merge(machine.env.vagrantfile.config.delphix)
10
+ config
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module DelphixEngine
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+
2
+ require 'vagrant-delphix/version'
3
+ require 'vagrant-delphix/plugin'
4
+ require 'vagrant-delphix/errors'
5
+
6
+ module VagrantPlugins
7
+ module DelphixEngine
8
+
9
+ def self.source_root
10
+ @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
11
+ end
12
+
13
+ I18n.load_path << File.expand_path('locales/en.yml', source_root)
14
+ I18n.reload!
15
+ end
16
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,13 @@
1
+ en:
2
+ vagrant_delphix:
3
+ action:
4
+ update_guests: "Updating /etc/hosts file on active guest machines..."
5
+ update_guest: "[%{name}] Updating /etc/hosts file..."
6
+ update_host: "Updating /etc/hosts file on host machine (password may be required)..."
7
+ config:
8
+ not_a_bool: "A value for %{config_key} can only be true or false, not type '%{value}'"
9
+ not_a_string: "A value for %{config_key} must be a String, not type '%{is_class}'"
10
+ not_a_number: "A value for %{config_key} must be a Number, not type '%{is_class}'"
11
+ not_an_array_or_string: "A value for %{config_key} must be an Array or String, not type '%{is_class}'"
12
+ not_a_proc: "A value for %{config_key} must be a Proc, not type '%{is_class}'"
13
+ not_defined: "Configuration of property '%{config_key}' is missing."
data/test/Vagrantfile ADDED
@@ -0,0 +1,63 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+ # box sizing
8
+ VB_MEMORY=1024
9
+ VB_CPUS=1
10
+
11
+ # generic setup
12
+ DOMAIN_NAME="delphix.local"
13
+
14
+ # env variables that point to the Delphix Engine
15
+ DELPHIX_ENGINE_IP ||= ENV['DELPHIX_ENGINE_IP'] || '172.16.138.157'
16
+ VMWARE_NETWORK_ADAPTER ||= ENV['VMWARE_NETWORK_ADAPTER'] || 'vmnet8'
17
+
18
+ IP_BASE = DELPHIX_ENGINE_IP.split('.')[0..2].join('.')
19
+
20
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
21
+
22
+ # Every Vagrant environment requires a box to build off of.
23
+ config.vm.box = "bento/centos-6.7"
24
+
25
+ # size of the box
26
+ config.vm.provider :virtualbox do |vb|
27
+ vb.memory = VB_MEMORY
28
+ vb.cpus = VB_CPUS
29
+ end
30
+
31
+ #config the delphix provisioner
32
+ config.delphix.enabled = true
33
+ config.delphix.engine_url = "http://172.16.138.157"
34
+ config.delphix.engine_user = 'delphix_admin'
35
+ config.delphix.engine_password = 'delphix'
36
+
37
+ # tasks for all environments
38
+ config.vm.provision "shell", path: "prepare_delphix.sh"
39
+
40
+ config.vm.define "source" do |node|
41
+
42
+ # networking
43
+ public_ipv4 = "#{IP_BASE}.42"
44
+ node.vm.hostname = "source.#{DOMAIN_NAME}"
45
+ node.vm.network "public_network", ip: public_ipv4, bridge: VMWARE_NETWORK_ADAPTER
46
+
47
+ # configure the Delphix provisioner
48
+ node.delphix.trace = false
49
+ node.delphix.env_name = "source"
50
+ node.delphix.env_ip = public_ipv4
51
+ node.delphix.env_port = 22
52
+ node.delphix.user = 'delphix'
53
+ node.delphix.password = 'delphix'
54
+ node.delphix.toolkit_path = '/home/delphix/toolkit'
55
+
56
+ # execute the Delphix provisioner.
57
+ node.vm.provision :delphix, run: "always"
58
+ # option run: "always" is a MUST for now,
59
+ # otherwise the environment will not be re-enabled once the VM has been shut doen ...
60
+
61
+ end
62
+
63
+ end
@@ -0,0 +1,24 @@
1
+ #!/bin/bash
2
+
3
+ # create locations for app and Delphix engine toolkit
4
+ export SETUP_HOME=/home/delphix
5
+ export TOOLKIT_HOME=$SETUP_HOME/toolkit
6
+
7
+ sudo echo "# DELPHIX #" >> /etc/profile
8
+ sudo echo "export SETUP_HOME=/home/delphix" >> /etc/profile
9
+ sudo echo "export TOOLKIT_HOME=$SETUP_HOME/toolkit" >> /etc/profile
10
+
11
+ # create a delphix user
12
+ useradd delphix
13
+ echo delphix | passwd delphix --stdin
14
+
15
+ # toolkit location
16
+ sudo mkdir -p $TOOLKIT_HOME
17
+ chown delphix:delphix $TOOLKIT_HOME
18
+ chmod 0770 $TOOLKIT_HOME
19
+
20
+ # add the user to wheel, i.e. sudoer group
21
+ sudo usermod -a -G wheel delphix
22
+
23
+ # add some requ.
24
+ sudo yum -y install glibc.i686 java-1.7.0-openjdk
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ cd test
4
+
5
+ vagrant destroy -f
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ cd test
4
+
5
+ vagrant halt
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ cd test
4
+
5
+ vagrant up
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'vagrant-delphix/version'
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.name = 'vagrant-delphix'
9
+ gem.version = VagrantPlugins::DelphixEngine::VERSION
10
+ gem.authors = ['Michael Kuehl']
11
+ gem.email = ['michael.kuehl@delphix.com']
12
+ gem.description = %q{A Vagrant plugin that interacts with the Delphix Engine}
13
+ gem.summary = gem.description
14
+ gem.license = 'MIT'
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ['lib']
19
+
20
+ gem.add_development_dependency 'bundler', '~> 1.3'
21
+ gem.add_development_dependency 'rake'
22
+
23
+ gem.add_dependency 'delphix_rb', '~> 0.3'
24
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-delphix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Kuehl
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: delphix_rb
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.3'
55
+ description: A Vagrant plugin that interacts with the Delphix Engine
56
+ email:
57
+ - michael.kuehl@delphix.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".ruby-gemset"
64
+ - ".ruby-version"
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - README.md
68
+ - Rakefile
69
+ - lib/vagrant-delphix.rb
70
+ - lib/vagrant-delphix/action.rb
71
+ - lib/vagrant-delphix/action/destroy_environment.rb
72
+ - lib/vagrant-delphix/action/disable_environment.rb
73
+ - lib/vagrant-delphix/action/enable_environment.rb
74
+ - lib/vagrant-delphix/config.rb
75
+ - lib/vagrant-delphix/errors.rb
76
+ - lib/vagrant-delphix/plugin.rb
77
+ - lib/vagrant-delphix/provisioner.rb
78
+ - lib/vagrant-delphix/util.rb
79
+ - lib/vagrant-delphix/version.rb
80
+ - locales/en.yml
81
+ - test/Vagrantfile
82
+ - test/prepare_delphix.sh
83
+ - test/rake_test_destroy.sh
84
+ - test/rake_test_halt.sh
85
+ - test/rake_test_up.sh
86
+ - vagrant-delphix.gemspec
87
+ homepage:
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.4.8
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: A Vagrant plugin that interacts with the Delphix Engine
111
+ test_files:
112
+ - test/Vagrantfile
113
+ - test/prepare_delphix.sh
114
+ - test/rake_test_destroy.sh
115
+ - test/rake_test_halt.sh
116
+ - test/rake_test_up.sh