Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use sec groups if enabled, don't use networks in Basic #134

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Vagrant.configure("2") do |config|
cloudstack.network_id = "AAAAAAAAAAAAAAAAAAA"
cloudstack.zone_id = "AAAAAAAAAAAAAAAAAAA"
cloudstack.project_id = "AAAAAAAAAAAAAAAAAAA"
cloudstack.network_type = "Advanced" # or "Basic"
end
end
```
Expand All @@ -82,7 +81,6 @@ Vagrant.configure("2") do |config|
cloudstack.name = "doge-is-a-hostname-now"
# Sadly there is currently no support for the project api in fog.
cloudstack.project_id = "AAAAAAAAAAAAAAAAAAA"
cloudstack.network_type = "Advanced" # or "Basic"
end
end
```
Expand Down Expand Up @@ -130,7 +128,6 @@ to update UUIDs in your Vagrantfile. If both are specified, the id parameter tak
* `domain_id` - Domain id to launch the instance into
* `network_id` - Network uuid that the instance should use
* `network_name` - Network name that the instance should use
* `network_type` - CloudStack Network Type(default: Advanced)
* `project_id` - Project uuid that the instance should belong to
* `service_offering_id`- Service offering uuid to use for the instance
* `service_offering_name`- Service offering name to use for the instance
Expand Down Expand Up @@ -211,9 +208,15 @@ supported with `vagrant-cloudstack`, currently. If any of these are
specified, Vagrant will emit a warning, but will otherwise boot
the Cloudstack machine.

### Basic networking versus Advanced networking

The plugin will determine this network type dynamically from the zone.
The setting `network_type` in the Vagrant file has been deprecated,
and is silently ignored.

### Basic Networking

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

If you already have Security Groups, you can associate them to your
Expand All @@ -226,7 +229,6 @@ Vagrant.configure("2") do |config|
config.vm.provider :cloudstack do |cloudstack|
cloudstack.api_key = "foo"
cloudstack.secret_key = "bar"
cloudstack.network_type = "basic"
cloudstack.security_group_ids = ['aaaa-bbbb-cccc-dddd', '1111-2222-3333-4444']
end
end
Expand All @@ -241,7 +243,6 @@ Vagrant.configure("2") do |config|
config.vm.provider :cloudstack do |cloudstack|
cloudstack.api_key = "foo"
cloudstack.secret_key = "bar"
cloudstack.network_type = "basic"
cloudstack.security_group_names = ['
min_fantastiska_security_group', 'another_security_grupp']
end
Expand All @@ -257,7 +258,6 @@ Vagrant.configure("2") do |config|
config.vm.provider :cloudstack do |cloudstack|
cloudstack.api_key = "foo"
cloudstack.secret_key = "bar"
cloudstack.network_type = "basic"
cloudstack.security_groups = [
{
:name => "Awesome_security_group",
Expand Down
1 change: 0 additions & 1 deletion functional-tests/rsync/Vagrantfile.advanced_networking
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
cloudstack.network_name = ENV['NETWORK_NAME']
cloudstack.service_offering_name = ENV['SERVICE_OFFERING_NAME']

cloudstack.network_type = 'Advanced'
cloudstack.pf_ip_address = public_source_nat_ip
cloudstack.pf_public_port = public_ssh_port
cloudstack.pf_private_port = ENV['PRIVATE_SSH_PORT']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |global_config|
cloudstack.network_name = ENV['NETWORK_NAME']
cloudstack.service_offering_name = ENV['SERVICE_OFFERING_NAME']

cloudstack.network_type = 'Advanced'
cloudstack.pf_ip_address = public_source_nat_ip

cloudstack.pf_public_port = options['public_port']
Expand Down
26 changes: 24 additions & 2 deletions lib/vagrant-cloudstack/action/run_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def call(env)
@template = CloudstackResource.new(domain_config.template_id, domain_config.template_name || env[:machine].config.vm.box, 'template')

hostname = domain_config.name
network_type = domain_config.network_type
project_id = domain_config.project_id
keypair = domain_config.keypair
static_nat = domain_config.static_nat
Expand All @@ -64,11 +63,34 @@ def call(env)
private_ip_address = domain_config.private_ip_address

@resource_service.sync_resource(@zone, { 'available' => true })
@resource_service.sync_resource(@network)
cs_zone = env[:cloudstack_compute].zones.find{ |f| f.id == @zone.id }
@resource_service.sync_resource(@service_offering)
@resource_service.sync_resource(@disk_offering)
@resource_service.sync_resource(@template, {'zoneid' => @zone.id, 'templatefilter' => 'executable' })

if cs_zone.network_type.downcase == 'basic'
# No network specification in basic zone
env[:ui].warn(I18n.t('vagrant_cloudstack.basic_network', :zone_name => @zone.name)) if @network.id || @network.name
@network = CloudstackResource.new(nil, nil, 'network')

# No portforwarding in basic zone, so none of the below
pf_ip_address = nil
pf_ip_address_id = nil
pf_public_port = nil
pf_public_rdp_port = nil
pf_public_port_randomrange = nil
else
@resource_service.sync_resource(@network)
end

if !cs_zone.security_groups_enabled
if !security_group_ids.empty? || !security_group_names.empty? || !security_groups.empty?
env[:ui].warn(I18n.t('vagrant_cloudstack.security_groups_disabled', :zone_name => @zone.name))
end
security_group_ids = []
security_group_names = []
security_groups = []
end
# Can't use Security Group IDs and Names at the same time
# Let's use IDs by default...
if security_group_ids.empty? and !security_group_names.empty?
Expand Down
6 changes: 6 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ en:
vagrant_cloudstack:
already_status: |-
The machine is already %{status}.
basic_network: |-
Network name or id defined but zone %{zone_name} is of network type 'Basic'
Network name or id will be ignored
launching_instance: |-
Launching an instance with the following settings...
launch_no_keypair_no_sshkey: |-
Expand All @@ -21,6 +24,9 @@ en:
Make sure rsync is installed and the binary can be found in the PATH.
rsync_folder: |-
Rsyncing folder: %{hostpath} => %{guestpath}
security_groups_disabled: |-
Security groups defined but not supported in the zone %{zone_name}
Defined security groups will be ignored
ssh_key_pair_creating: |-
Creating an SSH keypair in CloudStack...
ssh_key_pair_removing: |-
Expand Down
2 changes: 1 addition & 1 deletion vagrant-cloudstack.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Gem::Specification.new do |s|
s.version = VagrantPlugins::Cloudstack::VERSION
s.platform = Gem::Platform::RUBY
s.license = 'MIT'
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']
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']
s.email = 'int-toolkit@schubergphilis.com'
s.homepage = 'https://github.com/schubergphilis/vagrant-cloudstack/'
s.summary = 'Enables Vagrant to manage machines in Cloudstack.'
Expand Down