update opera related files 09/30909/1
authorHarry Huang <huangxiangyu5@huawei.com>
Mon, 13 Mar 2017 12:22:47 +0000 (20:22 +0800)
committerJustin chi <chigang@huawei.com>
Sat, 18 Mar 2017 06:00:23 +0000 (06:00 +0000)
1. update opera_adapter.py to sync new opera config
2. modify all os-nosdn-openo-ha.yml, add open-o version
   and vnf type
3. modify all network_openo.yml, using only one external
   ip and assign open-o docker ips

Change-Id: Iadcba8cc2fc17ddf32dfea9fe52c471a6bfadde8
Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
(cherry picked from commit 524fea7f6eacfa6a102614b7fb4c66e1be1b8287)

13 files changed:
deploy/conf/hardware_environment/huawei-pod1/network_openo.yml
deploy/conf/hardware_environment/huawei-pod1/os-nosdn-openo-ha.yml
deploy/conf/hardware_environment/huawei-pod2/network_openo.yml
deploy/conf/hardware_environment/huawei-pod2/os-nosdn-openo-ha.yml
deploy/conf/hardware_environment/intel-pod8/network_openo.yml
deploy/conf/hardware_environment/intel-pod8/os-nosdn-openo-ha.yml
deploy/conf/vm_environment/huawei-virtual1/network_openo.yml
deploy/conf/vm_environment/huawei-virtual2/network_openo.yml
deploy/conf/vm_environment/huawei-virtual3/network_openo.yml
deploy/conf/vm_environment/huawei-virtual4/network_openo.yml
deploy/conf/vm_environment/huawei-virtual7/network_openo.yml
deploy/conf/vm_environment/os-nosdn-openo-ha.yml
deploy/opera_adapter.py

index 80b80fc..6fc5bc4 100644 (file)
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
+# Copyright (c) 2017 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
@@ -83,6 +83,11 @@ public_vip:
   netmask: "24"
   interface: external
 
+openo_net:
+  openo_ip: 192.168.10.50
+  openo_docker_gw: 172.11.1.1
+  openo_docker_cidr: 172.11.1.0/24
+
 onos_nic: eth2
 public_net_info:
   enable: "True"
@@ -98,17 +103,3 @@ public_net_info:
   floating_ip_cidr: "192.168.10.0/24"
   floating_ip_start: "192.168.10.100"
   floating_ip_end: "192.168.10.200"
-
-openo_net:
-  openo_vm_ip: "192.168.10.50"
-  openo_vm_mask: "255.255.255.0"
-  openo_external_gw: "192.168.10.1"
-  openo_external_cidr: "192.168.10.0/24"
-
-openo_docker_net:
-  docker_ip_start: "192.168.10.51"
-  docker_ip_end: "192.168.10.90"
-
-juju_net:
-  juju_net_cidr: "12.1.1.0/24"
-  juju_net_gw: "12.1.1.1"
index 6eb50a2..0d403bc 100644 (file)
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
+# Copyright (c) 2017 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
@@ -16,8 +16,12 @@ ipmiUser: root
 ipmiVer: '2.0'
 
 deploy_options:
-  - orchestrator: open-o
-  - application: clearwater
+  orchestrator:
+    type: open-o
+    version: 1.0.0
+
+  vnf:
+    type:
 
 hosts:
   - name: host1
index 7f2d45d..1bba2da 100644 (file)
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
+# Copyright (c) 2017 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
@@ -83,6 +83,11 @@ public_vip:
   netmask: "24"
   interface: external
 
+openo_net:
+  openo_ip: 192.168.11.50
+  openo_docker_gw: 172.11.1.1
+  openo_docker_cidr: 172.11.1.0/24
+
 onos_nic: eth2
 public_net_info:
   enable: "True"
@@ -98,17 +103,3 @@ public_net_info:
   floating_ip_cidr: "192.168.11.0/24"
   floating_ip_start: "192.168.11.30"
   floating_ip_end: "192.168.11.100"
