Skip to content

Commit c8341b3

Browse files
committed
Only use sec groups if enabled, don't use networks in Basic
1 parent 467faaf commit c8341b3

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

README.md

Lines changed: 7 additions & 6 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

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: |-

0 commit comments

Comments
 (0)