vagrant-openstack-plugin 0.2.2 → 0.3.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fb275fa87d4601a051b59152af3219c4420bdb78
4
+ data.tar.gz: 9acfe025144bf974f4574475ea11457f05d83d14
5
+ SHA512:
6
+ metadata.gz: 03895c57bd627fba2402596e02eeb2384b137b23c8c6aafa120a97285b6675f923736b01065f0ceed6de4f83d9202dd507b3159d2af31142ce885ef2ae1835de
7
+ data.tar.gz: 9836a275ca793adf8168eeb12f851392bc9c1f95d4fbea4f337c1976a1a52bcaa3606037b67bc304580c54e25d0f2e1d9fefcea2599d02461c4c71971798ec91
data/Authors.txt ADDED
@@ -0,0 +1,11 @@
1
+ Brian Miller
2
+ Corey Stubbs
3
+ Hendrik Volkmer
4
+ Jasper Capel
5
+ Joe Topjian
6
+ Jon Burgess
7
+ Mathieu Mitchell
8
+ Mitchell Hashimoto
9
+ Stephan Renatus
10
+ Thomas Kadauke
11
+ Xavier Antoviaque
data/CHANGELOG.md CHANGED
@@ -1,3 +1,50 @@
1
- # 0.1.0 (March 14, 2013)
1
+ # Changelog for vagrant-openstack-plugin
2
2
 
3
- * Initial release.
3
+ ## 0.3.0 (September 25, 2013)
4
+
5
+ - Adds support to determine IP address to use
6
+ - Region Support
7
+ - Enabled controlling multiple VMs in parallel
8
+ - Honor disabling of synced folders
9
+ - Adds `availability_zone` option to specify instance zone
10
+ - Added --delete to rsync command
11
+ - Call SetHostname action from Vagrant core in up phase
12
+ - Handled not having the box and providing it via a box_url.
13
+ - Allowed vagrant ssh -c 'command'
14
+ - Adds tenant to network request
15
+ - Improved documentation
16
+
17
+ ## 0.2.2 (May 30, 2013)
18
+
19
+ - Also ignore HOSTUNREACH errors when first trying to connect to newly created VM
20
+
21
+ ## 0.2.1 (May 29, 2013)
22
+
23
+ - Fix passing user data to server on create
24
+ - Floating IP Capability
25
+ - Added ability to configure scheduler hints
26
+ - Update doc (network config in fact has higher precedence than address_id)
27
+ - 'address_id' now defaults to 'public', to reduce number of cases in read_ssh_info
28
+ - Introduced 'address_id' config, which has a higher order of precedence than 'network'
29
+
30
+ ## 0.2.0 (May 2, 2013)
31
+
32
+ - Added docs
33
+ - Removed metadata validation and bumped version
34
+ - Tenant and security groups are now configurable
35
+
36
+ ## 0.1.3 (April 26, 2013)
37
+
38
+ - Added the ability to pass metadata keypairs to instances
39
+ - Added support for nics configurations to allow for selection of a specific network on creation
40
+
41
+ ## 0.1.2 (April 26, 2013)
42
+
43
+ - Added the option of passing user data to VMs
44
+ - Enabled `vagrant provision` in this provider
45
+ - Made finding IP address more stable
46
+ - Doc improvements and minor fixes
47
+
48
+ ## 0.1.0 (March 14, 2013)
49
+
50
+ - Initial release
data/README.md CHANGED
@@ -56,23 +56,26 @@ Vagrant.configure("2") do |config|
56
56
  # Make sure the private key from the key pair is provided
57
57
  config.ssh.private_key_path = "~/.ssh/id_rsa"
58
58
 
