vagrant-conoha 0.1.6 → 0.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f9e567b352ad7363774274cbea6550bbf01c1dc
4
- data.tar.gz: 8c691159e46f9782317a64153f4b48f58e0bd3c6
3
+ metadata.gz: f5f6d8e918ef420c86161b4975201a0c2a8a7f57
4
+ data.tar.gz: bfed2b1a52dd42baabdc1d9bea2517372fa166ca
5
5
  SHA512:
6
- metadata.gz: c5fd61edd482dca4ca1df193b44791ef3b65eb8ab9741c2edad453eda19761a9e313746e286e0d9577a6150f98301032313fe819e65053c5570e9288f264a8d6
7
- data.tar.gz: 4c81e34573458debc06ea34d77325717a272b83bad161bf63a736c9bde6b1c53907e132cdc4091057ef485dbb4a15f4da1694e0b367d50c4fc48cdf31dfcb1f2
6
+ metadata.gz: aa75a9dbdcc1ee891f3b47b7dfea65f4a92790ca6d65e1e49550982da4525e232df65e25c90e202d604c8d5b6b54f1b06d4335f1ca9734f6c115ee8701f43cd4
7
+ data.tar.gz: 5cd9d0b742944b21262f159c4fc45d0861391162959c35565fde7e3842102e0aabfaabbde21acb7384aa440fe9c06543d19436879d46f0d7d39a899f3b102302
@@ -1,3 +1,6 @@
1
+ # 0.1.7
2
+ - upstream(0.9)に追従した
3
+
1
4
  # 0.1.6
2
5
  - upstream(0.7.2)に追従した
3
6
 
data/Gemfile CHANGED
@@ -3,7 +3,10 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.8.1'
6
+ gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.9.1'
7
+ # FIXME: Hack to allow Vagrant v1.6.5 to install for tests. Remove when
8
+ # support for 1.6.5 is dropped.
9
+ gem 'rack', '< 2'
7
10
  gem 'appraisal', '1.0.0'
8
11
  gem 'rubocop', '0.29.0', require: false
9
12
  gem 'coveralls', require: false
@@ -13,10 +13,6 @@ VAGRANTFILE_API_VERSION = "2"
13
13
 
14
14
  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
15
15
 
16
- # このプラグインではConoHa(OpenStack)のイメージを使用するため、boxは利用できません。
17
- # このパラメータを変更する必要はありません。
18
- config.vm.box = 'conoha'
19
-
20
16
  # vagrantがSSH接続する際のユーザ名を指定します。
21
17
  config.ssh.username = 'root'
22
18
 
@@ -36,8 +32,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
36
32
  conoha.tenant_name = 'gnct*******'
37
33
 
38
34
  # VPSのスペックを指定します(g-1gbの場合は1GBプランになります)。
39
- # 2015/08/27現在、以下のプランが利用可能です。
35
+ # 2017/02/23現在、以下のプランが利用可能です。
40
36
  #
37
+ # g-512mb
41
38
  # g-1gb
42
39
  # g-2gb
43
40
  # g-4gb
@@ -46,7 +43,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
46
43
  # g-32gb
47
44
  # g-64gb
48
45
  #
49
- # 最新のプラン一覧はvagrantのopenstackコマンドで取得できます。
46
+ # 最新のプラン一覧はvagrantのopenstackサブコマンドで取得できます。
50
47
  # 以下のコマンドを実行して下さい。
51
48
  #
52
49
  # $ vagrant openstack flavor-list
@@ -54,49 +51,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
54
51
  conoha.flavor = 'g-1gb'
55
52
 
56
53
  # VPSのイメージを指定します。
57
- # 2015/08/27現在、以下のイメージが利用可能です。
58
- #
59
- # vmi-archlinux-x86_64
60
- # vmi-centos-6.6-i386
61
- # vmi-centos-6.6-x86_64
62
- # vmi-centos-6.7-i386
63
- # vmi-centos-6.7-x86_64
64
- # vmi-centos-7.1-x86_64
65
- # vmi-concrete5-centos-6.7
66
- # vmi-debian-7-amd64
67
- # vmi-debian-7-i386
68
- # vmi-debian-8-amd64
69
- # vmi-debian-8-i386
70
- # vmi-docker-1.7.1-ubuntu-14.04
71
- # vmi-drupal-7.36-centos-6.6
72
- # vmi-fedora-21-x86_64
73
- # vmi-fedora-22-x86_64
74
- # vmi-freebsd-10.1-x86_64
75
- # vmi-freebsd-10.1-zfs-x86_64
76
- # vmi-gitlab-7.9.1-centos-6.6
77
- # vmi-hadoop-2.6-master-centos-6.6
78
- # vmi-hadoop-2.6-slave-centos-6.6
79
- # vmi-hinemos-5.0-centos-7.1
80
- # vmi-jenkins-1.6-centos-6.6
81
- # vmi-lamp-centos-6.6
82
- # vmi-meanstack-centos-6.6
83
- # vmi-opensuse-13.2-x86_64
84
- # vmi-owncloud-8-centos-6.6
85
- # vmi-redmine-3.0-centos-6.6
86
- # vmi-ror-4.2-centos-6.6
87
- # vmi-scientificlinux-7.1-x86_64
88
- # vmi-ubuntu-12.04-amd64
89
- # vmi-ubuntu-12.04-i386
90
- # vmi-ubuntu-14.04-amd64
91
- # vmi-ubuntu-14.04-i386
92
- # vmi-wp-4.3-centos-6-6
93
- #
94
- # 最新のイメージ一覧は、vagrantのopenstackコマンドで取得できます。
54
+ # 最新のイメージ一覧は、vagrantのopenstackサブコマンドで取得できます。
95
55
  # 以下のコマンドを実行してください。
