summaryrefslogtreecommitdiffstats
path: root/deploy
diff options
context:
space:
mode:
Diffstat (limited to 'deploy')
-rw-r--r--deploy/deploy.py16
-rw-r--r--deploy/environment.py5
-rw-r--r--deploy/libvirt_utils.py24
3 files changed, 32 insertions, 13 deletions
diff --git a/deploy/deploy.py b/deploy/deploy.py
index 71c39742..42a9d2f7 100644
--- a/deploy/deploy.py
+++ b/deploy/deploy.py
@@ -11,11 +11,11 @@
# TODO:
# [ ] 1. specify VM templates (Server, Controller & Compute) in deploy.yml
# [ ] 2. specify network templates in deploy.yml
-# [ ] 3. specify adapter(ipmi, libvirt) in deploy.yml
-# [ ] 4. get ipmi user/password from PDF (Pod Descriptor File)
-# [ ] 5. get pxe bridge from jjb
-# [ ] 6. enlarge the vm size of Controller & Compute in deploy.yml
-# [ ] 7. support scenarios options and configuration
+# [x] 3. specify adapter(ipmi, libvirt) in deploy.yml
+# [x] 4. get ipmi user/password from PDF (Pod Descriptor File)
+# [x] 5. get pxe bridge from jjb
+# [x] 6. enlarge the vm size of Controller & Compute in deploy.yml
+# [x] 7. support scenarios options and configuration
##############################################################################
import argparse
@@ -85,11 +85,11 @@ class DaisyDeployment(object):
self.adapter = self._get_adapter_info()
LI('The adapter is %s' % self.adapter)
- # TODO: modify the jjb code to provide bridge name
+ # Virtual deployment always uses 'daisy1' as default bridge.
if self.adapter == 'libvirt':
self.pxe_bridge = 'daisy1'
- else:
- self.pxe_bridge = 'br7'
+
+ LI('Use %s as the bridge name in daisy deployment.' % self.pxe_bridge)
self.daisy_server_info = self._get_daisy_server_info()
diff --git a/deploy/environment.py b/deploy/environment.py
index 5371e6ca..14240549 100644
--- a/deploy/environment.py
+++ b/deploy/environment.py
@@ -135,7 +135,6 @@ class BareMetalEnvironment(DaisyEnvironmentBase):
def create_daisy_server_vm(self):
# TODO: refactor the structure of deploy.yml, add VM template param of Daisy Server
- # add self.pxe_bridge into the vm template
if 'template' in self.deploy_struct:
# get VM name of Daisy Server from the template
template = self.deploy_struct['template']
@@ -144,7 +143,8 @@ class BareMetalEnvironment(DaisyEnvironmentBase):
create_vm(template,
name=self.daisy_server_info['name'],
- disks=[self.daisy_server_info['image']])
+ disks=[self.daisy_server_info['image']],
+ physical_bridge=self.pxe_bridge)
def reboot_nodes(self, boot_dev=None):
for node in self.deploy_struct['hosts']:
@@ -203,7 +203,6 @@ class VirtualEnvironment(DaisyEnvironmentBase):
def create_daisy_server_vm(self):
# TODO: refactor the structure of deploy.yml, add VM template param of Daisy Server
- # add self.pxe_bridge into the vm template
if 'template' in self.deploy_struct:
# get VM name of Daisy Server from the template
template = self.deploy_struct['template']
diff --git a/deploy/libvirt_utils.py b/deploy/libvirt_utils.py
index 8e4523de..3b9eae1c 100644
--- a/deploy/libvirt_utils.py
+++ b/deploy/libvirt_utils.py
@@ -69,6 +69,24 @@ def modify_vm_disk_file(root, disks):
devices.append(disk)
+def modify_vm_bridge(root, bridge):
+ devices = root.find('./devices')
+ for interface in devices.findall('interface'):
+ source = interface.find('source')
+ if interface.attrib.get('type', None) == 'bridge' \
+ and source is not None \
+ and source.attrib.get('bridge', None) == bridge:
+ # pxebr is already in the VM template
+ return
+
+ for interface in devices.findall('interface'):
+ devices.remove(interface)
+
+ interface = ET.Element('interface', attrib={'type': 'bridge'})
+ interface.append(ET.Element('source', attrib={'bridge': bridge}))
+ devices.append(interface)
+
+
def create_virtual_disk(disk_file, size):
LI('Create virtual disk file %s size %d GB' % (disk_file, size))
cmd = 'qemu-img create -f qcow2 {disk_file} {size}G'.format(
@@ -79,16 +97,18 @@ def create_virtual_disk(disk_file, size):
err_exit('Fail to create qemu image !')
-def create_vm(template, name=None, disks=None):
+def create_vm(template, name=None, disks=None, physical_bridge=None):
LI('Begin to create VM %s' % template)
- if name or disks:
+ if name or disks or physical_bridge:
tree = ET.ElementTree(file=template)
root = tree.getroot()
if name:
modify_vm_name(root, name)
if disks:
modify_vm_disk_file(root, disks)
+ if physical_bridge:
+ modify_vm_bridge(root, physical_bridge)
temp_file = path_join(WORKSPACE, 'tmp.xml')
tree.write(temp_file)