コード例 #1
0
ファイル: wicm.py プロジェクト: T-NOVA/WICM
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_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
コード例 #4
0
ファイル: wicm.py プロジェクト: T-NOVA/WICM
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