vagrant-arubacloud 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Vagrantfile_base ADDED
@@ -0,0 +1,23 @@
1
+ VAGRANTFILE_API_VERSION = '2'
2
+ %w{AC_USERNAME AC_PASSWORD}.each do |var|
3
+ abort "Please set the environment variable #{var} in order to run the test" unless ENV.key? var
4
+ end
5
+
6
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7
+ config.vm.box = "dummy"
8
+ config.vm.define :vmvgr01 do |vmvgr01_config|
9
+ vmvgr01_config.ssh.username = 'root'
10
+ vmvgr01_config.ssh.password = 'test123'
11
+ vmvgr01_config.vm.synced_folder ".", "/vagrant", disabled: true
12
+ vmvgr01_config.vm.provider :arubacloud do |ac, ac_override|
13
+ ac_override.nfs.functional = false # no nfs start
14
+ ac.arubacloud_username = ENV['AC_USERNAME']
15
+ ac.arubacloud_password = ENV['AC_PASSWORD']
16
+ ac.service_type = 4
17
+ ac.endpoint = "dc2"
18
+ ac.template_id = '601'
19
+ ac.server_name = 'lnxtestvag1'
20
+ ac.package_id = 'small'
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,108 @@
1
+ VAGRANTFILE_API_VERSION = '2'
2
+ %w{AC_USERNAME AC_PASSWORD}.each do |var|
3
+ abort "Please set the environment variable #{var} in order to run the test" unless ENV.key? var
4
+ end
5
+
6
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7
+ config.vm.box = "dummy"
8
+ config.vm.define :vmvgr01 do |vmvgr01_config|
9
+ vmvgr01_config.ssh.username = 'root'
10
+ vmvgr01_config.ssh.password = 'test123'
11
+ vmvgr01_config.vm.synced_folder ".", "/vagrant", disabled: true
12
+ vmvgr01_config.vm.synced_folder "/hostshare2", "/guestshare_norm"
13
+ vmvgr01_config.vm.provision "shell" do |s|
14
+ s.inline = "echo 'test start script ok'"
15
+ end
16
+ vmvgr01_config.vm.provider :arubacloud do |ac, ac_override|
17
+ ac_override.nfs.functional = false # no nfs start
18
+ ac.arubacloud_username = ENV['AC_USERNAME']
19
+ ac.arubacloud_password = ENV['AC_PASSWORD']
20
+ ac.service_type = 4
21
+ ac.endpoint = "dc2"
22
+ ac.template_id = '601'
23
+ ac.server_name = 'lnxtestvaga'
24
+ ac.package_id = 'small'
25
+ end
26
+ end
27
+ #
28
+ config.vm.define :vmvgr02 do |vmvgr02_config|
29
+ vmvgr02_config.ssh.username = 'root'
30
+ vmvgr02_config.ssh.password = 'test123'
31
+ vmvgr02_config.vm.synced_folder ".", "/vagrant", disabled: true
32
+ vmvgr02_config.vm.synced_folder "/hostshare2", "/guestshare_norm"
33
+ vmvgr02_config.vm.provision "shell" do |s|
34
+ s.inline = "echo 'test2 start script ok'"
35
+ end
36
+ vmvgr02_config.vm.provider :arubacloud do |ac, ac_override|
37
+ ac_override.nfs.functional = false # no nfs start
38
+ ac.arubacloud_username = ENV['AC_USERNAME']
39
+ ac.arubacloud_password = ENV['AC_PASSWORD']
40
+ ac.service_type = 4
41
+ ac.endpoint = "dc2"
42
+ ac.template_id = '601'
43
+ ac.server_name = 'lnxtestvagb'
44
+ ac.package_id = 'small'
45
+ end
46
+ end
47
+ #
48
+ config.vm.define :vmvgr03 do |vmvgr03_config|
49
+ vmvgr03_config.ssh.username = 'root'
50
+ vmvgr03_config.ssh.password = 'test123'
51
+ vmvgr03_config.vm.synced_folder ".", "/vagrant", disabled: true
52
+ vmvgr03_config.vm.synced_folder "/hostshare2", "/guestshare_norm"
53
+ vmvgr03_config.vm.provision "shell" do |s|
54
+ s.inline = "echo 'test machine 3 start script ok'"
55
+ end
56
+ vmvgr03_config.vm.provider :arubacloud do |ac, ac_override|
57
+ ac_override.nfs.functional = false # no nfs start
58
+ ac.arubacloud_username = ENV['AC_USERNAME']
59
+ ac.arubacloud_password = ENV['AC_PASSWORD']
60
+ ac.service_type = 4
61
+ ac.endpoint = "dc2"
62
+ ac.template_id = '601'
63
+ ac.server_name = 'lnxtestvagc'
64
+ ac.package_id = 'small'
65
+ end
66
+ end
67
+ #
68
+ config.vm.define :vmvgr04 do |vmvgr04_config|
69
+ vmvgr04_config.ssh.username = 'root'
70
+ vmvgr04_config.ssh.password = 'test123'
71
+ vmvgr04_config.vm.synced_folder ".", "/vagrant", disabled: true
72
+ vmvgr04_config.vm.synced_folder "/hostshare2", "/guestshare_norm"
73
+ vmvgr04_config.vm.provision "shell" do |s|
74
+ s.inline = "echo 'test machine 04 start script ok'"
75
+ end
76
+ vmvgr04_config.vm.provider :arubacloud do |ac, ac_override|
77
+ ac_override.nfs.functional = false # no nfs start
78
+ ac.arubacloud_username = ENV['AC_USERNAME']
79
+ ac.arubacloud_password = ENV['AC_PASSWORD']
80
+ ac.service_type = 4
81
+ ac.endpoint = "dc2"
82
+ ac.template_id = '601'
83
+ ac.server_name = 'lnxtestvagd'
84
+ ac.package_id = 'medium'
85
+ end
86
+ end
87
+ #
88
+ config.vm.define :vmvgr05 do |vmvgr05_config|
89
+ vmvgr05_config.ssh.username = 'root'
90
+ vmvgr05_config.ssh.password = 'test123'
91
+ vmvgr05_config.vm.synced_folder ".", "/vagrant", disabled: true
92
+ vmvgr05_config.vm.synced_folder "/hostshare2", "/guestshare_norm"
93
+ vmvgr05_config.vm.provision "shell" do |s|
94
+ s.inline = "echo 'test machine 5 start script ok'"
95
+ end
96
+ vmvgr05_config.vm.provider :arubacloud do |ac, ac_override|
97
+ ac_override.nfs.functional = false # no nfs start
98
+ ac.arubacloud_username = ENV['AC_USERNAME']
99
+ ac.arubacloud_password = ENV['AC_PASSWORD']
100
+ ac.service_type = 4
101
+ ac.endpoint = "dc2"
102
+ ac.template_id = '601'
103
+ ac.server_name = 'lnxtestvage'
104
+ ac.package_id = 'small'
105
+ end
106
+ end
107
+
108
+ end
@@ -0,0 +1,22 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
4
+
5
+ VAGRANTFILE_API_VERSION = '2'
6
+ %w{AC_USERNAME AC_PASSWORD}.each do |var|
7
+ abort "Please set the environment variable #{var} in order to run the test" unless ENV.key? var
8
+ end
9
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
10
+ config.vm.box = "dummy"
11
+ config.vm.define :vmvgr01 do |vmvgr01_config|
12
+ vmvgr01_config.ssh.password = 'dummy'
13
+ vmvgr01_config.vm.provider :arubacloud do |ac|
14
+ ac.arubacloud_username = ENV['AC_USERNAME']
15
+ ac.arubacloud_password = ENV['AC_PASSWORD']
16
+ ac.service_type = 4
17
+ ac.endpoint = "dc2"
18
+ ac.template_id = 'dummy'
19
+ ac.package_id = 'dummy'
20
+ end
21
+ end
22
+ end
data/Vagrantfile_pro ADDED
@@ -0,0 +1,32 @@
1
+ VAGRANTFILE_API_VERSION = '2'
2
+ %w{AC_USERNAME AC_PASSWORD}.each do |var|
3
+ abort "Please set the environment variable #{var} in order to run the test" unless ENV.key? var
4
+ end
5
+
6
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7
+ config.vm.box = "dummy"
8
+ config.vm.define :vmvgr01 do |vmvgr01_config|
9
+ vmvgr01_config.ssh.username = 'root'
10
+ vmvgr01_config.ssh.password = 'test123'
11
+ vmvgr01_config.vm.synced_folder ".", "/vagrant", disabled: true
12
+ vmvgr01_config.vm.synced_folder "/hostshare2", "/guestshare_norm"
13
+ vmvgr01_config.vm.provision "shell" do |s|
14
+ s.inline = "echo 'test start script ok'"
15
+ end
16
+ vmvgr01_config.vm.provider :arubacloud do |ac, ac_override|
17
+ ac_override.nfs.functional = false # no nfs start
18
+ ac.arubacloud_username = ENV['AC_USERNAME']
19
+ ac.arubacloud_password = ENV['AC_PASSWORD']
20
+ #
21
+ ac.service_type = 2
22
+ ac.endpoint = "dc2"
23
+ ac.cpu_number = 2
24
+ ac.ram_qty = 6
25
+ ac.hds = [{:type => 0, :size => 20}, {:type => 1, :size => 30}]
26
+ #
27
+ # CentOS 7.x 64bit with pro VmWare
28
+ ac.template_id = '691'
29
+ ac.server_name = 'lnxprotstvag2'
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,27 @@
1
+ VAGRANTFILE_API_VERSION = '2'
2
+ %w{AC_USERNAME AC_PASSWORD}.each do |var|
3
+ abort "Please set the environment variable #{var} in order to run the test" unless ENV.key? var
4
+ end
5
+
6
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7
+ config.vm.box = "dummy"
8
+ config.vm.define :vmvgr01 do |vmvgr01_config|
9
+ vmvgr01_config.ssh.username = 'root'
10
+ vmvgr01_config.ssh.password = 'test123'
11
+ vmvgr01_config.vm.synced_folder ".", "/vagrant", disabled: true
12
+ vmvgr01_config.vm.synced_folder "/hostshare2", "/guestshare_norm"
13
+ vmvgr01_config.vm.provision "shell" do |s|
14
+ s.inline = "echo 'test start script ok'"
15
+ end
16
+ vmvgr01_config.vm.provider :arubacloud do |ac, ac_override|
17
+ ac_override.nfs.functional = false # no nfs start
18
+ ac.arubacloud_username = ENV['AC_USERNAME']
19
+ ac.arubacloud_password = ENV['AC_PASSWORD']
20
+ ac.service_type = 4
21
+ ac.endpoint = "dc2"
22
+ ac.template_id = '601'
23
+ ac.server_name = 'lnxtestvag1'
24
+ ac.package_id = 'small'
25
+ end
26
+ end
27
+ end
data/cloud1.png ADDED
Binary file
@@ -45,6 +45,20 @@ module VagrantPlugins
45
45
  end
