Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #132 from jbatalle/master
Browse files Browse the repository at this point in the history
v0.10.0
  • Loading branch information
jbatalle authored Nov 16, 2016
2 parents 5e5b6fb + 2b7c798 commit f7f716c
Show file tree
Hide file tree
Showing 59 changed files with 1,173 additions and 497 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.10.0
- Included Compute api v2
- Provisioning fixes. Handling errors when Auth and flavor errors occurs.
- Updated Gemfiles for Monitoring.
- Fixed autoscaling using the assurance parameters.
- Saving monitoring per VDU.
- Fix Scaling forwarding.
- Fix registration of modules.

## 0.9.0
- Refactor. Removed unused files and functions.
- Hide credentials from logs.
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ TeNOR is the NFV Orchestrator platform developed by the [T-NOVA](http://www.t-no
[![Build Status](https://travis-ci.org/T-NOVA/TeNOR.svg?branch=master)](https://travis-ci.org/T-NOVA/TeNOR) [![License](https://img.shields.io/badge/License-Apache%202.0-yellowgreen.svg)](https://opensource.org/licenses/Apache-2.0)

## Prerequisites
- Ruby >= 2.2.5 (installation provided in dependencies/install_dependencies.sh)
- Ruby >= 2.2.5 (Recommended 2.3.1) (installation provided in dependencies/install_dependencies.sh)
- Bundler (installation provided in dependencies/install_dependencies.sh)
- MongoDB (installation provided in dependencies/install_dependencies.sh)
- Openstack Juno version or higher
- Enable Keystone and Nova_Flavors in Openstack Heat resources ([How to do it](#enable_heat_resources))

## Optional Requirements
- Service Mapping (https://github.com/T-NOVA/TeNOR/tree/master/service-mapper). Used when more than 1 PoP is available.
- Service Mapping (https://github.com/T-NOVA/TeNOR/tree/master/service-mapper). Used when more than 1 PoP is available. Requires the Infrastructure Repository.
- Infrastructure Repository (https://github.com/T-NOVA/infrastructure-repository). Used by the UI and the Service Mapping algorithm.
- Middleware API (https://github.com/T-NOVA/mAPI) (required for start/stop the Lifecycle events inside the VNFS)
- VIM Monitoring (https://github.com/T-NOVA/vim-monitoring). Used for receive the monitoring from each VNF.
- Netfloc (https://github.com/T-NOVA/netfloc). Used for the VNFFG.
- Netfloc (https://github.com/T-NOVA/netfloc). Used for the VNFFG. Requires ODL.
- WICM (https://github.com/T-NOVA/WICM).
- Apache Cassandra (optional, used for monitoring) (installation provided in dependencies/install_cassandra.sh)
- RabbitMq (optional, used for monitoring) (installation provided in dependencies/install_dependencies.sh)
Expand Down Expand Up @@ -229,6 +230,16 @@ In each VNFD can have 5 types of lifecycle event: start, stop, restart, scaling_
- Get the last PublicIps for scaling-out: get_attr[vdu0,CPudhr,PublicIp]
- Timeout before remove instance due scale-in event:
# Enable heat resources
TeNOR uses Openstack heat templates in order to deploy the VNFs. Make sure that Openstack used has the basic resource types. In general, Nova Flavors and Keystone types are disabled by default. Please, enable these resources.
You can see the available list of resources in:
` /usr/lib/python2.7/dist-packages/heat/contrib/ `
Then, modify the heat.conf (/etc/heat/heat.conf) and add the line:
`plugin_dirs=/usr/lib/python2.7/dist-packages/heat/contrib/nova_flavor/nova_flavor `
`plugin_dirs=/usr/lib/python2.7/dist-packages/heat/contrib/heat_keystone/heat_keystone `
# Development
## Microservice ports
Expand Down
6 changes: 3 additions & 3 deletions dependencies/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ function install_ruby {
cd ~
. ~/.rvm/scripts/rvm

echo "Installing Ruby 2.2.5..."
rvm install 2.2.5
echo "Installation of Ruby 2.2.5 done."
echo "Installing Ruby 2.3.1..."
rvm install 2.3.1
echo "Installation of Ruby 2.3.1 done."

echo "Installing Bundler..."
gem install bundler invoker
Expand Down
2 changes: 1 addition & 1 deletion ns-manager/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace :db do
task :seed do
puts 'Creating the admin user....'
begin
User.find_by(name: 'admin').destroy unless User.find_by(name: 'admin').nil?
User.find_by(name: 'admin')
rescue Mongoid::Errors::DocumentNotFound => e
salt = BCrypt::Engine.generate_salt
user1 = User.create(name: 'admin', email: '[email protected]', password: 'adminpass', password_confirmation: 'adminpass', password_salt: salt, password_hash: BCrypt::Engine.hash_secret('adminpass', salt), active: 1)
Expand Down
4 changes: 3 additions & 1 deletion ns-manager/helpers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ def self.send_dependencies_to_module(s, dep)

def self.send_dependencies_to_manager(manager, depends_on)
depends_on.each do |dep|
dep = dep[:name] if dep.is_a?(Hash)
s = Service.where(name: dep).first
begin
RestClient.post manager[:host] + ':' + manager[:port].to_s + '/modules/services', dep.to_json, :content_type => :json, 'X-Auth-Token' => manager['token']
RestClient.post manager[:host] + ':' + manager[:port].to_s + '/modules/services', s.to_json, :content_type => :json, 'X-Auth-Token' => manager['token']
rescue => e
logger.error e
end
Expand Down
4 changes: 2 additions & 2 deletions ns-manager/helpers/dc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module DcHelper
# @return [String] the object converted into the expected format.
def getDcs()
begin
return Dc.all.to_json
return Dc.all
rescue => e
logger.error e
logger.error 'Error Establishing a Database Connection'
Expand All @@ -43,7 +43,7 @@ def getDc(id)
logger.error 'DC not found'
return 404
end
return dc.to_json
return dc
end

def getDcsTokens()
Expand Down
3 changes: 1 addition & 2 deletions ns-manager/routes/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class ServiceConfiguration < TnovaManager
logger.debug "Service found but is down."
s.destroy
else
depends_on << { name: s['name'], host: s['host'], port: s['port'], token: s['token'], depends_on: s['depends_on'] }
depends_on << { name: s['name'], host: s['host'], port: s['port'], token: s['token'], depends_on: s['depends_on'], type: s['type'] }
end
rescue Mongoid::Errors::DocumentNotFound => e
logger.error 'Service not found.'
Expand All @@ -117,7 +117,6 @@ class ServiceConfiguration < TnovaManager

logger.debug 'Find services that have this module as dependency:'
dependencies = Service.any_of(depends_on: serv[:name]).entries
logger.debug dependencies
if dependencies.any?
dependencies.each do |dependency|
ServiceConfigurationHelper.send_dependencies_to_module(dependency, serv)
Expand Down
122 changes: 49 additions & 73 deletions ns-manager/routes/monitoring.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,84 +17,60 @@
#
# @see TnovaManager
class NsMonitoring < TnovaManager
# @method get_instances_monitoring_data
# @overload get '/instances/:instance_id/monitoring-data/'
# Get monitoring data given instance type and/or metrics
# @param [string] instance_type
# @param [string] instance_id
# @param [string] metric
get '/:instance_id/monitoring-data/' do |instance_id|
if params['instance_type'] == 'ns'
monitoring, errors = ServiceConfigurationHelper.get_module('ns_monitoring')
halt 500, errors if errors
composedUrl = "/ns-monitoring/#{instance_id}/monitoring-data/?" + request.env['QUERY_STRING']
elsif params['instance_type'] == 'vnf'
monitoring, errors = ServiceConfigurationHelper.get_module('vnf_manager')
halt 500, errors if errors
composedUrl = "/vnf-monitoring/#{instance_id}/monitoring-data/?" + request.env['QUERY_STRING']
end

# @method get_instances_monitoring_data
# @overload get '/instances/:instance_id/monitoring-data/'
# Get monitoring data given instance type and/or metrics
# @param [string] instance_type
# @param [string] instance_id
# @param [string] metric
get '/:instance_id/monitoring-data/' do
if params['instance_type'] == 'ns'
monitoring, errors = ServiceConfigurationHelper.get_module('ns_monitoring')
halt 500, errors if errors
composedUrl = "/ns-monitoring/"+params['instance_id'].to_s+"/monitoring-data/?"+request.env['QUERY_STRING']
elsif params['instance_type'] == 'vnf'
monitoring, errors = ServiceConfigurationHelper.get_module('vnf_manager')
halt 500, errors if errors
composedUrl = "/vnf-monitoring/"+params['instance_id'].to_s+"/monitoring-data/?"+request.env['QUERY_STRING']
end
begin
response = RestClient.get monitoring.host + composedUrl.to_s, 'X-Auth-Token' => monitoring.token, :content_type => :json
rescue Errno::ECONNREFUSED
halt 500, 'NS Monitoring unreachable'
rescue => e
logger.error e
# halt e.response.code, e.response.body
end

if (params["metric"])
#composedUrl = composedUrl + "/" + params["metric"]
end
begin
response = RestClient.get monitoring.host + composedUrl.to_s, 'X-Auth-Token' => monitoring.token, :content_type => :json
rescue Errno::ECONNREFUSED
halt 500, 'NS Monitoring unreachable'
rescue => e
logger.error e
#halt e.response.code, e.response.body
end
#return response.code, response.body
logger.debug response
if response.nil?
return 200
return 200 if response.nil?
return 200, response.body
end

# @method get_monitoring_data_last100
# @overload get '/instances/:instance_id/monitoring-data/last100'
# Get last 100 values
# @param [string] Instance id
get '/:instance_id/monitoring-data/last100/' do |instance_id|
if params['instance_type'] == 'ns'
monitoring, errors = ServiceConfigurationHelper.get_module('ns_monitoring')
halt 500, errors if errors
composedUrl = "/ns-monitoring/#{instance_id}/monitoring-data/last100/?" + request.env['QUERY_STRING']
elsif params['instance_type'] == 'vnf'
monitoring, errors = ServiceConfigurationHelper.get_module('vnf_manager')
halt 500, errors if errors
composedUrl = "/vnf-monitoring/#{instance_id}/monitoring-data/last100/?" + request.env['QUERY_STRING']
end

return 200, response.body
end

#/instances/:instance_id/monitoring-data/?instance_type=ns&metric
=begin
{
"nsi_id": "123",
"external_parameter_id": "987",
"value": "10.5"
}
=end
post '/ns-manager/sla-breaches' do

end

# @method get_monitoring_data_last100
# @overload get '/instances/:instance_id/monitoring-data/last100'
# Get last 100 values
# @param [string] Instance id
get '/:instance_id/monitoring-data/last100/' do
begin
response = RestClient.get monitoring.host + composedUrl.to_s, 'X-Auth-Token' => monitoring.token, :content_type => :json
rescue Errno::ECONNREFUSED
halt 500, 'NS Monitoring unreachable'
rescue => e
logger.error e.response
halt e.response.code, e.response.body
end

if params['instance_type'] == 'ns'
monitoring, errors = ServiceConfigurationHelper.get_module('ns_monitoring')
halt 500, errors if errors
composedUrl = "/ns-monitoring/"+params['instance_id'].to_s+"/monitoring-data/last100/?"+request.env['QUERY_STRING']
elsif params['instance_type'] == 'vnf'
monitoring, errors = ServiceConfigurationHelper.get_module('vnf_manager')
halt 500, errors if errors
composedUrl = "/vnf-monitoring/"+params['instance_id'].to_s+"/monitoring-data/last100/?"+request.env['QUERY_STRING']
return response
end

begin
response = RestClient.get monitoring.host + composedUrl.to_s, 'X-Auth-Token' => monitoring.token, :content_type => :json
rescue Errno::ECONNREFUSED
halt 500, 'NS Monitoring unreachable'
rescue => e
logger.error e.response
halt e.response.code, e.response.body
end

return response
end


end
9 changes: 6 additions & 3 deletions ns-manager/routes/ns_provisioning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,27 @@ class NsProvisioner < TnovaManager
pop_list = []
mapping_info = {}
if instantiation_info['pop_id'].nil?
pop_list = JSON.parse(getDcs())
if pop_list.empty?
available_pops = getDcs()
if available_pops.empty?
halt 400, "No PoPs registereds."
end
if !instantiation_info['mapping_id'].nil?
#using the Mapping algorithm specified in the instantiation request
mapping = ServiceConfigurationHelper.get_module_by_id(instantiation_info['mapping_id'])
mapping_info = mapping.host + ":" + mapping.port.to_s + mapping.path
pop_list = available_pops
elsif pop_list.size > 1
#using the first mapping algorithm
mapping, errors = ServiceConfigurationHelper.get_module_by_type('mapping')
mapping_info = mapping.host + ":" + mapping.port.to_s + mapping.path
pop_list = available_pops
else
#deploy to the unic PoP
pop_list << getDc(available_pops[0]['id'])
end
else
#deploying the Instance into the requested PoP
pop_list << JSON.parse(getDc(instantiation_info['pop_id']))
pop_list << getDc(instantiation_info['pop_id'])
end

infr_repo_url, errors = ServiceConfigurationHelper.get_module_by_type('infr_repo')
Expand Down
Loading

0 comments on commit f7f716c

Please sign in to comment.