summaryrefslogtreecommitdiffstats
path: root/fuel/prototypes/auto-deploy/deploy/tools
diff options
context:
space:
mode:
Diffstat (limited to 'fuel/prototypes/auto-deploy/deploy/tools')
-rwxr-xr-xfuel/prototypes/auto-deploy/deploy/tools/transplant0.sh40
-rwxr-xr-xfuel/prototypes/auto-deploy/deploy/tools/transplant1.sh67
-rwxr-xr-xfuel/prototypes/auto-deploy/deploy/tools/transplant2.sh98
-rwxr-xr-xfuel/prototypes/auto-deploy/deploy/tools/transplant_fuel_settings.py50
-rwxr-xr-xfuel/prototypes/auto-deploy/deploy/tools/transplant_interfaces.py77
-rwxr-xr-xfuel/prototypes/auto-deploy/deploy/tools/transplant_network_scheme.py42
-rwxr-xr-xfuel/prototypes/auto-deploy/deploy/tools/transplant_network_settings.py52
-rwxr-xr-xfuel/prototypes/auto-deploy/deploy/tools/transplant_opnfv_settings.py42
-rwxr-xr-xfuel/prototypes/auto-deploy/deploy/tools/transplant_settings.py36
9 files changed, 504 insertions, 0 deletions
diff --git a/fuel/prototypes/auto-deploy/deploy/tools/transplant0.sh b/fuel/prototypes/auto-deploy/deploy/tools/transplant0.sh
new file mode 100755
index 000000000..7c5883b56
--- /dev/null
+++ b/fuel/prototypes/auto-deploy/deploy/tools/transplant0.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# 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
+##############################################################################
+
+cleanup () {
+ if [ -n "$tmpDir" ]; then
+ rm -Rf $tmpDir
+ fi
+}
+
+trap cleanup exit
+
+error_exit () {
+ echo "Error: $@" >&2
+ exit 1
+}
+
+tmpDir=`mktemp -d /tmp/deaXXXX`
+
+export PATH=`dirname $0`:$PATH
+
+if [ $# -lt 1 ]; then
+ error_exit "Argument error"
+fi
+deafile=$1
+shift
+
+if [ ! -f "$deafile" ]; then
+ error_exit "Can't find $deafile"
+fi
+
+transplant_fuel_settings.py /etc/fuel/astute.yaml $deafile || \
+ error_exit "Could not transplant astute settings"
diff --git a/fuel/prototypes/auto-deploy/deploy/tools/transplant1.sh b/fuel/prototypes/auto-deploy/deploy/tools/transplant1.sh
new file mode 100755
index 000000000..2401c6f88
--- /dev/null
+++ b/fuel/prototypes/auto-deploy/deploy/tools/transplant1.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# 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
+##############################################################################
+
+cleanup () {
+ if [ -n "$tmpDir" ]; then
+ rm -Rf $tmpDir
+ fi
+}
+
+trap cleanup exit
+
+error_exit () {
+ echo "Error: $@" >&2
+ exit 1
+}
+
+tmpDir=`mktemp -d /tmp/deaXXXX`
+
+export PATH=`dirname $0`:$PATH
+
+if [ $# -lt 1 ]; then
+ error_exit "Argument error"
+fi
+deafile=$1
+shift
+
+if [ ! -f "$deafile" ]; then
+ error_exit "Can't find $deafile"
+fi
+
+if [ `fuel env | tail -n +3 | grep -v '^$' | wc -l` -ne 1 ]; then
+ error_exit "Not exactly one environment"
+fi
+envId=`fuel env | tail -n +3 | grep -v '^$' | awk '{ print $1 }'`
+
+fuel settings --env $envId --download --dir $tmpDir > /dev/null || \
+ error_exit "Could not get settings"
+
+fuel network --env $envId --download --dir $tmpDir > /dev/null || \
+ error_exit "Could not get network settings"
+
+cp $tmpDir/network_${envId}.yaml network_before.yaml
+
+# Transplant network settings
+transplant_network_settings.py $tmpDir/network_${envId}.yaml $deafile || \
+ error_exit "Could not transplant network settings"
+fuel network --env $envId --upload --dir $tmpDir || \
+ error_exit "Could not update network settings"
+cp $tmpDir/network_${envId}.yaml network_after.yaml
+
+# Transplant settings
+cp $tmpDir/settings_${envId}.yaml settings_before.yaml
+transplant_settings.py $tmpDir/settings_${envId}.yaml $deafile || \
+ error_exit "Could not transplant settings"
+fuel settings --env $envId --upload --dir $tmpDir || \
+ error_exit "Could not update settings"
+cp $tmpDir/settings_${envId}.yaml settings_after.yaml
+
+
diff --git a/fuel/prototypes/auto-deploy/deploy/tools/transplant2.sh b/fuel/prototypes/auto-deploy/deploy/tools/transplant2.sh
new file mode 100755
index 000000000..46c7a6008
--- /dev/null
+++ b/fuel/prototypes/auto-deploy/deploy/tools/transplant2.sh
@@ -0,0 +1,98 @@
+#!/bin/bash
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# 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
+##############################################################################
+
+cleanup () {
+ if [ -n "$tmpDir" ]; then
+ rm -Rf $tmpDir
+ fi
+}
+
+trap cleanup exit
+
+error_exit () {
+ echo "Error: $@" >&2
+ exit 1
+}
+
+# Return offset between DEA node id and cluster node id
+getDeaNodeOffset()
+{
+ local baseId
+
+ baseId=`fuel node | tail -n +3 | awk '{ print $1 }' | sed 's/ //g' | sort -n | head -1`
+ echo "$[baseId - 1]"
+}
+
+tmpDir=`mktemp -d /tmp/deaXXXX`
+
+export PATH=`dirname $0`:$PATH
+
+if [ $# -ne 1 ]; then
+ error_exit "Argument error"
+fi
+deaFile=$1
+
+if [ ! -f "$deaFile" ]; then
+ error_exit "Can't find $deaFile"
+fi
+
+
+if [ `fuel env | tail -n +3 | grep -v '^$' | wc -l` -ne 1 ]; then
+ error_exit "Not exactly one environment"
+fi
+envId=`fuel env | tail -n +3 | grep -v '^$' | awk '{ print $1 }'`
+
+# Phase 1: Graft deployment information
+fuel deployment --env $envId --default --dir $tmpDir || \
+ error_exit "Could not dump environment"
+
+for controller in `find $tmpDir -type f | grep -v compute`
+do
+ transplant_network_scheme.py $controller $deaFile controller || \
+ error_exit "Failed to graft `basename $controller`"
+
+ transplant_opnfv_settings.py $controller $deaFile controller || \
+ error_exit "Failed to graft `basename $controller`"
+done
+
+for compute in `find $tmpDir -type f | grep compute`
+do
+ transplant_network_scheme.py $compute $deaFile compute || \
+ error_exit "Failed to graft `basename $compute`"
+
+ transplant_opnfv_settings.py $compute $deaFile compute || \
+ error_exit "Failed to graft `basename $controller`"
+done
+
+fuel deployment --env $envId --upload --dir $tmpDir || \
+ error_exit "Could not upload environment"
+
+# Phase 2: Graft interface information
+deaOffset=`getDeaNodeOffset`
+echo "DEA offset: $deaOffset"
+
+for clusterNodeId in `fuel node | grep True | awk '{ print $1}'`
+do
+ deaNodeId=$[clusterNodeId - deaOffset]
+ echo "Node $clusterNodeId is $deaNodeId"
+ fuel node --node-id $clusterNodeId --network --download --dir $tmpDir || \
+ error_exit "Could not download node $clusterNodeId"
+
+ transplant_interfaces.py ${tmpDir}/node_${clusterNodeId}/interfaces.yaml \
+ $deaFile $deaNodeId || \
+ error_exit "Failed to graft interfaces"
+
+ fuel node --node-id $clusterNodeId --network --upload --dir $tmpDir || \
+ error_exit "Could not upload node $clusterNodeId"
+done
+
+
+
diff --git a/fuel/prototypes/auto-deploy/deploy/tools/transplant_fuel_settings.py b/fuel/prototypes/auto-deploy/deploy/tools/transplant_fuel_settings.py
new file mode 100755
index 000000000..49ea5e455
--- /dev/null
+++ b/fuel/prototypes/auto-deploy/deploy/tools/transplant_fuel_settings.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# 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 re
+import sys
+import os
+
+if len(sys.argv) != 3:
+ sys.stderr.write("Usage: "+sys.argv[0]+" <astutefile> <deafile>\n")
+ sys.exit(1)
+
+fuelfile = sys.argv[1]
+if not os.path.exists(fuelfile):
+ sys.stderr.write("ERROR: The file "+fuelfile+" could not be opened\n")
+ sys.exit(1)
+
+deafile = sys.argv[2]
+if not os.path.exists(deafile):
+ sys.stderr.write("ERROR: The file "+deafile+" could not be opened\n")
+ sys.exit(1)
+
+f = open(deafile, 'r')
+dea = yaml.load(f)
+f.close()
+
+f = open(fuelfile, 'r')
+fuel = yaml.load(f)
+f.close()
+
+dea = dea["fuel"]
+for property in dea.keys():
+ if property == "ADMIN_NETWORK":
+ for adminproperty in dea[property].keys():
+ fuel[property][adminproperty] = dea[property][adminproperty]
+ else:
+ fuel[property] = dea[property]
+
+f = open(fuelfile, 'w')
+f.write(yaml.dump(fuel, default_flow_style=False))
+f.close()
+
diff --git a/fuel/prototypes/auto-deploy/deploy/tools/transplant_interfaces.py b/fuel/prototypes/auto-deploy/deploy/tools/transplant_interfaces.py
new file mode 100755
index 000000000..609f360ba
--- /dev/null
+++ b/fuel/prototypes/auto-deploy/deploy/tools/transplant_interfaces.py
@@ -0,0 +1,77 @@
+#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# 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 re
+import sys
+import os
+
+if len(sys.argv) != 4:
+ sys.stderr.write("Usage: "+sys.argv[0]+" <infile> <deafile> <nodeid>\n")
+ sys.exit(1)
+
+infile = sys.argv[1]
+if not os.path.exists(infile):
+ sys.stderr.write("ERROR: The file "+infile+" could not be opened\n")
+ sys.exit(1)
+
+deafile = sys.argv[2]
+if not os.path.exists(deafile):
+ sys.stderr.write("ERROR: The file "+deafile+" could not be opened\n")
+ sys.exit(1)
+deafile = sys.argv[2]
+nodeid = int(sys.argv[3])
+
+namespace = "interfaces"
+
+f1 = open(infile, 'r')
+doc1 = yaml.load(f1)
+f1.close()
+
+f2 = open(deafile, 'r')
+doc2 = yaml.load(f2)
+f2.close()
+
+
+# Create lookup table network name -> id for current setup
+nwlookup = {}
+for interface in doc1:
+ iface = {}
+ networks = []
+ for network in interface["assigned_networks"]:
+ nwlookup[network["name"]] = network["id"]
+
+# Find network information in DEA for this node
+nodeInfo = {}
+for node in doc2["nodes"]:
+ if node["id"] == nodeid:
+ nodeInfo=node
+ print "Found nodeinfo for node %d" % nodeid
+
+out = {}
+out["interfaces"] = {}
+
+for interface in doc1:
+ assigned = []
+ nw = {}
+ interface["assigned_networks"] = []
+ try:
+ for nwname in nodeInfo["interfaces"][interface["name"]]:
+ iface = {}
+ iface["id"] = nwlookup[nwname]
+ iface["name"] = nwname
+ interface["assigned_networks"].append(iface)
+ except:
+ print "No match for interface " + interface["name"]
+
+f3 = open(infile, 'w')
+f3.write(yaml.dump(doc1, default_flow_style=False))
+f3.close()
diff --git a/fuel/prototypes/auto-deploy/deploy/tools/transplant_network_scheme.py b/fuel/prototypes/auto-deploy/deploy/tools/transplant_network_scheme.py
new file mode 100755
index 000000000..7d50cbefe
--- /dev/null
+++ b/fuel/prototypes/auto-deploy/deploy/tools/transplant_network_scheme.py
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# 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 re
+import sys
+import os
+
+if len(sys.argv) != 4:
+ sys.stderr.write("Usage: "+sys.argv[0]+" <file> <deafile> [compute|controller]\n")
+ sys.exit(1)
+
+file = sys.argv[1]
+if not os.path.exists(file):
+ sys.stderr.write("ERROR: The file "+file+" could not be opened\n")
+ sys.exit(1)
+
+deafile = sys.argv[2]
+namespace = sys.argv[3]
+
+f1 = open(file, 'r')
+doc1 = yaml.load(f1)
+f1.close()
+
+f2 = open(deafile, 'r')
+doc2 = yaml.load(f2)
+f1.close()
+
+doc1["network_scheme"]["transformations"] = doc2[namespace]
+
+f2 = open(file, 'w')
+f2.write(yaml.dump(doc1, default_flow_style=False))
+f2.close()
+
diff --git a/fuel/prototypes/auto-deploy/deploy/tools/transplant_network_settings.py b/fuel/prototypes/auto-deploy/deploy/tools/transplant_network_settings.py
new file mode 100755
index 000000000..c0a46bec0
--- /dev/null
+++ b/fuel/prototypes/auto-deploy/deploy/tools/transplant_network_settings.py
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# 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 re
+import sys
+import os
+
+if len(sys.argv) != 3:
+ sys.stderr.write("Usage: "+sys.argv[0]+" <file> <deafile>\n")
+ sys.exit(1)
+
+file = sys.argv[1]
+if not os.path.exists(file):
+ sys.stderr.write("ERROR: The file "+file+" could not be opened\n")
+ sys.exit(1)
+
+deafile = sys.argv[2]
+if not os.path.exists(deafile):
+ sys.stderr.write("ERROR: The file "+deafile+" could not be opened\n")
+ sys.exit(1)
+
+f1 = open(file, 'r')
+doc1 = yaml.load(f1)
+f1.close()
+
+f2 = open(deafile, 'r')
+doc2 = yaml.load(f2)
+f2.close()
+
+# Grab IDs from Fuel version, graft onto DEA version and save
+id = []
+groupid = []
+for nw in doc1["networks"]:
+ id.append(nw["id"])
+ groupid.append(nw["group_id"])
+
+for nw in doc2["network"]["networks"]:
+ nw["id"] = id.pop(0)
+ nw["group_id"] = groupid.pop(0)
+
+f3 = open(file, 'w')
+f3.write(yaml.dump(doc2["network"], default_flow_style=False))
+f3.close()
diff --git a/fuel/prototypes/auto-deploy/deploy/tools/transplant_opnfv_settings.py b/fuel/prototypes/auto-deploy/deploy/tools/transplant_opnfv_settings.py
new file mode 100755
index 000000000..00d095093
--- /dev/null
+++ b/fuel/prototypes/auto-deploy/deploy/tools/transplant_opnfv_settings.py
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# 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 re
+import sys
+import os
+
+if len(sys.argv) != 4:
+ sys.stderr.write("Usage: "+sys.argv[0]+" <file> <deafile> [compute|controller]\n")
+ sys.exit(1)
+
+file = sys.argv[1]
+if not os.path.exists(file):
+ sys.stderr.write("ERROR: The file "+file+" could not be opened\n")
+ sys.exit(1)
+
+deafile = sys.argv[2]
+namespace = sys.argv[3]
+
+f1 = open(file, 'r')
+doc1 = yaml.load(f1)
+f1.close()
+
+f2 = open(deafile, 'r')
+doc2 = yaml.load(f2)
+f1.close()
+
+doc1["opnfv"] = doc2["opnfv"][namespace]
+
+f2 = open(file, 'w')
+f2.write(yaml.dump(doc1, default_flow_style=False))
+f2.close()
+
diff --git a/fuel/prototypes/auto-deploy/deploy/tools/transplant_settings.py b/fuel/prototypes/auto-deploy/deploy/tools/transplant_settings.py
new file mode 100755
index 000000000..7f5c0d8e2
--- /dev/null
+++ b/fuel/prototypes/auto-deploy/deploy/tools/transplant_settings.py
@@ -0,0 +1,36 @@
+#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# 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 re
+import sys
+import os
+
+if len(sys.argv) != 3:
+ sys.stderr.write("Usage: "+sys.argv[0]+" <file> <deafile>\n")
+ sys.exit(1)
+
+file = sys.argv[1]
+if not os.path.exists(file):
+ sys.stderr.write("ERROR: The file "+file+" could not be opened\n")
+ sys.exit(1)
+
+deafile = sys.argv[2]
+
+f1 = open(deafile, 'r')
+doc = yaml.load(f1)
+f1.close()
+
+out = doc["settings"]
+f2 = open(file, 'w')
+f2.write(yaml.dump(out, default_flow_style=False))
+f2.close()
+