46
46
  end
47
47
 
48
+ def self.action_start
49
+ Vagrant::Action::Builder.new.tap do |b|
50
+ b.use ConfigValidate
51
+ b.use Call, IsCreated do |env, b1|
52
+ unless env[:result]
53
+ b1.use MessageNotCreated
54
+ next
55
+ end
56
+ b1.use ConnectArubaCloud
57
+ b1.use StartServer
58
+ end
59
+ end
60
+ end
61
+
48
62
  def self.action_provision
49
63
  Vagrant::Action::Builder.new.tap do |b|
50
64
  b.use ConfigValidate
@@ -60,11 +74,39 @@ module VagrantPlugins
60
74
  end
61
75
  end
62
76
 
63
- #def self.action_reload
64
- #Vagrant::Action::Builder.new.tap do |b|
77
+ def self.action_reload
78
+ Vagrant::Action::Builder.new.tap do |b|
79
+ b.use ConfigValidate
80
+ b.use ConnectArubaCloud
65
81
 
66
- #end
67
- #end
82
+ b.use Call, IsCreated do |env, b2|
83
+ if !env[:result]
84
+ b2.use MessageNotCreated
85
+ next
86
+ end
87
+ b2.use action_halt
88
+ # if not stopped , signal and exit
89
+ b2.use Call, IsState, Fog::ArubaCloud::Compute::Server::STOPPED do |envr, br|
90
+ if !envr[:result]
91
+ br.use Message, ' The server not respond at power off request.'
92
+ next
93
+ end
94
+ end
95
+ # VM is power off ; now can be powered on
96
+ b2.use action_start
97
+ b2.use Call, IsCreated do |env3, b3|
98
+ unless env3[:result]
99
+ b3.use Message, ' The server not re-create or not started '
100
+ next
101
+ end
102
+ # Use our custom provisioning class
103
+ b3.use ConnectArubaCloud
104
+ b3.use WaitForCommunicator
105
+ b3.use SyncedFolders
106
+ end
107
+ end
108
+ end
109
+ end
68
110
 
