Add opera support 75/27075/9
authorHarry Huang <huangxiangyu5@huawei.com>
Tue, 17 Jan 2017 06:45:57 +0000 (14:45 +0800)
committerHarry Huang <huangxiangyu5@huawei.com>
Sat, 4 Feb 2017 01:57:41 +0000 (09:57 +0800)
JIRA: COMPASS-504
JIRA: OPERA-1

Function:
  support open-o deployment by calling opera project.
  open-o deployment will start at the end of normal
  compass4nfv deployment.

Changes:
  1. add scenario and network yaml for opera
  2. add opera_adapter.py for calling opera

Attention:
  The git URL for opera will change after opera patch
  OPERA-2 is meraged. This patch should be modifed
  before meraged.

Change-Id: Id0afcece920c4107bb23f42b460c46eec3ca97e6
Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
deploy/compass_conf/package_metadata/openstack.conf
deploy/conf/vm_environment/huawei-virtual7/network.yml [new file with mode: 0644]
deploy/conf/vm_environment/os-nosdn-openo-noha.yml [new file with mode: 0644]
deploy/launch.sh
deploy/opera_adapter.py [new file with mode: 0644]

index 000c1a2..555f007 100755 (executable)
@@ -244,6 +244,86 @@ METADATA = {
         }
     },
 
