Skip to content

Commit b4ec378

Browse files
Merge pull request #134 from bheuvel/feature/zonetype_detect
Only use sec groups if enabled, don't use networks in Basic
2 parents 467faaf + f6fb216 commit b4ec378

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Vagrant.configure("2") do |config|
5656
cloudstack.network_id = "AAAAAAAAAAAAAAAAAAA"
5757
cloudstack.zone_id = "AAAAAAAAAAAAAAAAAAA"
5858
cloudstack.project_id = "AAAAAAAAAAAAAAAAAAA"
59-
cloudstack.network_type = "Advanced" # or "Basic"
6059
end
6160
end
6261
```
@@ -82,7 +81,6 @@ Vagrant.configure("2") do |config|
8281
cloudstack.name = "doge-is-a-hostname-now"
8382
# Sadly there is currently no support for the project api in fog.
8483
cloudstack.project_id = "AAAAAAAAAAAAAAAAAAA"
85-
cloudstack.network_type = "Advanced" # or "Basic"
8684
end
8785
end
8886
```
@@ -130,7 +128,6 @@ to update UUIDs in your Vagrantfile. If both are specified, the id parameter tak
130128
* `domain_id` - Domain id to launch the instance into
131129
* `network_id` - Network uuid that the instance should use
132130
* `network_name` - Network name that the instance should use
133-
* `network_type` - CloudStack Network Type(default: Advanced)
134131
* `project_id` - Project uuid that the instance should belong to
135132
* `service_offering_id`- Service offering uuid to use for the instance
136133
* `service_offering_name`- Service offering name to use for the instance
@@ -211,9 +208,15 @@ supported with `vagrant-cloudstack`, currently. If any of these are
211208
specified, Vagrant will emit a warning, but will otherwise boot
212209
the Cloudstack machine.
213210

211+
### Basic networking versus Advanced networking
212+
213+
The plugin will determine this network type dynamically from the zone.
214+
The setting `network_type` in the Vagrant file has been deprecated,
215+
and is silently ignored.
216+
214217
### Basic Networking
215218

216-
If you set the `network_type` to `basic`, you can use Security
219+
If the network type of your zone is `basic`, you can use Security
217220
Groups and associate rules in your Vagrantfile.
218221

