diff --git a/manifests/compute.pp b/manifests/compute.pp index 1227cb6..6e838e8 100644 --- a/manifests/compute.pp +++ b/manifests/compute.pp @@ -33,7 +33,6 @@ class openstack::compute ( $multi_host = false, # Quantum $quantum = false, - $quantum_sql_connection = false, $quantum_host = false, $quantum_user_password = false, $keystone_host = false, @@ -154,9 +153,6 @@ class openstack::compute ( } } else { - if ! $quantum_sql_connection { - fail('quantum sql connection must be specified when quantum is installed on compute instances') - } if ! $quantum_host { fail('quantum host must be specified when quantum is installed on compute instances') } @@ -176,25 +172,11 @@ class openstack::compute ( #sql_connection => $quantum_sql_connection, } - class { 'quantum::plugins::ovs': - tenant_network_type => 'gre', - enable_tunneling => true, - } - class { 'quantum::agents::ovs': - bridge_uplinks => ["br-virtual:${private_interface}"], enable_tunneling => true, local_ip => $internal_address, } - class { 'quantum::agents::dhcp': - use_namespaces => False, - } - - class { 'quantum::agents::l3': - auth_password => $quantum_user_password, - } - class { 'nova::compute::quantum': } # does this have to be installed on the compute node? diff --git a/manifests/nova/controller.pp b/manifests/nova/controller.pp index dd8a91d..f6dd736 100644 --- a/manifests/nova/controller.pp +++ b/manifests/nova/controller.pp @@ -160,11 +160,11 @@ class openstack::nova::controller ( class { 'quantum::plugins::ovs': sql_connection => $quantum_sql_connection, tenant_network_type => 'gre', - enable_tunneling => true, } class { 'quantum::agents::ovs': - bridge_uplinks => ["br-virtual:${private_interface}"], + bridge_uplinks => ["br-ex:${public_interface}"], + bridge_mappings => ['external:br-ex'], enable_tunneling => true, local_ip => $internal_address, } @@ -173,15 +173,10 @@ class openstack::nova::controller ( use_namespaces => False, } - -# class { 'quantum::agents::dhcp': -# use_namespaces => False, -# } -# -# -# class { 'quantum::agents::l3': -# auth_password => $quantum_user_password, -# } + class { 'quantum::agents::l3': + external_network_bridge => 'br-ex', + auth_password => $quantum_user_password, + } class { 'nova::network::quantum': #$fixed_range, diff --git a/spec/classes/openstack_compute_spec.rb b/spec/classes/openstack_compute_spec.rb index a217b3b..e23b4d3 100644 --- a/spec/classes/openstack_compute_spec.rb +++ b/spec/classes/openstack_compute_spec.rb @@ -8,6 +8,7 @@ describe 'openstack::compute' do :internal_address => '0.0.0.0', :nova_user_password => 'nova_pass', :rabbit_password => 'rabbit_pw', + :rabbit_host => '127.0.0.1', :rabbit_virtual_host => '/', :sql_connection => 'mysql://user:pass@host/dbname/', :cinder_sql_connection => 'mysql://user:pass@host/dbname/', @@ -228,4 +229,37 @@ describe 'openstack::compute' do } end + describe 'when configuring quantum' do + let :params do + default_params.merge({ + :internal_address => '127.0.0.1', + :public_interface => 'eth3', + :quantum => true, + :keystone_host => '127.0.0.1', + :quantum_host => '127.0.0.1', + :quantum_user_password => 'quantum_user_password', + }) + end + it 'should configure quantum' do + should contain_class('quantum').with( + :verbose => 'False', + :debug => 'False', + :rabbit_host => default_params[:rabbit_host], + :rabbit_password => default_params[:rabbit_password] + ) + should contain_class('quantum::agents::ovs').with( + :enable_tunneling => true, + :local_ip => '127.0.0.1' + ) + should contain_class('nova::compute::quantum') + should contain_class('nova::network::quantum').with( + :quantum_admin_password => 'quantum_user_password', + :quantum_connection_host => '127.0.0.1', + :quantum_url => "http://127.0.0.1:9696", + :quantum_admin_tenant_name => 'services', + :quantum_admin_auth_url => "http://127.0.0.1:35357/v2.0" + ) + end + end + end diff --git a/spec/classes/openstack_controller_spec.rb b/spec/classes/openstack_controller_spec.rb index f71591b..7abc586 100644 --- a/spec/classes/openstack_controller_spec.rb +++ b/spec/classes/openstack_controller_spec.rb @@ -403,6 +403,7 @@ describe 'openstack::controller' do end it { should_not contain_class('horizon') } end + end context 'cinder' do @@ -463,11 +464,61 @@ describe 'openstack::controller' do context 'when quantum' do let :params do - default_params.merge(:quantum => true) + default_params.merge({ + :quantum => true, + :verbose => true, + :quantum_user_password => 'q_pass', + :public_interface => 'eth_27' + }) end it { should_not contain_class('nova::network') } + it 'should configure quantum' do + + should contain_class('quantum').with({ + :rabbit_user => 'nova', + :rabbit_password => 'rabbit_pw', + :verbose => true, + :debug => true, + }) + + should contain_class('quantum::server').with({ + :auth_password => 'q_pass', + }) + + should contain_class('quantum::plugins::ovs').with({ + :sql_connection => 'mysql://quantum:quantum_pass@127.0.0.1/quantum?charset=utf8', + + }) + + should contain_class('quantum::agents::ovs').with( { + :bridge_uplinks => ["br-ex:eth_27"], + :bridge_mappings => ['external:br-ex'], + :enable_tunneling => true, + :local_ip => '127.0.0.1', + } ) + + should contain_class('quantum::agents::dhcp').with( { + :use_namespaces => 'False', + } ) + + should contain_class('quantum::agents::l3').with( { + :external_network_bridge => 'br-ex', + :auth_password => 'q_pass', + } ) + + should contain_class('nova::network::quantum').with({ + :quantum_admin_password => 'q_pass', + :quantum_connection_host => 'localhost', + :quantum_auth_strategy => 'keystone', + :quantum_url => "http://127.0.0.1:9696", + :quantum_admin_tenant_name => 'services', + :quantum_admin_auth_url => "http://127.0.0.1:35357/v2.0", + }) + + end + end context 'when nova network' do diff --git a/templates/test_nova.sh.erb b/templates/test_nova.sh.erb index 8f628d6..46da25f 100644 --- a/templates/test_nova.sh.erb +++ b/templates/test_nova.sh.erb @@ -38,9 +38,22 @@ nova --no-cache keypair-add --pub_key /tmp/id_rsa.pub key_cirros instance_name='<%= image_type %>_test_vm' <% if quantum -%> + +quantum net-create public --router:external=True +quantum subnet-create --allocation-pool start=172.16.2.128,end=172.16.2.150 public 172.16.2.0/24 + quantum net-create net1 quantum subnet-create net1 10.0.0.0/24 + quantum_net=`quantum net-list | grep net1 | awk -F' ' '{print $2}'` +quantum_public_net=`quantum net-list | grep public | awk -F' ' '{print $2}'` +quantum_prv_subnet=`quantum subnet-list | grep '10.0.0.0/24' | awk -F' ' '{print $2}'` + +quantum router-create router1 +quantum router-interface-add router1 $quantum_prv_subnet +quantum router-gateway-set router1 $quantum_public_net + + nova --no-cache boot --flavor 1 --image $IMAGE_ID --key_name key_cirros --nic net-id=$quantum_net $instance_name <% else -%> <% if floating_ip -%> @@ -68,10 +81,20 @@ sleep <%= sleep_time %> <% if floating_ip -%> # Now add the floating IP we reserved earlier to the machine. -nova --no-cache add-floating-ip $instance_name $floating_ip + # if not quantum + nova --no-cache add-floating-ip $instance_name $floating_ip # Wait and then try to SSH to the node, leveraging the private key # we generated earlier. sleep <%= sleep_time %> ssh $login_user@$floating_ip -i /tmp/id_rsa -o StrictHostKeyChecking=no hostname <% end -%> + +<% if quantum %> +# get port +ip_addr=`nova show $instance_name | grep 'net1 network' | awk -F'|' '{print $3}'` +port_id=`quantum port-list | grep $ip_addr | awk -F' ' '{print $2}'` +quantum floatingip-create --port_id $port_id $quantum_public_net +sleep <%= sleep_time %> +ssh $login_user@$floating_ip -i /tmp/id_rsa -o StrictHostKeyChecking=no hostname +<% end %> exit 0