diff options
author | chigang <chigang@huawei.com> | 2017-06-30 20:24:25 +0800 |
---|---|---|
committer | chigang <chigang@huawei.com> | 2017-07-03 21:19:28 +0800 |
commit | 95ecdb773c9fa90f9e4f1f792f5cc5dc8328fd6a (patch) | |
tree | 1b012703eb52f78fe35119a4f9eba98b221f69d9 /deploy/adapters/ansible/roles/setup-network/files/setup_networks/check_network.py | |
parent | d529e77a45c77c10ac6970ca9e733e92e89d138f (diff) |
Remove obsoleted code
JIRA:-
use OpenStack-ansible deploy openstack, so remove obsoleted code.
Some of the enhanced features will be added in later versions
Change-Id: Ie92b92b5de234a7d7d03b578b0bc15fd0218b3b3
Signed-off-by: chigang <chigang@huawei.com>
Diffstat (limited to 'deploy/adapters/ansible/roles/setup-network/files/setup_networks/check_network.py')
-rw-r--r-- | deploy/adapters/ansible/roles/setup-network/files/setup_networks/check_network.py | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/deploy/adapters/ansible/roles/setup-network/files/setup_networks/check_network.py b/deploy/adapters/ansible/roles/setup-network/files/setup_networks/check_network.py deleted file mode 100644 index be3c552a..00000000 --- a/deploy/adapters/ansible/roles/setup-network/files/setup_networks/check_network.py +++ /dev/null @@ -1,71 +0,0 @@ -############################################################################## -# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -import yaml -import sys -import subprocess - -import log as logging - -LOG = logging.getLogger("net-check") - - -def is_ip_reachable(ip): - cmd = "ping -c 2 %s" % ip - process = subprocess.Popen( - cmd, - stdout=subprocess.PIPE, - stderr=None, - shell=True) - - output = process.communicate()[0] - if " 0% packet loss" in output: - LOG.info("%s is reachable", ip) - elif "100% packet loss" in output: - LOG.error("%s is unreachable" % (ip)) - return False - else: - LOG.warn("%r", output) - - return True - - -def is_host_ips_reachable(settings): - external = settings["br-prv"]["ip"] - external_gw = settings["br-prv"]["gw"] - storage = settings["storage"]["ip"] - mgmt = settings["mgmt"]["ip"] - - return is_ip_reachable(external) \ - and is_ip_reachable(external_gw) \ - and is_ip_reachable(storage) \ - and is_ip_reachable(mgmt) - - -def main(hostname, config): - LOG.info("host is %s", hostname) - - result = True - - for host, settings in config.iteritems(): - LOG.info("check %s network connectivity start", host) - result = result and is_host_ips_reachable(settings) - - if result: - LOG.info("All hosts ips are reachable") - else: - LOG.error("Some hosts ips are unreachable !!!") - sys.exit(-1) - -if __name__ == "__main__": - hostname = yaml.load(sys.argv[1]) - config = yaml.load(sys.argv[2]) - config.pop(hostname, None) - - main(hostname, config) |