219222
If you already have Security Groups, you can associate them to your
@@ -226,7 +229,6 @@ Vagrant.configure("2") do |config|
226229
config.vm.provider :cloudstack do |cloudstack|
227230
cloudstack.api_key = "foo"
228231
cloudstack.secret_key = "bar"
229-
cloudstack.network_type = "basic"
230232
cloudstack.security_group_ids = ['aaaa-bbbb-cccc-dddd', '1111-2222-3333-4444']
231233
end
232234
end
@@ -241,7 +243,6 @@ Vagrant.configure("2") do |config|
241243
config.vm.provider :cloudstack do |cloudstack|
242244
cloudstack.api_key = "foo"
243245
cloudstack.secret_key = "bar"
244-
cloudstack.network_type = "basic"
245246
cloudstack.security_group_names = ['
246247
min_fantastiska_security_group', 'another_security_grupp']
247248
end
@@ -257,7 +258,6 @@ Vagrant.configure("2") do |config|
257258
config.vm.provider :cloudstack do |cloudstack|
258259
cloudstack.api_key = "foo"
259260
cloudstack.secret_key = "bar"
260-
cloudstack.network_type = "basic"
261261
cloudstack.security_groups = [
262262
{
263263
:name => "Awesome_security_group",

functional-tests/rsync/Vagrantfile.advanced_networking

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
2727
cloudstack.network_name = ENV['NETWORK_NAME']
2828
cloudstack.service_offering_name = ENV['SERVICE_OFFERING_NAME']
2929

30-
cloudstack.network_type = 'Advanced'
3130
cloudstack.pf_ip_address = public_source_nat_ip
3231
cloudstack.pf_public_port = public_ssh_port
3332
cloudstack.pf_private_port = ENV['PRIVATE_SSH_PORT']

functional-tests/vmlifecycle/Vagrantfile.advanced_networking

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |global_config|
5050
cloudstack.network_name = ENV['NETWORK_NAME']
5151
cloudstack.service_offering_name = ENV['SERVICE_OFFERING_NAME']
5252

53-
cloudstack.network_type = 'Advanced'
5453
cloudstack.pf_ip_address = public_source_nat_ip
5554

5655
cloudstack.pf_public_port = options['public_port']

lib/vagrant-cloudstack/action/run_instance.rb

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def call(env)
3737
@template = CloudstackResource.new(domain_config.template_id, domain_config.template_name || env[:machine].config.vm.box, 'template')
3838

3939
hostname = domain_config.name
40-
network_type = domain_config.network_type
4140
project_id = domain_config.project_id
4241
keypair = domain_config.keypair
4342
static_nat = domain_config.static_nat
@@ -64,11 +63,34 @@ def call(env)
6463
private_ip_address = domain_config.private_ip_address
6564

6665
@resource_service.sync_resource(@zone, { 'available' => true })
67-
@resource_service.sync_resource(@network)
66+
cs_zone = env[:cloudstack_compute].zones.find{ |f| f.id == @zone.id }
6867
@resource_service.sync_resource(@service_offering)
6968
@resource_service.sync_resource(@disk_offering)
7069
@resource_service.sync_resource(@template, {'zoneid' => @zone.id, 'templatefilter' => 'executable' })
7170

71+
if cs_zone.network_type.downcase == 'basic'
72+
# No network specification in basic zone
73+
env[:ui].warn(I18n.t('vagrant_cloudstack.basic_network', :zone_name => @zone.name)) if @network.id || @network.name
74+
@network = CloudstackResource.new(nil, nil, 'network')
75+
76+
# No portforwarding in basic zone, so none of the below
77+
pf_ip_address = nil
78+
pf_ip_address_id = nil
79+
pf_public_port = nil
80+
pf_public_rdp_port = nil
81+
pf_public_port_randomrange = nil
82+
else
83+
@resource_service.sync_resource(@network)
84+
end
85+
86+
if !cs_zone.security_groups_enabled
87+
if !security_group_ids.empty? || !security_group_names.empty? || !security_groups.empty?
88+
env[:ui].warn(I18n.t('vagrant_cloudstack.security_groups_disabled', :zone_name => @zone.name))
89+
end
90+
security_group_ids = []
91+
security_group_names = []
92+
security_groups = []
93+
end
7294
# Can't use Security Group IDs and Names at the same time
7395
# Let's use IDs by default...
7496
if security_group_ids.empty? and !security_group_names.empty?

locales/en.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ en:
22
vagrant_cloudstack:
33
already_status: |-
44
The machine is already %{status}.
5+
basic_network: |-
6+
Network name or id defined but zone %{zone_name} is of network type 'Basic'
7+
Network name or id will be ignored
58
launching_instance: |-
69
Launching an instance with the following settings...
710
launch_no_keypair_no_sshkey: |-
@@ -21,6 +24,9 @@ en:
2124
Make sure rsync is installed and the binary can be found in the PATH.
2225
rsync_folder: |-
2326
Rsyncing folder: %{hostpath} => %{guestpath}
27+
security_groups_disabled: |-
28+
Security groups defined but not supported in the zone %{zone_name}
29+
Defined security groups will be ignored
2430
ssh_key_pair_creating: |-
2531
Creating an SSH keypair in CloudStack...
2632
ssh_key_pair_removing: |-

vagrant-cloudstack.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
66
s.version = VagrantPlugins::Cloudstack::VERSION
77
s.platform = Gem::Platform::RUBY
88
s.license = 'MIT'
9-
s.authors = ['Mitchell Hashimoto', 'Carl Loa Odin', 'Tor-Åke Fransson', 'Olle Lundberg', 'Roeland Kuipers', 'Yuichi Uemura', 'Atsushi Sasaki', 'Nicolas Brechet', 'Peter Jönsson', 'Christophe Roux', 'Andrei Chiriaev', 'Miguel Ferreira', 'Timothy van Zadelhoff', 'Geurt Schimmel']
9+
s.authors = ['Mitchell Hashimoto', 'Carl Loa Odin', 'Tor-Åke Fransson', 'Olle Lundberg', 'Roeland Kuipers', 'Yuichi Uemura', 'Atsushi Sasaki', 'Nicolas Brechet', 'Peter Jönsson', 'Christophe Roux', 'Andrei Chiriaev', 'Miguel Ferreira', 'Timothy van Zadelhoff', 'Geurt Schimmel', 'Bob van den Heuvel']
1010
s.email = '[email protected]'
1111
s.homepage = 'https://github.com/schubergphilis/vagrant-cloudstack/'
1212
s.summary = 'Enables Vagrant to manage machines in Cloudstack.'

0 commit comments

Comments
 (0)