diff options
-rwxr-xr-x | ci/deploy/deploy.sh | 2 | ||||
-rw-r--r-- | deploy/common/__init__.py | 0 | ||||
-rw-r--r-- | deploy/common/query.py | 5 | ||||
-rw-r--r-- | deploy/config/__init__.py | 0 | ||||
-rw-r--r-- | deploy/config/network.py | 20 | ||||
-rw-r--r-- | deploy/config/vm_environment/zte-virtual1/network.yml | 21 | ||||
-rw-r--r-- | deploy/prepare.sh | 48 | ||||
-rw-r--r-- | deploy/prepare/__init__.py | 0 | ||||
-rw-r--r-- | deploy/prepare/execute.py | 32 |
9 files changed, 118 insertions, 10 deletions
diff --git a/ci/deploy/deploy.sh b/ci/deploy/deploy.sh index 3caacde4..0317d0ba 100755 --- a/ci/deploy/deploy.sh +++ b/ci/deploy/deploy.sh @@ -301,6 +301,8 @@ if [ $IS_BARE == 0 ];then echo "====== add relate config of kolla===========" ssh $SSH_PARAS $DAISY_IP "mkdir -p /etc/kolla/config/nova" ssh $SSH_PARAS $DAISY_IP "echo -e '[libvirt]\nvirt_type=qemu\ncpu_mode=none' >> /etc/kolla/config/nova/nova-compute.conf" + NETWORK_CONF="$REMOTE_SPACE/deploy/config/vm_environment/$LAB_NAME-$POD_NAME/network.yml" + ssh $SSH_PARAS $DAISY_IP "bash $REMOTE_SPACE/deploy/prepare.sh -n $NETWORK_CONF" fi echo "===prepare cluster and pxe===" diff --git a/deploy/common/__init__.py b/deploy/common/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/deploy/common/__init__.py diff --git a/deploy/common/query.py b/deploy/common/query.py new file mode 100644 index 00000000..9b1adc2c --- /dev/null +++ b/deploy/common/query.py @@ -0,0 +1,5 @@ +def find(function, sequence, default=None): + for s in sequence: + if function(s): + return s + return default diff --git a/deploy/config/__init__.py b/deploy/config/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/deploy/config/__init__.py diff --git a/deploy/config/network.py b/deploy/config/network.py new file mode 100644 index 00000000..ed14f95b --- /dev/null +++ b/deploy/config/network.py @@ -0,0 +1,20 @@ +import yaml + +from deploy.common import query + + +class NetworkConfig(object): + def __init__(self, network_file): + self._file = network_file + self._get_config() + + def _get_config(self): + self.config = yaml.safe_load(file(self._file)) + + def _get_network(self, name): + return query.find(lambda item: item['name'] == name, + self.config['networks']) + + @property + def external_network(self): + return self._get_network('EXTERNAL') diff --git a/deploy/config/vm_environment/zte-virtual1/network.yml b/deploy/config/vm_environment/zte-virtual1/network.yml index 7d746be6..6c8a2824 100644 --- a/deploy/config/vm_environment/zte-virtual1/network.yml +++ b/deploy/config/vm_environment/zte-virtual1/network.yml @@ -17,8 +17,8 @@ networks: - cidr: '10.20.11.0/24'
gateway: '10.20.11.1'
ip_ranges:
- - 'start': '10.20.11.3'
- 'end': '10.20.11.10'
+ - start: '10.20.11.3'
+ end: '10.20.11.10'
name: 'MANAGEMENT'
- cidr: '10.20.11.0/24'
gateway: '10.20.11.1'
@@ -27,22 +27,23 @@ networks: end: '10.20.11.10'
name: 'STORAGE'
- cidr: '172.10.101.0/24'
- gateway: '172.10.101.0'
+ gateway: '172.10.101.1'
ip_ranges:
- - 'start': '172.10.101.1'
- 'end': '172.10.101.10'
- 'name': 'EXTERNAL'
+ - start: 172.10.101.2
+ end: 172.10.101.20
+ name: EXTERNAL
+ network_name: admin_external
- cidr: '10.20.11.0/24'
gateway: '10.20.11.1'
ip_ranges:
- - 'start': '10.20.11.3'
- 'end': '10.20.11.10'
+ - start: '10.20.11.3'
+ end: '10.20.11.10'
name: 'PUBLICAPI'
- cidr: '10.20.11.0/24'
gateway: '10.20.11.1'
ip_ranges:
- - 'start': '10.20.11.3'
- 'end': '10.20.11.10'
+ - start: '10.20.11.3'
+ end: '10.20.11.10'
name: 'TENANT'
interfaces:
- name: 'EXTERNAL'
diff --git a/deploy/prepare.sh b/deploy/prepare.sh new file mode 100644 index 00000000..58d5a08f --- /dev/null +++ b/deploy/prepare.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +SCRIPT_PATH=$(readlink -f $(dirname $0)) + +export PYTHONPATH=$SCRIPT_PATH/.. + +usage () +{ +cat << EOF +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +`basename $0`: make preparation for daisy deployment + +usage: `basename $0` -n network_config_file + +OPTIONS: + -nw network configuration path, necessary + -h Print this message and exit + +Description: + prepare configuration + +Examples: +sudo `basename $0` -n /home/daisy/config/vm_environment/zte-virtual1/network.yml +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +EOF +} + +NETWORK_CONF='' + +while getopts "n:h" OPTION +do + case $OPTION in + n) + NETWORK_CONF=${OPTARG} + ;; + h) + usage + exit 0 + ;; + *) + echo "${OPTION} is not a valid argument" + usage + exit 0 + ;; + esac +done + +python $PYTHONPATH/deploy/prepare/execute.py -nw $NETWORK_CONF diff --git a/deploy/prepare/__init__.py b/deploy/prepare/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/deploy/prepare/__init__.py diff --git a/deploy/prepare/execute.py b/deploy/prepare/execute.py new file mode 100644 index 00000000..a50d9d9a --- /dev/null +++ b/deploy/prepare/execute.py @@ -0,0 +1,32 @@ +import argparse +import os + +from deploy.config.network import NetworkConfig + +NOVA_CONF_PATH = '/etc/kolla/config/nova' +NOVA_API_CONF = '{}/nova-api.conf'.format(NOVA_CONF_PATH) + + +def _config_nova_api(network_file): + xnet = NetworkConfig(network_file=network_file).external_network + if not os.path.isdir(NOVA_CONF_PATH): + os.makedirs(NOVA_CONF_PATH, mode=0644) + + with open(NOVA_API_CONF, 'w') as f: + f.write('[DEFAULT]\n' + 'default_floating_pool={}\n'.format(xnet['network_name'])) + f.close() + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('-nw', '--network-file', + type=str, + required=True, + help='network configuration file') + args = parser.parse_args() + _config_nova_api(args.network_file) + + +if __name__ == '__main__': + main() |