-
-openo_net:
-  openo_vm_ip: "192.168.11.50"
-  openo_vm_mask: "255.255.255.0"
-  openo_external_gw: "192.168.11.1"
-  openo_external_cidr: "192.168.11.0/24"
-
-openo_docker_net:
-  docker_ip_start: "192.168.11.51"
-  docker_ip_end: "192.168.11.90"
-
-juju_net:
-  juju_net_cidr: "12.1.1.0/24"
-  juju_net_gw: "12.1.1.1"
index e1219dd..a6dcccf 100644 (file)
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
+# Copyright (c) 2017 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
@@ -16,8 +16,12 @@ POWER_TOOL: ipmitool
 ipmiVer: '2.0'
 
 deploy_options:
-  - orchestrator: open-o
-  - application: clearwater
+  orchestrator:
+    type: open-o
+    version: 1.0.0
+
+  vnf:
+    type:
 
 hosts:
   - name: host1
index 48c47f7..12e40af 100644 (file)
@@ -83,6 +83,11 @@ public_vip:
   netmask: "24"
   interface: external
 
+openo_net:
+  openo_ip: 10.8.15.50
+  openo_docker_gw: 172.11.1.1
+  openo_docker_cidr: 172.11.1.0/24
+
 onos_nic: eth4
 public_net_info:
   enable: "True"
@@ -98,17 +103,3 @@ public_net_info:
   floating_ip_cidr: "10.8.15.0/24"
   floating_ip_start: "10.8.15.100"
   floating_ip_end: "10.8.15.200"
-
-openo_net:
-  openo_vm_ip: "10.8.15.50"
-  openo_vm_mask: "255.255.255.0"
-  openo_external_gw: "10.8.15.1"
-  openo_external_cidr: "10.8.15.0/24"
-
-openo_docker_net:
-  docker_ip_start: "10.8.15.51"
-  docker_ip_end: "10.8.15.90"
-
-juju_net:
-  juju_net_cidr: "12.1.1.0/24"
-  juju_net_gw: "12.1.1.1"
index f70414c..6d28a49 100644 (file)
@@ -17,8 +17,12 @@ ipmiPass: root
 ipmiVer: '1.0'
 
 deploy_options:
-  - orchestrator: open-o
-  - application: clearwater
+  orchestrator:
+    type: open-o
+    version: 1.0.0
+
+  vnf:
+    type:
 
 hosts:
   - name: host1
index 980fee7..a31c299 100644 (file)
@@ -83,6 +83,11 @@ public_vip:
   netmask: "24"
   interface: external
 
+openo_net:
+  openo_ip: 192.168.107.50
+  openo_docker_gw: 172.11.1.1
+  openo_docker_cidr: 172.11.1.0/24
+
 onos_nic: eth2
 public_net_info:
   enable: "True"
@@ -98,17 +103,3 @@ public_net_info:
   floating_ip_cidr: "192.168.107.0/24"
   floating_ip_start: "192.168.107.101"
   floating_ip_end: "192.168.107.199"
-
-openo_net:
-  openo_vm_ip: "192.168.107.50"
-  openo_vm_mask: "255.255.255.0"
-  openo_external_gw: "192.168.107.1"
-  openo_external_cidr: "192.168.107.0/24"
-
-openo_docker_net:
-  docker_ip_start: "192.168.107.51"
-  docker_ip_end: "192.168.107.90"
-
-juju_net:
-  juju_net_cidr: "12.1.1.0/24"
-  juju_net_gw: "12.1.1.1"
index da30e37..98b3a83 100644 (file)
@@ -83,6 +83,11 @@ public_vip:
   netmask: "24"
   interface: external
 
+openo_net:
+  openo_ip: 192.168.106.50
+  openo_docker_gw: 172.11.1.1
+  openo_docker_cidr: 172.11.1.0/24
+
 onos_nic: eth2
 public_net_info:
   enable: "True"
@@ -98,17 +103,3 @@ public_net_info:
   floating_ip_cidr: "192.168.106.0/24"
   floating_ip_start: "192.168.106.101"
   floating_ip_end: "192.168.106.199"
