aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NAME/__init__.py0
-rw-r--r--README1
-rw-r--r--setup.py23
-rw-r--r--tests/NAME_tests.py11
-rw-r--r--tests/__init__.py0
-rwxr-xr-xvnfmgr/vnfmgr_main.py72
-rw-r--r--vnfmgr/vnfmgr_odl/__init__.py0
-rwxr-xr-xvnfmgr/vnfmgr_odl/sample_config/RestConf-RSP-HttpPost.json (renamed from vnfmgr_sim/sample_config/RestConf-RSP-HttpPost.json)0
-rwxr-xr-xvnfmgr/vnfmgr_odl/sample_config/RestConf-SFCs-HttpPut.json (renamed from vnfmgr_sim/sample_config/RestConf-SFCs-HttpPut.json)0
-rwxr-xr-xvnfmgr/vnfmgr_odl/sample_config/RestConf-SFFs-HttpPut.json (renamed from vnfmgr_sim/sample_config/RestConf-SFFs-HttpPut.json)0
-rwxr-xr-xvnfmgr/vnfmgr_odl/sample_config/RestConf-SFPs-HttpPut.json (renamed from vnfmgr_sim/sample_config/RestConf-SFPs-HttpPut.json)0
-rwxr-xr-xvnfmgr/vnfmgr_odl/sample_config/RestConf-SFs-HttpPut.json (renamed from vnfmgr_sim/sample_config/RestConf-SFs-HttpPut.json)0
-rwxr-xr-xvnfmgr/vnfmgr_odl/vnfmgr_odl.py (renamed from vnfmgr_sim/vnfmgr_sim.py)13
-rw-r--r--vnfmgr/vnfmgr_os/__init__.py0
-rwxr-xr-xvnfmgr/vnfmgr_os/vnfmgr_os.py68
15 files changed, 182 insertions, 6 deletions
diff --git a/NAME/__init__.py b/NAME/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NAME/__init__.py
diff --git a/README b/README
new file mode 100644
index 0000000..04d252a
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+This code deploys the ODL-Openstack maanger.
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..9ff1699
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,23 @@
+import os
+from setuptools import setup
+
+# Utility function to read the README file.
+# Used for the long_description. It's nice, because now 1) we have a top level
+# README file and 2) it's easier to type in the README file than to put a raw
+# string in below ...
+def read(fname):
+ return open(os.path.join(os.path.dirname(__file__), fname)).read()
+
+setup(
+ name = "vnf manager simulator",
+ version = "1.0",
+ author = "Manuel Buil, Brady A. Johnson",
+ author_email = "manuel.buil@ericsson.com, brady.allen.johnson@ericsson.com",
+ description = ("A script which simulates an orchestrator"),
+ license = "Apache License Version 2.0",
+ keywords = "example documentation tutorial",
+ url = "https://gerrit.opnfv.org/gerrit/#/c/2519",
+ packages = [".."],
+ scripts = [".."],
+ long_description=read('README'),
+)
diff --git a/tests/NAME_tests.py b/tests/NAME_tests.py
new file mode 100644
index 0000000..9f83104
--- /dev/null
+++ b/tests/NAME_tests.py
@@ -0,0 +1,11 @@
+from nose.tools import *
+import NAME
+
+def setup():
+ print "SETUP!"
+
+def teardown():
+ print "TEAR DOWN!"
+
+def test_basic():
+ print "I RAN!"
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/__init__.py
diff --git a/vnfmgr/vnfmgr_main.py b/vnfmgr/vnfmgr_main.py
new file mode 100755
index 0000000..b5ab8be
--- /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
diff --git a/vnfmgr/vnfmgr_odl/__init__.py b/vnfmgr/vnfmgr_odl/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vnfmgr/vnfmgr_odl/__init__.py
diff --git a/vnfmgr_sim/sample_config/RestConf-RSP-HttpPost.json b/vnfmgr/vnfmgr_odl/sample_config/RestConf-RSP-HttpPost.json
index 998d1e0..998d1e0 100755
--- a/vnfmgr_sim/sample_config/RestConf-RSP-HttpPost.json
+++ b/vnfmgr/vnfmgr_odl/sample_config/RestConf-RSP-HttpPost.json
diff --git a/vnfmgr_sim/sample_config/RestConf-SFCs-HttpPut.json b/vnfmgr/vnfmgr_odl/sample_config/RestConf-SFCs-HttpPut.json
index 3444964..3444964 100755
--- a/vnfmgr_sim/sample_config/RestConf-SFCs-HttpPut.json
+++ b/vnfmgr/vnfmgr_odl/sample_config/RestConf-SFCs-HttpPut.json
diff --git a/vnfmgr_sim/sample_config/RestConf-SFFs-HttpPut.json b/vnfmgr/vnfmgr_odl/sample_config/RestConf-SFFs-HttpPut.json
index 191fd54..191fd54 100755
--- a/vnfmgr_sim/sample_config/RestConf-SFFs-HttpPut.json
+++ b/vnfmgr/vnfmgr_odl/sample_config/RestConf-SFFs-HttpPut.json
diff --git a/vnfmgr_sim/sample_config/RestConf-SFPs-HttpPut.json b/vnfmgr/vnfmgr_odl/sample_config/RestConf-SFPs-HttpPut.json
index da1f2c4..da1f2c4 100755
--- a/vnfmgr_sim/sample_config/RestConf-SFPs-HttpPut.json
+++ b/vnfmgr/vnfmgr_odl/sample_config/RestConf-SFPs-HttpPut.json
diff --git a/vnfmgr_sim/sample_config/RestConf-SFs-HttpPut.json b/vnfmgr/vnfmgr_odl/sample_config/RestConf-SFs-HttpPut.json
index 1ea27e7..1ea27e7 100755
--- a/vnfmgr_sim/sample_config/RestConf-SFs-HttpPut.json
+++ b/vnfmgr/vnfmgr_odl/sample_config/RestConf-SFs-HttpPut.json
diff --git a/vnfmgr_sim/vnfmgr_sim.py b/vnfmgr/vnfmgr_odl/vnfmgr_odl.py
index c907e30..4d35aeb 100755
--- a/vnfmgr_sim/vnfmgr_sim.py
+++ b/vnfmgr/vnfmgr_odl/vnfmgr_odl.py
@@ -6,7 +6,7 @@ __license__ = "Apache License version 2.0"
__version__ = "0.1"
__email__ = "brady.allen.johnson@ericsson.com"
__status__ = "beta"
-
+import pdb
import os
import time
import requests
@@ -22,7 +22,7 @@ class Context(object):
Context class to hold the configuration as specified on the command line
"""
def __init__(self):
- self.rest_path_prefix = 'restInput'
+ self.rest_path_prefix = 'sampleConfig'
self.rest_path_sf = 'RestConf-SFs-HttpPut.json'
self.rest_path_sf_sel = 'RestConf-SFselect-HttpPut.json'
self.rest_path_sfc = 'RestConf-SFCs-HttpPut.json'
@@ -378,7 +378,8 @@ def CLI(context):
elif option == '6':
send_rest(context, PUT, context.rest_url_acl, context.rest_path_acl)
elif option == '7':
- send_rest(context, PUT, context.rest_url_sf_sel, context.rest_path_sf_sel)
+ pdb.set_trace()
+ send_rest(context, PUT, context.rest_url_sf_sel, context.rest_path_sf_sel)
send_rest(context, PUT, context.rest_url_sf, context.rest_path_sf)
send_rest(context, PUT, context.rest_url_sff, context.rest_path_sff)
send_rest(context, PUT, context.rest_url_sfc, context.rest_path_sfc)
@@ -416,11 +417,11 @@ def main():
Command line arguments are expected.
Example invocations:
To display application command-line help:
- vnfmgr_sim.py --help
+ vnfmgr_odl.py --help
To start the application in interractive mode:
- vnfmgr_sim.py -prefix <input json dir>
+ vnfmgr_odl.py -prefix <input json dir>
To start the application in batch mode and send an SF JSON REST message:
- vnfmgr_sim.py -b -prefix <input json dir> --send-sf
+ vnfmgr_odl.py -b -prefix <input json dir> --send-sf
"""
context = Context()
diff --git a/vnfmgr/vnfmgr_os/__init__.py b/vnfmgr/vnfmgr_os/__init__.py
new file mode 100644
index 0000000..e69de29
--- /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 0000000..0067850
--- /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