aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmgr/vnfmgr_main.py
diff options
context:
space:
mode:
authorManuel Buil Mur <manuel.buil@ericsson.com>2015-10-09 16:48:36 +0200
committermbuil <manuel.buil@ericsson.com>2015-10-23 11:27:18 +0200
commit9c15bd683ccd0bf11d79ee0934a4cc3f78be521f (patch)
treeb0183e0e4fa543523b358315f4b6503e903fa7b8 /vnfmgr/vnfmgr_main.py
parent40513772b3fa20c33f44fd36a8969f0763d1f9cd (diff)
First version of VNF manager simulator
This simulator contacts Openstack to create the SF VMs and then contacts ODL to create the SFC. It is not intended to be a replacement of other VNF Managers such as Tacker or OpenMANO, just a simple simulation for testing and development purposes. Change-Id: Iaf691035d1b8435f5fccf559aebf6f3ed1afd066 Signed-off-by: mbuil <manuel.buil@ericsson.com>
Diffstat (limited to 'vnfmgr/vnfmgr_main.py')
-rwxr-xr-xvnfmgr/vnfmgr_main.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/vnfmgr/vnfmgr_main.py b/vnfmgr/vnfmgr_main.py
new file mode 100755
index 00000000..b5ab8be1
--- /dev/null
+++ b/vnfmgr/vnfmgr_main.py
@@ -0,0 +1,72 @@
+#################################################################
+# #
+# Copyright 2015 Ericsson AB #
+# All Rights Reserved #
+# #
+# Author: Manuel Buil <Manuel.Buil@ericsson.com> #
+# Version: 0.1 #
+# #
+#################################################################
+
+import pdb
+from vnfmgr_os.vnfmgr_os import OpenStack_API
+import vnfmgr_odl.vnfmgr_odl as odlscript
+import time
+import json
+
+if __name__ == "__main__":
+ #OpenStack environment information
+ authurl = "http://localhost:5000/v2.0"
+ adminTenantName = 'admin'
+ adminTenantUser = 'admin'
+ adminTenantPass = 'abc123'
+ tenantName = adminTenantName
+ tenantUser = adminTenantUser
+ tenantPass = adminTenantPass
+
+ openstack = OpenStack_API(authurl, tenantName, tenantUser, tenantPass)
+
+ # 1 - Get the SF type
+ # Provide the file with the SFC configuration
+ file_json = "vnfmgr_odl/sample_config/RestConf-SFCs-HttpPut.json"
+ # Read the config files which refer to SF
+ json_data=open(file_json).read()
+ data = json.loads(json_data)
+ pdb.set_trace()
+
+ # Grab the SF type
+ chains = data['service-function-chains']['service-function-chain']
+ for chain in chains:
+ SFs = chain['sfc-service-function']
+ for SF in SFs:
+ sf_type = SF['type']
+ name = SF['name']
+ #2 - Search the image in glance with that SF type
+ image = openstack.find_image(sf_type)
+ if image == None:
+ print("There is no image with that sf_name")
+ exit(1)
+ # 3 - Boot the VM without network
+ flavor = 1
+ print("About to deploy")
+ vm = openstack.create_vm(name,image,flavor)
+ if vm == None:
+ print("Problems to deploy the VM")
+ exit(1)
+
+ #Make the call to ODL to deploy SFC
+ context = odlscript.Context()
+ context.set_path_prefix_paths("vnfmgr_odl/sample_config")
+ pdb.set_trace()
+ odlscript.send_rest(context, "PUT", context.rest_url_sf_sel, context.rest_path_sf_sel)
+ odlscript.send_rest(context, "PUT", context.rest_url_sf, context.rest_path_sf)
+ odlscript.send_rest(context, "PUT", context.rest_url_sff, context.rest_path_sff)
+ odlscript.send_rest(context, "PUT", context.rest_url_sfc, context.rest_path_sfc)
+ odlscript.send_rest(context, "PUT", context.rest_url_sfp, context.rest_path_sfp)
+ time.sleep(1);
+ odlscript.send_rest(context, "POST", context.rest_url_rsp_rpc, context.rest_path_rsp)
+
+
+ #TO DO
+ # Check if the SF_VM already exists before creating it
+ # Network of the VM