henrydenhengst

XenServer: 6.5 - CentOS: 7.0 - OpenStack: Liberty

Dec 1st, 2015
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 11.88 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # https://www.citrix.com/blogs/2015/11/30/integrating-xenserver-rdo-and-neutron/
  4. #
  5. # Citrix XenServer is a great choice of hypervisor under OpenStack,
  6. # but there is no native integration between it and RedHat’s RDO packages.
  7. # This means that setting up an integrated environment using XenServer and RDO is more difficult than it should be.
  8. # This script aims to resolve that, giving a method where CentOS can be set up easily to use XenServer as the hypervisor.
  9. #
  10. # Environment: XenServer: 6.5 - CentOS: 7.0 - OpenStack: Liberty - Network: Neutron, ML2 plugin, OVS, VLAN
  11. #
  12. # 1. Install XenServer
  13. #
  14. # The XenServer integration with OpenStack has some optimizations which means that only EXT3 storage is supported.
  15. # Make sure when installing your XenServer you select Optimized for XenDesktop when prompted.
  16. # Use XenCenter to check that the SR type is EXT3 as fixing it after creating the VMs will require deleting the VMs and starting again.
  17. #
  18. # 2. Install OpenStack VM
  19. #
  20. # With XenServer, the Nova Compute service must run in a virtual machine on the hypervisor that they will be controlling.
  21. # As we’re using CentOS 7.0 for this environment, create a VM using the CentOS 7.0 template in XenCenter.
  22. # If you want to copy+paste the scripts from the rest of the blog, use the name “CentOS_RDO” for this VM.
  23. # Install the CentOS 7.0 VM but shut it down before installing RDO.
  24. #
  25. # 2.1 Create network for OpenStack VM
  26. #
  27. # In single box environment, we need three networks, “Integration network”, “External network”, “VM network”.
  28. # If you have appropriate networks for the above (e.g. a network that gives you external access)
  29. # then rename the existing network to have the appropriate name-label.
  30. # Note that a helper script rdo_xenserver_helper.sh is provided for some of the later steps in this blog
  31. # rely on these specific name labels, so if you choose not to use them then please also update the helper script.
  32. #
  33. # Run the following commands in dom0:
  34. xe network-create name-label=openstack-int-network
  35. xe network-create name-label=openstack-ext-network
  36. xe network-create name-label=openstack-vm-network
  37. #
  38. # 2.2 Create virtual network interfaces for OpenStack VM
  39. #
  40. # This step requires the VM to be shut down,
  41. # as it’s modifying the network setup and the PV tools have not been installed in the guest.
  42. #
  43. vm_uuid=$(xe vm-list name-label=CentOS_RDO minimal=true)
  44. vm_net_uuid=$(xe network-list name-label=openstack-vm-network minimal=true)
  45. next_device=$(xe vm-param-get uuid=$vm_uuid param-name=allowed-VIF-devices | cut -d';' -f1)
  46. vm_vif_uuid=$(xe vif-create device=$next_device network-uuid=$vm_net_uuid vm-uuid=$vm_uuid)
  47. xe vif-plug uuid=$vm_vif_uuid
  48. #
  49. ext_net_uuid=$(xe network-list name-label=openstack-ext-network minimal=true)
  50. next_device=$(xe vm-param-get uuid=$vm_uuid param-name=allowed-VIF-devices | cut -d';' -f1)
  51. ext_vif_uuid=$(xe vif-create device=$next_device network-uuid=$ext_net_uuid vm-uuid=$vm_uuid)
  52. xe vif-plug uuid=$ext_vif_uuid
  53. #
  54. # You can also choose use helper script to do these in dom0.
  55. #
  56. # source rdo_xenserver_helper.sh
  57. # create_vif
  58. #
  59. # 2.3 Configure OpenStackVM/Hypervisor communications
  60. #
  61. # Use HIMN tool (plugin for XenCenter) to add internal management network to OpenStack VMs.
  62. # This effectively performs the following operations,
  63. # which could also be performed manually in dom0 or use rdo_xenserver_helper.sh.
  64. #
  65. source rdo_xenserver_helper.sh
  66. create_himn
  67. #
  68. # Note: If using the commands manually, they should be run when the OpenStack VM is shut down
  69. #
  70. # Set up DHCP on the HIMN network for OpenStack VM, allowing OpenStack VM to access its own hypervisor
  71. # on the static address 169.254.0.1. Run helper script in domU.
  72. #
  73. source rdo_xenserver_helper.sh
  74. active_himn_interface
  75. #
  76. # 3. Install RDO
  77. #
  78. # 3.1 RDO Quickstart gives detailed installation guide, please follow the instruction step by step.
  79. # This manual only pointed out the steps that must pay attation to during installation.
  80. #
  81. # 3.2 Step 3: Run Packstack to install OpenStack
  82. #
  83. # Rather than running packstack immediately, we need to generate an answerfile so that we can tweak the configuration.
  84. #
  85. # Generate answer file:
  86. #
  87. packstack --gen-answer-file=<ANSWER_FILE>
  88. # Install OpenStack services:
  89. #
  90. packstack --answer-file=<ANSWER_FILE>
  91. # These items in <ANSWER_FILE> should be changed as below:
  92. #
  93. CONFIG_NEUTRON_ML2_TYPE_DRIVERS=vlan
  94. CONFIG_NEUTRON_ML2_TENANT_NETWORK_TYPES=vlan
  95. # These items in <ANSWER_FILE> should be changed according to your environment:
  96. #
  97. CONFIG_NEUTRON_ML2_VLAN_RANGES=<physnet1:1000:1050>
  98. CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=<physnet1:br-eth1,phyext:br-ex>
  99. CONFIG_NEUTRON_OVS_BRIDGE_IFACES=<br-eth1:eth1,br-ex:eth2>
  100. # NOTE:
  101. # <physnet1:1000:1050>: physnet1 is physical network name for VLAN provider and tenant networks.
  102. # 1000:1050 is VLAN tag ranges on each physical network for allocation to tenant networks.
  103. #
  104. # <physnet1:br-eth1,phyext:br-ex>: br-eth1 is OVS bridge for VM network.
  105. # br-ex is OVS bridge for External network, neutron L3 agent use it for external traffic.
  106. #
  107. # <br-eth1:eth1,br-ex:eth2>: eth1 is OpenStack VM’s NIC which connected to VM network.
  108. # eth2 is OpenStack VM’s NIC which connected to External network.
  109. #
  110. # 4. Configure Nova and Neutron
  111. #
  112. # 4.1 Copy Nova and Neutron plugins to XenServer host.
  113. #
  114. source rdo_xenserver_helper.sh
  115. install_dom0_plugins
  116. #
  117. # 4.2 Edit /etc/nova/nova.conf, switch compute driver to XenServer.
  118. #
  119. [DEFAULT]
  120. compute_driver=xenapi.XenAPIDriver
  121.  
  122. [xenserver]
  123. connection_url=http://169.254.0.1
  124. connection_username=root
  125. connection_password=<password>
  126. vif_driver=nova.virt.xenapi.vif.XenAPIOpenVswitchDriver
  127. ovs_int_bridge=<integration network bridge>
  128. # NOTE:
  129. #
  130. # The integration_bridge above can be found from dom0:
  131. #
  132. xe network-list name-label=openstack-int-network params=bridge
  133. #
  134. # 169.254.0.1 is hypervisor dom0’s address which OpenStack VM can reach via HIMN.
  135. #
  136. # 4.3 Install XenAPI Python XML RPC lightweight bindings.
  137. #
  138. yum install -y python-pip
  139. pip install xenapi
  140. # 4.4 Configure Neutron
  141. #
  142. # Edit /etc/neutron/rootwrap.conf to support uing XenServer remotely.
  143. #
  144. [xenapi]
  145. # XenAPI configuration is only required by the L2 agent if it is to
  146. # target a XenServer/XCP compute host's dom0.
  147. xenapi_connection_url=http://169.254.0.1
  148. xenapi_connection_username=root
  149. xenapi_connection_password=<password>
  150. # 4.5 Restart Nova and Neutron Services
  151. #
  152. for svc in api cert conductor compute scheduler; do \
  153.     service openstack-nova-$svc restart; \
  154. done
  155. #
  156. service neutron-openvswitch-agent restart
  157. # 5. Launch another neutron-openvswitch-agent for talking with Dom0
  158. #
  159. # XenServer has a seperation of Dom0 and DomU and all instances’ VIFs are actually managed by Dom0.
  160. # Their corresponding OVS ports are created in Dom0.
  161. # Thus, we should manually start the other ovs agent which is in charge of these ports and is talking to Dom0,
  162. # refer xenserver_neutron picture.
  163. #
  164. # 5.1 Create another configuration file
  165. #
  166. cp /etc/neutron/plugins/ml2/openvswitch_agent.ini /etc/neutron/plugins/ml2/openvswitch_agent.ini.dom0
  167. #
  168. [ovs]
  169. integration_bridge = xapi3
  170. bridge_mappings = physnet1:xapi2
  171.  
  172. [agent]
  173. root_helper = neutron-rootwrap-xen-dom0 /etc/neutron/rootwrap.conf
  174. root_helper_daemon =
  175. minimize_polling = False
  176.  
  177. [securitygroup]
  178. firewall_driver = neutron.agent.firewall.NoopFirewallDriver
  179. # NOTE:
  180. #
  181. # xapi3 the integration bridge is xapX in the graph. xapi2 is vm network bridge, it’s xapiY in the graph.
  182. #
  183. xe network-list name-label=openstack-int-network params=bridgexe network-list name-label=openstack-vm-network params=bridge
  184. #
  185. # 5.2 Launch neutron-openvswitch-agent
  186. #
  187. # 6. Replace cirros guest with one setup to work for XenServer
  188. #
  189. /usr/bin/python2 /usr/bin/neutron-openvswitch-agent --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/openvswitch_agent.ini.dom0 --config-dir /etc/neutron/conf.d/neutron-openvswitch-agent --log-file /var/log/neutron/openvswitch-agent.log.dom0 &
  190. # 6. Replace cirros guest with one set up to work for XenServer
  191. #
  192. nova image-delete cirros
  193. #
  194. wget http://ca.downloads.xensource.com/OpenStack/cirros-0.3.4-x86_64-disk.vhd.tgz
  195. #
  196. glance image-create --name cirros --container-format ovf --disk-format vhd --property vm_mode=xen --visibility public --file cirros-0.3.4-x86_64-disk.vhd.tgz
  197. #
  198. # 7. Launching instance and test its connectivity
  199. #
  200. source keystonerc_demo
  201.  
  202. # [root@localhost ~(keystone_demo)]#
  203. glance image-list
  204. #    +--------------------------------------+--------+
  205. #    | ID                                   | Name   |
  206. #    +--------------------------------------+--------+
  207. #    | 5c227c8e-3cfa-4368-963c-6ebc2f846ee1 | cirros |
  208. #    +--------------------------------------+--------+
  209. #
  210. # [root@localhost ~(keystone_demo)]#
  211. neutron net-list
  212. #    +--------------------------------------+---------+--------------------------------------------------+
  213. #    | id                                   | name    | subnets                                          |
  214. #    +--------------------------------------+---------+--------------------------------------------------+
  215. #    | 91c0f6ac-36f2-46fc-b075-6213a241fc2b | private | 3a4eebdc-6727-43e3-b5fe-8760d64c00fb 10.0.0.0/24 |
  216. #    | 7ccf5c93-ca20-4962-b8bb-bff655e29788 | public  | 4e023f19-dfdd-4d00-94cc-dbea59b31698             |
  217. #    +--------------------------------------+---------+--------------------------------------------------+
  218. #
  219. nova boot --flavor m1.tiny --image cirros --nic net-id=91c0f6ac-36f2-46fc-b075-6213a241fc2b demo-instance
  220. #
  221. # [root@localhost ~(keystone_demo)]#
  222. neutron floatingip-create public
  223. # Created a new floatingip:
  224. #    +---------------------+--------------------------------------+
  225. #    | Field               | Value                                |
  226. #    +---------------------+--------------------------------------+
  227. #    | fixed_ip_address    |                                      |
  228. #    | floating_ip_address | 172.24.4.228                         |
  229. #    | floating_network_id | 7ccf5c93-ca20-4962-b8bb-bff655e29788 |
  230. #    | id                  | 2f0e7c1e-07dc-4c7e-b9a6-64f312e7f693 |
  231. #    | port_id             |                                      |
  232. #    | router_id           |                                      |
  233. #    | status              | DOWN                                 |
  234. #    | tenant_id           | 838ec33967ff4f659b808e4a593e7085     |
  235. #    +---------------------+--------------------------------------+
  236. #
  237. nova add-floating-ip demo-instance 172.24.4.228
  238. #
  239. # After these above steps, we have succefully booted an instance with floating ip,
  240. # use “nova list” will output the instances
  241. #
  242. # [root@localhost ~(keystone_demo)]#
  243. nova list
  244. #    +--------------------------------------+---------------+--------+------------+-------------+--------------------------------+
  245. #    | ID                                   | Name          | Status | Task State | Power State | Networks                       |
  246. #    +--------------------------------------+---------------+--------+------------+-------------+--------------------------------+
  247. #    | ac82fcc8-1609-4d34-a4a7-80e5985433f7 | demo-inst1    | ACTIVE | -          | Running     | private=10.0.0.3, 172.24.4.227 |
  248. #    | f302a03f-3761-48e6-a786-45b324182545 | demo-instance | ACTIVE | -          | Running     | private=10.0.0.4, 172.24.4.228 |
  249. #    +--------------------------------------+---------------+--------+------------+-------------+--------------------------------+
  250. # Test the connectivity via floating ip, “ping 172.24.4.228” at the OpenStack VM, will properbly get outputs like:
  251. #
  252. # [root@localhost ~(keystone_demo)]#
  253. ping 172.24.4.228
  254. #    PING 172.24.4.228 (172.24.4.228) 56(84) bytes of data.
  255. #    64 bytes from 172.24.4.228: icmp_seq=1 ttl=63 time=1.76 ms
  256. #    64 bytes from 172.24.4.228: icmp_seq=2 ttl=63 time=0.666 ms
  257. #    64 bytes from 172.24.4.228: icmp_seq=3 ttl=63 time=0.284 ms
Advertisement
Add Comment
Please, Sign In to add comment