-
-openo_net:
-  openo_vm_ip: "192.168.106.50"
-  openo_vm_mask: "255.255.255.0"
-  openo_external_gw: "192.168.106.1"
-  openo_external_cidr: "192.168.106.0/24"
-
-openo_docker_net:
-  docker_ip_start: "192.168.106.51"
-  docker_ip_end: "192.168.106.90"
-
-juju_net:
-  juju_net_cidr: "12.1.1.0/24"
-  juju_net_gw: "12.1.1.1"
index 643dd24..fd2e2c0 100644 (file)
@@ -83,6 +83,11 @@ public_vip:
   netmask: "24"
   interface: external
 
+openo_net:
+  openo_ip: 192.168.101.50
+  openo_docker_gw: 172.11.1.1
+  openo_docker_cidr: 172.11.1.0/24
+
 onos_nic: eth2
 public_net_info:
   enable: "True"
@@ -98,17 +103,3 @@ public_net_info:
   floating_ip_cidr: "192.168.101.0/24"
   floating_ip_start: "192.168.101.101"
   floating_ip_end: "192.168.101.199"
-
-openo_net:
-  openo_vm_ip: "192.168.101.50"
-  openo_vm_mask: "255.255.255.0"
-  openo_external_gw: "192.168.101.1"
-  openo_external_cidr: "192.168.101.0/24"
-
-openo_docker_net:
-  docker_ip_start: "192.168.101.51"
-  docker_ip_end: "192.168.101.90"
-
-juju_net:
-  juju_net_cidr: "12.1.1.0/24"
-  juju_net_gw: "12.1.1.1"
index 6353618..dfa1f17 100644 (file)
@@ -83,6 +83,11 @@ public_vip:
   netmask: "24"
   interface: external
 
+openo_net:
+  openo_ip: 192.168.103.50
+  openo_docker_gw: 172.11.1.1
+  openo_docker_cidr: 172.11.1.0/24
+
 onos_nic: eth2
 public_net_info:
   enable: "True"
@@ -98,17 +103,3 @@ public_net_info:
   floating_ip_cidr: "192.168.103.0/24"
   floating_ip_start: "192.168.103.101"
   floating_ip_end: "192.168.103.199"
-
-openo_net:
-  openo_vm_ip: "192.168.103.50"
-  openo_vm_mask: "255.255.255.0"
-  openo_external_gw: "192.168.103.1"
-  openo_external_cidr: "192.168.103.0/24"
-
-openo_docker_net:
-  docker_ip_start: "192.168.103.51"
-  docker_ip_end: "192.168.103.90"
-
-juju_net:
-  juju_net_cidr: "12.1.1.0/24"
-  juju_net_gw: "12.1.1.1"
index 2bf972e..1567185 100644 (file)
@@ -83,6 +83,11 @@ public_vip:
   netmask: "24"
   interface: external
 
+openo_net:
+  openo_ip: 192.168.83.50
+  openo_docker_gw: 172.11.1.1
+  openo_docker_cidr: 172.11.1.0/24
+
 onos_nic: eth2
 public_net_info:
   enable: "True"
@@ -98,17 +103,3 @@ public_net_info:
   floating_ip_cidr: "192.168.83.0/24"
   floating_ip_start: "192.168.83.101"
   floating_ip_end: "192.168.83.199"
-
-openo_net:
-  openo_vm_ip: "192.168.83.50"
-  openo_vm_mask: "255.255.255.0"
-  openo_external_gw: "192.168.83.250"
-  openo_external_cidr: "192.168.83.0/24"
-
-openo_docker_net:
-  docker_ip_start: "192.168.83.51"
-  docker_ip_end: "192.168.83.90"
-
-juju_net:
-  juju_net_cidr: "12.1.1.0/24"
-  juju_net_gw: "12.1.1.1"
index c26567f..69784c5 100644 (file)
@@ -12,8 +12,12 @@ TYPE: virtual
 FLAVOR: cluster
 
 deploy_options:
-  - orchestrator: open-o
-  - application: clearwater
+  orchestrator:
+    type: open-o
+    version: 1.0.0
+
+  vnf:
+    type:
 
 hosts:
   - name: host1
index d040999..09702fc 100644 (file)
@@ -8,11 +8,11 @@
 ##############################################################################
 
 import os
-import yaml
 import sys
