summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Yang <yangyang1@zte.com.cn>2017-07-20 19:41:02 +0800
committerAlex Yang <yangyang1@zte.com.cn>2017-07-20 19:41:02 +0800
commitdc420d5d13308110e36313d1b88cbf7fa11b0378 (patch)
tree5fe4483125d880bf973b9767d790a359201f1187
parent6ea756e7cad324e70fd9546b15a268e910127d46 (diff)
Sync some patches of bash script to python
Change-Id: Ia1eb59e62b1bb98b1871ec591e2c925c1734cc2e Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
-rw-r--r--deploy/daisy_server.py5
-rw-r--r--deploy/environment.py27
-rw-r--r--templates/virtual_environment/vms/computer.xml4
-rw-r--r--templates/virtual_environment/vms/controller.xml4
4 files changed, 36 insertions, 4 deletions
diff --git a/deploy/daisy_server.py b/deploy/daisy_server.py
index eb711afd..152bbe52 100644
--- a/deploy/daisy_server.py
+++ b/deploy/daisy_server.py
@@ -265,8 +265,7 @@ class DaisyServer(object):
def post_deploy(self):
LI('Post deploy ...')
- cmd = 'export PYTHONPATH={python_path}; python {script} -nw {net_file}'.format(
- python_path=self.remote_dir,
- script=path_join(self.remote_dir, 'deploy/post/execute.py'),
+ cmd = 'bash {script} -n {net_file}'.format(
+ script=path_join(self.remote_dir, 'deploy/post.sh'),
net_file=path_join(self.remote_dir, self.net_file_name))
self.ssh_run(cmd, check=False)
diff --git a/deploy/environment.py b/deploy/environment.py
index b3024ed5..abea6210 100644
--- a/deploy/environment.py
+++ b/deploy/environment.py
@@ -7,6 +7,8 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import commands
+import itertools
import os
import shutil
import time
@@ -41,6 +43,7 @@ CREATE_QCOW2_PATH = path_join(WORKSPACE, 'tools')
VMDEPLOY_DAISY_SERVER_NET = path_join(WORKSPACE, 'templates/virtual_environment/networks/daisy.xml')
VMDEPLOY_TARGET_NODE_NET = path_join(WORKSPACE, 'templates/virtual_environment/networks/external.xml')
+VMDEPLOY_TARGET_KEEPALIVED_NET = path_join(WORKSPACE, 'templates/virtual_environment/networks/keepalived.xml')
VMDEPLOY_DAISY_SERVER_VM = path_join(WORKSPACE, 'templates/virtual_environment/vms/daisy.xml')
BMDEPLOY_DAISY_SERVER_VM = path_join(WORKSPACE, 'templates/physical_environment/vms/daisy.xml')
@@ -172,6 +175,9 @@ class VirtualEnvironment(DaisyEnvironmentBase):
super(VirtualEnvironment, self).__init__(deploy_struct, net_struct, adapter, pxe_bridge,
daisy_server_info, work_dir, storage_dir, scenario)
self.check_configuration()
+ self._daisy_server_net = None
+ self._daisy_os_net = None
+ self._daisy_keepalived_net = None
def check_configuration(self):
self.check_nodes_template()
@@ -193,6 +199,7 @@ class VirtualEnvironment(DaisyEnvironmentBase):
if net_name != self.pxe_bridge:
self.delete_virtual_network(VMDEPLOY_DAISY_SERVER_NET)
err_exit('Network name %s is wrong, pxe bridge is %s' % (net_name, self.pxe_bridge))
+ self._daisy_server_net = net_name
def create_daisy_server_vm(self):
# TODO: refactor the structure of deploy.yml, add VM template param of Daisy Server
@@ -250,7 +257,11 @@ class VirtualEnvironment(DaisyEnvironmentBase):
def create_nodes(self):
# TODO: support virtNetTemplatePath in deploy.yml
# and multi interfaces, not only all-in-one
- create_virtual_network(VMDEPLOY_TARGET_NODE_NET)
+ net_name = create_virtual_network(VMDEPLOY_TARGET_NODE_NET)
+ self._daisy_os_net = net_name
+ net_name = create_virtual_network(VMDEPLOY_TARGET_KEEPALIVED_NET)
+ self._daisy_keepalived_net = net_name
+
for node in self.deploy_struct['hosts']:
self.create_virtual_node(node)
time.sleep(20)
@@ -300,3 +311,17 @@ class VirtualEnvironment(DaisyEnvironmentBase):
self.reboot_nodes(boot_devs=['hd'])
self.server.check_openstack_installation(len(self.deploy_struct['hosts']))
self.server.post_deploy()
+ self._post_deploy()
+
+ def _post_deploy(self):
+ LI('Disable iptables rules of daisy networks on deploy server')
+ networks = [self._daisy_server_net, self._daisy_os_net]
+ options = ['-o', '-i']
+ for (network, option) in list(itertools.product(networks, options)):
+ cmd = 'iptables -D FORWARD {option} {network} -j REJECT --reject-with icmp-port-unreachable'.format(
+ option=option, network=network)
+ status, output = commands.getstatusoutput(cmd)
+ if status:
+ LW('iptables command failed: %s' % output)
+ else:
+ LI('iptables command success: %s' % cmd)
diff --git a/templates/virtual_environment/vms/computer.xml b/templates/virtual_environment/vms/computer.xml
index ee038108..0add4367 100644
--- a/templates/virtual_environment/vms/computer.xml
+++ b/templates/virtual_environment/vms/computer.xml
@@ -76,6 +76,10 @@
<source network='daisy2' bridge='daisy2'/>
<model type='rtl8139'/>
</interface>
+ <interface type='network'>
+ <source network='daisy3' bridge='daisy3'/>
+ <model type='rtl8139'/>
+ </interface>
<serial type='pty'>
<source path='/dev/pts/4'/>
<target port='0'/>
diff --git a/templates/virtual_environment/vms/controller.xml b/templates/virtual_environment/vms/controller.xml
index 69424015..22a98f51 100644
--- a/templates/virtual_environment/vms/controller.xml
+++ b/templates/virtual_environment/vms/controller.xml
@@ -76,6 +76,10 @@
<source network='daisy2' bridge='daisy2'/>
<model type='rtl8139'/>
</interface>
+ <interface type='network'>
+ <source network='daisy3' bridge='daisy3'/>
+ <model type='rtl8139'/>
+ </interface>
<serial type='pty'>
<source path='/dev/pts/4'/>
<target port='0'/>