-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from hadik3r/master
add support for private key
- Loading branch information
Showing
18 changed files
with
1,381 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright (c) 2015 SONATA-NFV | ||
# 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. | ||
# Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION] | ||
# nor the names of its contributors may be used to endorse or promote | ||
# products derived from this software without specific prior written | ||
# permission. | ||
# This work has been performed in the framework of the SONATA project, | ||
# funded by the European Commission under Grant number 671517 through | ||
# the Horizon 2020 and 5G-PPP programmes. The authors would like to | ||
# acknowledge the contributions of their colleagues of the SONATA | ||
# partner consortium (www.sonata-nfv.eu). | ||
|
||
FROM python:3.4-slim | ||
MAINTAINER SONATA | ||
|
||
# configrurations | ||
ENV mongo_host mongo | ||
ENV mongo_port 27017 | ||
ENV broker_host amqp://guest:guest@broker:5672/%2F | ||
ENV broker_exchange son-kernel | ||
|
||
ADD son-ssm-examples/vCDN_placement /placement | ||
ADD son-mano-framework/son-mano-base /son-mano-base | ||
ADD son-sm-template /son-sm-template | ||
ADD utils/delayedstart.sh /delayedstart.sh | ||
|
||
WORKDIR /son-mano-base | ||
Run python setup.py install | ||
|
||
WORKDIR /son-sm-template | ||
RUN python setup.py install | ||
|
||
WORKDIR /placement | ||
RUN python setup.py develop | ||
|
||
CMD ["placement"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Include the license file | ||
include ../../LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# vCDN Pilot Placement SSM | ||
Placement SSM to be used for vCDN pilot. | ||
|
||
## Requires | ||
* Docker | ||
* Python3.4 | ||
* RabbitMQ | ||
|
||
## Implementation | ||
* Implemented in Python 3.4 | ||
* Dependencies: amqp-storm | ||
* The main implementation can be found in: `son-ssm-examples/vCDN_placement/placement/placement.py` | ||
|
||
## How to run it | ||
|
||
* To run the placement SSM locally, you need: | ||
* a running RabbitMQ broker (see general README.md of [son-mano framework repository](https://github.com/sonata-nfv/son-mano-framework) for info on how to do this) | ||
* a running Service Specific Registry (SMR) connected to the broker (see general README.md of [SMR repository](https://github.com/sonata-nfv/son-mano-framework) for info on how to do this) | ||
|
||
* Run the placement SSM (in a Docker container): | ||
* (do in `son-sm/`) | ||
* `docker build -t sonssmvcdnplacement1 -f son-ssm-examples/vCDN_placement/Dockerfile .` | ||
* `docker run --name sonssmvcdnplacement1 --net=sonata --network-alias=sonssmvcdnplacement1 sonssmvcdnplacement1` | ||
|
||
* Or: Run the placement SSM (directly in your terminal not in a Docker container): | ||
* (In `son-sm/son-sm-template/`) | ||
* `python3.4 setup.py install` | ||
* (In `son-sm/son-ssm-examples/vCDN_placement/`) | ||
* `python3.4 setup.py develop` | ||
* (In `son-sm/`) | ||
* `python3.4 son-ssm-examples/vCDN_placement/placement/placement.py` | ||
|
||
## How to test it | ||
* Do the following; each in a separate terminal. | ||
1. Run the fake_SMR | ||
2. Run the placement container | ||
3. In son-sm/son-ssm-examples/vCDN_placement/placement/test run python3.4 placementtrigger.py | ||
|
||
* The expected results are as follows: | ||
|
||
* In the placementtrigger terminal: | ||
|
||
``` | ||
{'status': 'COMPLETED', 'mapping': {'vnfd2': {'vim': '1234'}, 'vnfd1': {'vim': '1234'}}, 'error': None} | ||
``` | ||
|
||
* In placement terminal: | ||
|
||
``` | ||
INFO:son-sm-base:Starting sonssmvcdnplacement1 ... | ||
INFO:son-sm-base:Sending registration request... | ||
INFO:son-sm-base:sonssmvcdnplacement1 registered with uuid:23345 | ||
DEBUG:vCDN-ssm-placement:Received registration ok event. | ||
INFO:vCDN-ssm-placement:Subscribed to placement.ssm.1234 | ||
INFO:vCDN-ssm-placement:Placement started | ||
INFO:vCDN-ssm-placement:Mapping algorithm started. | ||
INFO:vCDN-ssm-placement:Mapping succeeded: {'vnfd1': {'vim': '1234'}, 'vnfd2': {'vim': '1234'}} | ||
INFO:vCDN-ssm-placement:The mapping calculation has succeeded. | ||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from placement import placement | ||
|
||
|
||
def main(): | ||
placement.main() | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
""" | ||
Copyright (c) 2015 SONATA-NFV | ||
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. | ||
Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION] | ||
nor the names of its contributors may be used to endorse or promote | ||
products derived from this software without specific prior written | ||
permission. | ||
This work has been performed in the framework of the SONATA project, | ||
funded by the European Commission under Grant number 671517 through | ||
the Horizon 2020 and 5G-PPP programmes. The authors would like to | ||
acknowledge the contributions of their colleagues of the SONATA | ||
partner consortium (www.sonata-nfv.eu). | ||
""" | ||
|
||
import logging | ||
import yaml | ||
from sonsmbase.smbase import sonSMbase | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
LOG = logging.getLogger("vCDN-ssm-placement") | ||
LOG.setLevel(logging.DEBUG) | ||
logging.getLogger("son-mano-base:messaging").setLevel(logging.INFO) | ||
|
||
|
||
class PlacementSSM(sonSMbase): | ||
|
||
def __init__(self): | ||
|
||
""" | ||
:param specific_manager_type: specifies the type of specific manager that could be either fsm or ssm. | ||
:param service_name: the name of the service that this specific manager belongs to. | ||
:param function_name: the name of the function that this specific manager belongs to, will be null in SSM case | ||
:param specific_manager_name: the actual name of specific manager (e.g., scaling, placement) | ||
:param id_number: the specific manager id number which is used to distinguish between multiple SSM/FSM | ||
that are created for the same objective (e.g., scaling with algorithm 1 and 2) | ||
:param version: version | ||
:param description: description | ||
""" | ||
self.specific_manager_type = 'ssm' | ||
self.service_name = 'vcdn' | ||
self.specific_manager_name = 'placement' | ||
self.id_number = '1' | ||
self.version = 'v0.1' | ||
self.description = "Placement SSM" | ||
|
||
super(self.__class__, self).__init__(specific_manager_type= self.specific_manager_type, | ||
service_name= self.service_name, | ||
specific_manager_name = self.specific_manager_name, | ||
id_number = self.id_number, | ||
version = self.version, | ||
description = self.description) | ||
|
||
|
||
def on_registration_ok(self): | ||
|
||
LOG.debug("Received registration ok event.") | ||
|
||
# For testing, here we set the service uuid. | ||
# In the actual scenario this should be set by SLM and SMR during the SSM instantiation. | ||
# if self.sfuuid == None: | ||
#self.sfuuid = '1234' | ||
|
||
# Register to placement topic. | ||
topic = 'placement.ssm.' + self.sfuuid | ||
|
||
self.manoconn.register_async_endpoint(self.on_place,topic= topic) | ||
|
||
LOG.info("Subscribed to {0}".format(topic)) | ||
|
||
def on_place(self, ch, method, properties, payload): | ||
""" | ||
This method organises the placement calculation, and | ||
provides the response for the SLM. | ||
""" | ||
|
||
LOG.info("Placement started") | ||
message = yaml.load(payload) | ||
topology = message['topology'] | ||
nsd = message['nsd'] | ||
functions = message['vnfds'] | ||
nap = message['nap'] | ||
|
||
mapping = self.placement_alg(nsd, functions, topology, nap) | ||
|
||
if mapping is None: | ||
LOG.info("The mapping calculation has failed.") | ||
message = {} | ||
message['error'] = 'Unable to perform placement.' | ||
message['status'] = 'ERROR' | ||
|
||
else: | ||
LOG.info("The mapping calculation has succeeded.") | ||
message = {} | ||
message['error'] = None | ||
message['status'] = "COMPLETED" | ||
message['mapping'] = mapping | ||
|
||
is_dict = isinstance(message, dict) | ||
LOG.info("Type Dict: " + str(is_dict)) | ||
|
||
payload = yaml.dump(message) | ||
self.manoconn.notify('placement.ssm.' + self.sfuuid, | ||
payload, | ||
correlation_id=properties.correlation_id) | ||
|
||
return | ||
|
||
def placement_alg(self, nsd, functions, topology, nap): | ||
""" | ||
This is the default placement algorithm that is used if the SLM | ||
is responsible to perform the placement | ||
""" | ||
LOG.info("Mapping algorithm started.") | ||
mapping = {} | ||
|
||
ingress = nap['ingress'][0]['location'] | ||
egress = nap['egress'][0]['location'] | ||
|
||
# Find the sum of demands of vCC and vTC | ||
vtc_vcc_total_core = 0 | ||
vtc_vcc_total_memory = 0 | ||
for vnfd in functions: | ||
if vnfd['intance_uuid'] == 'vtc-vnf' or vnfd['intance_uuid'] == 'vcc-vnf': | ||
vtc_vcc_total_core += vnfd['virtual_deployment_units'][0]['resource_requirements']['cpu']['vcpus'] | ||
vtc_vcc_total_memory += vnfd['virtual_deployment_units'][0]['resource_requirements']['memory']['size'] | ||
|
||
# Find the sum of demands of vCC and vTC | ||
|
||
vtu_total_core = 0 | ||
vtu_total_memory = 0 | ||
for vnfd in functions: | ||
if vnfd['intance_uuid'] == 'vtu-vnf': | ||
vtu_total_core = vnfd['virtual_deployment_units'][0]['resource_requirements']['cpu']['vcpus'] | ||
vtu_total_memory = vnfd['virtual_deployment_units'][0]['resource_requirements']['memory']['size'] | ||
|
||
if ingress == "" and egress == "": | ||
|
||
for vnfd in functions: | ||
if vnfd['name'] == 'vtc-vnf' or vnfd['name'] == 'vcc-vnf': | ||
for vim in topology: | ||
cpu_req = vtc_vcc_total_core <= (vim['core_total'] - vim['core_used']) | ||
mem_req = vtc_vcc_total_memory <= (vim['memory_total'] - vim['memory_used']) | ||
if cpu_req and mem_req: | ||
LOG.debug('VNF ' + vnfd['intance_uuid'] + ' mapped on VIM ' + vim['vim_uuid']) | ||
mapping[vnfd['intance_uuid']] = {} | ||
mapping[vnfd['intance_uuid']]['vim'] = vim['vim_uuid'] | ||
vim['core_used'] = vim['core_used'] + \ | ||
vnfd['virtual_deployment_units'][0]['resource_requirements']['cpu'][ | ||
'vcpus'] | ||
vim['memory_used'] = vim['memory_used'] + \ | ||
vnfd['virtual_deployment_units'][0]['resource_requirements'][ | ||
'memory'][ | ||
'size'] | ||
break | ||
|
||
if vnfd['name'] == 'vtu-vnf': | ||
for vim in topology: | ||
cpu_req = vtu_total_core <= (vim['core_total'] - vim['core_used']) | ||
mem_req = vtu_total_memory <= (vim['memory_total'] - vim['memory_used']) | ||
|
||
if cpu_req and mem_req: | ||
LOG.debug('VNF ' + vnfd['intance_uuid'] + ' mapped on VIM ' + vim['vim_uuid']) | ||
mapping[vnfd['intance_uuid']] = {} | ||
mapping[vnfd['intance_uuid']]['vim'] = vim['vim_uuid'] | ||
vim['core_used'] = vim['core_used'] + \ | ||
vnfd['virtual_deployment_units'][0]['resource_requirements']['cpu'][ | ||
'vcpus'] | ||
vim['memory_used'] = vim['memory_used'] + \ | ||
vnfd['virtual_deployment_units'][0]['resource_requirements'][ | ||
'memory'][ | ||
'size'] | ||
break | ||
else: | ||
# Place vTC and vCC on the Egress PoP close to users and | ||
# place vTU on Ingress PoP close to the server | ||
for vnfd in functions: | ||
if vnfd['name'] == 'vtc-vnf' or vnfd['name'] == 'vcc-vnf': | ||
for vim in topology: | ||
if vim['vim_city'] == egress: | ||
cpu_req = vtc_vcc_total_core <= (vim['core_total'] - vim['core_used']) | ||
mem_req = vtc_vcc_total_memory <= (vim['memory_total'] - vim['memory_used']) | ||
if cpu_req and mem_req: | ||
LOG.debug('VNF ' + vnfd['intance_uuid'] + ' mapped on VIM ' + vim['vim_uuid']) | ||
mapping[vnfd['intance_uuid']] = {} | ||
mapping[vnfd['intance_uuid']]['vim'] = vim['vim_uuid'] | ||
vim['core_used'] = vim['core_used'] + \ | ||
vnfd['virtual_deployment_units'][0]['resource_requirements']['cpu'][ | ||
'vcpus'] | ||
vim['memory_used'] = vim['memory_used'] + \ | ||
vnfd['virtual_deployment_units'][0]['resource_requirements']['memory'][ | ||
'size'] | ||
break | ||
|
||
if vnfd['name'] == 'vtu-vnf': | ||
for vim in topology: | ||
if vim['vim_city'] == ingress: | ||
cpu_req = vtu_total_core <= (vim['core_total'] - vim['core_used']) | ||
mem_req = vtu_total_memory <= (vim['memory_total'] - vim['memory_used']) | ||
|
||
if cpu_req and mem_req: | ||
LOG.debug('VNF ' + vnfd['intance_uuid'] + ' mapped on VIM ' + vim['vim_uuid']) | ||
mapping[vnfd['intance_uuid']] = {} | ||
mapping[vnfd['intance_uuid']]['vim'] = vim['vim_uuid'] | ||
vim['core_used'] = vim['core_used'] + \ | ||
vnfd['virtual_deployment_units'][0]['resource_requirements']['cpu'][ | ||
'vcpus'] | ||
vim['memory_used'] = vim['memory_used'] + \ | ||
vnfd['virtual_deployment_units'][0]['resource_requirements']['memory'][ | ||
'size'] | ||
break | ||
|
||
# Check if all VNFs have been mapped | ||
if len(mapping.keys()) == len(functions): | ||
LOG.info("Mapping succeeded: " + str(mapping)) | ||
return mapping | ||
else: | ||
return None | ||
|
||
def main(): | ||
PlacementSSM() | ||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.