MissionCriticalCloud/vagrant-cloudstack

View on GitHub
functional-tests/vmlifecycle/Vagrantfile.advanced_networking

Summary

Maintainability
Test Coverage
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = '2'

Vagrant.require_version '>= 1.5.0'

machines = {
  'linux-box' => {
    'template'       => ENV['LINUX_TEMPLATE_NAME'],
    'communicator'   => 'ssh',
    'rsync_disabled' => true
  },
  'windows-box' => {
    'template'       => ENV['WINDOWS_TEMPLATE_NAME'],
    'communicator'   => 'winrm',
    'rsync_disabled' => true
  }
}


Vagrant.configure(VAGRANTFILE_API_VERSION) do |global_config|
  machines.each_pair do |name, options|
    global_config.vm.define name do |config|
      config.vm.box = options['template']

      config.vm.communicator = options['communicator']
      config.winrm.retry_delay = 30
      config.vm.synced_folder ".", "/vagrant", type: "rsync",
        rsync__exclude: [".git/", "vendor"], disabled: options['rsync_disabled']
      config.vm.provider :cloudstack do |cloudstack, override|

        cloudstack.display_name = ENV['TEST_NAME']

        cloudstack.host       = ENV['CLOUDSTACK_HOST']
        cloudstack.path       = '/client/api'
        cloudstack.port       = '443'
        cloudstack.scheme     = 'https'
        cloudstack.api_key    = ENV['CLOUDSTACK_API_KEY']
        cloudstack.secret_key = ENV['CLOUDSTACK_SECRET_KEY']
        cloudstack.expunge_on_destroy = ENV['EXPUNGE_ON_DESTROY']=="true"

        cloudstack.zone_name             = ENV['ZONE_NAME']
        cloudstack.network_name          = ENV['NETWORK_NAME']
        cloudstack.service_offering_name = ENV['SERVICE_OFFERING_NAME']
        cloudstack.disk_offering_name    = ENV['DISK_OFFERING_NAME']

        cloudstack.pf_ip_address         = ENV['PUBLIC_SOURCE_NAT_IP']

        cloudstack.pf_public_port        = options['public_port']
        cloudstack.pf_private_port       = options['private_port']
        cloudstack.pf_trusted_networks   = ENV['SOURCE_CIDR']
        cloudstack.pf_open_firewall      = false


        cloudstack.ssh_key               = ENV['SSH_KEY'] unless ENV['SSH_KEY'].nil?
        cloudstack.ssh_user              = ENV['SSH_USER'] unless ENV['SSH_USER'].nil?
        cloudstack.vm_user               = ENV['WINDOWS_USER'] unless ENV['WINDOWS_USER'].nil?

      end
    end
  end
end