Пример #1
0
def service_request_delete(ns_instance_id=None):
    try:
        logger.info('Request delete Service: {}'.format(ns_instance_id))

        service_info = service.get(ns_instance_id)[0]
    except Exception:
        logger.error('Request delete Service {} failed : Service not found'
                     .format(ns_instance_id))
        return jsonify({'error': 'Service {} not found!'
                        .format(ns_instance_id)}), 400

    if service_info['status'] not in ['ALLOCATED', 'ACTIVE']:

        logger.error(('Request delete Service {} failed : Service'
                     'not in deletable state').format(ns_instance_id))

        return jsonify({'error': 'Service {} is not in deletable state!'
                        .format(ns_instance_id)}), 400

    service.set_status(ns_instance_id, 'TERMINATING')

    if service_info['status'] == 'ACTIVE':
        vtn.chain_delete(service_info['client_mkt_id'], ns_instance_id,
                         service_info['nap_mkt_id'])

    service.delete_service(ns_instance_id)
    logger.info('Service: {} deleted!'.format(ns_instance_id))
    return jsonify({'deleted': {'ns_instance_id': ns_instance_id}}), 200
Пример #2
0
def service_request_delete(ns_instance_id=None):
    try:
        logger.info('Request delete Service: {}'.format(ns_instance_id))

        service_info = service.get(ns_instance_id)[0]
    except Exception:
        logger.error('Request delete Service {} failed : Service not found'
                     .format(ns_instance_id))
        return jsonify({'error': 'Service {} not found!'
                        .format(ns_instance_id)}), 400

    if service_info['status'] not in ['ALLOCATED', 'ACTIVE']:

        logger.error(('Request delete Service {} failed : Service'
                     'not in deletable state').format(ns_instance_id))

        return jsonify({'error': 'Service {} is not in deletable state!'
                        .format(ns_instance_id)}), 400

    service.set_status(ns_instance_id, 'TERMINATING')

    if service_info['status'] == 'ACTIVE':
        vtn.chain_delete(service_info['client_mkt_id'], ns_instance_id,
                         service_info['nap_mkt_id'])

    service.delete_service(ns_instance_id)
    logger.info('Service: {} deleted!'.format(ns_instance_id))
    return jsonify({'deleted': {'ns_instance_id': ns_instance_id}}), 200
Пример #3
0
def service_redirect(odl, mkt_id):

	service_info = service.get(mkt_id)[0]
	nap_info = nap.get(service_info['nap_mkt_id'])[0]
	nfvi_info = nfvi.get(service_info['nfvi_mkt_id'])[0]

	#request new ids
	flows = service.create_service_flows(mkt_id)
	try:
		flow = 0
		odl.redirect(
			flows[flow]['switch'], flows[flow]['of_table'], flows[flow]['of_id'], 
			'SERVICE_{:}_CE_NFVI'.format(mkt_id),
			nap_info['ce_port'], nap_info['ce_transport']['vlan_id'], 
			nfvi_info['ce_port'], service_info['ce_transport']['vlan_id'],
			priority=1000, cookie=0xc01dbabe)

		flow = 1
		odl.redirect(
			flows[flow]['switch'], flows[flow]['of_table'], flows[flow]['of_id'], 
			'SERVICE_{:}_NFVI_CE'.format(mkt_id),
			nfvi_info['ce_port'], service_info['ce_transport']['vlan_id'], 
			nap_info['ce_port'], nap_info['ce_transport']['vlan_id'],
			priority=1000, cookie=0xc01dbabe)

		flow = 2
		odl.redirect(
			flows[flow]['switch'], flows[flow]['of_table'], flows[flow]['of_id'], 
			'SERVICE_{:}_PE_NFVI'.format(mkt_id),
			nap_info['pe_port'], nap_info['pe_transport']['vlan_id'], 
			nfvi_info['pe_port'], service_info['pe_transport']['vlan_id'],
			priority=1000, cookie=0xc01dbabe)

		flow = 3
		odl.redirect(
			flows[flow]['switch'], flows[flow]['of_table'], flows[flow]['of_id'], 
			'SERVICE_{:}_NFVI_PE'.format(mkt_id),
			nfvi_info['pe_port'], service_info['pe_transport']['vlan_id'], 
			nap_info['pe_port'], nap_info['pe_transport']['vlan_id'],
			priority=1000, cookie=0xc01dbabe)
		
	except Exception, e:
		for i in xrange(0, flow):
			odl.delete(
				flows[i]['switch'], 
				flows[i]['of_table'], 
				flows[i]['of_id'])
			service.delete_flows(mkt_id)
		raise e
