summaryrefslogtreecommitdiffstats
path: root/deploy/environment.py
diff options
context:
space:
mode:
authorZhijiang Hu <hu.zhijiang@zte.com.cn>2017-07-25 02:06:37 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-25 02:06:37 +0000
commit4aab5fede6d007aa7c934aabbe7294b793bc6087 (patch)
treea7611d433f6a66dd65bc2e98963ede5c73bf6926 /deploy/environment.py
parent7ac1730803aac27f1c9bbc2e83f158fbb77ffab6 (diff)
parentdc420d5d13308110e36313d1b88cbf7fa11b0378 (diff)
Merge "Sync some patches of bash script to python"
Diffstat (limited to 'deploy/environment.py')
-rw-r--r--deploy/environment.py27
1 files changed, 26 insertions, 1 deletions
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)