69
111
  def self.action_read_ssh_info
70
112
  Vagrant::Action::Builder.new.tap do |b|
@@ -120,11 +162,10 @@ module VagrantPlugins
120
162
  b2.use MessageAlreadyCreated
121
163
  next
122
164
  end
123
-
124
165
  b2.use ConnectArubaCloud
125
- # b2.use RunInitScript # temporarily removed
126
166
  b2.use CreateServer
127
167
  b2.use WaitForCommunicator
168
+ b2.use SyncedFolders
128
169
  end
129
170
  end
130
171
  end
@@ -148,13 +189,13 @@ module VagrantPlugins
148
189
  autoload :ConnectArubaCloud, action_root.join('connect_arubacloud')
149
190
  autoload :CreateServer, action_root.join('create_server')
150
191
  autoload :HaltServer, action_root.join('halt_server')
192
+ autoload :StartServer, action_root.join('start_server')
151
193
  autoload :DeleteServer, action_root.join('delete_server')
152
194
  autoload :IsCreated, action_root.join('is_created')
153
195
  autoload :MessageNotCreated, action_root.join('message_not_created')
154
196
  autoload :MessageAlreadyCreated, action_root.join('message_already_created')
155
197
  autoload :ReadSSHInfo, action_root.join('read_ssh_info')