96
56
  #
97
57
  # $ vagrant openstack image-list
98
58
  #
99
- conoha.image = 'vmi-ubuntu-14.04-amd64'
59
+ conoha.image = 'vmi-ubuntu-16.04-amd64-unified'
100
60
 
101
61
  # リージョンを指定します。
102
62
  # 東京(tyo1)、シンガポール(sin1)、アメリカ(sjc1)から指定して下さい。
@@ -39,7 +39,13 @@ module VagrantPlugins
39
39
  else
40
40
  b2.use Provision
41
41
  end
42
- b2.use SyncFolders
42
+ if env[:machine].provider_config.use_legacy_synced_folders
43
+ env[:machine].ui.warn I18n.t('vagrant_openstack.config.sync_folders_deprecated')
44
+ b2.use SyncFolders
45
+ else
46
+ # Standard Vagrant implementation.
47
+ b2.use SyncedFolders
48
+ end
43
49
  end
44
50
  end
45
51
  end
@@ -61,6 +67,7 @@ module VagrantPlugins
61
67
  # key.
62
68
  def self.action_read_state
63
69
  new_builder.tap do |b|
70
+ b.use HandleBox
64
71
  b.use ConfigValidate
65
72
  b.use ConnectOpenstack
66
73
  b.use ReadState
@@ -97,6 +104,7 @@ module VagrantPlugins
97
104
 
98
105
  def self.action_up
99
106
  new_builder.tap do |b|
107
+ b.use HandleBox
100
108
  b.use ConfigValidate
101
109
  b.use ConnectOpenstack
102
110
 
@@ -111,7 +119,15 @@ module VagrantPlugins
111
119
  b2.use Provision
112
120
  end
113
121
  end
114
- b2.use SyncFolders
122
+
123
+ if env[:machine].provider_config.use_legacy_synced_folders
124
+ env[:machine].ui.warn I18n.t('vagrant_openstack.config.sync_folders_deprecated')
125
+ b2.use SyncFolders
126
+ else
127
+ # Standard Vagrant implementation.
128
+ b2.use SyncedFolders
129
+ end
130
+
115
131
  b2.use CreateStack
116
132
  b2.use CreateServer
117
133
  b2.use Message, I18n.t('vagrant_openstack.ssh_disabled_provisioning') if ssh_disabled
@@ -99,7 +99,7 @@ module VagrantPlugins
99
99
  end
100
100
  end
101
101
 
102
- log = "Lauching server '#{server_name}' in project '#{config.tenant_name}' "
102
+ log = "Launching server '#{server_name}' in project '#{config.tenant_name}' "
103
103
  log << "with flavor '#{options[:flavor].name}' (#{options[:flavor].id}), "
104
104
  unless options[:image].nil?
105
105
  log << "image '#{options[:image].name}' (#{options[:image].id}) "
@@ -132,7 +132,7 @@ module VagrantPlugins
132
132
  @logger.info "Waiting for the server with id #{server_id} to be built..."
133
133
  env[:ui].info(I18n.t('vagrant_openstack.waiting_for_build'))
134
134
  config = env[:machine].provider_config
135
- timeout(config.server_create_timeout, Errors::Timeout) do
135
+ Timeout.timeout(config.server_create_timeout, Errors::Timeout) do
136
136
  server_status = 'WAITING'
137
137
  until server_status == 'ACTIVE'
138
138
  @logger.debug('Waiting for server to be ACTIVE')
@@ -60,7 +60,7 @@ module VagrantPlugins
60
60
  @logger.info "Waiting for the stack with id #{stack_id} to be built..."
61
61
  env[:ui].info(I18n.t('vagrant_openstack.waiting_for_stack'))
62
62
  config = env[:machine].provider_config
63
- timeout(config.stack_create_timeout, Errors::Timeout) do
63
+ Timeout.timeout(config.stack_create_timeout, Errors::Timeout) do
64
64
  stack_status = 'CREATE_IN_PROGRESS'
65
65
  until stack_status == 'CREATE_COMPLETE'
66
66
  @logger.debug('Waiting for stack to be CREATED')
@@ -32,7 +32,7 @@ module VagrantPlugins
32
32
  @logger.info "Waiting for the instance with id #{instance_id} to be deleted..."
33
33
  env[:ui].info(I18n.t('vagrant_openstack.waiting_deleted'))
34
34
  config = env[:machine].provider_config
35
- timeout(config.server_delete_timeout, Errors::Timeout) do
35
+ Timeout.timeout(config.server_delete_timeout, Errors::Timeout) do
36
36
  delete_ok = false
37
37
  until delete_ok
38
38
  begin
@@ -57,7 +57,7 @@ module VagrantPlugins
57
57
  @logger.info "Waiting for the stack with id #{stack_id} to be deleted..."
58
58
  env[:ui].info(I18n.t('vagrant_openstack.waiting_for_stack_deleted'))
59
59
  config = env[:machine].provider_config
60
- timeout(config.stack_delete_timeout, Errors::Timeout) do
60
+ Timeout.timeout(config.stack_delete_timeout, Errors::Timeout) do
61
61
  stack_status = 'DELETE_IN_PROGRESS'
62
62
  until stack_status == 'DELETE_COMPLETE'
63
63
  @logger.debug('Waiting for stack to be DELETED')
@@ -18,7 +18,7 @@ module VagrantPlugins
18
18
  env[:ui].info(I18n.t('vagrant_openstack.waiting_start'))
19
19
  client = env[:openstack_client].nova
20
20
  config = env[:machine].provider_config