59
- config.vm.provider :openstack do |os| # e.g.
60
- os.username = "YOUR USERNAME" # "#{ENV['OS_USERNAME']}"
61
- os.api_key = "YOUR API KEY" # "#{ENV['OS_PASSWORD']}"
62
- os.flavor = /m1.tiny/
63
- os.image = /Ubuntu/
64
- os.endpoint = "KEYSTONE AUTH URL" # "#{ENV['OS_AUTH_URL']}/tokens"
65
- os.keypair_name = "YOUR KEYPAIR NAME"
66
- os.ssh_username = "SSH USERNAME"
67
- os.metadata = {"key" => "value"} # Optional
68
- os.network = "YOUR NETWORK_NAME" # Optional
69
- os.address_id = "YOUR ADDRESS ID" # Optional (`network` above has higher precedence)
70
- os.scheduler_hints = {
59
+ config.vm.provider :openstack do |os|
60
+ os.username = "YOUR USERNAME" # e.g. "#{ENV['OS_USERNAME']}"
61
+ os.api_key = "YOUR API KEY" # e.g. "#{ENV['OS_PASSWORD']}"
62
+ os.flavor = /m1.tiny/ # Regex or String
63
+ os.image = /Ubuntu/ # Regex or String
64
+ os.endpoint = "KEYSTONE AUTH URL" # e.g. "#{ENV['OS_AUTH_URL']}/tokens"
65
+ os.keypair_name = "YOUR KEYPAIR NAME" # as stored in Nova
66
+ os.ssh_username = "SSH USERNAME" # login for the VM
67
+
68
+ os.metadata = {"key" => "value"} # optional
69
+ os.user_data = "#cloud-config\nmanage_etc_hosts: True" # optional
70
+ os.network = "YOUR NETWORK_NAME" # optional
71
+ os.address_id = "YOUR ADDRESS ID" # optional (`network` above has higher precedence)
72
+ os.scheduler_hints = {
71
73
  :cell => 'australia'
72
- } # Optional
73
- os.security_groups = ['ssh', 'http'] # Optional
74
- os.tenant = "YOUR TENANT_NAME" # Optional
75
-
74
+ } # optional
75
+ os.availability_zone = "az0001" # optional
76
+ os.security_groups = ['ssh', 'http'] # optional
77
+ os.tenant = "YOUR TENANT_NAME" # optional
78
+ os.floating_ip = "33.33.33.33" # optional (The floating IP to assign for this instance)
76
79
  end
77
80
  end