156
198
  autoload :ReadState, action_root.join('read_state')
157
- # autoload :RunInitScript, action_root.join("run_init_script")
158
199
  autoload :ListServers, action_root.join('list_servers')
159
200
  autoload :ListTemplates, action_root.join('list_templates')
160
201
  autoload :ArubaProvision, action_root.join('aruba_provision')
@@ -16,6 +16,7 @@ module VagrantPlugins
16
16
  config = env[:machine].provider_config
17
17
  arubacloud_username = config.arubacloud_username
18
18
  arubacloud_password = config.arubacloud_password
19
+ arubacloud_dc = config.endpoint
19
20
 
20
21
  params = {
21
22
  :provider => :arubacloud,
@@ -24,7 +25,7 @@ module VagrantPlugins
24
25
  }
25
26
 
26
27
  if config.url
27
- @logger.info("Connecting to Datacenter: #{config.url}")
28
+ @logger.info("Connecting to Datacenter: #{arubacloud_dc} url: #{config.url} ")
28
29
  params[:url] = config.url
29
30
  end
30
31
 
@@ -35,4 +36,4 @@ module VagrantPlugins
35
36
  end
36
37
  end
37
38
  end
38
- end
39
+ end
@@ -18,52 +18,63 @@ module VagrantPlugins
18
18
 
19
19
  def call(env)
20
20
  config = env[:machine].provider_config
21
+ arubacloud_dc = config.endpoint
22
+ tb_package_id = {'small' => 'CPU: 1, Ram(GB): 1, DiskSize(GB): 20',
23
+ 'medium' => 'CPU: 1, Ram(GB): 2, DiskSize(GB): 40',
24
+ 'large' => 'CPU: 2, Ram(GB): 4, DiskSize(GB): 80',
25
+ 'extra large' => 'CPU: 4, Ram(GB): 8, DiskSize(GB): 160'
26
+ }
27
+ tb_package_id.default = " *unknow package_id* "
21
28
 
22
- env[:ui].info('Creating machine...')
29
+ sshpwd = env[:machine].config.ssh.password
23
30
 
24
31
  # Set Server Name
25
32
  server_name = config.server_name || env[:machine].name
26
33
 
27
34
  # Output the settings we're going to use to the user
28
35
  env[:ui].info('Creating a server with the following settings...')
