summaryrefslogtreecommitdiffstats
path: root/vnfmgr/vnfmgr_os
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_os
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_os')
-rw-r--r--vnfmgr/vnfmgr_os/__init__.py0
-rwxr-xr-xvnfmgr/vnfmgr_os/vnfmgr_os.py68
2 files changed, 68 insertions, 0 deletions
diff --git a/vnfmgr/vnfmgr_os/__init__.py b/vnfmgr/vnfmgr_os/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/vnfmgr/vnfmgr_os/__init__.py
diff --git a/vnfmgr/vnfmgr_os/vnfmgr_os.py b/vnfmgr/vnfmgr_os/vnfmgr_os.py
new file mode 100755
index 00000000..00678503
--- /dev/null
+++ b/vnfmgr/vnfmgr_os/vnfmgr_os.py
@@ -0,0 +1,68 @@
+#################################################################
+# #
+# Copyright 2015 Ericsson AB #
+# All Rights Reserved #
+# #
+# Author: Manuel Buil <Manuel.Buil@ericsson.com> #
+# Version: 0.1 #
+# #
+#################################################################
+
+import pdb
+
+from novaclient.v2 import client as nova
+from novaclient import exceptions as novaexceptions
+from keystoneclient.v2_0 import client as keystone
+from glanceclient import client as glance
+
+
+class OpenStack_API:
+ def __init__(self, authurl, tenantName, tenantUser, tenantPass):
+ self.authurl=authurl
+ self.tenantName=tenantName
+ self.tenantUser=tenantUser
+ self.tenantPass=tenantPass
+
+ def get_token(self):
+ # Establish connection to Openstack controller
+ osconn = keystone.Client(username=self.tenantUser, password=self.tenantPass, tenant_name=self.tenantName, auth_url=self.authurl)
+ token = osconn.auth_token
+ return token
+
+ def get_endpoint(self,service_type, endpoint_type):
+ # Establish connection to Openstack controller
+ osconn = keystone.Client(username=self.tenantUser, password=self.tenantPass, tenant_name=self.tenantName, auth_url=self.authurl)
+ endpoint = osconn.service_catalog.url_for(service_type=service_type, endpoint_type=endpoint_type)
+ return endpoint
+
+ def find_image(self,SF_type):
+ # Find in glance the image that matches the SF we want to deploy
+ token = self.get_token()
+ endpoint = self.get_endpoint('image','publicURL')
+ osconn = glance.Client('1',endpoint=endpoint,token=token)
+ image_list = osconn.images.list()
+ for item in image_list:
+ try:
+ image_type = item.properties.get('image_type', None)
+ image_id=None
+ if (image_type == SF_type):
+ image_id = item.id
+ break
+ except:
+ print("Errrorr")
+
+ #Search image which matches the SF type
+ return image_id
+
+ def create_vm(self, name, image, flavor, nics=None):
+ # Establish connection to Openstack controller
+ osconn = nova.Client(self.tenantUser, self.tenantPass, self.tenantName, self.authurl, service_type="compute")
+ try:
+ if nics is None:
+ vm = osconn.servers.create(name,image,flavor)
+ else:
+ vm = osconn.servers.create(name,image,flavor,nics)
+ except:
+ print("Something wrong happened while creating the VM")
+ vm = None
+ return vm