78
81
  ```
@@ -125,8 +128,11 @@ This provider exposes quite a few provider-specific configuration options:
125
128
  * `address_id` - A specific address identifier to use when connecting to the
126
129
  instance. `network` has higher precedence.
127
130
  * `scheduler_hints` - Pass hints to the open stack scheduler, see `--hint` flag in [OpenStack filters doc](http://docs.openstack.org/trunk/openstack-compute/admin/content/scheduler-filters.html)
131
+ * `availability_zone` - Specify the availability zone in which the instance
132
+ must be created.
128
133
  * `security_groups` - List of security groups to be applied to the machine.
129
134
  * `tenant` - Tenant name. You only need to specify this if your OpenStack user has access to multiple tenants.
135
+ * `region` - Region Name. Specify the region you want the instance to be launched in for multi-region environments.
130
136
 
131
137
 
132
138
  These can be set like typical provider-specific configuration:
@@ -60,8 +60,23 @@ module VagrantPlugins
60
60
  end
61
61
  end
62
62
 
63
+ def self.action_ssh_run
64
+ Vagrant::Action::Builder.new.tap do |b|
65
+ b.use ConfigValidate
66
+ b.use Call, IsCreated do |env, b2|
67
+ if !env[:result]
68
+ b2.use MessageNotCreated
69
+ next
70
+ end
71
+
72
+ b2.use SSHRun
73
+ end
74
+ end
75
+ end
76
+
63
77
  def self.action_up
64
78
  Vagrant::Action::Builder.new.tap do |b|
79
+ b.use HandleBoxUrl
65
80
  b.use ConfigValidate
66
81
  b.use Call, IsCreated do |env, b2|
67
82
  if env[:result]
@@ -72,6 +87,7 @@ module VagrantPlugins
72
87
  b2.use ConnectOpenStack
73
88
  b2.use Provision
74
89
  b2.use SyncFolders
90
+ b2.use SetHostname
75
91
  b2.use WarnNetworks
76
92
  b2.use CreateServer
77
93
  end
@@ -20,6 +20,7 @@ module VagrantPlugins
20
20
  endpoint = config.endpoint
21
21
  username = config.username
22
22
  tenant = config.tenant
23
+ region = config.region
23
24
 
24
25
  @logger.info("Connecting to OpenStack...")
25
26
  env[:openstack_compute] = Fog::Compute.new({
@@ -27,7 +28,8 @@ module VagrantPlugins
27
28
  :openstack_username => username,
28
29
  :openstack_api_key => api_key,
29
30
  :openstack_auth_url => endpoint,
30
- :openstack_tenant => tenant
31
+ :openstack_tenant => tenant,
32
+ :openstack_region => region
31
33
  })
32
34
 
33
35
  if config.network
@@ -35,7 +37,8 @@ module VagrantPlugins
35
37
  :provider => :openstack,
36
38
  :openstack_username => username,
37
39
  :openstack_api_key => api_key,
38
- :openstack_auth_url => endpoint
40
+ :openstack_auth_url => endpoint,
41
+ :openstack_tenant => tenant
39
42
  })
40
43
  end
41
44
 
@@ -41,7 +41,8 @@ module VagrantPlugins
41
41
  :metadata => config.metadata,
42
42
  :user_data => config.user_data,
43
43
  :security_groups => config.security_groups,
44
- :os_scheduler_hints => config.scheduler_hints
44
+ :os_scheduler_hints => config.scheduler_hints,
45
+ :availability_zone => config.availability_zone
45
46
  }
46
47
 
47
48
  # Find a network if provided
@@ -31,11 +31,49 @@ module VagrantPlugins
31
31
 
32
32
  config = machine.provider_config
33
33
 
34
+ # Print a list of the available networks
35
+ server.addresses.each do |network_name, network_info|
36
+ @logger.debug("OpenStack Network Name: #{network_name}")
37
+ end
38
+
34
39
  if config.network
35
40
  host = server.addresses[config.network].last['addr'] rescue nil
36
41
  else
37
42
  host = server.addresses[config.address_id].last['addr'] rescue nil
38
43
  end
44
+
45
+ # If host is still nil, try to find the IP address another way
46
+ if host.nil?
47
+ @logger.debug("Was unable to determine what network to use. Trying to find a valid IP to use.")
48
+ if server.public_ip_addresses.length > 0
49
+ @logger.debug("Public IP addresses available: #{server.public_ip_addresses}")
50
+ if config.floating_ip
51
+ if server.public_ip_addresses.include?(config.floating_ip)
52
+ @logger.debug("Using the floating IP defined in Vagrantfile.")
53
+ host = config.floating_ip
54
+ else
55
+ @logger.debug("The floating IP that was specified is not available to this instance.")
56
+ raise Errors::FloatingIPNotValid
57
+ end
58
+ else
59
+ host = server.public_ip_address
60
+ @logger.debug("Using the first available public IP address: #{host}.")
61
+ end
62
+ elsif server.private_ip_addresses.length > 0
63
+ @logger.debug("Private IP addresses available: #{server.private_ip_addresses}")
64
+ host = server.private_ip_address
65
+ @logger.debug("Using the first available private IP address: #{host}.")
66
+ end
67
+ end
68
+
69
+ # If host got this far and is still nil/empty, raise an error or
70
+ # else vagrant will try connecting to localhost which will never
71
+ # make sense in this scenario
72
+ if host.nil? or host.empty?
73
+ @logger.debug("No valid SSH host could be found.")
74
+ raise Errors::SSHNoValidHost
75
+ end
76
+
39
77
  # Read the DNS info
40
78
  return {
41
79
  # Usually there should only be one public IP
@@ -19,6 +19,13 @@ module VagrantPlugins
19
19
  ssh_info = env[:machine].ssh_info
20
20
 
21
21
  env[:machine].config.vm.synced_folders.each do |id, data|
22
+
23
+ # ignore disabled shared folders
24
+ if data[:disabled]
25
+ @logger.info "Not syncing disabled folder: #{data[:hostpath]} => #{data[:guestpath]}"
26
+ next
27
+ end
28
+
22
29
  hostpath = File.expand_path(data[:hostpath], env[:root_path])
23
30
  guestpath = data[:guestpath]
24
31
 
@@ -37,7 +44,7 @@ module VagrantPlugins
37
44
 
38
45
  # Rsync over to the guest path using the SSH info
39
46
  command = [
40
- "rsync", "--verbose", "--archive", "-z",
47
+ "rsync", "--verbose", "--archive", "-z", "--delete",
41
48
  "--exclude", ".vagrant/",
42
49
  "-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path]}'",
43
50
  hostpath,
@@ -31,12 +31,12 @@ module VagrantPlugins
31
31
  #
32
32
  # @return [String]
33
33
  attr_accessor :username
34
-
34
+
35
35
  # The name of the keypair to use.
36
36
  #
37
37
  # @return [String]
38
38
  attr_accessor :keypair_name
39
-
39
+
40
40
  # Network configurations for the instance
41
41
  #
42
42
  # @return [String]
@@ -50,6 +50,9 @@ module VagrantPlugins
50
50
  # Pass hints to the OpenStack scheduler, e.g. { "cell": "some cell name" }
51
51
  attr_accessor :scheduler_hints
52
52
 
53
+ # Specify the availability zone in which to create the instance
54
+ attr_accessor :availability_zone
55
+
53
56
  # List of strings representing the security groups to apply.
54
57
  # e.g. ['ssh', 'http']
55
58
  #
@@ -77,11 +80,17 @@ module VagrantPlugins
77
80
  #
78
81
  # @return [String]
79
82
  attr_accessor :user_data
80
-
83
+
81
84
  # The floating IP address from the IP pool which will be assigned to the instance.
82
85
  #
83
86
  # @return [String]
84
87
  attr_accessor :floating_ip
88
+
89
+ # The region to specify when the OpenStack cloud has multiple regions
90
+ #
91
+ # @return [String]
92
+ attr_accessor :region
93
+
85
94
  def initialize
86
95
  @api_key = UNSET_VALUE
87
96
  @endpoint = UNSET_VALUE
@@ -94,11 +103,13 @@ module VagrantPlugins
94
103
  @network = UNSET_VALUE
95
104
  @address_id = UNSET_VALUE
96
105
  @scheduler_hints = UNSET_VALUE
106
+ @availability_zone = UNSET_VALUE
97
107
  @security_groups = UNSET_VALUE
98
108
  @ssh_username = UNSET_VALUE
99
109
  @tenant = UNSET_VALUE
100
110
  @user_data = UNSET_VALUE
101
111
  @floating_ip = UNSET_VALUE
112
+ @region = UNSET_VALUE
102
113
  end
103
114
 
104
115
  def finalize!
@@ -116,6 +127,7 @@ module VagrantPlugins
116
127
  @keypair_name = nil if @keypair_name == UNSET_VALUE
117
128
 
118
129
  @scheduler_hints = nil if @scheduler_hints == UNSET_VALUE
130
+ @availability_zone = nil if @availability_zone == UNSET_VALUE
119
131
  @security_groups = nil if @security_groups == UNSET_VALUE
120
132
 
121
133
  # The SSH values by default are nil, and the top-level config
@@ -125,6 +137,8 @@ module VagrantPlugins
125
137
  @tenant = nil if @tenant == UNSET_VALUE
126
138
  @user_data = "" if @user_data == UNSET_VALUE
127
139
  @floating_ip = nil if @floating_ip == UNSET_VALUE
140
+
141
+ @region = nil if @region == UNSET_VALUE
128
142
  end
129
143
 
130
144
  def validate(machine)
@@ -132,7 +146,7 @@ module VagrantPlugins
132
146
 
133
147
  errors << I18n.t("vagrant_openstack.config.api_key_required") if !@api_key
134
148
  errors << I18n.t("vagrant_openstack.config.username_required") if !@username
135
-
149
+
136
150
  { "OpenStack Provider" => errors }
137
151
  end
138
152
  end
@@ -22,6 +22,14 @@ module VagrantPlugins
22
22
  class RsyncError < VagrantOpenStackError
23
23
  error_key(:rsync_error)
24
24
  end
25
+
26
+ class SSHNoValidHost < VagrantOpenStackError
27
+ error_key(:ssh_no_valid_host)
28
+ end
29
+
30
+ class FloatingIPNotValid < VagrantOpenStackError
31
+ error_key(:floating_ip_not_valid)
32
+ end
25
33
  end
26
34
  end
27
35
  end
@@ -23,7 +23,7 @@ module VagrantPlugins
23
23
  Config
24
24
  end
25
25
 
26
- provider(:openstack) do
26
+ provider(:openstack, parallel: true) do
27
27
  # Setup some things
28
28
  OpenStack.init_i18n
29
29
  OpenStack.init_logging
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module OpenStack
3
- VERSION = "0.2.2"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -54,7 +54,14 @@ en:
54
54
  Host path: %{hostpath}
55
55
  Guest path: %{guestpath}
56
56
  Error: %{stderr}
57
-
57
+ ssh_no_valid_host: |-
58
+ Unable to determine what host to connect to. Run `vagrant up` in
59
+ debug mode to see a list of networks available to your tenant.
60
+ Then set either `os.network` or `os.address_id` to one of the
61
+ network names.
62
+ floating_ip_not_valid: |-
63
+ The floating IP specified in the Vagrantfile does not match an
64
+ available public IP address returned by OpenStack.
58
65
  states:
59
66
  short_active: |-
60
67
  active
metadata CHANGED
@@ -1,74 +1,61 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: vagrant-openstack-plugin
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Mitchell Hashimoto
9
8
  - Thomas Kadauke
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-05-30 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2013-09-25 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
16
  name: fog
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
22
21
  version: 1.10.1
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ! '>='
29
- - !ruby/object:Gem::Version
30
- version: 1.10.1
31
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *id001
25
+ - !ruby/object:Gem::Dependency
32
26
  name: rake
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ! '>='
37
- - !ruby/object:Gem::Version
38
- version: '0'
27
+ requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - &id004
30
+ - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: "0"
39
33
  type: :development
40
34
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *id002
36
+ - !ruby/object:Gem::Dependency
48
37
  name: rspec
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
38
+ requirement: &id003 !ruby/object:Gem::Requirement
39
+ requirements:
52
40
  - - ~>
53
- - !ruby/object:Gem::Version
41
+ - !ruby/object:Gem::Version
54
42
  version: 2.13.0
55
43
  type: :development
56
44
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ~>
61
- - !ruby/object:Gem::Version
62
- version: 2.13.0
45
+ version_requirements: *id003
63
46
  description: Enables Vagrant to manage machines in OpenStack Cloud.
64
- email:
47
+ email:
65
48
  - mitchell@hashicorp.com
66
49
  - t.kadauke@cloudbau.de
67
50
  executables: []
51
+
68
52
  extensions: []
53
+
69
54
  extra_rdoc_files: []
70
- files:
55
+
56
+ files:
71
57
  - .gitignore
58
+ - Authors.txt
72
59
  - CHANGELOG.md
73
60
  - Gemfile
74
61
  - LICENSE.txt
@@ -99,33 +86,26 @@ files:
99
86
  - vagrant-openstack-plugin.gemspec
100
87
  homepage: http://www.vagrantup.com
101
88
  licenses: []
89
+
90
+ metadata: {}
91
+
102
92
  post_install_message:
103
93
  rdoc_options: []
104
- require_paths:
94
+
95
+ require_paths:
105
96
  - lib
106
- required_ruby_version: !ruby/object:Gem::Requirement
107
- none: false
108
- requirements:
109
- - - ! '>='
110
- - !ruby/object:Gem::Version
111
- version: '0'
112
- segments:
113
- - 0
114
- hash: 688615191550607003
115
- required_rubygems_version: !ruby/object:Gem::Requirement
116
- none: false
117
- requirements:
118
- - - ! '>='
119
- - !ruby/object:Gem::Version
120
- version: '0'
121
- segments:
122
- - 0
123
- hash: 688615191550607003
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - *id004
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - *id004
124
103
  requirements: []
104
+
125
105
  rubyforge_project:
126
- rubygems_version: 1.8.24
106
+ rubygems_version: 2.1.3
127
107
  signing_key:
128
- specification_version: 3
108
+ specification_version: 4
129
109
  summary: Enables Vagrant to manage machines in OpenStack Cloud.
130
- test_files:
110
+ test_files:
131
111
  - spec/vagrant-openstack-plugin/config_spec.rb