21
- timeout(config.server_active_timeout, Errors::Timeout) do
21
+ Timeout.timeout(config.server_active_timeout, Errors::Timeout) do
22
22
  while client.get_server_details(env, env[:machine].id)['status'] != 'ACTIVE'
23
23
  sleep @retry_interval
24
24
  @logger.info('Waiting for server to be active')
@@ -18,7 +18,7 @@ module VagrantPlugins
18
18
  env[:ui].info(I18n.t('vagrant_openstack.waiting_stop'))
19
19
  client = env[:openstack_client].nova
20
20
  config = env[:machine].provider_config
21
- timeout(config.server_stop_timeout, Errors::Timeout) do
21
+ Timeout.timeout(config.server_stop_timeout, Errors::Timeout) do
22
22
  while client.get_server_details(env, env[:machine].id)['status'] != 'SHUTOFF'
23
23
  sleep @retry_interval
24
24
  @logger.info('Waiting for server to stop')
@@ -10,24 +10,16 @@ module VagrantPlugins
10
10
  config = env[:machine].provider_config
11
11
  client = env[:openstack_client]
12
12
  endpoints = client.session.endpoints
13
- endpoint_type = config.endpoint_type
14
13
  @logger.info(I18n.t('vagrant_openstack.client.looking_for_available_endpoints'))
15
14
  @logger.info("Selecting endpoints matching region '#{config.region}'") unless config.region.nil?
16
15
 
17
16
  catalog.each do |service|
18
17
  se = service['endpoints']
19
- if config.region.nil?
20
- if se.size > 1
21
- env[:ui].warn I18n.t('vagrant_openstack.client.multiple_endpoint', size: se.size, type: service['type'])
22
- env[:ui].warn " => #{service['endpoints'][0][endpoint_type]}"
23
- end
24
- url = se[0][endpoint_type].strip
25
- else
26
- se.each do |endpoint|
27
- url = endpoint[endpoint_type].strip if endpoint['region'].eql? config.region
28
- end
18
+ if config.identity_api_version == '2'
19
+ get_endpoints_2(env, se, service, config, endpoints)
20
+ elsif config.identity_api_version == '3'
21
+ get_interfaces_3(se, service, config, endpoints)
29
22
  end
30
- endpoints[service['type'].to_sym] = url unless url.nil? || url.empty?
31
23
  end
32
24
 
33
25
  endpoints[:network] = choose_api_version('Neutron', 'openstack_network_url', 'v2') do
@@ -41,6 +33,37 @@ module VagrantPlugins
41
33
 
42
34
  private
43
35
 
36
+ def get_endpoints_2(env, se, service, config, endpoints)
37
+ endpoint_type = config.endpoint_type
38
+ if config.region.nil?
39
+ if se.size > 1
40
+ env[:ui].warn I18n.t('vagrant_openstack.client.multiple_endpoint', size: se.size, type: service['type'])
41
+ env[:ui].warn " => #{service['endpoints'][0][endpoint_type]}"
42
+ end
43
+ url = se[0][endpoint_type].strip
44
+ else
45
+ se.each do |endpoint|
46
+ url = endpoint[endpoint_type].strip if endpoint['region'].eql? config.region
47
+ end
48
+ end
49
+ endpoints[service['type'].to_sym] = url unless url.nil? || url.empty?
50
+ end
51
+
52
+ def get_interfaces_3(se, service, config, endpoints)
53
+ url = nil
54
+ se.each do |endpoint|
55
+ next if endpoint['interface'] != config.interface_type
56
+ if config.region.nil?
57
+ url = endpoint['url']
58
+ break
59
+ elsif endpoint['region'] == config.region
60
+ url = endpoint['url']
61
+ break
62
+ end
63
+ end
64
+ endpoints[service['type'].to_sym] = url unless url.nil? || url.empty?
65
+ end
66
+
44
67
  def choose_api_version(service_name, url_property, version_prefix = nil, fail_if_not_found = true)
45
68
  versions = yield
46
69
 
@@ -19,20 +19,13 @@ module VagrantPlugins
19
19
  config = env[:machine].provider_config
20
20
  @logger.info(I18n.t('vagrant_openstack.client.authentication', project: config.tenant_name, user: config.username))
21
21
 
22
- post_body =
23
- {
24
- auth:
25
- {
26
- tenantName: config.tenant_name,
27
- passwordCredentials:
28
- {
29
- username: config.username,
30
- password: '****'
31
- }
32
- }
33
- }
34
-
35
- auth_url = get_auth_url_v2 env
22
+ if config.identity_api_version == '2'
23
+ post_body = get_body_2 config
24
+ auth_url = get_auth_url_2 env
25
+ elsif config.identity_api_version == '3'
26
+ post_body = get_body_3 config
27
+ auth_url = get_auth_url_3 env
28
+ end
36
29
 