+import yaml
+import re
 import subprocess
 import traceback
-import ipaddress
 
 
 def load_file(file):
@@ -33,23 +33,25 @@ def dump_file(data, file):
             return None
 
 
-def sync_openo_network_yml(network, net_config):
-    """sync opera/conf/network.yml according to Network file"""
-    for i in net_config["openo_net"].keys():
-        net_config["openo_net"][i] = network["openo_net"][i]
+def sync_openo_config(openo_config, dha, network):
+    """sync opera/conf/open-o.yml according to DHA and Network file"""
+    deploy_opts = dha.get('deploy_options')
+    openo_net = network.get('openo_net')
+    if deploy_opts['orchestrator']['type'] != 'open-o':
+        print("orchestrator is not openo")
+        sys.exit(1)
 
-    sorted_ips = sorted(net_config["openo_docker_net"].items(),
-                        key=lambda item: item[1])
-    docker_ips = [i[0] for i in sorted_ips]
-    docker_start_ip = unicode(network["openo_docker_net"]["docker_ip_start"],
-                              "utf-8")
-    docker_start_ip = ipaddress.IPv4Address(docker_start_ip)
-    for i in docker_ips:
-        net_config["openo_docker_net"][i] = str(docker_start_ip)
-        docker_start_ip += 1
+    openo_config['openo_version'] = deploy_opts['orchestrator']['version']
+    openo_config['vnf_type'] = deploy_opts['vnf']['type']
+    openo_config['openo_net']['openo_ip'] = openo_net['openo_ip']
 
-    for i in net_config["juju_net"].keys():
-        net_config["juju_net"][i] = network["juju_net"][i]
+
+def sync_admin_openrc(network, admin_openrc_file):
+    ip = re.compile("\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}")
+    with open(admin_openrc_file, 'r+') as fd:
+        data = fd.read()
+        fd.seek(0)
+        fd.write(re.sub(ip, network['public_vip']['ip'], data))
 
 
 if __name__ == "__main__":
@@ -58,6 +60,11 @@ if __name__ == "__main__":
         sys.exit(1)
 
     _, dha_file, network_file = sys.argv
+    compass_dir = os.getenv('COMPASS_DIR')
+
+    if not compass_dir:
+        print("env var COMPASS_DIR  doesn't exit")
+        sys.exit(1)
 
     if not os.path.exists(dha_file):
         print("DHA file doesn't exit")
@@ -76,27 +83,28 @@ if __name__ == "__main__":
         print('format error in NETWORK: %s' % network_file)
         sys.exit(1)
 
-    if dha["deploy_options"][0]["orchestrator"] != "open-o":
-        sys.exit(0)
-
-    compass_dir = os.getenv('COMPASS_DIR')
     work_dir = os.path.join(compass_dir, 'work')
     opera_dir = os.path.join(work_dir, 'opera')
     conf_dir = os.path.join(opera_dir, 'conf')
-    net_config_file = os.path.join(conf_dir, 'network.yml')
+    openo_config_file = os.path.join(conf_dir, 'open-o.yml')
+    admin_openrc_file = os.path.join(conf_dir, 'admin-openrc.sh')
 
     p1 = subprocess.Popen(
         "git clone https://gerrit.opnfv.org/gerrit/opera",
         cwd=work_dir, shell=True)
     p1.communicate()
 
-    if not os.path.exists(net_config_file):
-        print('file opera/conf/network.yml not found')
+    if not os.path.exists(openo_config_file):
+        print('file opera/conf/open-o.yml not found')
+        sys.exit(1)
+    if not os.path.exists(admin_openrc_file):
+        print('file opera/conf/admin-openrc.sh not found')
         sys.exit(1)
 
-    net_config = load_file(net_config_file)
-    sync_openo_network_yml(network, net_config)
-    dump_file(net_config, net_config_file)
+    openo_config = load_file(openo_config_file)
+    sync_openo_config(openo_config, dha, network)
+    dump_file(openo_config, openo_config_file)
+    sync_admin_openrc(network, admin_openrc_file)
 
     p2 = subprocess.Popen("./opera_launch.sh", cwd=opera_dir, shell=True)
     p2.communicate()