Initial openvim v0.4.6 upload

Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
diff --git a/test/2VM_2I.sh b/test/2VM_2I.sh
new file mode 100755
index 0000000..96f8100
--- /dev/null
+++ b/test/2VM_2I.sh
@@ -0,0 +1,286 @@
+#!/bin/bash
+
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+#
+#author Alfonso Tierno
+#
+#script to test openvim with the creation of flavors and interfaces
+#using images already inserted
+#
+
+echo " Creates 1 flavor, 3 nets, 2 VMs (US)
+  Interfaces: 2 sriov, 1 passthrough, 1 sriov dedicated
+  Test mac address allocation, 1 VM with direct network attach, 
+  another VM with network attach after creation"
+echo
+echo -n "type network model to test network model (empty to skip)? "
+read model
+echo "Press enter to continue"
+read kk
+if [ -n "$model" ]
+then
+	model="model: '${model}'"
+fi
+#echo _${model}_
+
+#image to load
+imagePath=/mnt/powervault/virtualization/vnfs/os/US1404.qcow2
+#image to load as an extra disk, can be any
+imagePath_extra=/mnt/powervault/virtualization/vnfs/os/US1404user.qcow2
+#default network to use
+network_eth0=default
+
+
+DIRNAME=`dirname $0`
+
+function del_rubbish(){
+  echo "Press enter to delete the deployed things"
+  read kk
+  [ -n "$DEL_server" ]  && ${DIRNAME}/test_openvim.py -f del server $DEL_server
+  [ -n "$DEL_network" ] && ${DIRNAME}/test_openvim.py -f del network $DEL_network
+  [ -n "$DEL_flavor" ]  && ${DIRNAME}/test_openvim.py -f del flavor $DEL_flavor
+  [ -n "$DEL_image" ]   && ${DIRNAME}/test_openvim.py -f del image $DEL_image
+  rm -f kk.out
+}
+
+function proccess_out(){ # action_text  field to retrieve
+  if egrep -q "\"error\""  kk.out
+  then
+    echo "failed to" $1
+    cat kk.out
+    del_rubbish
+    exit -1
+  fi
+  if [ -z "$2" ] ; then pattern='"id"' ; else pattern="$2" ; fi
+  value=`egrep  "$pattern"  kk.out `
+  value=${value##* \"}
+  value=${value%\"*}
+  if [[ -z "$value" ]]
+  then 
+    echo "not found the field" $2
+    cat kk.out
+    del_rubbish
+    exit -1
+  fi
+}
+
+#proccess_out "insert server tidgen1" '^            "id"'
+#echo $value
+#exit 0
+
+
+
+echo -n "get ${imagePath##*/} image:                       "
+${DIRNAME}/test_openvim.py -F"path=$imagePath" images > kk.out
+proccess_out "get ${imagePath##*/}" 
+echo $value
+image1=$value
+
+
+echo -n "get ${imagePath_extra##*/} image:                 "
+${DIRNAME}/test_openvim.py -F"path=$imagePath_extra" images > kk.out
+proccess_out "get ${imagePath_extra##*/}" 
+echo $value
+image2=$value
+
+
+echo -n "get ${network_eth0} network:                 "
+${DIRNAME}/test_openvim.py -F"name=$network_eth0" network > kk.out
+proccess_out "get  ${network_eth0} network" 
+echo $value
+network_eth0=$value
+
+
+echo -n "insert flavor:                                    "
+${DIRNAME}/test_openvim.py new flavor '
+---
+flavor:
+  name: 5PTh_8G_2I
+  description: flavor to test openvim
+  extended: 
+    processor_ranking: 205
+    numas:
+    -  memory: 8
+       paired-threads: 5
+       interfaces:
+       - name: xe0
+         dedicated: "yes"
+         bandwidth: "10 Gbps"
+         vpci: "0000:00:10.0"
+         #mac_address: "10:10:10:10:10:10"
+       - name: xe1
+         dedicated: "yes:sriov"
+         bandwidth: "10 Gbps"
+         vpci: "0000:00:11.0"
+         mac_address: "10:10:10:10:10:11"
+'  > kk.out
+proccess_out "insert flavor" 
+echo $value
+flavor1=$value
+DEL_flavor="$DEL_flavor $flavor1"
+
+
+echo -n "insert ptp net1:                                  "
+${DIRNAME}/test_openvim.py new network '
+---
+network:
+  name: network-xe0
+  type: ptp
+'  > kk.out
+proccess_out "insert network 0" 
+echo $value
+network0=$value
+DEL_network="$DEL_network $value"
+
+
+echo -n "insert ptp net2:                                  "
+${DIRNAME}/test_openvim.py new network '
+---
+network:
+  name: network-xe1
+  type: ptp
+'  > kk.out
+proccess_out "insert network 1"
+echo $value
+network1=$value
+DEL_network="$DEL_network $value"
+
+
+
+echo -n "insert bridge network net2:                       "
+${DIRNAME}/test_openvim.py new network '
+---
+network:
+  name: network-net2
+  type: bridge_data
+'  > kk.out
+proccess_out "insert network 2"
+echo $value
+network2=$value
+DEL_network="$DEL_network $value"
+
+echo -n "insert test VM 1:                                 "
+${DIRNAME}/test_openvim.py new server "
+---
+server:
+  name: test_VM1
+  descrition: US or tidgen with 1 SRIOV 1 PASSTHROUGH
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  networks:
+  - name: mgmt0
+    vpci: '0000:00:0a.0'
+    uuid: ${network_eth0}
+    mac_address: '10:10:10:10:10:12'
+  - name: eth0
+    vpci: '0000:00:0b.0'
+    uuid: '$network2'
+    mac_address: '10:10:10:10:10:13'
+    ${model}
+"  > kk.out
+proccess_out "insert test VM 2" '^        "id"'
+echo $value
+server1=$value
+DEL_server="$DEL_server $value"
+
+
+
+echo -n "insert test VM 2:                                 "
+${DIRNAME}/test_openvim.py new server "
+---
+server:
+  name: test_VM2
+  descrition: US or tidgen with direct network attach
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  extended:
+    processor_ranking: 205
+    numas:
+    -  memory: 8
+       threads: 10
+       interfaces:
+       - name: xe0
+         dedicated: 'yes'
+         bandwidth: '10 Gbps'
+         vpci: '0000:00:10.0'
+         #mac_address: '10:10:10:10:aa:10'
+         uuid: '$network0'
+       - name: xe1
+         dedicated: 'no'
+         bandwidth: '7 Gbps'
+         vpci: '0000:00:11.0'
+         mac_address: '10:10:10:10:aa:11'
+         uuid: '$network1'
+    devices:
+    - type: disk
+      imageRef: '$image2'
+  networks:
+  - name: mgmt0
+    vpci: '0000:00:0a.0'
+    uuid: ${network_eth0}
+    mac_address: '10:10:10:10:aa:12'
+  - name: eth0
+    vpci: '0000:00:0b.0'
+    uuid: '$network2'
+    mac_address: '10:10:10:10:aa:13'
+    ${model}
+"  > kk.out
+proccess_out "insert test VM 2" '^        "id"'
+echo $value
+server2=$value
+DEL_server="$DEL_server $value"
+
+echo -n "get xe0 iface uuid from tidgen1:                  "
+${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe0"  ports > kk.out
+proccess_out "get xe0 uuid port from tidgen1" 
+echo $value
+iface_xe0=$value
+
+
+echo -n "get xe1 iface uuid from tidgen1:                  "
+${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe1"  ports > kk.out
+proccess_out "get xe1 uuid port from tidgen1" 
+echo $value
+iface_xe1=$value
+
+
+echo -n "attach xe0 from tidgen1 to network                "
+${DIRNAME}/test_openvim.py -f edit ports $iface_xe0 "network_id: $network0" > kk.out
+proccess_out "attach xe0 from tidgen1 to network"
+echo "ok"
+
+
+echo -n "attach xe1 from tidgen1 to network                "
+${DIRNAME}/test_openvim.py -f edit ports $iface_xe1 "network_id: $network1" > kk.out
+proccess_out "attach xe1 from tidgen1 to network"
+echo "ok"
+
+
+echo 
+echo finish. Check connections!!
+echo click return to delete all deployed things
+echo
+
+del_rubbish
+exit 0
+
diff --git a/test/2VM_2I_2VLAN.sh b/test/2VM_2I_2VLAN.sh
new file mode 100755
index 0000000..1e0f626
--- /dev/null
+++ b/test/2VM_2I_2VLAN.sh
@@ -0,0 +1,276 @@
+#!/bin/bash
+
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+#
+#author Alfonso Tierno
+#
+#script to test openvim with the creation of flavors and interfaces
+#using images already inserted
+#
+
+echo " Creates 1 flavor, 3 nets, 2 VMs (US)
+  Interfaces: 2 sriov, 1 passthrough, 1 sriov dedicated
+  Test mac address allocation, 1 VM with direct network attach, 
+  another VM with network attach after creation"
+echo
+echo "Press enter to continue"
+read kk
+
+#image to load
+imagePath=/mnt/powervault/virtualization/vnfs/os/US1404.qcow2
+#image to load as an extra disk, can be any
+imagePath_extra=/mnt/powervault/virtualization/vnfs/os/US1404user.qcow2
+#default network to use
+network_eth0=default
+
+
+DIRNAME=`dirname $0`
+
+function del_rubbish(){
+  echo "Press enter to delete the deployed things"
+  read kk
+  [ -n "$DEL_server" ]  && ${DIRNAME}/test_openvim.py -f del server $DEL_server
+  [ -n "$DEL_network" ] && ${DIRNAME}/test_openvim.py -f del network $DEL_network
+  [ -n "$DEL_flavor" ]  && ${DIRNAME}/test_openvim.py -f del flavor $DEL_flavor
+  [ -n "$DEL_image" ]   && ${DIRNAME}/test_openvim.py -f del image $DEL_image
+  rm -f kk.out
+}
+
+function proccess_out(){ # action_text  field to retrieve
+  if egrep -q "\"error\""  kk.out
+  then
+    echo "failed to" $1
+    cat kk.out
+    del_rubbish
+    exit -1
+  fi
+  if [ -z "$2" ] ; then pattern='"id"' ; else pattern="$2" ; fi
+  value=`egrep  "$pattern"  kk.out `
+  value=${value##* \"}
+  value=${value%\"*}
+  if [[ -z "$value" ]]
+  then 
+    echo "not found the field" $2
+    cat kk.out
+    del_rubbish
+    exit -1
+  fi
+}
+
+#proccess_out "insert server tidgen1" '^            "id"'
+#echo $value
+#exit 0
+
+
+
+echo -n "get ${imagePath##*/} image:                       "
+${DIRNAME}/test_openvim.py -F"path=$imagePath" images > kk.out
+proccess_out "get ${imagePath##*/}" 
+echo $value
+image1=$value
+
+
+echo -n "get ${imagePath_extra##*/} image:                 "
+${DIRNAME}/test_openvim.py -F"path=$imagePath_extra" images > kk.out
+proccess_out "get ${imagePath_extra##*/}" 
+echo $value
+image2=$value
+
+
+echo -n "get ${network_eth0} network:                 "
+${DIRNAME}/test_openvim.py -F"name=$network_eth0" network > kk.out
+proccess_out "get  ${network_eth0} network" 
+echo $value
+network_eth0=$value
+
+
+echo -n "insert flavor:                                    "
+${DIRNAME}/test_openvim.py new flavor '
+---
+flavor:
+  name: 5PTh_8G_2I
+  description: flavor to test openvim
+  extended: 
+    processor_ranking: 205
+    numas:
+    -  memory: 8
+       paired-threads: 5
+       interfaces:
+       - name: xe0
+         dedicated: "yes"
+         bandwidth: "10 Gbps"
+         vpci: "0000:00:10.0"
+         #mac_address: "10:10:10:10:10:10"
+       - name: xe1
+         dedicated: "no"
+         bandwidth: "10 Gbps"
+         vpci: "0000:00:11.0"
+         mac_address: "10:10:10:10:10:11"
+'  > kk.out
+proccess_out "insert flavor" 
+echo $value
+flavor1=$value
+DEL_flavor="$DEL_flavor $flavor1"
+
+
+echo -n "insert ptp net1:                                  "
+${DIRNAME}/test_openvim.py new network '
+---
+network:
+  name: network-xe0
+  type: ptp
+'  > kk.out
+proccess_out "insert network 0" 
+echo $value
+network0=$value
+DEL_network="$DEL_network $value"
+
+
+echo -n "insert ptp net2:                                  "
+${DIRNAME}/test_openvim.py new network '
+---
+network:
+  name: network-xe1
+  type: ptp
+'  > kk.out
+proccess_out "insert network 1"
+echo $value
+network1=$value
+DEL_network="$DEL_network $value"
+
+
+
+echo -n "insert bridge network net2:                       "
+${DIRNAME}/test_openvim.py new network '
+---
+network:
+  name: network-net2
+  type: bridge_data
+'  > kk.out
+proccess_out "insert network 2"
+echo $value
+network2=$value
+DEL_network="$DEL_network $value"
+
+echo -n "insert test VM 1:                                 "
+${DIRNAME}/test_openvim.py new server "
+---
+server:
+  name: test_VM1
+  descrition: US or tidgen with 1 SRIOV 1 PASSTHROUGH
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  networks:
+  - name: mgmt0
+    vpci: '0000:00:0a.0'
+    uuid: ${network_eth0}
+    mac_address: '10:10:10:10:10:12'
+  - name: eth0
+    vpci: '0000:00:0b.0'
+    uuid: '$network2'
+    mac_address: '10:10:10:10:10:13'
+"  > kk.out
+proccess_out "insert test VM 2" '^        "id"'
+echo $value
+server1=$value
+DEL_server="$DEL_server $value"
+
+
+
+echo -n "insert test VM 2:                                 "
+${DIRNAME}/test_openvim.py new server "
+---
+server:
+  name: test_VM2
+  descrition: US or tidgen with direct network attach
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  networks:
+  - name: mgmt0
+    vpci: '0000:00:0a.0'
+    uuid: ${network_eth0}
+    mac_address: '10:10:10:10:aa:12'
+  - name: eth0
+    vpci: '0000:00:0b.0'
+    uuid: '$network2'
+    mac_address: '10:10:10:10:aa:13'
+  extended:
+    processor_ranking: 205
+    numas:
+    -  memory: 8
+       threads: 10
+       interfaces:
+       - name: xe0
+         dedicated: 'yes'
+         bandwidth: '10 Gbps'
+         vpci: '0000:00:10.0'
+         #mac_address: '10:10:10:10:aa:10'
+         uuid: '$network0'
+       - name: xe1
+         dedicated: 'no'
+         bandwidth: '7 Gbps'
+         vpci: '0000:00:11.0'
+         mac_address: '10:10:10:10:aa:11'
+         uuid: '$network1'
+    devices:
+    - type: disk
+      imageRef: '$image2'
+"  > kk.out
+proccess_out "insert test VM 2" '^        "id"'
+echo $value
+server2=$value
+DEL_server="$DEL_server $value"
+
+echo -n "get xe0 iface uuid from tidgen1:                  "
+${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe0"  ports > kk.out
+proccess_out "get xe0 uuid port from tidgen1" 
+echo $value
+iface_xe0=$value
+
+
+echo -n "get xe1 iface uuid from tidgen1:                  "
+${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe1"  ports > kk.out
+proccess_out "get xe1 uuid port from tidgen1" 
+echo $value
+iface_xe1=$value
+
+
+echo -n "attach xe0 from tidgen1 to network                "
+${DIRNAME}/test_openvim.py -f edit ports $iface_xe0 "network_id: $network0" > kk.out
+proccess_out "attach xe0 from tidgen1 to network"
+echo "ok"
+
+
+echo -n "attach xe1 from tidgen1 to network                "
+${DIRNAME}/test_openvim.py -f edit ports $iface_xe1 "network_id: $network1" > kk.out
+proccess_out "attach xe1 from tidgen1 to network"
+echo "ok"
+
+
+echo 
+echo finsish. Check connections!!
+echo
+
+del_rubbish
+exit 0
+
diff --git a/test/2VM_NoHuge.sh b/test/2VM_NoHuge.sh
new file mode 100755
index 0000000..9326ec2
--- /dev/null
+++ b/test/2VM_NoHuge.sh
@@ -0,0 +1,199 @@
+#!/bin/bash
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+#
+#author Alfonso Tierno
+#
+#script to test openvim with the creation of flavors and interfaces
+#in cloud style
+#
+
+echo " Creates 1 flavor, 3 nets, 2 VMs (US)
+  WITHOUT huge pages, nor NUMA assigment
+  network attach after creation"
+echo
+echo "Press enter to continue"
+read kk
+
+#image to load
+imagePath=/mnt/powervault/virtualization/vnfs/os/US1404.qcow2
+#image to load as an extra disk, can be any
+imagePath_extra=/mnt/powervault/virtualization/vnfs/os/US1404user.qcow2
+#default network to use
+network_eth0=default
+
+
+DIRNAME=`dirname $0`
+
+function del_rubbish(){
+  echo "Press enter to delete the deployed things"
+  read kk
+  [ -n "$DEL_server" ]  && ${DIRNAME}/test_openvim.py -f del server $DEL_server
+  [ -n "$DEL_network" ] && ${DIRNAME}/test_openvim.py -f del network $DEL_network
+  [ -n "$DEL_flavor" ]  && ${DIRNAME}/test_openvim.py -f del flavor $DEL_flavor
+  [ -n "$DEL_image" ]   && ${DIRNAME}/test_openvim.py -f del image $DEL_image
+  rm -f kk.out
+}
+
+function proccess_out(){ # action_text  field to retrieve
+  if egrep -q "\"error\""  kk.out
+  then
+    echo "failed to" $1
+    cat kk.out
+    del_rubbish
+    exit -1
+  fi
+  if [ -z "$2" ] ; then pattern='"id"' ; else pattern="$2" ; fi
+  value=`egrep  "$pattern"  kk.out `
+  value=${value##* \"}
+  value=${value%\"*}
+  if [[ -z "$value" ]]
+  then 
+    echo "not found the field" $2
+    cat kk.out
+    del_rubbish
+    exit -1
+  fi
+}
+
+#proccess_out "insert server tidgen1" '^            "id"'
+#echo $value
+#exit 0
+
+
+
+echo -n "get ${imagePath##*/} image:                       "
+${DIRNAME}/test_openvim.py -F"path=$imagePath" images > kk.out
+proccess_out "get ${imagePath##*/}" 
+echo $value
+image1=$value
+
+
+echo -n "get ${imagePath_extra##*/} image:                 "
+${DIRNAME}/test_openvim.py -F"path=$imagePath_extra" images > kk.out
+proccess_out "get ${imagePath_extra##*/}" 
+echo $value
+image2=$value
+
+
+echo -n "get ${network_eth0} network:                 "
+${DIRNAME}/test_openvim.py -F"name=$network_eth0" network > kk.out
+proccess_out "get  ${network_eth0} network" 
+echo $value
+network_eth0=$value
+
+
+echo -n "insert flavor:                                    "
+${DIRNAME}/test_openvim.py new flavor '
+---
+flavor:
+  name: CloudVM
+  description: normal cloud image with 1G, 1core
+  ram: 1024
+  vcpus: 1
+'  > kk.out
+proccess_out "insert flavor" 
+echo $value
+flavor1=$value
+DEL_flavor="$DEL_flavor $flavor1"
+
+
+echo
+echo "Press enter to continue"
+read kk
+
+echo -n "insert bridge network net2:                       "
+${DIRNAME}/test_openvim.py new network '
+---
+network:
+  name: network-bridge
+  type: bridge_data
+'  > kk.out
+proccess_out "insert network 2"
+echo $value
+network2=$value
+DEL_network="$DEL_network $value"
+
+echo -n "insert test VM 1:                                 "
+${DIRNAME}/test_openvim.py new server "
+---
+server:
+  name: test_VM1
+  descrition: US  1 core
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  networks:
+  - name: mgmt0
+    vpci: '0000:00:0a.0'
+    uuid: ${network_eth0}
+    mac_address: '10:10:10:10:10:12'
+  - name: eth0
+    vpci: '0000:00:0b.0'
+    uuid: '$network2'
+    mac_address: '10:10:10:10:10:13'
+"  > kk.out
+proccess_out "insert test VM 2" '^        "id"'
+echo $value
+server1=$value
+DEL_server="$DEL_server $value"
+
+
+echo
+echo "Press enter to continue"
+read kk
+
+echo -n "insert test VM 2:                                 "
+${DIRNAME}/test_openvim.py new server "
+---
+server:
+  name: test_VM2
+  descrition: US 1G 1core
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  ram: 1024
+  vcpus: 1
+  networks:
+  - name: mgmt0
+    vpci: '0000:00:0a.0'
+    uuid: ${network_eth0}
+    mac_address: '10:10:10:10:aa:12'
+  - name: eth0
+    vpci: '0000:00:0b.0'
+    uuid: '$network2'
+    mac_address: '10:10:10:10:aa:13'
+  extended:
+    devices:
+    - type: disk
+      imageRef: '$image2'
+"  > kk.out
+proccess_out "insert test VM 2" '^        "id"'
+echo $value
+server2=$value
+DEL_server="$DEL_server $value"
+
+echo 
+echo finsish. Check connections!!
+echo
+
+del_rubbish
+exit 0
+
diff --git a/test/flavors/2Th_2G.yaml b/test/flavors/2Th_2G.yaml
new file mode 100644
index 0000000..3df9573
--- /dev/null
+++ b/test/flavors/2Th_2G.yaml
@@ -0,0 +1,37 @@
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+
+{
+"flavor":{
+    "name":"2Th_2G",
+    "description":"2 Threads, 2Gbyte, only 2 management interfaces",
+    "extended":{
+        "processor_ranking":205, 
+        "numas":[
+            {
+                "memory":2, 
+                "threads":2
+            }
+        ]
+    }
+}
+}
diff --git a/test/flavors/5PTh_8G_2I.yaml b/test/flavors/5PTh_8G_2I.yaml
new file mode 100644
index 0000000..9ffeb49
--- /dev/null
+++ b/test/flavors/5PTh_8G_2I.yaml
@@ -0,0 +1,39 @@
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+# 5Th_8G_2P
+flavor:
+    name:        5PTh_8G_2I
+    description: 5Pair threads (10tthreads) 8GB memory and 2 dataplane passthrough interfaces
+    extended:
+        processor_ranking: 100 
+        numas:
+        -  memory:         8 
+           paired-threads: 5
+           interfaces: 
+           -   name:       xe0
+               vpci:       "0000:00:10.0"
+               bandwidth:  10 Gbps
+               dedicated:  "yes"
+           -   name:       xe1
+               vpci:       "0000:00:11.0"
+               bandwidth:  10 Gbps
+               dedicated:  "yes"
diff --git a/test/flavors/new_flavor.yaml b/test/flavors/new_flavor.yaml
new file mode 100644
index 0000000..fab23d5
--- /dev/null
+++ b/test/flavors/new_flavor.yaml
@@ -0,0 +1,45 @@
+
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+{
+    "${}":[
+        "${name} flavor name",
+        "${description} flavor description (${name})",
+        "${processor_ranking} processnor ranking (100)",
+        "${memory} memory in GB (2)",
+        "${threads} threads needed (2)"
+    ],
+
+"flavor":{
+    "name":"${name}",
+    "description":"${description}",
+    "extended":{
+        "processor_ranking":"${processor_ranking int}", 
+        "numas":[
+            {
+                "memory":"${memory int}", 
+                "threads":"${threads int}"
+            }
+        ]
+    }
+}
+}
diff --git a/test/get_params.sh b/test/get_params.sh
new file mode 100755
index 0000000..0a0f6df
--- /dev/null
+++ b/test/get_params.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+#
+#author Alfonso Tierno
+#
+#script that obtain the parameters from the configuration file
+#it is a bit unsafe because a comment in the yaml configuration file
+#can wrong this script  
+
+#get params from configuration file
+
+[ -z "$1" ] && echo "usage: $0 [openvim_cfg_file]" && exit
+
+OPENVIM_PORT=`grep http_port: $1`
+OPENVIM_PORT=${OPENVIM_PORT#http_port:}
+OPENVIM_PORT=${OPENVIM_PORT%%#*}
+OPENVIM_PORT=`eval echo ${OPENVIM_PORT}`  # remove white spaces
+
+OPENVIM_ADMIN_PORT=`grep http_admin_port: $1`
+OPENVIM_ADMIN_PORT=${OPENVIM_ADMIN_PORT#http_admin_port:}
+OPENVIM_ADMIN_PORT=${OPENVIM_ADMIN_PORT%%#*}
+OPENVIM_ADMIN_PORT=`eval echo ${OPENVIM_ADMIN_PORT}`  # remove white spaces
+
+OPENVIM_HOST=`grep http_host: $1`
+OPENVIM_HOST=${OPENVIM_HOST#http_host:}
+OPENVIM_HOST=${OPENVIM_HOST%%#*}
+OPENVIM_HOST=`eval echo ${OPENVIM_HOST}`  # remove white spaces
+
+OPENVIM_OF_IP=`grep of_controller_ip: $1`
+OPENVIM_OF_IP=${OPENVIM_OF_IP#of_controller_ip:}
+OPENVIM_OF_IP=${OPENVIM_OF_IP%%#*}
+OPENVIM_OF_IP=`eval echo ${OPENVIM_OF_IP}`  # remove white spaces
+
+OPENVIM_OF_PORT=`grep of_controller_port: $1`
+OPENVIM_OF_PORT=${OPENVIM_OF_PORT#of_controller_port:}
+OPENVIM_OF_PORT=${OPENVIM_OF_PORT%%#*}
+OPENVIM_OF_PORT=`eval echo ${OPENVIM_OF_PORT}`  # remove white spaces
+
+OPENVIM_OF_DPID=`grep of_controller_dpid: $1`
+OPENVIM_OF_DPID=${OPENVIM_OF_DPID#of_controller_dpid:}
+OPENVIM_OF_DPID=${OPENVIM_OF_DPID%%#*}
+OPENVIM_OF_DPID=`eval echo ${OPENVIM_OF_DPID}`  # remove white spaces
+
diff --git a/test/hosts/host-example0.json b/test/hosts/host-example0.json
new file mode 100644
index 0000000..b5dc5ee
--- /dev/null
+++ b/test/hosts/host-example0.json
@@ -0,0 +1,465 @@
+{
+    "host":{
+        "name": "fake-host-0",
+        "user": "user", 
+        "password": "password", 
+        "ip_name": "fakehost0" 
+    },
+"host-data":
+{
+    "name": "fake-host-0",
+    "ranking": 300,
+    "description": "fake host 0 for test mode",
+    "ip_name": "fakehost0",
+    "features": "lps,dioc,hwsv,ht,64b,tlbps",
+    "user": "user",
+    "password": "password",
+    "numas": [
+        {
+            "cores": [
+                {
+                    "core_id": 0,
+                    "thread_id": 12,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 0,
+                    "thread_id": 36,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 13
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 37
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 14
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 38
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 15
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 39
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 16
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 40
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 17
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 41
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 18
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 42
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 19
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 43
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 20
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 44
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 21
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 45
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 22
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 46
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 23
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 47
+                }
+            ],
+            "numa_socket": 1,
+            "hugepages": 28,
+            "memory": 32
+        },
+        {
+            "cores": [
+                {
+                    "core_id": 0,
+                    "thread_id": 0,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 0,
+                    "thread_id": 24,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 1
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 25
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 2
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 26
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 3
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 27
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 4
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 28
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 5
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 29
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 6
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 30
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 7
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 31
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 8
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 32
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 9
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 33
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 10
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 34
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 11
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 35
+                }
+            ],
+            "interfaces": [
+                {
+                    "source_name": "eth8",
+                    "Mbps": 10000,
+                    "pci": "0000:08:00.0",
+                    "switch_port": "port0/2",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "a6:12:27:bd:2d:ef",
+                            "pci": "0000:08:10.0",
+                            "source_name": 0,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "be:8a:40:58:cf:de",
+                            "pci": "0000:08:10.2",
+                            "source_name": 1,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "c6:bf:7a:30:13:55",
+                            "pci": "0000:08:10.4",
+                            "source_name": 2,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "be:32:50:ef:ea:4e",
+                            "pci": "0000:08:10.6",
+                            "source_name": 3,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "ae:36:60:bc:41:78",
+                            "pci": "0000:08:11.0",
+                            "source_name": 4,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "52:22:3a:99:67:4e",
+                            "pci": "0000:08:11.2",
+                            "source_name": 5,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "0a:b8:00:2c:8a:b2",
+                            "pci": "0000:08:11.4",
+                            "source_name": 6,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "e2:f6:70:83:a3:ec",
+                            "pci": "0000:08:11.6",
+                            "source_name": 7,
+                            "vlan": 101
+                        }
+                    ],
+                    "mac": "90:e2:ba:0c:36:4c"
+                },
+                {
+                    "source_name": "eth17",
+                    "Mbps": 10000,
+                    "pci": "0000:08:00.1",
+                    "switch_port": "port0/3",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "92:0e:27:0c:ad:eb",
+                            "pci": "0000:08:10.1",
+                            "source_name": 0,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "be:99:65:e8:98:a3",
+                            "pci": "0000:08:10.3",
+                            "source_name": 1,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "8a:3b:54:42:88:b2",
+                            "pci": "0000:08:10.5",
+                            "source_name": 2,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "c6:5d:8a:c5:05:f7",
+                            "pci": "0000:08:10.7",
+                            "source_name": 3,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "96:bd:61:02:4f:d6",
+                            "pci": "0000:08:11.1",
+                            "source_name": 4,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "22:5d:85:2c:1b:fd",
+                            "pci": "0000:08:11.3",
+                            "source_name": 5,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "e6:7f:8a:48:bc:26",
+                            "pci": "0000:08:11.5",
+                            "source_name": 6,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "2e:4a:e6:68:18:fa",
+                            "pci": "0000:08:11.7",
+                            "source_name": 7,
+                            "vlan": 107
+                        }
+                    ],
+                    "mac": "90:e2:ba:0c:36:4d"
+                },
+                {
+                    "source_name": "eth26",
+                    "Mbps": 10000,
+                    "pci": "0000:06:00.0",
+                    "switch_port": "port0/0",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "02:79:15:02:ad:cc",
+                            "pci": "0000:06:10.0",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "06:81:ef:de:ec:6b",
+                            "pci": "0000:06:10.2",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "f2:4e:96:f3:8e:73",
+                            "pci": "0000:06:10.4",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "e2:86:91:23:c5:76",
+                            "pci": "0000:06:10.6",
+                            "source_name": 3,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "52:12:a0:77:cc:47",
+                            "pci": "0000:06:11.0",
+                            "source_name": 4,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "ca:17:4a:c4:cb:bf",
+                            "pci": "0000:06:11.2",
+                            "source_name": 5,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "de:13:4c:5d:70:e8",
+                            "pci": "0000:06:11.4",
+                            "source_name": 6,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "0a:5f:d2:db:7f:e2",
+                            "pci": "0000:06:11.6",
+                            "source_name": 7,
+                            "vlan": 100
+                        }
+                    ],
+                    "mac": "90:e2:ba:0b:6b:b4"
+                },
+                {
+                    "source_name": "eth35",
+                    "Mbps": 10000,
+                    "pci": "0000:06:00.1",
+                    "switch_port": "port0/1",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "a2:08:55:fe:c5:db",
+                            "pci": "0000:06:10.1",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "7a:dd:c7:46:2a:91",
+                            "pci": "0000:06:10.3",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "92:a8:1d:4e:cc:a8",
+                            "pci": "0000:06:10.5",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "02:1a:d6:87:c4:cc",
+                            "pci": "0000:06:10.7",
+                            "source_name": 3,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "ea:1b:8b:2a:da:9a",
+                            "pci": "0000:06:11.1",
+                            "source_name": 4,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "aa:c3:fe:e5:f2:96",
+                            "pci": "0000:06:11.3",
+                            "source_name": 5,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "e2:66:1f:00:b3:45",
+                            "pci": "0000:06:11.5",
+                            "source_name": 6,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "da:3c:d8:a3:f4:e0",
+                            "pci": "0000:06:11.7",
+                            "source_name": 7,
+                            "vlan": 100
+                        }
+                    ],
+                    "mac": "90:e2:ba:0b:6b:b5"
+                }
+            ],
+            "numa_socket": 0,
+            "hugepages": 28,
+            "memory": 32
+        }
+    ]
+}
+}
+
diff --git a/test/hosts/host-example1.json b/test/hosts/host-example1.json
new file mode 100644
index 0000000..766aaef
--- /dev/null
+++ b/test/hosts/host-example1.json
@@ -0,0 +1,698 @@
+{
+"host":{
+    "name": "fake-host-1",
+    "user": "user",
+    "password": "password",
+    "ip_name": "fakehost1"
+},
+"host-data":
+{
+    "name": "fake-host-1",
+    "ranking": 300,
+    "description": "fake host 1 for test mode",
+    "ip_name": "fakehost1",
+    "features": "lps,dioc,hwsv,ht,64b,tlbps",
+    "user": "user",
+    "password": "password",
+    "numas": [
+        {
+            "cores": [
+                {
+                    "core_id": 0,
+                    "thread_id": 1,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 0,
+                    "thread_id": 25,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 3
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 27
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 5
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 29
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 7
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 31
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 9
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 33
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 11
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 35
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 13
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 37
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 15
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 39
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 17
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 41
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 19
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 43
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 21
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 45
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 23
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 47
+                }
+            ],
+            "interfaces": [
+                {
+                    "source_name": "p2p1",
+                    "Mbps": 10000,
+                    "pci": "0000:44:00.0",
+                    "switch_port": "port0/4",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "4e:2e:a5:ab:7f:4b",
+                            "pci": "0000:44:10.0",
+                            "source_name": 0,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "a6:43:f6:4f:b6:ea",
+                            "pci": "0000:44:10.2",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "b2:fe:29:81:71:0a",
+                            "pci": "0000:44:10.4",
+                            "source_name": 2,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "aa:9d:13:62:80:e5",
+                            "pci": "0000:44:10.6",
+                            "source_name": 3,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "3a:30:7f:c6:67:04",
+                            "pci": "0000:44:11.0",
+                            "source_name": 4,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "c6:20:45:8f:30:08",
+                            "pci": "0000:44:11.2",
+                            "source_name": 5,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "66:3d:09:bc:d6:32",
+                            "pci": "0000:44:11.4",
+                            "source_name": 6,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "46:e5:0c:f6:c4:ae",
+                            "pci": "0000:44:11.6",
+                            "source_name": 7,
+                            "vlan": 106
+                        }
+                    ],
+                    "mac": "a0:36:9f:35:ed:14"
+                },
+                {
+                    "source_name": "p2p2",
+                    "Mbps": 10000,
+                    "pci": "0000:44:00.1",
+                    "switch_port": "port0/5",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "ea:b6:5d:98:d9:86",
+                            "pci": "0000:44:10.1",
+                            "source_name": 0,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "36:4c:31:5a:5f:66",
+                            "pci": "0000:44:10.3",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "42:a0:5d:fa:8d:8c",
+                            "pci": "0000:44:10.5",
+                            "source_name": 2,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "c6:50:23:c5:53:ff",
+                            "pci": "0000:44:10.7",
+                            "source_name": 3,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "12:2e:6c:79:a3:cc",
+                            "pci": "0000:44:11.1",
+                            "source_name": 4,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "be:f0:8e:7b:50:46",
+                            "pci": "0000:44:11.3",
+                            "source_name": 5,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "6e:6e:15:44:1c:1d",
+                            "pci": "0000:44:11.5",
+                            "source_name": 6,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "9a:e8:1e:e6:af:31",
+                            "pci": "0000:44:11.7",
+                            "source_name": 7,
+                            "vlan": 107
+                        }
+                    ],
+                    "mac": "a0:36:9f:35:ed:16"
+                },
+                {
+                    "source_name": "p3p2",
+                    "Mbps": 10000,
+                    "pci": "0000:43:00.1",
+                    "switch_port": "port0/7",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "2e:b7:dc:aa:9a:35",
+                            "pci": "0000:43:10.1",
+                            "source_name": 0,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "42:71:39:50:92:a5",
+                            "pci": "0000:43:10.3",
+                            "source_name": 1,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "22:ac:a0:64:a4:00",
+                            "pci": "0000:43:10.5",
+                            "source_name": 2,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "7e:81:e0:56:c0:aa",
+                            "pci": "0000:43:10.7",
+                            "source_name": 3,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "de:87:8d:ed:81:1a",
+                            "pci": "0000:43:11.1",
+                            "source_name": 4,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "fe:29:e9:da:45:df",
+                            "pci": "0000:43:11.3",
+                            "source_name": 5,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "b6:e7:67:46:22:de",
+                            "pci": "0000:43:11.5",
+                            "source_name": 6,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "5e:9e:10:7a:66:e9",
+                            "pci": "0000:43:11.7",
+                            "source_name": 7,
+                            "vlan": 107
+                        }
+                    ],
+                    "mac": "a0:36:9f:35:ed:0a"
+                },
+                {
+                    "source_name": "p3p1",
+                    "Mbps": 10000,
+                    "pci": "0000:43:00.0",
+                    "switch_port": "port0/6",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "5e:2e:05:67:7b:05",
+                            "pci": "0000:43:10.0",
+                            "source_name": 0,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "fa:a4:01:f0:7e:d4",
+                            "pci": "0000:43:10.2",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "32:aa:7b:9a:e3:6b",
+                            "pci": "0000:43:10.4",
+                            "source_name": 2,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "fa:8d:b3:2f:a6:59",
+                            "pci": "0000:43:10.6",
+                            "source_name": 3,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "f2:92:f3:f0:ba:06",
+                            "pci": "0000:43:11.0",
+                            "source_name": 4,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "c2:8a:1b:55:13:52",
+                            "pci": "0000:43:11.2",
+                            "source_name": 5,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "5a:55:8e:f4:a5:4f",
+                            "pci": "0000:43:11.4",
+                            "source_name": 6,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "8a:21:a1:bb:d4:b2",
+                            "pci": "0000:43:11.6",
+                            "source_name": 7,
+                            "vlan": 106
+                        }
+                    ],
+                    "mac": "a0:36:9f:35:ed:08"
+                }
+            ],
+            "numa_socket": 1,
+            "hugepages": 28,
+            "memory": 32
+        },
+        {
+            "cores": [
+                {
+                    "core_id": 0,
+                    "thread_id": 0,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 0,
+                    "thread_id": 24,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 2
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 26
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 4
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 28
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 6
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 30
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 8
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 32
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 10
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 34
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 12
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 36
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 14
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 38
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 16
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 40
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 18
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 42
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 20
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 44
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 22
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 46
+                }
+            ],
+            "interfaces": [
+                {
+                    "source_name": "p5p1",
+                    "Mbps": 10000,
+                    "pci": "0000:04:00.0",
+                    "switch_port": "port0/8",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "46:28:47:80:9d:fe",
+                            "pci": "0000:04:10.0",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "5a:5d:cb:52:93:66",
+                            "pci": "0000:04:10.2",
+                            "source_name": 1,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "42:42:2e:2d:44:9d",
+                            "pci": "0000:04:10.4",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "4a:ef:c2:a5:c8:ad",
+                            "pci": "0000:04:10.6",
+                            "source_name": 3,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "0a:0c:b1:8b:da:c6",
+                            "pci": "0000:04:11.0",
+                            "source_name": 4,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "46:e7:85:ad:1f:3e",
+                            "pci": "0000:04:11.2",
+                            "source_name": 5,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "5e:a4:8f:8f:b0:53",
+                            "pci": "0000:04:11.4",
+                            "source_name": 6,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "d2:76:f2:21:fb:42",
+                            "pci": "0000:04:11.6",
+                            "source_name": 7,
+                            "vlan": 101
+                        }
+                    ],
+                    "mac": "a0:36:9f:33:09:6c"
+                },
+                {
+                    "source_name": "p5p2",
+                    "Mbps": 10000,
+                    "pci": "0000:04:00.1",
+                    "switch_port": "port0/9",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "f2:c8:15:59:9d:9e",
+                            "pci": "0000:04:10.1",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "ca:30:b2:c2:d9:d6",
+                            "pci": "0000:04:10.3",
+                            "source_name": 1,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "1a:03:de:f7:f5:db",
+                            "pci": "0000:04:10.5",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "ca:6d:e0:c3:1e:f5",
+                            "pci": "0000:04:10.7",
+                            "source_name": 3,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "aa:35:ab:70:29:5c",
+                            "pci": "0000:04:11.1",
+                            "source_name": 4,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "02:b3:c4:a6:12:df",
+                            "pci": "0000:04:11.3",
+                            "source_name": 5,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "52:4f:13:67:d5:1f",
+                            "pci": "0000:04:11.5",
+                            "source_name": 6,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "3a:7f:b2:58:61:81",
+                            "pci": "0000:04:11.7",
+                            "source_name": 7,
+                            "vlan": 101
+                        }
+                    ],
+                    "mac": "a0:36:9f:33:09:6e"
+                },
+                {
+                    "source_name": "p7p1",
+                    "Mbps": 10000,
+                    "pci": "0000:06:00.0",
+                    "switch_port": "port0/10",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "6e:51:ee:3c:66:fa",
+                            "pci": "0000:06:10.0",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "26:0c:7a:db:9b:7e",
+                            "pci": "0000:06:10.2",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "66:b0:59:cf:6b:fc",
+                            "pci": "0000:06:10.4",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "f6:52:a5:ff:97:b9",
+                            "pci": "0000:06:10.6",
+                            "source_name": 3,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "4a:5c:b2:6a:25:15",
+                            "pci": "0000:06:11.0",
+                            "source_name": 4,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "86:0f:85:c2:42:b1",
+                            "pci": "0000:06:11.2",
+                            "source_name": 5,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "b2:3d:24:1d:3e:40",
+                            "pci": "0000:06:11.4",
+                            "source_name": 6,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "ca:3f:fc:7b:32:36",
+                            "pci": "0000:06:11.6",
+                            "source_name": 7,
+                            "vlan": 100
+                        }
+                    ],
+                    "mac": "a0:36:9f:33:0c:d4"
+                },
+                {
+                    "source_name": "p7p2",
+                    "Mbps": 10000,
+                    "pci": "0000:06:00.1",
+                    "switch_port": "port0/11",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "76:28:ae:b5:31:25",
+                            "pci": "0000:06:10.1",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "5e:fa:d1:f7:eb:44",
+                            "pci": "0000:06:10.3",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "56:d3:6a:b0:af:2e",
+                            "pci": "0000:06:10.5",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "3e:75:f3:00:aa:ba",
+                            "pci": "0000:06:10.7",
+                            "source_name": 3,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "5e:fd:b0:e2:59:47",
+                            "pci": "0000:06:11.1",
+                            "source_name": 4,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "ee:a7:2f:ab:73:0f",
+                            "pci": "0000:06:11.3",
+                            "source_name": 5,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "d6:e9:f1:c6:40:00",
+                            "pci": "0000:06:11.5",
+                            "source_name": 6,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "36:b0:af:0e:5b:68",
+                            "pci": "0000:06:11.7",
+                            "source_name": 7,
+                            "vlan": 100
+                        }
+                    ],
+                    "mac": "a0:36:9f:33:0c:d6"
+                }
+            ],
+            "numa_socket": 0,
+            "hugepages": 28,
+            "memory": 32
+        }
+    ]
+}
+}
diff --git a/test/hosts/host-example2.json b/test/hosts/host-example2.json
new file mode 100644
index 0000000..ddda8f7
--- /dev/null
+++ b/test/hosts/host-example2.json
@@ -0,0 +1,698 @@
+{
+    "host":{
+        "name": "fake-host-2",
+        "user": "user", 
+        "password": "password", 
+        "ip_name": "fakehost2" 
+    },
+"host-data":
+{
+    "name": "fake-host-2",
+    "ranking": 300,
+    "description": "fake host 2 for test mode",
+    "ip_name": "fakehost2",
+    "features": "lps,dioc,hwsv,ht,64b,tlbps",
+    "user": "user",
+    "password": "password",
+    "numas": [
+        {
+            "cores": [
+                {
+                    "core_id": 0,
+                    "thread_id": 1,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 0,
+                    "thread_id": 25,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 3
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 27
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 5
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 29
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 7
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 31
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 9
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 33
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 11
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 35
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 13
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 37
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 15
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 39
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 17
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 41
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 19
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 43
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 21
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 45
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 23
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 47
+                }
+            ],
+            "interfaces": [
+                {
+                    "source_name": "p2p1",
+                    "Mbps": 10000,
+                    "pci": "0000:44:00.0",
+                    "switch_port": "port0/12",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "fe:49:52:59:2f:0b",
+                            "pci": "0000:44:10.0",
+                            "source_name": 0,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "16:df:ee:65:d1:a9",
+                            "pci": "0000:44:10.2",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "e6:10:3a:09:cc:eb",
+                            "pci": "0000:44:10.4",
+                            "source_name": 2,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "f6:8e:ef:92:70:9a",
+                            "pci": "0000:44:10.6",
+                            "source_name": 3,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "fa:a5:0e:21:bc:89",
+                            "pci": "0000:44:11.0",
+                            "source_name": 4,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "fa:72:5a:b0:07:44",
+                            "pci": "0000:44:11.2",
+                            "source_name": 5,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "3e:8f:5c:1a:5d:e1",
+                            "pci": "0000:44:11.4",
+                            "source_name": 6,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "f2:e0:34:e2:e1:2d",
+                            "pci": "0000:44:11.6",
+                            "source_name": 7,
+                            "vlan": 106
+                        }
+                    ],
+                    "mac": "a0:36:9f:35:e9:a0"
+                },
+                {
+                    "source_name": "p2p2",
+                    "Mbps": 10000,
+                    "pci": "0000:44:00.1",
+                    "switch_port": "port0/13",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "ba:76:24:e0:79:75",
+                            "pci": "0000:44:10.1",
+                            "source_name": 0,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "b2:26:81:5b:18:7b",
+                            "pci": "0000:44:10.3",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "da:46:a9:f4:ab:42",
+                            "pci": "0000:44:10.5",
+                            "source_name": 2,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "86:e0:ec:33:cc:18",
+                            "pci": "0000:44:10.7",
+                            "source_name": 3,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "ee:ee:49:da:20:75",
+                            "pci": "0000:44:11.1",
+                            "source_name": 4,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "be:fa:18:da:f3:ba",
+                            "pci": "0000:44:11.3",
+                            "source_name": 5,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "96:fa:8d:ed:50:02",
+                            "pci": "0000:44:11.5",
+                            "source_name": 6,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "22:1b:cb:33:a7:5a",
+                            "pci": "0000:44:11.7",
+                            "source_name": 7,
+                            "vlan": 107
+                        }
+                    ],
+                    "mac": "a0:36:9f:35:e9:a2"
+                },
+                {
+                    "source_name": "p3p2",
+                    "Mbps": 10000,
+                    "pci": "0000:43:00.1",
+                    "switch_port": "port0/15",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "a6:6e:28:6c:5b:04",
+                            "pci": "0000:43:10.1",
+                            "source_name": 0,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "be:35:42:86:3d:fd",
+                            "pci": "0000:43:10.3",
+                            "source_name": 1,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "0a:92:99:92:02:e4",
+                            "pci": "0000:43:10.5",
+                            "source_name": 2,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "b6:a6:3a:f1:1e:57",
+                            "pci": "0000:43:10.7",
+                            "source_name": 3,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "be:3f:1a:ef:76:c0",
+                            "pci": "0000:43:11.1",
+                            "source_name": 4,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "6a:cc:a6:bf:61:cd",
+                            "pci": "0000:43:11.3",
+                            "source_name": 5,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "fe:c1:15:a9:c5:12",
+                            "pci": "0000:43:11.5",
+                            "source_name": 6,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "6a:ff:59:aa:63:34",
+                            "pci": "0000:43:11.7",
+                            "source_name": 7,
+                            "vlan": 107
+                        }
+                    ],
+                    "mac": "a0:36:9f:35:ed:42"
+                },
+                {
+                    "source_name": "p3p1",
+                    "Mbps": 10000,
+                    "pci": "0000:43:00.0",
+                    "switch_port": "port0/14",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "c6:18:cb:6c:c4:04",
+                            "pci": "0000:43:10.0",
+                            "source_name": 0,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "a6:4e:90:89:90:d8",
+                            "pci": "0000:43:10.2",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "fe:9a:82:91:a5:3a",
+                            "pci": "0000:43:10.4",
+                            "source_name": 2,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "22:a3:ef:27:50:fd",
+                            "pci": "0000:43:10.6",
+                            "source_name": 3,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "c6:57:98:69:67:e2",
+                            "pci": "0000:43:11.0",
+                            "source_name": 4,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "6a:f9:81:ae:40:94",
+                            "pci": "0000:43:11.2",
+                            "source_name": 5,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "86:00:37:7f:6e:05",
+                            "pci": "0000:43:11.4",
+                            "source_name": 6,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "f2:e6:fc:7d:71:9b",
+                            "pci": "0000:43:11.6",
+                            "source_name": 7,
+                            "vlan": 106
+                        }
+                    ],
+                    "mac": "a0:36:9f:35:ed:40"
+                }
+            ],
+            "numa_socket": 1,
+            "hugepages": 60,
+            "memory": 64
+        },
+        {
+            "cores": [
+                {
+                    "core_id": 0,
+                    "thread_id": 0,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 0,
+                    "thread_id": 24,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 2
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 26
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 4
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 28
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 6
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 30
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 8
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 32
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 10
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 34
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 12
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 36
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 14
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 38
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 16
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 40
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 18
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 42
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 20
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 44
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 22
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 46
+                }
+            ],
+            "interfaces": [
+                {
+                    "source_name": "p5p1",
+                    "Mbps": 10000,
+                    "pci": "0000:04:00.0",
+                    "switch_port": "port0/16",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "02:ef:c9:38:c7:01",
+                            "pci": "0000:04:10.0",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "92:04:e9:fe:c7:f9",
+                            "pci": "0000:04:10.2",
+                            "source_name": 1,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "a2:41:32:78:25:48",
+                            "pci": "0000:04:10.4",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "9e:65:ab:e8:a0:2b",
+                            "pci": "0000:04:10.6",
+                            "source_name": 3,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "0a:38:88:4c:76:1b",
+                            "pci": "0000:04:11.0",
+                            "source_name": 4,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "4e:8f:96:e1:d2:99",
+                            "pci": "0000:04:11.2",
+                            "source_name": 5,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "62:b3:0a:15:1b:cc",
+                            "pci": "0000:04:11.4",
+                            "source_name": 6,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "fa:29:6a:04:c3:fc",
+                            "pci": "0000:04:11.6",
+                            "source_name": 7,
+                            "vlan": 101
+                        }
+                    ],
+                    "mac": "a0:36:9f:33:16:f4"
+                },
+                {
+                    "source_name": "p5p2",
+                    "Mbps": 10000,
+                    "pci": "0000:04:00.1",
+                    "switch_port": "port0/17",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "1a:07:7d:f5:ab:bf",
+                            "pci": "0000:04:10.1",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "12:63:9b:75:5c:02",
+                            "pci": "0000:04:10.3",
+                            "source_name": 1,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "be:f8:54:de:8e:39",
+                            "pci": "0000:04:10.5",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "82:bb:12:83:82:b9",
+                            "pci": "0000:04:10.7",
+                            "source_name": 3,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "06:5c:e3:40:c3:e0",
+                            "pci": "0000:04:11.1",
+                            "source_name": 4,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "32:54:10:77:36:d1",
+                            "pci": "0000:04:11.3",
+                            "source_name": 5,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "0e:0f:3f:23:d6:17",
+                            "pci": "0000:04:11.5",
+                            "source_name": 6,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "46:14:84:51:3d:ec",
+                            "pci": "0000:04:11.7",
+                            "source_name": 7,
+                            "vlan": 101
+                        }
+                    ],
+                    "mac": "a0:36:9f:33:16:f6"
+                },
+                {
+                    "source_name": "p7p1",
+                    "Mbps": 10000,
+                    "pci": "0000:06:00.0",
+                    "switch_port": "port0/18",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "d6:8a:a7:27:bc:7c",
+                            "pci": "0000:06:10.0",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "9e:f4:67:21:28:12",
+                            "pci": "0000:06:10.2",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "b6:f8:b7:c8:ae:07",
+                            "pci": "0000:06:10.4",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "0e:e8:34:7a:3b:c4",
+                            "pci": "0000:06:10.6",
+                            "source_name": 3,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "82:5d:0f:7a:20:91",
+                            "pci": "0000:06:11.0",
+                            "source_name": 4,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "f2:6b:6a:4a:e3:93",
+                            "pci": "0000:06:11.2",
+                            "source_name": 5,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "b2:d6:af:b0:12:f4",
+                            "pci": "0000:06:11.4",
+                            "source_name": 6,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "22:0b:01:19:dd:3c",
+                            "pci": "0000:06:11.6",
+                            "source_name": 7,
+                            "vlan": 100
+                        }
+                    ],
+                    "mac": "a0:36:9f:33:0f:1c"
+                },
+                {
+                    "source_name": "p7p2",
+                    "Mbps": 10000,
+                    "pci": "0000:06:00.1",
+                    "switch_port": "port0/19",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "0a:2f:77:8f:53:da",
+                            "pci": "0000:06:10.1",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "a2:f5:63:1d:1c:4d",
+                            "pci": "0000:06:10.3",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "86:80:6c:d8:da:e0",
+                            "pci": "0000:06:10.5",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "5a:9d:1c:19:3f:07",
+                            "pci": "0000:06:10.7",
+                            "source_name": 3,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "ea:a9:fb:95:29:34",
+                            "pci": "0000:06:11.1",
+                            "source_name": 4,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "0e:3a:e9:65:5b:d3",
+                            "pci": "0000:06:11.3",
+                            "source_name": 5,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "ce:cd:53:c6:7b:ca",
+                            "pci": "0000:06:11.5",
+                            "source_name": 6,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "52:b1:4e:91:34:8c",
+                            "pci": "0000:06:11.7",
+                            "source_name": 7,
+                            "vlan": 100
+                        }
+                    ],
+                    "mac": "a0:36:9f:33:0f:1e"
+                }
+            ],
+            "numa_socket": 0,
+            "hugepages": 60,
+            "memory": 64
+        }
+    ]
+}
+}
diff --git a/test/hosts/host-example3.json b/test/hosts/host-example3.json
new file mode 100644
index 0000000..a115e45
--- /dev/null
+++ b/test/hosts/host-example3.json
@@ -0,0 +1,698 @@
+{
+    "host":{
+        "name": "fake-host-3",
+        "user": "user", 
+        "password": "password", 
+        "ip_name": "fakehost3" 
+    },
+"host-data":
+{
+    "name": "fake-host-3",
+    "ranking": 300,
+    "description": "fake host 3 for test mode",
+    "ip_name": "fakehost3",
+    "features": "lps,dioc,hwsv,ht,64b,tlbps",
+    "user": "user",
+    "password": "password",
+    "numas": [
+        {
+            "cores": [
+                {
+                    "core_id": 0,
+                    "thread_id": 1,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 0,
+                    "thread_id": 25,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 3
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 27
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 5
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 29
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 7
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 31
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 9
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 33
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 11
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 35
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 13
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 37
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 15
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 39
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 17
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 41
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 19
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 43
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 21
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 45
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 23
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 47
+                }
+            ],
+            "interfaces": [
+                {
+                    "source_name": "p2p1",
+                    "Mbps": 10000,
+                    "pci": "0000:44:00.0",
+                    "switch_port": "port1/0",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "ce:24:06:7d:7a:5b",
+                            "pci": "0000:44:10.0",
+                            "source_name": 0,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "a6:2d:10:75:dc:06",
+                            "pci": "0000:44:10.2",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "4a:39:f1:d1:aa:46",
+                            "pci": "0000:44:10.4",
+                            "source_name": 2,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "ee:df:34:b3:cf:50",
+                            "pci": "0000:44:10.6",
+                            "source_name": 3,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "46:02:47:d8:f5:66",
+                            "pci": "0000:44:11.0",
+                            "source_name": 4,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "a6:11:78:97:b4:ab",
+                            "pci": "0000:44:11.2",
+                            "source_name": 5,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "36:c0:13:a4:4c:77",
+                            "pci": "0000:44:11.4",
+                            "source_name": 6,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "b6:3b:b5:43:3a:44",
+                            "pci": "0000:44:11.6",
+                            "source_name": 7,
+                            "vlan": 106
+                        }
+                    ],
+                    "mac": "a0:36:9f:25:97:f4"
+                },
+                {
+                    "source_name": "p2p2",
+                    "Mbps": 10000,
+                    "pci": "0000:44:00.1",
+                    "switch_port": "port1/1",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "f6:38:e9:5e:f9:42",
+                            "pci": "0000:44:10.1",
+                            "source_name": 0,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "f6:1e:b9:d3:15:69",
+                            "pci": "0000:44:10.3",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "2e:22:7f:44:86:e0",
+                            "pci": "0000:44:10.5",
+                            "source_name": 2,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "5a:3f:db:66:d6:90",
+                            "pci": "0000:44:10.7",
+                            "source_name": 3,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "b2:05:b8:f3:ae:20",
+                            "pci": "0000:44:11.1",
+                            "source_name": 4,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "fa:fe:24:82:12:b5",
+                            "pci": "0000:44:11.3",
+                            "source_name": 5,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "36:2a:0e:cb:29:01",
+                            "pci": "0000:44:11.5",
+                            "source_name": 6,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "46:71:c0:8a:9c:48",
+                            "pci": "0000:44:11.7",
+                            "source_name": 7,
+                            "vlan": 107
+                        }
+                    ],
+                    "mac": "a0:36:9f:25:97:f6"
+                },
+                {
+                    "source_name": "p3p2",
+                    "Mbps": 10000,
+                    "pci": "0000:43:00.1",
+                    "switch_port": "port1/3",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "72:fd:7a:af:91:57",
+                            "pci": "0000:43:10.1",
+                            "source_name": 0,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "fa:c4:d7:e1:3b:07",
+                            "pci": "0000:43:10.3",
+                            "source_name": 1,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "c2:03:28:4a:0a:8e",
+                            "pci": "0000:43:10.5",
+                            "source_name": 2,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "66:1b:78:65:67:e2",
+                            "pci": "0000:43:10.7",
+                            "source_name": 3,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "be:4b:e9:77:ff:a2",
+                            "pci": "0000:43:11.1",
+                            "source_name": 4,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "02:9a:94:e2:79:c0",
+                            "pci": "0000:43:11.3",
+                            "source_name": 5,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "b2:80:62:dd:09:ea",
+                            "pci": "0000:43:11.5",
+                            "source_name": 6,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "ea:41:30:8e:af:b9",
+                            "pci": "0000:43:11.7",
+                            "source_name": 7,
+                            "vlan": 107
+                        }
+                    ],
+                    "mac": "a0:36:9f:25:97:de"
+                },
+                {
+                    "source_name": "p3p1",
+                    "Mbps": 10000,
+                    "pci": "0000:43:00.0",
+                    "switch_port": "port1/2",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "66:80:a0:55:83:93",
+                            "pci": "0000:43:10.0",
+                            "source_name": 0,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "fe:fd:72:b8:fe:bb",
+                            "pci": "0000:43:10.2",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "6a:70:92:7f:6b:7b",
+                            "pci": "0000:43:10.4",
+                            "source_name": 2,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "3a:14:75:5e:63:15",
+                            "pci": "0000:43:10.6",
+                            "source_name": 3,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "2e:c9:5d:6e:27:48",
+                            "pci": "0000:43:11.0",
+                            "source_name": 4,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "02:f7:bb:82:78:1f",
+                            "pci": "0000:43:11.2",
+                            "source_name": 5,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "0e:5e:b6:a8:6c:80",
+                            "pci": "0000:43:11.4",
+                            "source_name": 6,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "8e:bf:81:bc:cb:44",
+                            "pci": "0000:43:11.6",
+                            "source_name": 7,
+                            "vlan": 106
+                        }
+                    ],
+                    "mac": "a0:36:9f:25:97:dc"
+                }
+            ],
+            "numa_socket": 1,
+            "hugepages": 28,
+            "memory": 32
+        },
+        {
+            "cores": [
+                {
+                    "core_id": 0,
+                    "thread_id": 0,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 0,
+                    "thread_id": 24,
+                    "status": "noteligible"
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 2
+                },
+                {
+                    "core_id": 1,
+                    "thread_id": 26
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 4
+                },
+                {
+                    "core_id": 2,
+                    "thread_id": 28
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 6
+                },
+                {
+                    "core_id": 3,
+                    "thread_id": 30
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 8
+                },
+                {
+                    "core_id": 4,
+                    "thread_id": 32
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 10
+                },
+                {
+                    "core_id": 5,
+                    "thread_id": 34
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 12
+                },
+                {
+                    "core_id": 6,
+                    "thread_id": 36
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 14
+                },
+                {
+                    "core_id": 7,
+                    "thread_id": 38
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 16
+                },
+                {
+                    "core_id": 8,
+                    "thread_id": 40
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 18
+                },
+                {
+                    "core_id": 9,
+                    "thread_id": 42
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 20
+                },
+                {
+                    "core_id": 10,
+                    "thread_id": 44
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 22
+                },
+                {
+                    "core_id": 11,
+                    "thread_id": 46
+                }
+            ],
+            "interfaces": [
+                {
+                    "source_name": "p5p1",
+                    "Mbps": 10000,
+                    "pci": "0000:04:00.0",
+                    "switch_port": "port1/4",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "aa:ef:2c:23:ae:04",
+                            "pci": "0000:04:10.0",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "2e:d5:b9:3e:c4:8b",
+                            "pci": "0000:04:10.2",
+                            "source_name": 1,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "4e:d6:55:09:17:1e",
+                            "pci": "0000:04:10.4",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "ce:42:cc:9c:5a:32",
+                            "pci": "0000:04:10.6",
+                            "source_name": 3,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "1e:71:34:7f:5d:47",
+                            "pci": "0000:04:11.0",
+                            "source_name": 4,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "26:5c:e4:db:8c:48",
+                            "pci": "0000:04:11.2",
+                            "source_name": 5,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "5e:48:23:56:63:c0",
+                            "pci": "0000:04:11.4",
+                            "source_name": 6,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "9a:a2:fa:97:19:84",
+                            "pci": "0000:04:11.6",
+                            "source_name": 7,
+                            "vlan": 101
+                        }
+                    ],
+                    "mac": "a0:36:9f:27:46:a0"
+                },
+                {
+                    "source_name": "p5p2",
+                    "Mbps": 10000,
+                    "pci": "0000:04:00.1",
+                    "switch_port": "port1/5",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "0a:9b:b5:d1:e6:34",
+                            "pci": "0000:04:10.1",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "5e:87:4a:22:e9:57",
+                            "pci": "0000:04:10.3",
+                            "source_name": 1,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "ea:94:d5:f6:ee:bb",
+                            "pci": "0000:04:10.5",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "5a:3f:17:6b:bb:8b",
+                            "pci": "0000:04:10.7",
+                            "source_name": 3,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "8e:af:5c:cc:c8:82",
+                            "pci": "0000:04:11.1",
+                            "source_name": 4,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "3e:a0:df:f0:2b:07",
+                            "pci": "0000:04:11.3",
+                            "source_name": 5,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "ae:7d:00:9b:54:4d",
+                            "pci": "0000:04:11.5",
+                            "source_name": 6,
+                            "vlan": 100
+                        },
+                        {
+                            "mac": "fa:b5:0d:c6:78:87",
+                            "pci": "0000:04:11.7",
+                            "source_name": 7,
+                            "vlan": 101
+                        }
+                    ],
+                    "mac": "a0:36:9f:27:46:a2"
+                },
+                {
+                    "source_name": "p7p1",
+                    "Mbps": 10000,
+                    "pci": "0000:06:00.0",
+                    "switch_port": "port1/6",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "22:4a:21:37:84:80",
+                            "pci": "0000:06:10.0",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "b2:8f:2c:04:08:08",
+                            "pci": "0000:06:10.2",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "fe:2e:71:1f:99:dd",
+                            "pci": "0000:06:10.4",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "1a:2c:7c:98:39:b6",
+                            "pci": "0000:06:10.6",
+                            "source_name": 3,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "6e:39:08:a9:7e:b1",
+                            "pci": "0000:06:11.0",
+                            "source_name": 4,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "4a:00:f3:5b:15:27",
+                            "pci": "0000:06:11.2",
+                            "source_name": 5,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "b2:c3:48:da:24:55",
+                            "pci": "0000:06:11.4",
+                            "source_name": 6,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "72:85:cd:18:ee:5d",
+                            "pci": "0000:06:11.6",
+                            "source_name": 7,
+                            "vlan": 100
+                        }
+                    ],
+                    "mac": "a0:36:9f:27:45:80"
+                },
+                {
+                    "source_name": "p7p2",
+                    "Mbps": 10000,
+                    "pci": "0000:06:00.1",
+                    "switch_port": "port1/7",
+                    "switch_dpid": "00:01:02:03:04:05:06:07",
+                    "sriovs": [
+                        {
+                            "mac": "0a:60:1a:9d:ba:e2",
+                            "pci": "0000:06:10.1",
+                            "source_name": 0,
+                            "vlan": 104
+                        },
+                        {
+                            "mac": "72:cb:0a:99:2f:7e",
+                            "pci": "0000:06:10.3",
+                            "source_name": 1,
+                            "vlan": 103
+                        },
+                        {
+                            "mac": "f2:2b:6b:d8:95:aa",
+                            "pci": "0000:06:10.5",
+                            "source_name": 2,
+                            "vlan": 106
+                        },
+                        {
+                            "mac": "b2:3a:4a:a8:c9:e9",
+                            "pci": "0000:06:10.7",
+                            "source_name": 3,
+                            "vlan": 105
+                        },
+                        {
+                            "mac": "06:85:75:b1:e8:10",
+                            "pci": "0000:06:11.1",
+                            "source_name": 4,
+                            "vlan": 107
+                        },
+                        {
+                            "mac": "12:41:69:61:89:3a",
+                            "pci": "0000:06:11.3",
+                            "source_name": 5,
+                            "vlan": 102
+                        },
+                        {
+                            "mac": "86:03:a8:5a:ad:71",
+                            "pci": "0000:06:11.5",
+                            "source_name": 6,
+                            "vlan": 101
+                        },
+                        {
+                            "mac": "ca:9c:5c:ad:e2:e2",
+                            "pci": "0000:06:11.7",
+                            "source_name": 7,
+                            "vlan": 100
+                        }
+                    ],
+                    "mac": "a0:36:9f:27:45:82"
+                }
+            ],
+            "numa_socket": 0,
+            "hugepages": 28,
+            "memory": 32
+        }
+    ]
+}
+}
diff --git a/test/hosts/new_host.yaml b/test/hosts/new_host.yaml
new file mode 100644
index 0000000..affe668
--- /dev/null
+++ b/test/hosts/new_host.yaml
@@ -0,0 +1,36 @@
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+{
+    "${}":[
+        "${name} host name",
+        "${user} host user (n2)",
+        "${ip_name} host access ip or name (${name}.hi.inet)",
+        "${description} host description (${name})"
+    ],
+
+    "host":{
+        "name": "${name}",
+        "user": "${user}", 
+        "ip_name": "${ip_name}", 
+        "description": "${description}" 
+    }
+}
diff --git a/test/images/new_image.yaml b/test/images/new_image.yaml
new file mode 100644
index 0000000..a599884
--- /dev/null
+++ b/test/images/new_image.yaml
@@ -0,0 +1,34 @@
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+
+{
+    "${}":[
+        "${name} image name",
+        "${path} image path (/mnt/powervault/virtualization/vnfs/os/US1404user.qcow2)",
+        "${description} image description (${name})"
+    ],
+"image":{
+    "name":"${name}",
+    "description":"${description}",
+    "path":"${path}" 
+}
+}
diff --git a/test/networks/net-example0.yaml b/test/networks/net-example0.yaml
new file mode 100644
index 0000000..cfae0c7
--- /dev/null
+++ b/test/networks/net-example0.yaml
@@ -0,0 +1,6 @@
+network:
+    name:               default
+    type:               bridge_man
+    provider:physical:  default
+    shared:             true
+
diff --git a/test/networks/net-example1.yaml b/test/networks/net-example1.yaml
new file mode 100644
index 0000000..cbc7980
--- /dev/null
+++ b/test/networks/net-example1.yaml
@@ -0,0 +1,6 @@
+network:
+    name:               macvtap:em1
+    type:               bridge_man
+    provider:physical:  macvtap:em1
+    shared:             true
+
diff --git a/test/networks/net-example2.yaml b/test/networks/net-example2.yaml
new file mode 100644
index 0000000..f913670
--- /dev/null
+++ b/test/networks/net-example2.yaml
@@ -0,0 +1,6 @@
+network:
+    name:               shared_bridge_net
+    type:               bridge_data
+    provider:physical:  bridge:virbrMan1
+    shared:             true
+
diff --git a/test/networks/net-example3.yaml b/test/networks/net-example3.yaml
new file mode 100644
index 0000000..ed3b940
--- /dev/null
+++ b/test/networks/net-example3.yaml
@@ -0,0 +1,16 @@
+network:
+    name:               data_net
+    type:               data
+
+    #if you want to connect this network to a concrete switch port for outside connectivity
+    #indicate it at provider_physical with openflow:<switch_port>[:vlan]
+    #<switch_port> must be a valid openflow port (one of the listed with openvim openflow-port-list)
+    #add [:vlan] without spaces if this port must be vlan tagged. If missing it is not tagged
+
+    #provider:vlan  contains the vlan used by the SRIOV interfaces connected to this network
+    #it always contain a value regardless used or not. If missing openvim will assign a value
+    
+    provider:physical:  openflow:port1/8:vlan
+    provider:vlan:      3001
+    shared:             true
+
diff --git a/test/networks/new_network.yaml b/test/networks/new_network.yaml
new file mode 100644
index 0000000..af1e673
--- /dev/null
+++ b/test/networks/new_network.yaml
@@ -0,0 +1,33 @@
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+
+{
+    "${}":[
+        "${name} provide a network name",
+        "${type} provide a type: bridge_data,bridge_man,data,ptp (ptp)"
+    ],
+
+    "network":{
+            "name": "${name}",
+            "type": "${type}"
+    }
+}
diff --git a/test/ports/new_port.yaml b/test/ports/new_port.yaml
new file mode 100644
index 0000000..6a07a3a
--- /dev/null
+++ b/test/ports/new_port.yaml
@@ -0,0 +1,41 @@
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+
+{
+    "${}":[
+        "${name} provide a port name",
+        "${net_id} provide the network uuid (null):",
+        "${vlan} provide the vlan if any (null):",
+        "${port} provide the attached switch port (Te0/47)",
+        "${mac} provide the mac of external device if known (null):"
+    ],
+
+    "port":{
+        "name": "${name}",
+        "network_id": "${net_id null}",
+        "type": "external",
+        "binding:vlan": "${vlan null-int}",
+        "binding:switch_port": "${port}",
+        "mac_address": "${mac null}"
+    }
+}
+
diff --git a/test/servers/new_server.yaml b/test/servers/new_server.yaml
new file mode 100644
index 0000000..6f30d14
--- /dev/null
+++ b/test/servers/new_server.yaml
@@ -0,0 +1,49 @@
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+{
+    "${}":[
+        "${name} provide a name (VM)",
+        "${description} provide a description (${name})",
+        "${image_id} provide image_id uuid",
+        "${flavor_id} provide flavor_id uuid",
+        "${network0} provide a bridge network id; enter='default' (00000000-0000-0000-0000-000000000000)",
+        "${network1} provide a bridge network id; enter='virbrMan' (60f5227e-195f-11e4-836d-52540030594e)"
+    ],
+"server":{
+    "networks":[
+        {
+            "name":"mgmt0",
+            "vpci": "0000:00:0a.0",
+            "uuid":"${network0}"
+        },
+        {
+            "name":"ge0",
+            "vpci": "0000:00:0b.0",
+            "uuid":"${network1}"
+        }
+    ],
+    "name":"${name}", 
+    "description":"${description}",
+    "imageRef":  "${image_id}", 
+    "flavorRef": "${flavor_id}" 
+}
+}
diff --git a/test/tenants/new_tenant.yaml b/test/tenants/new_tenant.yaml
new file mode 100644
index 0000000..82ac36a
--- /dev/null
+++ b/test/tenants/new_tenant.yaml
@@ -0,0 +1,32 @@
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+{
+    "${}":[
+        "${name} tenant name",
+        "${description} tenant description (${name})"
+    ],
+
+    "tenant":{
+        "name": "${name}",
+        "description": "${description}" 
+    }
+}
diff --git a/test/test_openflow.sh b/test/test_openflow.sh
new file mode 100755
index 0000000..88fdc70
--- /dev/null
+++ b/test/test_openflow.sh
@@ -0,0 +1,217 @@
+#!/bin/bash
+
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+#
+#author Alfonso Tierno
+#
+#script to test openflow connector with the creation of rules
+#
+
+function usage(){
+    echo -e "usage: ${BASH_SOURCE[0]} [OPTIONS] \n  test openflow connector "
+    echo -e "  OPTIONS:"
+    echo -e "    -f --force       does not prompt for confirmation"
+    echo -e "    -v --same-vlan   use this if the parameter 'of_controller_nets_with_same_vlan'"
+    echo -e "                     is not false at openvimd.cfg to avoid test unrealizable openflow nets"
+    echo -e "    -d --debug       show debug information at each command. It is quite verbose"
+    echo -e "    -h --help        shows this help"
+}
+
+
+function delete_and_exit(){
+  echo
+  [[ $force != y ]] && read -e -p "  Press enter to delete the deployed things " kk
+  echo
+  for f in $TODELETE
+  do
+    if [[ $f == restore ]]
+    then
+      printf "%-50s" "restoring back old rules: "
+      result=`openflow install ./test_openflow_old_rules.bk $debug `
+      if [[ $? != 0 ]]
+      then 
+        echo  "FAIL cannot install old rules:"
+        echo  "$result"
+      else
+        rm ./test_openflow_old_rules.bk
+        echo OK "./test_openflow_old_rules.bk deleted"
+      fi
+    else
+      printf "%-50s" "removing $f rule: "
+      result=`openflow delete  $f -f $debug`
+      [[ $? != 0 ]] && echo  "FAIL cannot delete" &&  echo  "$result" || echo OK
+    fi
+  done
+  exit $1
+}
+
+force=n
+same_vlan=n
+debug=""
+TODELETE=""
+#detect if is called with a source to use the 'exit'/'return' command for exiting
+[[ ${BASH_SOURCE[0]} != $0 ]] && echo "Do not execute this script as SOURCE" >&2 && return 1
+
+#check correct arguments
+for param in $*
+do
+   if [[ $param == -h ]] || [[ $param == --help ]]
+   then
+       usage
+       exit 0
+   elif [[ $param == -d ]] || [[ $param == --debug ]]
+   then
+       debug="--debug"
+   elif [[ $param == -v ]] || [[ $param == --same-vlan ]]
+   then
+       same_vlan=y
+   elif [[ $param == -f ]] || [[ $param == --force ]]
+   then
+       force=y
+   else
+       echo "invalid argument '$param'?. See $0 --help" && exit 1
+   fi
+done
+
+#detect if environment variables are set
+fail=""
+[[ -z $OF_CONTROLLER_TYPE ]] && echo "OF_CONTROLLER_TYPE not defined" >&2 && fail=1
+[[ -z $OF_CONTROLLER_IP ]] &&   echo "OF_CONTROLLER_IP not defined" >&2 && fail=1
+[[ -z $OF_CONTROLLER_PORT ]] && echo "OF_CONTROLLER_PORT not defined" >&2 && fail=1
+[[ -z $OF_CONTROLLER_DPID ]] && echo "OF_CONTROLLER_DPID not defined" >&2 && fail=1
+[[ -n $fail ]] && exit 1
+
+
+export _exit=delete_and_exit
+if [[ $force != y ]]
+then
+  echo " This will remove temporally the existing openflow rules and restored back a the end"
+  read -e -p "Press enter to continue, CTRL+C to abort " kk
+fi
+
+
+printf "%-50s" "obtain port list: "
+result=`openflow port-list $debug | gawk '/^ /{print substr($1,0,length($1)-1)}'`
+[[ $? != 0 ]] && echo  "FAIL" && echo "$result" && $_exit 1
+ports=`echo $result | wc -w`
+[[ $ports -lt 4 ]] && echo  "FAIL not enough ports managed by this DPID, needed at least 4" && $_exit 1
+echo OK $ports ports
+port0=`echo $result | cut -d" " -f1`
+port1=`echo $result | cut -d" " -f2`
+port2=`echo $result | cut -d" " -f3`
+port3=`echo $result | cut -d" " -f4`
+
+
+printf "%-50s" "saving the current rules: "
+openflow list $debug > ./test_openflow_old_rules.bk
+[[ $? != 0 ]] && echo  "FAIL cannot obtain existing rules" && $_exit 1
+echo OK "> ./test_openflow_old_rules.bk"
+
+printf "%-50s" "clearing all current rules: "
+openflow clear -f $debug 
+[[ $? != 0 ]] && echo  "FAIL cannot clear existing rules" && $_exit 1
+result=`openflow list | wc -l`
+[[ $result != 1 ]] && echo  "FAIL rules not completely cleared" && $_exit 1
+echo OK
+TODELETE="restore"
+
+printf "%-50s" "clearing again all rules: "
+openflow clear -f $debug
+[[ $? != 0 ]] && echo  "FAIL when there are not any rules" && $_exit 1
+result=`openflow list | wc -l`
+[[ $result != 1 ]] && echo  "FAIL rules not completely cleared" && $_exit 1
+echo OK
+TODELETE="restore"
+
+
+printf "%-50s" "new rule vlan,mac -> no vlan: "
+rule_name=fromVlanMac_to_NoVlan1
+openflow add $rule_name --priority 1000 --matchmac "aa:bb:cc:dd:ee:ff" --matchvlan 500 --inport $port0 --stripvlan --out $port1 $debug 
+[[ $? != 0 ]] && echo  "FAIL cannot insert new rule" && $_exit 1
+expected="$OF_CONTROLLER_DPID 1000 $rule_name $port0 aa:bb:cc:dd:ee:ff 500 vlan=None,out=$port1"
+result=`openflow list | grep $rule_name`
+[[ $? != 0 ]] && echo  "FAIL rule bad inserted"  && $_exit 1
+result=`echo $result` #remove blanks
+[[ "$result" != "$expected" ]]  && echo "FAIL" && echo "    expected: $expected\n    obtained: $result" && $_exit 1
+echo OK $rule_name
+TODELETE="$rule_name $TODELETE"
+
+printf "%-50s" "new rule mac -> vlan: "
+rule_name=fromMac_to_Vlan2
+openflow add $rule_name --priority 1001 --matchmac "ff:ff:ff:ff:ff:ff" --inport $port1 --setvlan 501 --out $port2 --out $port3 $debug 
+[[ $? != 0 ]] && echo  "FAIL cannot insert new rule" && $_exit 1
+expected="$OF_CONTROLLER_DPID 1001 $rule_name $port1 ff:ff:ff:ff:ff:ff any vlan=501,out=$port2,out=$port3"
+result=`openflow list | grep $rule_name`
+[[ $? != 0 ]] && echo  "FAIL rule bad inserted"  && $_exit 1
+result=`echo $result` #remove blanks
+[[ "$result" != "$expected" ]]  && echo "FAIL" && echo "    expected: $expected\n    obtained: $result"  && $_exit 1
+echo OK  $rule_name
+TODELETE="$rule_name $TODELETE"
+
+printf "%-50s" "new rule None -> None: "
+rule_name=fromNone_to_None
+openflow add $rule_name --priority 1002 --inport $port2 --out $port0 $debug 
+[[ $? != 0 ]] && echo  "FAIL cannot insert new rule" && $_exit 1
+expected="$OF_CONTROLLER_DPID 1002 $rule_name $port2 any any out=$port0"
+result=`openflow list | grep $rule_name`
+[[ $? != 0 ]] && echo  "FAIL rule bad inserted" && $_exit 1
+result=`echo $result` #remove blanks
+[[ "$result" != "$expected" ]]  && echo "FAIL" && echo "    expected: $expected\n    obtained: $result" && $_exit 1
+echo OK $rule_name
+TODELETE="$rule_name $TODELETE"
+
+printf "%-50s" "new rule vlan -> vlan: "
+rule_name=fromVlan_to_Vlan1
+openflow add $rule_name --priority 1003 --matchvlan 504 --inport $port3 --setvlan 505 --out $port0 $debug 
+[[ $? != 0 ]] && echo  "FAIL cannot insert new rule" && $_exit 1
+expected="$OF_CONTROLLER_DPID 1003 $rule_name $port3 any 504 vlan=505,out=$port0"
+result=`openflow list | grep $rule_name`
+[[ $? != 0 ]] && echo  "FAIL rule bad inserted" && $_exit 1
+result=`echo $result` #remove blanks
+[[ "$result" != "$expected" ]]  && echo "FAIL" && echo "    expected: $expected\n    obtained: $result"  && $_exit 1
+echo OK $rule_name
+TODELETE="$rule_name $TODELETE"
+
+
+if [[ $same_vlan == n ]]
+then
+
+  printf "%-50s" "new rule Vlan -> Vlan_Vlan: "
+  rule_name=fromVlan_to_Vlan1Vlan1
+  openflow add $rule_name --priority 1005 --inport $port3 --matchvlan 505 --setvlan 510 --out $port0 --setvlan 511 --out $port1 --stripvlan --out=$port2 $debug 
+  [[ $? != 0 ]] && echo  "FAIL cannot insert new rule" && $_exit 1
+  expected="$OF_CONTROLLER_DPID 1005 $rule_name $port3 any 505 vlan=510,out=$port0,vlan=511,out=$port1,vlan=None,out=$port2"
+  result=`openflow list | grep $rule_name`
+  [[ $? != 0 ]] && echo  "FAIL rule bad inserted" && $_exit 1
+  result=`echo $result` #remove blanks
+  [[ "$result" != "$expected" ]]  && echo "FAIL" && echo "    expected: $expected\n    obtained: $result" && $_exit 1
+  echo OK $rule_name
+  TODELETE="$rule_name $TODELETE"
+
+fi
+
+echo 
+echo DONE
+
+$_exit 0
+
diff --git a/test/test_openvim.py b/test/test_openvim.py
new file mode 100755
index 0000000..73fcc23
--- /dev/null
+++ b/test/test_openvim.py
@@ -0,0 +1,708 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+'''
+This is a client tester for openvim.
+It is almost DEPRECATED by the openvim client
+
+The reason for keeping is because it is used for some scripts
+and it contain the -r option (delete recursive)  
+that it is very useful for deleting content of database.
+Another difference from openvim is that it is more verbose
+and so more suitable for the developers
+'''
+
+__author__="Alfonso Tierno"
+__date__ ="$5-oct-2014 11:09:29$"
+
+import requests
+import json
+import yaml
+import sys
+import getopt
+from jsonschema import validate as js_v, exceptions as js_e
+
+version="0.0.2"
+global global_config
+
+
+def get_elements(url):
+    headers_req = {'content-type': 'application/json'}
+    try:
+        vim_response = requests.get(url, headers = headers_req)
+        #print vim_response
+        #print vim_response.status_code
+        if vim_response.status_code == 200:
+        #print vim_response.json()
+        #print json.dumps(vim_response.json(), indent=4)
+            content = vim_response.json()
+            return 1, content
+            #print http_content
+        else:
+            text = " Error. VIM response '%s': not possible to GET %s" % (vim_response.status_code, url)
+            text += "\n " + vim_response.text
+            #print text
+            return -vim_response.status_code,text
+    except requests.exceptions.RequestException, e:
+        return -1, " Exception "+ str(e.message)
+
+def delete_elements(url):
+    headers_req = {'content-type': 'application/json'}
+    
+    try:
+        vim_response = requests.delete(url, headers = headers_req)
+        #print vim_response
+        #print vim_response.status_code
+        if vim_response.status_code == 200:
+            pass
+            #print vim_response.json()
+            #print json.dumps(vim_response.json(), indent=4)
+        else:
+            #print vim_response.text
+            text = " Error. VIM response '%s': not possible to DELETE %s" % (vim_response.status_code, url)
+            text += "\n " + vim_response.text
+            #print text
+            return -vim_response.status_code,text
+    except requests.exceptions.RequestException, e:
+        return -1, " Exception "+ str(e.message)
+    return 1, None
+
+
+def new_elements(url, payload):
+    headers_req = {'Accept': 'application/json', 'content-type': 'application/json'}
+    #print str(payload)
+    try:
+        vim_response = requests.post(url, data=json.dumps(payload), headers=headers_req)
+        #print vim_response
+        #print vim_response.status_code
+        if vim_response.status_code == 200:
+            #print vim_response.json()
+            #print json.dumps(vim_response.json(), indent=4)
+            return 1, vim_response.text
+        else:
+            #print vim_response.text
+            text = "Error. VIM response '%s': not possible to ADD %s" % (vim_response.status_code, url)
+            text += "\n" + vim_response.text
+            #print text
+            return -vim_response.status_code,text
+    except requests.exceptions.RequestException, e:
+        return -1, " Exception "+ str(e.message)
+
+
+def get_details(url, what, c):
+    item_list = []
+    return_dict = {what+'s': []}
+    
+    item = c.get(what,None)
+    if item is None: item = c.get(what+'s',None)
+    if item is None:
+        error_text= " Internal error, not found '" + what +"[s]' in content"
+        print 'get_details()', error_text, c
+        return -1, error_text 
+    if type(item) is list: 
+        item_list = item
+    else:
+        item_list.append(item)
+    if len(item_list)==0:
+        print what, "not found"
+        return 1
+    for item in item_list: 
+        uuid = item.get('id',None)
+        if uuid is None: uuid = item.get('uuid',None)
+        if uuid is None:
+            error_text= " Internal error, not found 'id/uuid' in item"
+            print 'get_details()', error_text, item
+            return -1, error_text 
+        #print " get", what, uuid, "     >>>>>>>> ",
+        r,c = get_elements(url + "/" + uuid)
+        if r<0:              
+        #    print "fail"
+            print " get", what, uuid, "fail", c
+            return -1, c
+        #else:
+        #    print 'ok'
+        return_dict[what+'s'].append(c[what])
+    return 1, return_dict
+
+
+def action_details(url, what, c, force, payload):
+    item_list = []
+    return_dict = {what+'s': []}
+    headers_req = {'Accept': 'application/json', 'content-type': 'application/json'}
+    fail=0
+    ok=0
+    
+    #Allows for payload both keypairs inside a 'server','port' ... or directly. In later case, put keypairs inside what
+        
+    item = c.get(what,None)
+    if item is None: item = c.get(what+'s',None)
+    if item is None:
+        error_text= " Internal error, not found '" + what +"[s]' in content"
+        print 'get_details()', error_text, c
+        return -1, error_text 
+    if type(item) is list: 
+        item_list = item
+    else:
+        item_list.append(item)
+    if len(item_list)==0:
+        print what, "not found"
+        return 1
+    for item in item_list: 
+        name = item.get('name',None)
+        uuid = item.get('id',None)
+        if uuid is None: uuid = item.get('uuid',None)
+        if uuid is None:
+            error_text= " Internal error, not found 'id/uuid' in item"
+            print 'get_details()', error_text, item
+            return -1, error_text 
+        if not force:
+            r = raw_input("Action on  " + what + " " + uuid + " " + name + " (y/N)? ")
+            if  len(r)>0  and r[0].lower()=="y":
+                print " put", what, uuid, "     >>>>>>>> ",
+            else:
+                continue
+
+        #print str(payload)
+        try:
+            vim_response = requests.post(url + "/" + uuid + "/action", data=json.dumps(payload), headers=headers_req)
+            if vim_response.status_code == 200:
+                print 'ok'
+                ok += 1
+                return_dict[what+'s'].append(vim_response.json())
+                return_dict[what+'s'][-1]['uuid'] = uuid
+                return_dict[what+'s'][-1]['name'] = name
+            else:
+                fail += 1
+                print "fail"
+                #print vim_response.text
+                #text = "Error. VIM response '%s': not possible to PUT %s" % (vim_response.status_code, url)
+                #text += "\n" + vim_response.text
+                #print text
+                error_dict = vim_response.json()
+                error_dict['error']['uuid']=uuid
+                error_dict['error']['name']=name
+                return_dict[what+'s'].append(error_dict)
+        except requests.exceptions.RequestException, e:
+            return -1, " Exception "+ str(e.message)
+    if ok>0 and fail>0: return 0, return_dict
+    elif fail==0 :      return 1, return_dict
+    else:               return -1, return_dict
+
+
+
+def edit_details(url, what, c, force, payload):
+    item_list = []
+    return_dict = {what+'s': []}
+    headers_req = {'Accept': 'application/json', 'content-type': 'application/json'}
+    fail=0
+    ok=0
+    
+    #Allows for payload both keypairs inside a 'server','port' ... or directly. In later case, put keypairs inside what
+    if what not in payload:
+        payload = {what:payload}
+        
+    item = c.get(what,None)
+    if item is None: item = c.get(what+'s',None)
+    if item is None:
+        error_text= " Internal error, not found '" + what +"[s]' in content"
+        print 'get_details()', error_text, c
+        return -1, error_text 
+    if type(item) is list: 
+        item_list = item
+    else:
+        item_list.append(item)
+    if len(item_list)==0:
+        print what, "not found"
+        return 1
+    for item in item_list: 
+        name = item.get('name',None)
+        uuid = item.get('id',None)
+        if uuid is None: uuid = item.get('uuid',None)
+        if uuid is None:
+            error_text= " Internal error, not found 'id/uuid' in item"
+            print 'get_details()', error_text, item
+            return -1, error_text 
+        if not force:
+            r = raw_input("Edit " + what + " " + uuid + " " + name + " (y/N)? ")
+            if  len(r)>0  and r[0].lower()=="y":
+                print " put", what, uuid, "     >>>>>>>> ",
+            else:
+                continue
+
+        #print str(payload)
+        try:
+            vim_response = requests.put(url + "/" + uuid, data=json.dumps(payload), headers=headers_req)
+            if vim_response.status_code == 200:
+                print 'ok'
+                ok += 1
+                return_dict[what+'s'].append( vim_response.json()[what] )
+            else:
+                fail += 1
+                print "fail"
+                #print vim_response.text
+                #text = "Error. VIM response '%s': not possible to PUT %s" % (vim_response.status_code, url)
+                #text += "\n" + vim_response.text
+                #print text
+                error_dict = vim_response.json()
+                error_dict['error']['uuid']=uuid
+                error_dict['error']['name']=name
+                return_dict[what+'s'].append(error_dict)
+        except requests.exceptions.RequestException, e:
+            return -1, " Exception "+ str(e.message)
+    if ok>0 and fail>0: return 0, return_dict
+    elif fail==0 :      return 1, return_dict
+    else:               return -1, return_dict
+
+def get_del_recursive(url, what, url_suffix, force=False, recursive=False):
+    #print
+    #print " get", what, a, "     >>>>>>>> ",
+    r,c = get_elements(url + what + 's' + url_suffix)
+    if r<0:
+        print c, "when getting", what, url_suffix
+        return -1 
+    #    print "ok"
+
+    list_todelete = c.get(what, None)
+    if list_todelete is None: list_todelete = c.get(what+'s', None)
+    if list_todelete is None:
+        print " Internal error, not found '" + what +"[s]' in", c
+        return -3,  " Internal error, not found a valid dictionary"
+    if type(list_todelete) == dict:
+        list_todelete = (list_todelete, )
+    
+    if len(list_todelete)==0:
+        print what, url_suffix, "not found"
+        return 1
+    for c in list_todelete:
+        uuid=c.get('id', None)
+        if uuid is None:
+            uuid=c.get('uuid', None)
+        if uuid is None:
+            print "Id not found"
+            continue
+        name = c.get("name","")
+        if recursive:
+            if what=='tenant' :
+                get_del_recursive(url + uuid + "/", 'server', "", force, recursive)
+                get_del_recursive(url + uuid + "/", 'flavor', "", force, recursive)
+                get_del_recursive(url + uuid + "/", 'image', "", force, recursive)
+                get_del_recursive(url, 'network', "?tenant_id="+uuid, force, recursive)
+            elif what=='flavors' :
+                #get_del_recursive(url, 'servers', "?flavorRef="+uuid, force, recursive)
+                pass
+            elif what=='image' :
+                get_del_recursive(url, 'server', "?imageRef="+uuid, force, recursive)
+            elif what=='hosts' :
+                get_del_recursive(url, 'server', "?hostId="+uuid, force, recursive)
+                
+        if not force:
+            r = raw_input("Delete " + what + " " + uuid + " " + name + " (y/N)? ")
+            if  len(r)>0  and r[0].lower()=="y":
+                pass
+            else:
+                continue
+        r,c = delete_elements(url + what + "s/" + uuid)
+        if r<0:
+            #print "Error deleting", vimURI, -r
+            print c
+        else:
+            print what, uuid, name, "deleted"
+    return 1
+
+def check_valid_uuid(uuid):
+    id_schema = {"type" : "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"}
+    try:
+        js_v(uuid, id_schema)
+        return True
+    except js_e.ValidationError:
+        return False
+
+def change_string(text, var_list):
+    end=0
+    type_=None
+    while True:
+        ini = text.find("${", end)
+        if ini<0: return text
+        end = text.find("}", ini) 
+        if end<0: return text
+        end+=1
+        
+        var = text[ini:end]
+        if ' ' in var:
+            kk=var.split(" ")
+            var=kk[0]+"}"
+            type_=kk[-1][:-1]
+        var = var_list.get(var, None)
+        if var==None: return text
+        
+        text =  text[:ini] + var + text[end:]
+        if type_ != None:
+            if 'null' in type_ and text=="null":
+                return None
+            if 'int' in type_ : #and text.isnumeric():
+                return int(text)
+    return text
+
+def chage_var_recursively(data, var_list):
+    '''Check recursively the conent of data, and look for "*${*}*" variables and changes  
+    It assumes that this variables are not in the key of dictionary,
+    Attributes:
+        'data': dictionary, or list. None or empty is consideted valid
+        'var_list': dictionary (name:change) pairs
+    Return:
+        None, data is modified
+    '''
+        
+    if type(data) is dict:
+        for k in data.keys():
+            if type(data[k]) is dict or type(data[k]) is tuple or type(data[k]) is list:
+                chage_var_recursively(data[k], var_list)
+            elif type(data[k]) is str:
+                data[k] = change_string(data[k], var_list)
+    if type(data) is list:
+        for k in range(0,len(data)):
+            if type(data[k]) is dict or type(data[k]) is list:
+                chage_var_recursively(data[k], var_list)
+            elif type(data[k]) is str:
+                data[k] = change_string(data[k], var_list)
+
+def change_var(data):
+    if type(data) is not dict:
+        return -1, "Format error, not a object (dictionary)"
+    if "${}" not in data:
+        return 0, data
+
+    var_list={}
+    for var in data["${}"]:
+        r = var.find("}",) + 1
+        if r<=2 or var[:2] != '${':
+            return -1, "Format error at '${}':" + var
+        #change variables inside description text
+        if "${" in var[r:]:
+            var = var[:r] + change_string(var[r:], var_list)
+        d_start = var.rfind("(",) + 1
+        d_end   = var.rfind(")",) 
+        if d_start>0 and d_end>=d_start:
+            default = var[d_start:d_end]
+        else: default=None
+        v = raw_input(var[r:] + "? ")
+        if v=="":
+            if default != None:
+                v = default
+            else:
+                v = raw_input("  empty string? try again: ")
+        var_list[ var[:r] ] = str(v) 
+    
+    del data["${}"]
+    chage_var_recursively(data, var_list)
+    return 0, data
+
+def parse_yaml_json(text):
+    try:
+        data = yaml.load(text)
+        return 0, data
+    except yaml.YAMLError, exc:
+        error_pos = ""
+        if hasattr(exc, 'problem_mark'):
+            mark = exc.problem_mark
+            error_pos = " at position: (%s:%s)" % (mark.line+1, mark.column+1)
+        return -1, " Error yaml/json format error at " + error_pos
+
+def load_file(file_, parse=False):
+    try:
+        f = open(file_, 'r')
+        read_data = f.read()
+        f.close()
+        if not parse:
+            return 0, read_data
+    except IOError, e:
+        return -1, " Error opening file '" + file_ + "': " + e.args[1]
+    
+    try:
+        data = yaml.load(read_data)
+        return change_var(data)
+    except yaml.YAMLError, exc:
+        error_pos = ""
+        if hasattr(exc, 'problem_mark'):
+            mark = exc.problem_mark
+            error_pos = " at position: (%s:%s)" % (mark.line+1, mark.column+1)
+        return -2, " Error yaml/json format error at '"+ file_ +"'"+error_pos
+
+def load_configuration(configuration_file):
+    default_tokens ={'http_port':8080, 'http_host':'localhost', 'test_mode':False, 'of_controller_nets_with_same_vlan':True}
+    
+    r, config = load_file(configuration_file, parse=True)
+    if r < 0:
+        return False, config
+
+    #Check default values tokens
+    for k,v in default_tokens.items():
+        if k not in config: config[k]=v
+    
+    return (True, config)
+
+items_list = ('server','host','tenant','image','flavor','network','port')
+action_list = ('list','get','new','del','edit','action')
+
+
+def usage(complete=False):
+    global items_list
+    global action_list
+    print "Usage: ", sys.argv[0], "[options]", " [" + ",".join(action_list) +"] ", "<item>   [<other>] "
+    print "   Perform an test action over openvim"
+    print "      "+",".join(action_list)+": List (by default), GET detais, Creates, Deletes, Edit"
+    print "      <item>: can be one of " + ",".join(items_list)
+    print "      <other>: list of uuid|name for 'get|del'; list of json/yaml files for 'new' or 'edit'"
+    if not complete:
+        print "   Type -h or --help for a complete list of options"
+        return
+    print "   Options:"
+    print "      -v|--version: prints current version"
+    print "      -c|--config [configuration_file]: loads the configuration file (default: openvimd.cfg)"
+    print "      -h|--help: shows this help"
+    print "      -u|--url [URL]: url to use instead of the one loaded from configuration file"
+    print "      -t|--tenant [tenant uuid]: tenant to be used for some comands. IF mising it will use the default obtained in configuration file"
+    print "      -F|--filter [A=B[&C=D...]: URL query string used for 'get' or 'del' commands"
+    print "      -f|--force : Do not ask for confirmation when deleting. Also remove dependent objects."
+    print "      -r|--recursive : Delete also dependency elements, (from tenants: images, flavors,server; from hosts: instances; ..."
+    print "   Examples:"
+    print "     ",sys.argv[0]," tenant                                #list tenants "
+    print "     ",sys.argv[0]," -F'device_owner=external' get port    #get details of all external ports"
+    print "     ",sys.argv[0]," del server ses pan                    #delete server names 'ses' and 'pan'. Do not ask for confirmation"
+    print "     ",sys.argv[0]," -r -f del host                        #delete all host and all the dependencies "
+    print "     ",sys.argv[0]," new host ./Host/nfv100.json           #add a host which information is in this file"
+    print "     ",sys.argv[0]," edit network f348faf8-59ef-11e4-b4c7-52540030594e  '{\"network\":{\"admin_state_up\":false}}'"
+    print "                             #change the admin status of this network"
+    return
+
+
+if __name__=="__main__":
+    global vimURI
+    global vimURI_admin
+    
+    global what
+    global query_string
+#init variables    
+    action="list"
+    what=None
+    url=None
+    query_string = ""
+    force = False
+    recursive = False
+    tenant = None
+    additional = []
+    #look for parent dir
+    config_file = '../openvimd.cfg'
+    pos = sys.argv[0].rfind("/")
+    if pos<0:
+        base_dir="./"
+    else:
+        base_dir = sys.argv[0] [:pos+1]
+    if pos>=0:
+        config_file = base_dir + config_file
+
+#get params    
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], "hvrfc:u:t:F:", 
+            ["config", "help", "version", "force", "filter","tenant","url","recursive"])
+    except getopt.GetoptError, err:
+        print " Error:", err # will print something like "option -a not recognized"
+        usage()
+        sys.exit(-2)
+
+    for o, a in opts:
+        if o in ("-v", "--version"):
+            print "test_openvim version", version, "Oct 2014"
+            print "(c) Copyright Telefonica"
+            sys.exit(0)
+        elif o in ("-h", "--help"):
+            usage(True)
+            sys.exit(0)
+        elif o in ("-c", "--config"):  config_file = a
+        elif o in ("-f", "--force"):   force = True
+        elif o in ("-r", "--recursive"):   recursive = True
+        elif o in ("-F", "--filter"):  query_string = "?"+a
+        elif o in ("-u", "--url"):     url = a
+        elif o in ("-t", "--tenant"):  tenant = a
+        else:
+            assert False, "Unhandled option"
+
+    for a in args:
+        if len(a) == 0:
+            print " Warning!!! Found an empty parameter?"
+        elif a[0]=="-":
+            print " Error!!! Put options parameter at the beginning"
+            sys.exit(-2)
+        elif what is not None:
+            additional.append(a)
+        elif a in items_list:
+            what=a
+        elif a[:-1] in items_list and a[-1]=='s':
+            what=a[:-1]
+        elif a in action_list:
+            action=a
+        else:
+            print " Missing <item>", ",".join(items_list)
+            sys.exit(-2)
+    if what is None:
+        usage()
+        sys.exit(-1)
+    #Load configuration file
+    r, config_dic = load_configuration(config_file)
+    #print config_dic
+    if not r:
+        print config_dic
+        config_dic={}
+        #exit(-1)
+        
+    #override parameters obtained by command line
+    try:
+        if url is not None:
+            vimURI = vimURI_admin = url
+        else:
+            vimURI = "http://" + config_dic['http_host'] +":"+ str(config_dic['http_port']) + "/openvim/"
+            if 'http_admin_port' in config_dic:
+                vimURI_admin = "http://" + config_dic['http_host'] +":"+ str(config_dic['http_admin_port']) + "/openvim/"
+    except: #key error 
+        print " Error: can not get URL; neither option --u,-url, nor reading configuration file"
+        exit(-1)
+    if tenant is None:
+        tenant = config_dic.get('tenant_id', None)
+    
+#check enough parameters
+    URI=vimURI
+    if (what in ('host','port') and action in ('del','new')) or (what=='host' and action=='edit' ):
+        if vimURI_admin is None:
+            print " Error: Can not get admin URL; neither option -t,--tenant, nor reading configuration file"
+            exit(-1)
+        else:
+            URI=vimURI_admin
+    if URI[-1] != "/": URI+="/"
+    if what in ('server','image','flavor'):
+        if tenant is None:
+            print " Error: Can not get tenant; neither option -t,--tenant, nor reading configuration file"
+            exit(-1)
+        URI += tenant + "/"
+    
+    
+    exit_code=0
+    try:
+#load file for new/edit
+        payload_list=[]
+        if action=='new' or action=='edit' or action=='action':
+            if len(additional)==0:
+                if action=='new' : 
+                    additional.append(base_dir+what+"s/new_"+what+".yaml")
+                    #print " New what? Missing additional parameters to complete action"
+                else:
+                    print " What must be edited? Missing additional parameters to complete action"
+                    exit(-1)
+            if action=='edit'or action=='action':
+                #obtain only last element
+                additional_temp = additional[:-1]
+                additional = additional[-1:]
+                
+            for a in additional:
+                r,payload = load_file(a, parse=True)
+                if r<0:
+                    if r==-1 and "{" in a or ":" in a:
+                        #try to parse directly
+                        r,payload = parse_yaml_json(a)
+                        if r<0:
+                            print payload
+                            exit (-1)
+                    else:
+                        print payload
+                        exit (-1)
+                payload_list.append(payload)
+            if action=='edit'or action=='action':
+                additional = additional_temp
+
+                
+#perform actions NEW
+        if action=='new':
+            for payload in payload_list:
+                print "\n new", what, a, "     >>>>>>>> ",
+                r,c = new_elements(URI+what+'s', payload)
+                if r>0:
+                    print "ok"
+                else:
+                    print "fail"
+                    exit_code = -1
+                print c
+                #try to decode
+            exit(exit_code)
+            
+    #perform actions GET LIST EDIT DEL
+        if len(additional)==0:
+            additional=[""]
+        for a in additional:
+            filter_qs = query_string 
+            if a != "" :
+                if check_valid_uuid(a):
+                    if len(filter_qs) > 0:  filter_qs += "&" + "id=" + str(a)
+                    else:                   filter_qs += "?" + "id=" + str(a)
+                else:
+                    if len(filter_qs) > 0:  filter_qs += "&" + "name=" + str(a)
+                    else:                   filter_qs += "?" + "name=" + str(a)
+
+            if action=='list' or action=='get' or action=='edit'or action=='action':
+                url = URI + what+'s'
+                print url + filter_qs
+                #print " get", what, a, "     >>>>>>>> ",
+                r,c = get_elements(url + filter_qs)
+                if r<0:              
+                    #print "fail"
+                    exit_code = -1
+                    print c
+                else:             
+                    #print "ok"
+                    if action=='list':
+                        print json.dumps(c, indent=4)
+                        continue
+                    
+                    if action=='get':
+                        r1,c1 = get_details(url, what, c)
+                    elif action=='action':
+                        r1,c1 = action_details(url, what, c, force, payload_list[0])
+                    else: # action=='edit':
+                        r1,c1 = edit_details(url, what, c, force, payload_list[0])
+                    if r1<0:              
+                        exit_code = -1
+                    else:             
+                        if r>0: print "ok"
+                        else: print "ok with some fails"
+                    print json.dumps(c1, indent=4)
+
+            elif action=='del':
+                r = get_del_recursive(URI, what, filter_qs, force, recursive)
+                if r<0:              
+                    exit_code = -1
+        exit(exit_code)
+            
+    except KeyboardInterrupt:
+        print " Canceled"
+    
+
diff --git a/test/test_vim.sh b/test/test_vim.sh
new file mode 100755
index 0000000..58441e5
--- /dev/null
+++ b/test/test_vim.sh
@@ -0,0 +1,558 @@
+#!/bin/bash
+
+##
+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
+# This file is part of openmano
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact with: nfvlabs@tid.es
+##
+
+#
+#author Alfonso Tierno
+#
+#script to test openvim with the creation of flavors and interfaces, openflow rules
+#using images already inserted
+#
+
+function usage(){
+    echo -e "usage: ${BASH_SOURCE[0]} [OPTIONS] \n  test openvim "
+    echo -e "  OPTIONS:"
+    echo -e "    -f --force       does not prompt for confirmation"
+    echo -e "    -v --same-vlan   use this if the parameter 'of_controller_nets_with_same_vlan'"
+    echo -e "                     is not false at openvimd.cfg to avoid test unrealizable openflow nets"
+    echo -e "    -h --help        shows this help"
+    echo -e "    -c --create      create management network and two images (valid for test mode)"
+    echo
+    echo    "This script test openvim, creating flavors, images, vms, de-attaching dataplane port"
+    echo    "from one network to other and testing openflow generated rules."
+    echo    "By default (unless -c option) uses and already created management network and two valid images."
+    echo    "If -c option is set, it creates the network and images with fake content (only usefull for"
+    echo    "openvim in 'test' mode) This is speccified in this shell variables:"
+    echo    "     VIM_TEST_NETWORK_INTERNET name of the mamagement network to use"
+    echo    "     VIM_TEST_IMAGE_PATH       path of a vm image to use, the image is created if not exist"
+    echo    "     VIM_TEST_IMAGE_PATH_EXTRA path of another vm image to use, the image is created if not exist"
+}
+
+#detect if is called with a source to use the 'exit'/'return' command for exiting
+[[ ${BASH_SOURCE[0]} != $0 ]] && echo "Do not execute this script as SOURCE" >&2 && return 1
+
+#check correct arguments
+force=n
+same_vlan=n
+create=n
+for param in $*
+do
+   if [[ $param == -h ]] || [[ $param == --help ]]
+   then
+       usage
+       exit 0
+   elif [[ $param == -v ]] || [[ $param == --same-vlan ]]
+   then
+       same_vlan=y
+   elif [[ $param == -f ]] || [[ $param == --force ]]
+   then
+       force=y
+   elif [[ $param == -c ]] || [[ $param == --create ]]
+   then
+       create=y
+   else
+       echo "invalid argument '$param'?" &&  usage >&2 && exit 1
+   fi
+done
+
+#detect if environment variables are set
+fail=""
+[[ $create == n ]] && [[ -z $VIM_TEST_NETWORK_INTERNET ]] && echo "VIM_TEST_NETWORK_INTERNET not defined" >&2 && fail=1
+[[ $create == n ]] && [[ -z $VIM_TEST_IMAGE_PATH ]] && echo "VIM_TEST_IMAGE_PATH not defined" >&2 && fail=1
+[[ $create == n ]] && [[ -z $VIM_TEST_IMAGE_PATH_EXTRA ]] && echo "VIM_TEST_IMAGE_PATH_EXTRA not defined" >&2 && fail=1
+[[ -n $fail ]] && exit 1
+
+[[ $create == y ]] && [[ -z $VIM_TEST_IMAGE_PATH ]] &&       VIM_TEST_IMAGE_PATH="/test/path/of/image1"
+[[ $create == y ]] && [[ -z $VIM_TEST_IMAGE_PATH_EXTRA ]] && VIM_TEST_IMAGE_PATH_EXTRA="/test/path2/of/image2"
+TODELETE=""
+export _exit=delete_and_exit
+
+function delete_and_exit(){
+  echo
+  [[ $force != y ]] && read -e -p "  Press enter to delete the deployed things " kk
+  echo
+  for f in $TODELETE
+  do
+      openvim ${f%%:*}-delete  ${f##*:} -f
+  done
+  exit $1
+}
+
+
+function is_valid_uuid(){
+    echo "$1" | grep -q -E '^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$' && return 0
+    return 1
+}
+
+function process_cmd(){
+  # test the result of the previos command, if fails execute the $_exit command
+  # params:
+  #   uuid <variable> <result...>  : test that the first word of <result> is a valid uuid, stored it at <variable>. Print uuid
+  #   fail <reason>   <result...>  : test that the previous command has failed. If not print the <reason> why it needs to fail
+  #   ok   <result...>             : test that the previos command has not failed. Print OK
+  cmd_result=$?
+  if [[ $1 == uuid ]]
+  then
+    [[ $cmd_result == 0 ]] || ! shift 2 || ! echo "FAIL: $*" >&2 || $_exit 1
+    is_valid_uuid $3 || ! shift 2 || ! echo "FAIL: $*" >&2 || $_exit 1
+    eval $2=$3
+    echo $3
+  elif [[ $1 == fail ]]
+  then
+    [[ $cmd_result != "0" ]] || ! echo "NOT FAIL:  $2" >&2 || $_exit 1
+    echo "fail OK" 
+  elif  [[ $1 == ok ]]
+  then
+    [[ $cmd_result == 0 ]] || ! shift 1 || ! echo "FAIL: $*" >&2 || $_exit 1
+    echo OK
+  fi
+
+}
+
+function test_of_rules(){
+  #test the number of rules of a network, wait until 10 seconds
+  timeout_=10
+  while true 
+  do #it can take some seconds to get it ready
+    result=`openvim openflow-net-list $1`
+    nb_rules=`echo $result | grep actions -o | wc -l`
+    [[ $nb_rules == $2 ]] && echo "OK" && break
+    [[ $timeout_ == 0 ]] && echo "FAIL $result" >&2 && $_exit 1  
+    sleep 1
+    timeout_=$((timeout_ - 1))
+  done
+}
+
+echo " Test VIM with 3 VM deployments. It delete the created items at the end"
+echo " "
+[[ $force != y ]] && read -e -p "Press enter to continue, CTRL+C to abort " kk
+
+
+printf "%-50s" "1   get ${VIM_TEST_IMAGE_PATH##*/} image: "
+image1=`openvim image-list -F"path=${VIM_TEST_IMAGE_PATH}" | gawk '{print $1}'`
+if is_valid_uuid $image1 
+then
+    echo $image1
+else
+    #create the image
+    echo not found
+    printf "%-50s" " b  create ${VIM_TEST_IMAGE_PATH##*/} image: "
+    result=`openvim image-create --name=test-image1 --path=${VIM_TEST_IMAGE_PATH} --description=for-test`
+    process_cmd uuid image1 $result
+    TODELETE="image:$image1 $TODELETE"
+fi
+    
+printf "%-50s" "2   get ${VIM_TEST_IMAGE_PATH_EXTRA##*/} image: "
+image2=`openvim image-list -F"path=${VIM_TEST_IMAGE_PATH_EXTRA}" | gawk '{print $1}'`
+if is_valid_uuid $image2 
+then
+    echo $image2
+else
+    #create the image
+    echo not found
+    printf "%-50s" " b  create ${VIM_TEST_IMAGE_PATH_EXTRA##*/} image: "
+    result=`openvim image-create --name=test-image1 --path=${VIM_TEST_IMAGE_PATH_EXTRA} --description=for-test`
+    process_cmd uuid image2 $result
+    TODELETE="image:$image2 $TODELETE"
+fi
+    
+if [[ $create == y ]]
+then
+    printf "%-50s" "3   create management network: "
+    result=`openvim net-create "name: test_mgmt_net
+type: bridge_man"`
+    process_cmd uuid network_eth0 $result
+    TODELETE="net:$network_eth0 $TODELETE"
+else
+    printf "%-50s" "3   get ${VIM_TEST_NETWORK_INTERNET} network: "
+    result=`openvim net-list -F"name=$VIM_TEST_NETWORK_INTERNET"`
+    process_cmd uuid network_eth0 $result
+fi
+
+printf "%-50s" "4   insert flavor1: "
+result=`openvim flavor-create '
+---
+flavor:
+  name: flavor1
+  description: flavor to test openvim
+  extended: 
+    processor_ranking: 205
+    numas:
+    -  memory: 8
+       paired-threads: 5
+       interfaces:
+       - name: xe0
+         dedicated: "yes"
+         bandwidth: "10 Gbps"
+         vpci: "0000:00:10.0"
+         #mac_address: "10:10:10:10:10:12"
+       - name: xe1
+         dedicated: "no"
+         bandwidth: "10 Gbps"
+         vpci: "0000:00:11.0"
+         mac_address: "10:10:10:10:10:13"
+'`
+process_cmd uuid flavor1 $result 
+TODELETE="flavor:$flavor1 $TODELETE"
+
+printf "%-50s" "5   insert net_ptp: "
+result=`openvim net-create '
+---
+network:
+  name: test_net_ptp
+  type: ptp
+'`
+process_cmd uuid net_ptp  $result
+TODELETE="net:$net_ptp $TODELETE"
+
+printf "%-50s" " b  insert net_data: "
+result=`openvim net-create '
+---
+network:
+  name: test_net_data
+  type: data
+'`
+process_cmd uuid net_data $result
+TODELETE="net:$net_data $TODELETE"
+
+printf "%-50s" "6   insert net_bind network bound to net_data: "
+result=`openvim net-create 'name: test_net_binded
+type: data
+bind_net: test_net_data'`
+process_cmd uuid net_bind $result
+TODELETE="net:$net_bind $TODELETE"
+
+printf "%-50s" "7   insert bridge network net2: "
+result=`openvim net-create '
+---
+network:
+  name: test_bridge_net2
+  type: bridge_data'`
+process_cmd uuid network2 $result
+TODELETE="net:$network2 $TODELETE"
+
+printf "%-50s" "8   add VM1 dataplane not connected: "
+result=`openvim vm-create "
+---
+server:
+  name: test_VM1
+  descrition: US or server with 1 SRIOV 1 PASSTHROUGH
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  networks:
+  - name: mgmt0
+    vpci: '0000:00:0a.0'
+    uuid: ${network_eth0}
+    mac_address: '10:10:10:10:10:10'
+  - name: eth0
+    vpci: '0000:00:0b.0'
+    uuid: '$network2'
+    mac_address: '10:10:10:10:10:11'
+"`
+process_cmd uuid  server1 $result
+TODELETE="vm:$server1 $TODELETE"
+
+printf "%-50s" "9   add VM2 oversubscribe flavor: "
+result=`openvim vm-create "
+---
+server:
+  name: test_VM2
+  descrition: US or server with direct network attach
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  networks:
+  - name: mgmt0
+    vpci: '0000:00:0a.0'
+    uuid: ${network_eth0}
+    mac_address: '10:10:10:10:11:10'
+  - name: eth0
+    vpci: '0000:00:0b.0'
+    uuid: '$network2'
+    mac_address: '10:10:10:10:11:11'
+  extended:
+    processor_ranking: 205
+    numas:
+    -  memory: 8
+       threads: 10
+       interfaces:
+       - name: xe0
+         dedicated: 'yes:sriov'
+         bandwidth: '10 Gbps'
+         vpci: '0000:00:11.0'
+         mac_address: '10:10:10:10:11:12'
+         uuid: '$net_ptp'
+    devices:
+    - type: disk
+      imageRef: '$image2'
+"`
+process_cmd uuid  server2 $result
+TODELETE="vm:$server2 $TODELETE"
+
+printf "%-50s" "10  test VM with repeated vpci: "
+result=`openvim vm-create "
+---
+server:
+  name: test_VMfail
+  descrition: repeated mac address
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  networks:
+  - name: mgmt0
+    vpci: '0000:00:10.0'
+    uuid: ${network_eth0}
+"`
+process_cmd fail "Duplicate vpci 0000:00:10.0" $result
+
+printf "%-50s" " b  test VM with repeated mac address: "
+result=`openvim vm-create "
+---
+server:
+  name: test_VMfail
+  descrition: repeated mac address
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  networks:
+  - name: mgmt0
+    vpci: '0000:00:0a.0'
+    uuid: ${network_eth0}
+    mac_address: '10:10:10:10:10:10'
+"`
+process_cmd fail "Duplicate mac 10:10:10:10:10:10" $result
+
+
+printf "%-50s" " c  test VM with wrong iface name at networks: "
+result=`openvim vm-create "
+---
+server:
+  name: test_VMfail
+  descrition: repeated mac address
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  networks:
+  - name: missing
+    type: PF
+    uuid: '$net_ptp'
+"`
+process_cmd fail "wrong iface name at networks" $result
+
+
+printf "%-50s" " d  test VM with wrong iface type at networks: "
+result=`openvim vm-create "
+---
+server:
+  name: test_VMfail
+  descrition: repeated mac address
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  networks:
+  - name: xe0
+    type: VF
+    uuid: '$net_ptp'
+"`
+process_cmd fail "wrong iface type at networks" $result
+
+
+printf "%-50s" "11  add VM3 dataplane connected: "
+result=`openvim vm-create "
+---
+server:
+  name: test_VM3
+  descrition: US or server with 2 dataplane connected
+  imageRef: '$image1'
+  flavorRef: '$flavor1'
+  networks:
+  - name: mgmt0
+    vpci: '0000:00:0a.0'
+    uuid: ${network_eth0}
+    mac_address: '10:10:10:10:12:10'
+  - name: eth0
+    vpci: '0000:00:0b.0'
+    uuid: '$network2'
+    type: virtual
+    mac_address: '10:10:10:10:12:11'
+  - name: xe0
+    type: PF
+    uuid: '$net_data'
+  - name: xe1
+    type: VF
+    uuid: '$net_ptp'
+    mac_address: '10:10:10:10:12:13'
+"`
+process_cmd uuid server3 $result
+TODELETE="vm:$server3 $TODELETE"
+
+printf "%-50s" "12  check 2 openflow rules for net_ptp: "
+test_of_rules $net_ptp 2
+
+printf "%-50s" "13  check net-down  net_ptp: "
+result=`openvim net-down -f ${net_ptp}`
+process_cmd ok $result
+
+printf "%-50s" " b  check 0 openflow rules for net_ptp: "
+test_of_rules $net_ptp 0
+
+printf "%-50s" " c  check net-up  net_ptp: "
+result=`openvim net-up -f ${net_ptp}`
+process_cmd ok $result
+
+printf "%-50s" " d  check 2 openflow rules for net_ptp: "
+test_of_rules $net_ptp 2
+
+printf "%-50s" "14  check 0 openflow rules for net_data: "
+test_of_rules $net_data 0
+
+[[ $force != y ]] && read -e -p "  Test control plane, and server2:xe0 to server3:xe1 connectivity. Press enter to continue " kk
+
+printf "%-50s" "15  get xe0 iface uuid from server1: "
+result=`openvim port-list -F"device_id=${server1}&name=xe0"`
+process_cmd uuid server1_xe0 $result
+
+printf "%-50s" " b  get xe1 iface uuid from server1: "
+result=`openvim port-list -F"device_id=${server1}&name=xe1"`
+process_cmd uuid server1_xe1 $result
+
+printf "%-50s" " c  get xe0 iface uuid from server3: "
+result=`openvim port-list -F"device_id=${server3}&name=xe0"`
+process_cmd uuid server3_xe0 $result
+
+printf "%-50s" " d  get xe1 iface uuid from server3: "
+result=`openvim port-list -F"device_id=${server3}&name=xe1"`
+process_cmd uuid server3_xe1 $result
+
+printf "%-50s" " e  get xe0 iface uuid from server3: "
+result=`openvim port-list -F"device_id=${server2}&name=xe0"`
+process_cmd uuid server2_xe0 $result
+
+printf "%-50s" "16  test ptp 3connex server1:xe0 -> net_ptp: "
+result=`openvim port-edit $server1_xe0 "network_id: $net_ptp" -f`
+process_cmd fail "Can not connect 3 interfaces to ptp network"
+
+printf "%-50s" "17  attach server1:xe0 to net_data: "
+result=`openvim port-edit $server1_xe0 "network_id: $net_data" -f`
+process_cmd ok $result
+
+printf "%-50s" "18  check 2 openflow rules for net_data: "
+test_of_rules $net_data 2
+
+[[ $force != y ]] && read -e -p "  Test server1:xe0 to server3:xe0 connectivity. Press enter to continue " kk
+
+if [[ $same_vlan == n ]]
+then
+
+  printf "%-50s" "19  attach server1:xe1 to net-data: "
+  result=`openvim port-edit $server1_xe1 "network_id: $net_data" -f`
+  process_cmd ok $result
+
+  printf "%-50s" " b  check 9 openflow rules for net_data: "
+  test_of_rules $net_data 9
+
+  [[ $force != y ]] && read -e -p "  Test server1:xe0,server1:xe1,server3:xe0 connectivity. Press enter to continue " kk
+
+  printf "%-50s" " c  re-attach server3:xe1 to net-data: "
+  result=`openvim port-edit $server3_xe1 "network_id: $net_data" -f`
+  process_cmd ok $result
+
+  printf "%-50s" " d  check 16 openflow rules for net_data: "
+  test_of_rules $net_data 16
+
+  printf "%-50s" " e  check 0 openflow rules for net_ptp: "
+  test_of_rules $net_ptp 0
+
+  [[ $force != y ]] && read -e -p "  Test server1:xe0,server1:xe1,server3:xe0,server3:xe1 connectivity. Press enter to continue " kk
+
+  printf "%-50s" " f  detach server1:xe1 from net-data: "
+  result=`openvim port-edit $server1_xe1 "network_id: null" -f `
+  process_cmd ok $result
+
+  printf "%-50s" " g  detach server3:xe1 to net-data: "
+  result=`openvim port-edit $server3_xe1 "network_id: null" -f`
+  process_cmd ok $result
+
+  printf "%-50s" " h  check 2 openflow rules for net_data: "
+  test_of_rules $net_data 2
+
+else
+  echo "19  skipping unrealizable test because --same_vlan option "
+fi
+
+printf "%-50s" "20  check 2 openflow rules for net_data: "
+test_of_rules $net_data 2
+
+printf "%-50s" " a  attach server2:xe0 to net_bind: "
+result=`openvim port-edit $server2_xe0 "network_id: $net_bind" -f`
+process_cmd ok $result
+
+printf "%-50s" " b  check 6 openflow rules for net_data: "
+   #type      src_net	   src_port    => dst_port       dst_net
+   #unicast   net_data     server1:xe0 => server3:xe0    net_data
+   #unicast   net_data     server3:xe0 => server1:xe0    net_data
+   #unicast   net_data     server1:xe0 => server2:xe0    net_bind
+   #unicast   net_data     server3:xe0 => server2:xe0    net_bind
+   #broadcast net_data     server1:xe0 => server3:xe0,server2:xe0    net_data,net_bind
+   #broadcast net_data     server3:xe0 => server1:xe0,server2:xe0    net_data,net_bind
+test_of_rules $net_data 6
+
+
+printf "%-50s" " c  check 3 openflow rules for net_bind: "
+   #type      src_net	   src_port    => dst_port       dst_net
+   #unicast   net_bind     server2:xe0 => server1:xe0    net_data
+   #unicast   net_bind     server2:xe0 => server3:xe0    net_data
+   #broadcast net_bind     server2:xe0 => server1:xe0,server3:xe0    net_data,net_data
+test_of_rules $net_bind 3
+
+printf "%-50s" " d  attach server1:xe1 to net_bind: "
+result=`openvim port-edit $server1_xe1 "network_id: $net_bind" -f`
+process_cmd ok $result
+
+printf "%-50s" " e  check 8 openflow rules for net_data: "
+   #type      src_net      src_port    => dst_port       dst_net
+   #unicast   net_data     server1:xe0 => server3:xe0    net_data
+   #unicast   net_data     server3:xe0 => server1:xe0    net_data
+   #unicast   net_data     server1:xe0 => server2:xe0    net_bind
+   #unicast   net_data     server1:xe0 => server1:xe1    net_bind
+   #unicast   net_data     server3:xe0 => server2:xe0    net_bind
+   #unicast   net_data     server3:xe0 => server1:xe1    net_bind
+   #broadcast net_data     server1:xe0 => server3:xe0,server2:xe0,server1:xe1    net_data,net_bind,net_bind
+   #broadcast net_data     server3:xe0 => server1:xe0,server2:xe0,server1:xe1    net_data,net_bind,net_bind
+test_of_rules $net_data 8
+
+
+printf "%-50s" " f  check 8 openflow rules for net_bind: "
+test_of_rules $net_bind 8
+
+printf "%-50s" " d  put net_data down: "
+result=`openvim net-down $net_data -f`
+process_cmd ok $result
+
+printf "%-50s" " e  check 0 openflow rules for net_data: "
+test_of_rules $net_data 0
+
+printf "%-50s" " e  check 2 openflow rules for net_bind: "
+test_of_rules $net_bind 2
+
+
+
+echo 
+echo DONE
+
+$_exit 0
+