37
30
  headers = {
38
31
  content_type: :json,
@@ -41,13 +34,19 @@ module VagrantPlugins
41
34
 
42
35
  log_request(:POST, auth_url, post_body.to_json, headers)
43
36
 
44
- post_body[:auth][:passwordCredentials][:password] = config.password
37
+ if config.identity_api_version == '2'
38
+ post_body[:auth][:passwordCredentials][:password] = config.password
39
+ elsif config.identity_api_version == '3'
40
+ post_body[:auth][:identity][:password][:user][:password] = config.password
41
+ end
45
42
 
46
43
  authentication = RestUtils.post(env, auth_url, post_body.to_json, headers) do |response|
47
44
  log_response(response)
48
45
  case response.code
49
46
  when 200
50
47
  response
48
+ when 201
49
+ response
51
50
  when 401
52
51
  fail Errors::AuthenticationFailed
53
52
  when 404
@@ -57,17 +56,69 @@ module VagrantPlugins
57
56
  end
58
57
  end
59
58
 
60
- access = JSON.parse(authentication)['access']
61
- response_token = access['token']
62
- @session.token = response_token['id']
63
- @session.project_id = response_token['tenant']['id']
64
-
65
- access['serviceCatalog']
59
+ if config.identity_api_version == '2'
60
+ access = JSON.parse(authentication)['access']
61
+ response_token = access['token']
62
+ @session.token = response_token['id']
63
+ @session.project_id = response_token['tenant']['id']
64
+ return access['serviceCatalog']
65
+ elsif config.identity_api_version == '3'
66
+ body = JSON.parse(authentication)
67
+ @session.token = authentication.headers[:x_subject_token]
68
+ @session.project_id = body['token']['project']['id']
69
+ return body['token']['catalog']
70
+ end
66
71
  end
67
72
 
68
73
  private
69
74
 
70
- def get_auth_url_v2(env)
75
+ def get_body_2(config)
76
+ {
77
+ auth:
78
+ {
79
+ tenantName: config.tenant_name,
80
+ passwordCredentials:
81
+ {
82
+ username: config.username,
83
+ password: '****'
84
+ }
85
+ }
86
+ }
87
+ end
88
+
89
+ def get_body_3(config)
90
+ {
91
+ auth:
92
+ {
93
+ identity: {
94
+ methods: ['password'],
95
+ password: {
96
+ user: {
97
+ name: config.username,
98
+ domain: {
99
+ name: config.domain_name
100
+ },
101
+ password: '****'
102
+ }
103
+ }
104
+ },
105
+ scope: {
106
+ project: {
107
+ name: config.project_name,
108
+ domain: { name: config.domain_name }
109
+ }
110
+ }
111
+ }
112
+ }
113
+ end
114
+
115
+ def get_auth_url_3(env)
116
+ url = env[:machine].provider_config.openstack_auth_url
117
+ return url if url.match(%r{/tokens/*$})
118
+ "#{url}/auth/tokens"
119
+ end
120
+
121
+ def get_auth_url_2(env)
71
122
  url = env[:machine].provider_config.openstack_auth_url
72
123
  return url if url.match(%r{/tokens/*$})
73
124
  "#{url}/tokens"
@@ -52,6 +52,11 @@ module VagrantPlugins
52
52
  #
53
53
  attr_accessor :tenant_name
54
54
 
55
+ #
56
+ # The name of the openstack project on witch the vm will be created, changed name in v3 identity API.
57
+ #
58
+ attr_accessor :project_name
59
+
55
60
  # The name of the server. This defaults to the name of the machine
56
61
  # defined by Vagrant (via `config.vm.define`), but can be overriden
57
62
  # here.
@@ -62,6 +67,11 @@ module VagrantPlugins
62
67
  # @return [String]
63
68
  attr_accessor :username
64
69
 
70
+ # The domain name to access Openstack, this defaults to Default.
71
+ #
72
+ # @return [String]
73
+ attr_accessor :domain_name
74
+
65
75
  # The name of the keypair to use.
66
76
  #
67
77
  # @return [String]
@@ -87,6 +97,8 @@ module VagrantPlugins
87
97
 
88
98
  # Opt files/directories in to the rsync operation performed by this provider
89
99
  #
100
+ # @deprecated Use standard Vagrant synced folders instead.
101
+ #
90
102
  # @return [Array]
91
103
  attr_accessor :rsync_includes
92
104
 
@@ -108,12 +120,16 @@ module VagrantPlugins
108
120
 
109
121
  # Sync folder method. Can be either "rsync" or "none"
110
122
  #
123
+ # @deprecated Use standard Vagrant synced folders instead.
124
+ #
111
125
  # @return [String]
112
126
  attr_accessor :sync_method
113
127
 
114
128
  # Sync folder ignore files. A list of files containing exclude patterns to ignore in the rsync operation
115
129
  # performed by this provider
116
130
  #
131
+ # @deprecated Use standard Vagrant synced folders instead.
132
+ #
117
133
  # @return [Array]
118
134
  attr_accessor :rsync_ignore_files
119
135
 
@@ -172,6 +188,16 @@ module VagrantPlugins
172
188
  # @return [String]
173
189
  attr_accessor :endpoint_type
174
190
 
191
+ # Specify the endpoint_type to use : publicL, admin, or internal (default is public)
192
+ #
193
+ # @return [String]
194
+ attr_accessor :interface_type
195
+
196
+ # Specify the authentication version to use : 2 or 3 (ddefault is 2()
197
+ #
198
+ # @return [String]
199
+ attr_accessor :identity_api_version
200
+
175
201
  #
176
202
  # @return [Integer]
177
203
  attr_accessor :server_create_timeout
@@ -204,6 +230,20 @@ module VagrantPlugins
204
230
  # @return [Boolean]
205
231
  attr_accessor :meta_args_support
206
232
 
233
+ # A switch for enabling the legacy synced folders implementation.
234
+ #
235
+ # This defaults to false, but is automatically set to true if any of the
236
+ # legacy synced folder options are used:
237
+ #
238
+ # - {#rsync_includes}
239
+ # - {#rsync_ignore_files}
240
+ # - {#sync_method}
241
+ #
242
+ # @deprecated Use standard Vagrant synced folders instead.
243
+ #
244
+ # @return [Boolean]
245
+ attr_accessor :use_legacy_synced_folders
246
+
207
247
  def initialize
208
248
  @password = UNSET_VALUE
209
249
  @openstack_compute_url = UNSET_VALUE
@@ -213,6 +253,8 @@ module VagrantPlugins
213
253
  @openstack_image_url = UNSET_VALUE
214
254
  @openstack_auth_url = UNSET_VALUE
215
255
  @endpoint_type = UNSET_VALUE
256
+ @interface_type = UNSET_VALUE
257
+ @identity_api_version = UNSET_VALUE
216
258
  @region = UNSET_VALUE
217
259
  @flavor = UNSET_VALUE
218
260
  @image = UNSET_VALUE
@@ -248,6 +290,7 @@ module VagrantPlugins
248
290
  @stack_delete_timeout = UNSET_VALUE
249
291
  @meta_args_support = UNSET_VALUE
250
292
  @http = HttpConfig.new
293
+ @use_legacy_synced_folders = UNSET_VALUE
251
294
  end
252
295
 
253
296
  def merge(other)
@@ -288,7 +331,7 @@ module VagrantPlugins
288
331
  result
289
332
  end
290
333
 
291
- # rubocop:disable Metrics/CyclomaticComplexity
334
+ # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
292
335
  def finalize!
293
336
  @password = nil if @password == UNSET_VALUE
294
337
  @openstack_compute_url = nil if @openstack_compute_url == UNSET_VALUE
@@ -298,19 +341,20 @@ module VagrantPlugins
298
341
  @openstack_image_url = nil if @openstack_image_url == UNSET_VALUE
299
342
  @openstack_auth_url = nil if @openstack_auth_url == UNSET_VALUE
300
343
  @endpoint_type = 'publicURL' if @endpoint_type == UNSET_VALUE
344
+ @interface_type = 'public' if @interface_type == UNSET_VALUE
345
+ @identity_api_version = '2' if @identity_api_version == UNSET_VALUE
301
346
  @region = nil if @region == UNSET_VALUE
302
347
  @flavor = nil if @flavor == UNSET_VALUE
303
348
  @image = nil if @image == UNSET_VALUE
304
349
  @volume_boot = nil if @volume_boot == UNSET_VALUE
305
350
  @tenant_name = nil if @tenant_name == UNSET_VALUE
351
+ @project_name = nil if @project_name == UNSET_VALUE
306
352
  @server_name = nil if @server_name == UNSET_VALUE
307
353
  @username = nil if @username == UNSET_VALUE
308
- @rsync_includes = nil if @rsync_includes.empty?
309
- @rsync_ignore_files = nil if @rsync_ignore_files.empty?
354
+ @domain_name = 'Default' if @domain_name == UNSET_VALUE
310
355
  @floating_ip = nil if @floating_ip == UNSET_VALUE
311
356
  @floating_ip_pool = nil if @floating_ip_pool == UNSET_VALUE
312
357
  @floating_ip_pool_always_allocate = false if floating_ip_pool_always_allocate == UNSET_VALUE
313
- @sync_method = 'rsync' if @sync_method == UNSET_VALUE
314
358
  @keypair_name = nil if @keypair_name == UNSET_VALUE
315
359
  @admin_pass = nil if @admin_pass == UNSET_VALUE
316
360
  @public_key_path = nil if @public_key_path == UNSET_VALUE
@@ -321,6 +365,27 @@ module VagrantPlugins
321
365
  @metadata = nil if @metadata == UNSET_VALUE
322
366
  @ssh_disabled = false if @ssh_disabled == UNSET_VALUE
323
367
 
368
+ # The value of use_legacy_synced_folders is used by action chains
369
+ # to determine which synced folder implementation to run.
370
+ if @use_legacy_synced_folders == UNSET_VALUE
371
+ @use_legacy_synced_folders = !(
372
+ (@rsync_includes.nil? || @rsync_includes.empty?) &&
373
+ (@rsync_ignore_files.nil? || @rsync_ignore_files.empty?) &&
374
+ (@sync_method.nil? || @sync_method == UNSET_VALUE))
375
+ end
376
+
377
+ if @use_legacy_synced_folders
378
+ # Original defaults.
379
+ @rsync_includes = nil if @rsync_includes.empty?
380
+ @rsync_ignore_files = nil if @rsync_ignore_files.empty?
381
+ @sync_method = 'rsync' if @sync_method == UNSET_VALUE
382
+ else
383
+ # Disable all sync settings.
384
+ @rsync_includes = nil
385
+ @rsync_ignore_files = nil
386
+ @sync_method = nil
387
+ end
388
+
324
389
  # The SSH values by default are nil, and the top-level config
325
390
  # `config.ssh` and `config.vm.boot_timeout` values are used.
326
391
  @ssh_username = nil if @ssh_username == UNSET_VALUE
@@ -338,8 +403,10 @@ module VagrantPlugins
338
403
  @stacks = nil if @stacks.empty?
339
404
  @http.finalize!
340
405
  end
341
- # rubocop:enable Metrics/CyclomaticComplexity
406
+ # rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
342
407
 
408
+ #
409
+ # @deprecated Use standard Vagrant synced folders instead.
343
410
  def rsync_include(inc)
344
411
  @rsync_includes << inc
345
412
  end
@@ -349,13 +416,12 @@ module VagrantPlugins
349
416
 
350
417
  errors << I18n.t('vagrant_openstack.config.password_required') if @password.nil? || @password.empty?
351
418
  errors << I18n.t('vagrant_openstack.config.username_required') if @username.nil? || @username.empty?
352
- errors << I18n.t('vagrant_openstack.config.tenant_name_required') if @tenant_name.nil? || @tenant_name.empty?
353
- errors << I18n.t('vagrant_openstack.config.invalid_endpoint_type') unless %w(publicURL adminURL internalURL).include?(@endpoint_type)
419
+ errors << I18n.t('vagrant_openstack.config.invalid_api_version') unless %w(2 3).include?(@identity_api_version)
354
420
 
421
+ validate_api_version(errors)
355
422
  validate_ssh_username(machine, errors)
356
423
  validate_stack_config(errors)
357
424
  validate_ssh_timeout(errors)
358
- validate_admin_pass(errors)
359
425
 
360
426
  if machine.config.ssh.private_key_path
361
427
  puts I18n.t('vagrant_openstack.config.keypair_name_required').yellow unless @keypair_name || @public_key_path
@@ -379,11 +445,15 @@ module VagrantPlugins
379
445
 
380
446
  private
381
447
 
382
- def validate_admin_pass(errors)
383
- return if @admin_pass == '' || @admin_pass.nil?
384
-
385
- reg = /\A(?=.*?[A-Z])(?=.*?[a-z])(?=.*?\d)(?=.*?[!-~&&[^A-Za-z\d]])[!-~]{9,70}+\z/
386
- errors << I18n.t('vagrant_openstack.config.invalid_admin_pass') unless @admin_pass =~ reg
448
+ def validate_api_version(errors)
449
+ if @identity_api_version == '2'
450
+ errors << I18n.t('vagrant_openstack.config.tenant_name_required') if @tenant_name.nil? || @tenant_name.empty?
451
+ errors << I18n.t('vagrant_openstack.config.invalid_endpoint_type') unless %w(publicURL adminURL internalURL).include?(@endpoint_type)
452
+ elsif @identity_api_version == '3'
453
+ errors << I18n.t('vagrant_openstack.config.domain_required') if @domain_name.nil? || @domain_name.empty?
454
+ errors << I18n.t('vagrant_openstack.config.project_name_required') if @project_name.nil? || @project_name.empty?
455
+ errors << I18n.t('vagrant_openstack.config.invalid_interface_type') unless %w(public admin internal).include?(@interface_type)
456
+ end
387
457
  end
388
458
 
389
459
  def validate_stack_config(errors)
@@ -16,7 +16,12 @@ module VagrantPlugins
16
16
  if addresses.size == 1
17
17
  net_addresses = addresses.first[1]
18
18
  else
19
- net_addresses = addresses[env[:machine].provider_config.networks[0]]
19
+ first_network = env[:machine].provider_config.networks[0]
20
+ if first_network.is_a? String
21
+ net_addresses = addresses[first_network]
22
+ else
23
+ net_addresses = addresses[first_network[:name]]
24
+ end
20
25
  end
21
26
  fail Errors::UnableToResolveIP if net_addresses.size == 0
22
27
  net_addresses[0]['addr']
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  # Stable versions must respect the pattern given
5
5
  # by VagrantPlugins::ConoHa::VERSION_PATTERN
6
6
  #
7
- VERSION = '0.1.6'
7
+ VERSION = '0.1.7'
8
8
 
9
9
  #
10
10
  # Stable version must respect the naming convention 'x.y.z'
@@ -65,7 +65,7 @@ module VagrantPlugins
65
65
 
66
66
  # rubocop:disable Lint/HandleExceptions
67
67
  def self.check_version
68
- timeout(3, Errors::Timeout) do
68
+ Timeout.timeout(3, Errors::Timeout) do
69
69
  VersionChecker.instance.check
70
70
  end
71
71
  rescue
@@ -140,8 +140,19 @@ en:
140
140
  to the standard vagrant configuration option `config.vm.boot_timeout`.
141
141
  invalid_value_for_parameter: |-
142
142
  Invalid value '%{value}' for parameter '%{parameter}'
143
- invalid_admin_pass: |-
144
- admin_pass must be contain at least 9 characters, least 1 number and both lower and uppercase letters, and specialcharacters.
143
+ sync_folders_deprecated: |-
144
+ The following configuration settings are deprecated and should be
145
+ removed: rsync_includes, rsync_ignore_files, sync_method. Using these
146
+ settings causes the OpenStack provider to fall back to an old synced
147
+ folder implementation instead of using standard Vagrant synced folders.
148
+ domain_required: |-
149
+ A domain is required when using identity API version 3
150
+ project_name_required: |-
151
+ A project name is required when using identity API version 3
152
+ invalid_interface_type: |-
153
+ Interface type must be public, admin or internal (if not provided, default is public)
154
+ invalid_api_version: |-
155
+ identity API verison must be 2 or 3 (if nto provided, default is 2)
145
156
 
146
157
  errors:
147
158
  default: |-
@@ -18,10 +18,13 @@ describe VagrantPlugins::ConoHa::Action::ConnectOpenstack do
18
18
  config.stub(:openstack_volume_url) { nil }
19
19
  config.stub(:openstack_image_url) { nil }
20
20
  config.stub(:tenant_name) { 'testTenant' }
21
+ config.stub(:project_name) { 'testTenant' }
21
22
  config.stub(:username) { 'username' }
22
23
  config.stub(:password) { 'password' }
23
24
  config.stub(:region) { nil }
24
25
  config.stub(:endpoint_type) { 'publicURL' }
26
+ config.stub(:interface_type) { 'public' }
27
+ config.stub(:identity_api_version) { '2' }
25
28
  end
26
29
  end
27
30
 
@@ -243,6 +246,78 @@ describe VagrantPlugins::ConoHa::Action::ConnectOpenstack do
243
246
  end
244
247
  end
245
248
 
249
+ context 'with one endpoint by service v3' do
250
+ it 'read service catalog and stores endpoints URL in session v3' do
251
+ catalog = [
252
+ {
253
+ 'endpoints' => [
254
+ {
255
+ 'url' => 'http://nova/v2/projectId',
256
+ 'interface' => 'public',
257
+ 'region' => 'RegionOne',
258
+ 'id' => '1'
259
+ }
260
+ ],
261
+ 'type' => 'compute',
262
+ 'name' => 'nova'
263
+ },
264
+ {
265
+ 'endpoints' => [
266
+ {
267
+ 'url' => 'http://neutron',
268
+ 'interface' => 'public',
269
+ 'region' => 'RegionOne',
270
+ 'id' => '2'
271
+ }
272
+ ],
273
+ 'type' => 'network',
274
+ 'name' => 'neutron'
275
+ },
276
+ {
277
+ 'endpoints' => [
278
+ {
279
+ 'url' => 'http://cinder/v2/projectId',
280
+ 'interface' => 'public',
281
+ 'region' => 'RegionOne',
282
+ 'id' => '2'
283
+ }
284
+ ],
285
+ 'type' => 'volume',
286
+ 'name' => 'cinder'
287
+ },
288
+ {
289
+ 'endpoints' => [
290
+ {
291
+ 'url' => 'http://glance',
292
+ 'interface' => 'public',
293
+ 'region' => 'RegionOne',
294
+ 'id' => '2'
295
+ }
296
+ ],
297
+ 'type' => 'image',
298
+ 'name' => 'glance'
299
+ }
300
+ ]
301
+
302
+ double.tap do |keystone|
303
+ keystone.stub(:authenticate).with(anything) { catalog }
304
+ env[:openstack_client].stub(:keystone) { keystone }
305
+ end
306
+ env[:openstack_client].stub(:neutron) { neutron }
307
+ env[:openstack_client].stub(:glance) { glance }
308
+ config.stub(:domain_name) { 'dummy' }
309
+ config.stub(:identity_api_version) { '3' }
310
+
311
+ @action.call(env)
312
+
313
+ expect(env[:openstack_client].session.endpoints)
314
+ .to eq(compute: 'http://nova/v2/projectId',
315
+ network: 'http://neutron/v2.0',
316
+ volume: 'http://cinder/v2/projectId',
317
+ image: 'http://glance/v2.0')
318
+ end
319
+ end
320
+
246
321
  context 'with multiple regions' do
247
322
  it 'read service catalog and stores endpoints URL for desired regions in session' do
248
323
  catalog = [
@@ -17,6 +17,9 @@ describe VagrantPlugins::ConoHa::KeystoneClient do
17
17
  config.stub(:username) { 'username' }
18
18
  config.stub(:password) { 'password' }
19
19
  config.stub(:http) { http }
20
+ config.stub(:interface_type) { 'public' }
21
+ config.stub(:identity_api_version) { '2' }
22
+ config.stub(:project_name) { 'testTenant' }
20
23
  end
21
24
  end
22
25
 
@@ -52,6 +55,29 @@ describe VagrantPlugins::ConoHa::KeystoneClient do
52
55
  ]}}'
53
56
  end
54
57
 
58
+ let(:keystone_response_headers_v3) do
59
+ {
60
+ 'Accept' => 'application/json',
61
+ 'Content-Type' => 'application/json',
62
+ 'x_subject_token' => '0123456789'
63
+ }
64
+ end
65
+
66
+ let(:keystone_request_body_v3) do
67
+ '{"auth":{"identity":{"methods":["password"],"password":{"user":{"name":"username","domain":'\
68
+ '{"name":"dummy"},"password":"password"}}},"scope":{"project":{"name":"testTenant","domain":'\
69
+ '{"name":"dummy"}}}}}'
70
+ end
71
+
72
+ let(:keystone_response_body_v3) do
73
+ '{"token":{"is_domain":false,"methods":["password"],"roles":[{"id":"1234","name":"_member_"}],
74
+ "is_admin_project":false,"project":{"domain":{"id":"1234","name":"dummy"},"id":"012345678910",
75
+ "name":"testTenantId"},"catalog":[
76
+ {"endpoints":[{"id":"eid1","interface":"public","url":"http://nova"}],"type":"compute"},
77
+ {"endpoints":[{"id":"eid2","interface":"public","url":"http://neutron"}],"type":"network"}
78
+ ]}}'
79
+ end
80
+
55
81
  before :each do
56
82
  @keystone_client = VagrantPlugins::ConoHa.keystone
57
83
  end
@@ -146,5 +172,53 @@ describe VagrantPlugins::ConoHa::KeystoneClient do
146
172
  end
147
173
  end
148
174
  end
175
+
176
+ # V3
177
+ context 'with good credentials v3' do
178
+ it 'store token and tenant id' do
179
+ config.stub(:domain_name) { 'dummy' }
180
+ config.stub(:identity_api_version) { '3' }
181
+ config.stub(:openstack_auth_url) { 'http://keystoneAuthV3' }
182
+
183
+ stub_request(:post, 'http://keystoneAuthV3/auth/tokens')
184
+ .with(
185
+ body: keystone_request_body_v3,
186
+ headers: keystone_request_headers)
187
+ .to_return(
188
+ status: 200,
189
+ body: keystone_response_body_v3,
190
+ headers: keystone_response_headers_v3)
191
+
192
+ @keystone_client.authenticate(env)
193
+
194
+ session.token.should eq('0123456789')
195
+ session.project_id.should eq('012345678910')
196
+ end
197
+ end
198
+
199
+ context 'with wrong credentials v3' do
200
+ it 'raise an unauthorized error ' do
201
+ config.stub(:domain_name) { 'dummy' }
202
+ config.stub(:identity_api_version) { '3' }
203
+ config.stub(:openstack_auth_url) { 'http://keystoneAuthV3' }
204
+
205
+ stub_request(:post, 'http://keystoneAuthV3/auth/tokens')
206
+ .with(
207
+ body: keystone_request_body_v3,
208
+ headers: keystone_request_headers)
209
+ .to_return(
210
+ status: 401,
211
+ body: '{
212
+ "error": {
213
+ "message": "The request you have made requires authentication.",
214
+ "code": 401,
215
+ "title": "Unauthorized"
216
+ }
217
+ }',
218
+ headers: keystone_response_headers_v3)
219
+
220
+ expect { @keystone_client.authenticate(env) }.to raise_error(Errors::AuthenticationFailed)
221
+ end
222
+ end
149
223
  end
150
224
  end
@@ -460,7 +460,7 @@ describe VagrantPlugins::ConoHa::NovaClient do
460
460
  {
461
461
  'Accept' => 'application/json',
462
462
  'Accept-Encoding' => 'gzip, deflate',
463
- 'User-Agent' => 'Ruby',
463
+ 'User-Agent' => /.*/,
464
464
  'X-Auth-Token' => '123456'
465
465
  })
466
466
  .to_return(status: 200, body: '
@@ -16,7 +16,10 @@ describe VagrantPlugins::ConoHa::Config do
16
16
  its(:image) { should be_nil }
17
17
  its(:server_name) { should be_nil }
18
18
  its(:username) { should be_nil }
19
+ its(:use_legacy_synced_folders) { should eq(false) }
19
20
  its(:rsync_includes) { should be_nil }
21
+ its(:rsync_ignore_files) { should be_nil }
22
+ its(:sync_method) { should be_nil }
20
23
  its(:keypair_name) { should be_nil }
21
24
  its(:public_key_path) { should be_nil }
22
25
  its(:availability_zone) { should be_nil }
@@ -55,11 +58,36 @@ describe VagrantPlugins::ConoHa::Config do
55
58
  end
56
59
  end
57
60
 
61
+ describe 'use_legacy_synced_folders' do
62
+ it 'should default to true if sync_method is set' do
63
+ subject.sync_method = 'rsync'
64
+ subject.finalize!
65
+
66
+ expect(subject.use_legacy_synced_folders).to eq(true)
67
+ end
68
+
69
+ it 'should default to true if rsync_includes is non-empty' do
70
+ subject.rsync_includes = ['some/file']
71
+ subject.finalize!
72
+
73
+ expect(subject.use_legacy_synced_folders).to eq(true)
74
+ end
75
+
76
+ it 'should default to true if rsync_ignore_files is non-empty' do
77
+ subject.rsync_ignore_files = ['some/file']
78
+ subject.finalize!
79
+
80
+ expect(subject.use_legacy_synced_folders).to eq(true)
81
+ end
82
+ end
83
+
58
84
  it 'should not default rsync_includes if overridden' do
59
85
  inc = 'core'
60
86
  subject.send(:rsync_include, inc)
61
87
  subject.finalize!
62
- subject.send(:rsync_includes).should include(inc)
88
+
89
+ expect(subject.rsync_includes).to include(inc)
90
+ expect(subject.use_legacy_synced_folders).to eq(true)
63
91
  end
64
92
  end
65
93
 
@@ -12,13 +12,15 @@ Gem::Specification.new do |gem|
12
12
  gem.homepage = 'https://github.com/hironobu-s/vagrant-conoha/'
13
13
  gem.license = 'MIT'
14
14
 
15
- gem.add_dependency 'json', '1.8.3'
16
- gem.add_dependency 'rest-client', '~> 1.6.0'
15
+ gem.add_dependency 'json', '>= 1.8.1', '< 3.0'
16
+ gem.add_dependency 'rest-client', '>= 1.6.0', '< 3.0'
17
17
  gem.add_dependency 'terminal-table', '1.4.5'
18
18
  gem.add_dependency 'sshkey', '1.6.1'
19
19
  gem.add_dependency 'colorize', '0.7.3'
20
20
 
21
- gem.add_development_dependency 'rake'
21
+ # Constraint rake to properly handle deprecated method usage
22
+ # from within rspec 3.1.z
23
+ gem.add_development_dependency 'rake', '~> 11.3.0'
22
24
  gem.add_development_dependency 'rspec', '~> 3.1.0'
23
25
  gem.add_development_dependency 'rspec-its', '~> 1.0.1'
24
26
  gem.add_development_dependency 'rspec-expectations', '~> 3.1.2'
metadata CHANGED
@@ -1,43 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-conoha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hironobu Saitoh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2017-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.8.3
19
+ version: 1.8.1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - '='
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.8.1
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 1.8.3
32
+ version: '3.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rest-client
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
39
  version: 1.6.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '3.0'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
- - - "~>"
47
+ - - ">="
39
48
  - !ruby/object:Gem::Version
40
49
  version: 1.6.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '3.0'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: terminal-table
43
55
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +96,16 @@ dependencies:
84
96
  name: rake
85
97
  requirement: !ruby/object:Gem::Requirement
86
98
  requirements:
87
- - - ">="
99
+ - - "~>"
88
100
  - !ruby/object:Gem::Version
89
- version: '0'
101
+ version: 11.3.0
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
93
105
  requirements:
94
- - - ">="
106
+ - - "~>"
95
107
  - !ruby/object:Gem::Version
96
- version: '0'
108
+ version: 11.3.0
97
109
  - !ruby/object:Gem::Dependency
98
110
  name: rspec
99
111
  requirement: !ruby/object:Gem::Requirement
@@ -300,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
300
312
  version: '0'
301
313
  requirements: []
302
314
  rubyforge_project:
303
- rubygems_version: 2.2.2
315
+ rubygems_version: 2.5.1
304
316
  signing_key:
305
317
  specification_version: 4
306
318
  summary: Enables Vagrant to manage VPS in ConoHa.