Пример #4
0
def service_request_put(ns_instance_id=None):
    try:
        logger.info('Request enable Service: {}'.format(ns_instance_id))

        service_info = service.get(ns_instance_id)[0]
    except Exception:
        logger.error('Request enable Service {} failed : Service not found'
                     .format(ns_instance_id))

        return jsonify({'error': 'Service {} not found!'
                        .format(ns_instance_id)}), 400

    if service_info['status'] != 'ALLOCATED':
        logger.error(('Request enable Service {} failed : Service '
                      'not in ALLOCATED state').format(ns_instance_id))

        return jsonify({'error': 'Service {} is not in ALLOCATED state!'
                        .format(ns_instance_id)}), 400
    try:
        ce_pe = []
        for hop in service_info['ce_pe']:
            nfvi_info = nfvi.get(hop['nfvi_mkt_id'])[0]

            ce_pe.append(((nfvi_info['switch'], nfvi_info['port'],
                           hop['transport']['vlan_id'])))

        pe_ce = []
        for hop in service_info['pe_ce']:
            nfvi_info = nfvi.get(hop['nfvi_mkt_id'])[0]

            pe_ce.append(((nfvi_info['switch'], nfvi_info['port'],
                           hop['transport']['vlan_id'])))


        vtn.chain_create(service_info['client_mkt_id'],
                         service_info['ns_instance_id'],
                         service_info['nap_mkt_id'],
                         ce_pe, pe_ce)
    except Exception as ex:
        logger.error('Request enable Service {} failed VTN Manager: {}'
                     .format(ns_instance_id, ex))
        return jsonify({'error': 'Unable to put redirection in place!'}), 500

    logger.info('Service: {} enabled!'.format(ns_instance_id))
    service.set_status(ns_instance_id, 'ACTIVE')

    return jsonify({'activated': {'ns_instance_id': ns_instance_id}}), 201
Пример #5
0
def service_request_put(ns_instance_id=None):
    try:
        logger.info('Request enable Service: {}'.format(ns_instance_id))

        service_info = service.get(ns_instance_id)[0]
    except Exception:
        logger.error('Request enable Service {} failed : Service not found'
                     .format(ns_instance_id))

        return jsonify({'error': 'Service {} not found!'
                        .format(ns_instance_id)}), 400

    if service_info['status'] != 'ALLOCATED':
        logger.error(('Request enable Service {} failed : Service '
                      'not in ALLOCATED state').format(ns_instance_id))

        return jsonify({'error': 'Service {} is not in ALLOCATED state!'
                        .format(ns_instance_id)}), 400
    try:
        interfaces = []
        for nfvi_path in service_info['path']:
            nfvi_info = nfvi.get(nfvi_path['nfvi_mkt_id'])[0]

            interfaces.append(((nfvi_info['switch'], nfvi_info['ce_port'],
                                nfvi_path['ce_transport']['vlan_id']), (
                               nfvi_info['switch'], nfvi_info['pe_port'],
                               nfvi_path['pe_transport']['vlan_id'])))

        vtn.chain_create(service_info['client_mkt_id'],
                         service_info['ns_instance_id'],
                         service_info['nap_mkt_id'],
                         interfaces)
    except Exception as ex:
        logger.error('Request enable Service {} failed VTN Manager: {}'
                     .format(ns_instance_id, ex))
        return jsonify({'error': 'Unable to put redirection in place!'}), 500

    logger.info('Service: {} enabled!'.format(ns_instance_id))
    service.set_status(ns_instance_id, 'ACTIVE')

    return jsonify({'activated': {'ns_instance_id': ns_instance_id}}), 201
Пример #6
0
def service_redirect(odl, mkt_id):

	service_info = service.get(mkt_id)[0]
	nap_info = nap.get(service_info['nap_mkt_id'])[0]
	nfvi_info = nfvi.get(service_info['nfvi_mkt_id'])[0]

	#request new ids
	flows = service.create_service_flows(mkt_id)

	flow = flows[0]
	odl.redirect(
		flow['switch'], flow['of_table'], flow['of_id'], 
		'SERVICE_{:}_CE_NFVI'.format(mkt_id),
		nap_info['ce_port'], nap_info['ce_transport']['vlan_id'], 
		nfvi_info['ce_port'], service_info['ce_transport']['vlan_id'],
		priority=1000, cookie=0xc01dbabe)

	flow = flows[1]
	odl.redirect(
		flow['switch'], flow['of_table'], flow['of_id'], 
		'SERVICE_{:}_NFVI_CE'.format(mkt_id),
		nfvi_info['ce_port'], service_info['ce_transport']['vlan_id'], 
		nap_info['ce_port'], nap_info['ce_transport']['vlan_id'],
		priority=1000, cookie=0xc01dbabe)

	flow = flows[2]
	odl.redirect(
		flow['switch'], flow['of_table'], flow['of_id'], 
		'SERVICE_{:}_PE_NFVI'.format(mkt_id),
		nap_info['pe_port'], nap_info['pe_transport']['vlan_id'], 
		nfvi_info['pe_port'], service_info['pe_transport']['vlan_id'],
		priority=1000, cookie=0xc01dbabe)

	flow = flows[3]
	odl.redirect(
		flow['switch'], flow['of_table'], flow['of_id'], 
		'SERVICE_{:}_NFVI_PE'.format(mkt_id),
		nfvi_info['pe_port'], service_info['pe_transport']['vlan_id'], 
		nap_info['pe_port'], nap_info['pe_transport']['vlan_id'],
		priority=1000, cookie=0xc01dbabe)
Пример #7
0
def service_request_get(ns_instance_id=None):
    logger.info('Request to get Service: {}'.format('id -> {}'.format(
        ns_instance_id) if ns_instance_id else 'All Services'))

    return jsonify({'services': service.get(ns_instance_id)}), 200
Пример #8
0
def service_request_get(ns_instance_id=None):
    logger.info('Request to get Service: {}'.format('id -> {}'.format(
        ns_instance_id) if ns_instance_id else 'All Services'))

    return jsonify({'services': service.get(ns_instance_id)}), 200