+    'openo_net': {
+        '_self': {
+            'mapping_to': 'openo_net',
+            'is_required': False
+        },
+
+        'openo_vm_ip': {
+            '_self': {
+            'mapping_to': 'openo_vm_ip',
+            'is_required': False,
+            'field': 'general',
+            }
+        },
+        'openo_vm_mask': {
+            '_self': {
+            'mapping_to': 'openo_vm_mask',
+            'is_required': False,
+            'field': 'general',
+            }
+        },
+        'openo_external_gw': {
+            '_self': {
+            'mapping_to': 'openo_external_gw',
+            'is_required': False,
+            'field': 'general',
+            }
+        },
+        'openo_external_cidr': {
+            '_self': {
+            'mapping_to': 'openo_external_cidr',
+            'is_required': False,
+            'field': 'general',
+            }
+        }
+    },
+
+    'openo_docker_net': {
+        '_self': {
+            'mapping_to': 'openo_docker_net',
+            'is_required': False
+        },
+
+        'docker_ip_start': {
+            '_self': {
+            'mapping_to': 'docker_ip_start',
+            'is_required': False,
+            'field': 'general',
+            }
+        },
+        'docker_ip_end': {
+            '_self': {
+            'mapping_to': 'docker_ip_end',
+            'is_required': False,
+            'field': 'general',
+            }
+        }
+    },
+
+    'juju_net': {
+        '_self': {
+            'mapping_to': 'juju_net',
+            'is_required': False
+        },
+
+        'juju_net_cidr': {
+            '_self': {
+            'mapping_to': 'juju_net_cidr',
+            'is_required': False,
+            'field': 'general',
+            }
+        },
+        'juju_net_gw': {
+            '_self': {
+            'mapping_to': 'juju_net_gw',
+            'is_required': False,
+            'field': 'general',
+            }
+        }
+    },
+
     'public_net_info': {
         '_self': {
             'mapping_to': 'public_net_info'
diff --git a/deploy/conf/vm_environment/huawei-virtual7/network.yml b/deploy/conf/vm_environment/huawei-virtual7/network.yml
new file mode 100644 (file)
index 0000000..12547b7
--- /dev/null
@@ -0,0 +1,105 @@
+---
+nic_mappings: []
+bond_mappings: []
+
+provider_net_mappings:
+  - name: br-prv
+    network: physnet
+    interface: eth1
+    type: ovs
+    role:
+      - controller
+      - compute
+
+sys_intf_mappings:
+  - name: mgmt
+    interface: eth1
+    vlan_tag: 101
+    type: vlan
+    role:
+      - controller
+      - compute
+
+  - name: storage
+    interface: eth1
+    vlan_tag: 102
+    type: vlan
+    role:
+      - controller
+      - compute
+
+  - name: external
+    interface: br-prv
+    type: ovs
+    role:
+      - controller
+      - compute
+
+ip_settings:
+  - name: mgmt
+    ip_ranges:
+      - - "172.16.1.1"
+        - "172.16.1.254"
+    cidr: "172.16.1.0/24"
+    role:
+      - controller
+      - compute
+
+  - name: storage
+    ip_ranges:
+      - - "172.16.2.1"
+        - "172.16.2.254"
+    cidr: "172.16.2.0/24"
+    role:
+      - controller
+      - compute
+
+  - name: external
+    ip_ranges:
+      - - "192.168.83.210"
+        - "192.168.83.220"
+    cidr: "192.168.83.0/24"
+    gw: "192.168.83.250"
+    role:
+      - controller
+      - compute
+
+internal_vip:
+  ip: 172.16.1.222
+  netmask: "24"
+  interface: mgmt
+
+public_vip:
+  ip: 192.168.83.222
+  netmask: "24"
+  interface: external
+
+onos_nic: eth2
+public_net_info:
+  enable: "True"
+  network: ext-net
+  type: flat
+  segment_id: 1000
+  subnet: ext-subnet
+  provider_network: physnet
+  router: router-ext
+  enable_dhcp: "False"
+  no_gateway: "False"
+  external_gw: "192.168.83.250"
+  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"
diff --git a/deploy/conf/vm_environment/os-nosdn-openo-noha.yml b/deploy/conf/vm_environment/os-nosdn-openo-noha.yml
new file mode 100644 (file)
index 0000000..0165332
--- /dev/null
@@ -0,0 +1,36 @@
+---
+TYPE: virtual
+FLAVOR: cluster
+
+deploy_options:
+  - orchestrator: open-o
+
+hosts:
+  - name: host1
+    roles:
+      - controller
+      - ha
+      - ceph-adm
+      - ceph-mon
+
+  - name: host2
+    roles:
+      - controller
+      - ha
+      - ceph-mon
+
+  - name: host3
+    roles:
+      - controller
+      - ha
+      - ceph-mon
+
+  - name: host4
+    roles:
+      - compute
+      - ceph-osd
+
+  - name: host5
+    roles:
+      - compute
+      - ceph-osd
index 7d0e269..aa47678 100755 (executable)
@@ -141,3 +141,6 @@ echo "+-----------------+----------+--------------------------------+"
 echo "NOTE: openrc file is in the controller nodes"
 echo ""
 
+if [[ ${DHA##*/} =~ "openo" ]]; then
+    python ${COMPASS_DIR}/deploy/opera_adapter.py $DHA $NETWORK
+fi
diff --git a/deploy/opera_adapter.py b/deploy/opera_adapter.py
new file mode 100644 (file)
index 0000000..bccbfce
--- /dev/null
@@ -0,0 +1,93 @@
+import os
+import yaml
+import sys
+import subprocess
+import traceback
+import ipaddress
+
+
+def load_file(file):
+    with open(file) as fd:
+        try:
+            return yaml.load(fd)
+        except:
+            traceback.print_exc()
+            return None
+
+
+def dump_file(data, file):
+    with open(file, 'w') as fd:
+        try:
+            return yaml.dump(data, fd, default_flow_style=False)
+        except:
+            traceback.print_exc()
+            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]
+
+    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
+
+    for i in net_config["juju_net"].keys():
+        net_config["juju_net"][i] = network["juju_net"][i]
+
+
+if __name__ == "__main__":
+    if len(sys.argv) != 3:
+        print("parameter wrong%d %s" % (len(sys.argv), sys.argv))
+        sys.exit(1)
+
+    _, dha_file, network_file = sys.argv
+
+    if not os.path.exists(dha_file):
+        print("DHA file doesn't exit")
+        sys.exit(1)
+    if not os.path.exists(network_file):
+        print("NETWORK file doesn't exit")
+        sys.exit(1)
+
+    dha = load_file(dha_file)
+    network = load_file(network_file)
+
+    if not dha:
+        print('format error in DHA: %s' % dha_file)
+        sys.exit(1)
+    if not network:
+        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')
+
+    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')
+        sys.exit(1)
+
+    net_config = load_file(net_config_file)
+    sync_openo_network_yml(network, net_config)
+    dump_file(net_config, net_config_file)
+
+    p2 = subprocess.Popen("./opera_launch.sh", cwd=opera_dir, shell=True)
+    p2.communicate()