29
- env[:ui].info(" -- Name: #{server_name}")
30
- env[:ui].info(" -- Root Password: #{config.admin_password}")
31
- env[:ui].info(" -- Package: #{config.package_id}")
32
- env[:ui].info(" -- OS Template: #{config.template_id}")
33
- env[:ui].info(" -- Service Type: #{config.service_type}")
34
-
36
+ env[:ui].info(" -- Datacenter: #{arubacloud_dc}")
37
+ env[:ui].info(" -- Name: #{server_name}")
38
+ env[:ui].info(" -- Root Password: #{sshpwd}")
35
39
  # Build the config hash according to the service type
36
40
  if config.service_type.eql? 4
37
41
  options = {
38
42
  :name => server_name,
39
43
  :vm_type => 'smart',
40
- :admin_passwd => config.admin_password,
44
+ :admin_passwd => sshpwd,
41
45
  :cpu => 1,
42
46
  :memory => 1,
43
47
  :template_id => config.template_id,
44
48
  :package_id => config.package_id
45
49
  }
50
+ env[:ui].info(" -- Package: #{config.package_id} config as: #{tb_package_id[config.package_id]}")
51
+
46
52
  else
47
53
  # Processing hds
48
54
  disks = []
55
+ accum = "["
49
56
  config.hds.each do |disk_spec|
50
57
  disks << env[:arubacloud_compute].disks.create({
51
58
  :size => disk_spec[:size],
52
- :virtual_disk_type => disk_spec[:type]
53
- })
54
- .get_hash
59
+ :virtual_disk_type => disk_spec[:type]}).get_hash
60
+ accum += "(hd#{disk_spec[:type]}: #{disk_spec[:size]})"
55
61
  end
62
+ accum += "]"
56
63
  options = {
57
64
  :name => server_name,
58
65
  :vm_type => 'pro',
59
- :admin_passwd => config.admin_password,
66
+ :admin_passwd => sshpwd,
60
67
  :cpu => config.cpu_number,
61
68
  :memory => config.ram_qty,
62
69
  :template_id => config.template_id,
63
70
  :disks => disks
64
71
  }
72
+ env[:ui].info(" -- Config as: CPU: #{config.cpu_number}, Ram(GB): #{config.ram_qty}, Disk(GB): #{accum} ")
65
73
  end
66
74
 
75
+ env[:ui].info(" -- OS Template: #{config.template_id}")
76
+ env[:ui].info(" -- Service Type: #{config.service_type} (#{options[:vm_type]}) ")
77
+
67
78
  # Create the server
68
79
  begin
69
80
  server = env[:arubacloud_compute].servers.create(options)
@@ -87,14 +98,14 @@ module VagrantPlugins
87
98
  env[:machine].id = server.id
88
99
 
89
100
  # Wait for ssh to be ready
90
- env[:ui].info('Waiting for the server to be ready...')
101
+ env[:ui].info(" [#{arubacloud_dc}] " + 'Waiting until server is ready...')
91
102
 
92
- retryable(:tries => 10, :sleep => 60) do
103
+ retryable(:tries => 20, :sleep => 45) do
93
104
  next if env[:interrupted]
94
105
  server.wait_for(5) { ready? }
95
106
  end
96
107
 
97
- env[:ui].info('The server is ready!')
108
+ env[:ui].info(" [#{arubacloud_dc}] " + 'The server is ready!')
98
109
 
99
110
  @app.call(env)
100
111
  end
@@ -102,4 +113,4 @@ module VagrantPlugins
102
113
  end
103
114
  end
104
115
  end
105
- end
116
+ end
@@ -13,7 +13,9 @@ module VagrantPlugins
13
13
 
14
14
  def call(env)
15
15
  if env[:machine].id
16
- env[:ui].info(I18n.t('vagrant_arubacloud.deleting_server'))
16
+ config = env[:machine].provider_config
17
+ arubacloud_dc = config.endpoint
18
+ env[:ui].info(" [#{arubacloud_dc}] " + I18n.t('vagrant_arubacloud.deleting_server'))
17
19
  # On fog side, get will call get_service_details, I must be sure
18
20
  # that the returned object has the "id" parameters not nil
19
21
  server = env[:arubacloud_compute].servers.get(env[:machine].id)