Search in sources :

Example 1 with OdlMappingserviceService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceService in project lispflowmapping by opendaylight.

the class SubnetDataProcessor method create.

/**
 * Method adds the newly created subnet as an EID prefix to the
 * MappingService. The subnet's network UUID is used as the key for this EID
 * prefix.
 */
@Override
public void create(Subnet subnet) {
    // TODO update for multi-tenancy
    LOG.info("Neutron Subnet Created request : Subnet name: " + subnet.getName() + " Subnet Cidr: " + subnet.getCidr());
    LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
    // Determine the IANA code for the subnet IP version
    // Default is set to IPv4 for neutron subnets
    final Eid eid = LispAddressUtil.asIpv4PrefixEid(String.valueOf(subnet.getCidr().getValue()));
    try {
        final OdlMappingserviceService lfmdb = lispNeutronService.getMappingDbService();
        if (lfmdb == null) {
            LOG.debug("lfmdb is null!!!");
            return;
        }
        final AddKeyInput addKeyInput = LispUtil.buildAddKeyInput(eid, subnet.getUuid().getValue());
        final Future<RpcResult<Void>> result = lfmdb.addKey(addKeyInput);
        final Boolean isSuccessful = result.get().isSuccessful();
        if (isSuccessful) {
            LOG.debug("Neutron Subnet Added to MapServer : Subnet name: " + subnet.getName() + " EID Prefix: " + subnet.getCidr() + " Key: " + subnet.getUuid());
        }
        LOG.info("Neutron Subnet Created request : Subnet name: " + subnet.getName() + " Subnet Cidr: " + subnet.getCidr());
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Adding new subnet to lisp service mapping service failed. Subnet : " + subnet.toString() + "Error: " + ExceptionUtils.getStackTrace(e));
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) AddKeyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) OdlMappingserviceService(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceService) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with OdlMappingserviceService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceService in project lispflowmapping by opendaylight.

the class SubnetDataProcessor method delete.

/**
 * Method removes the EID prefix and key associated with the deleted subnet
 * from Lisp mapping service.
 */
@Override
public void delete(Subnet subnet) {
    LOG.info("Neutron Subnet Deleted Request : Subnet name: " + subnet.getName() + " Subnet Cidr: " + subnet.getCidr() + "Key: " + subnet.getUuid());
    LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
    // Determine the IANA code for the subnet IP version
    // Default is set to IPv4 for neutron subnets
    final Eid eid = LispAddressUtil.asIpv4PrefixEid(String.valueOf(subnet.getCidr().getValue()));
    try {
        final OdlMappingserviceService lfmdb = lispNeutronService.getMappingDbService();
        if (lfmdb == null) {
            LOG.debug("lfmdb is null!!!");
            return;
        }
        final RemoveKeyInput removeKeyInput = LispUtil.buildRemoveKeyInput(eid);
        final Future<RpcResult<Void>> result = lfmdb.removeKey(removeKeyInput);
        final Boolean isSuccessful = result.get().isSuccessful();
        if (isSuccessful) {
            LOG.debug("Neutron Subnet Deleted from MapServer : Subnet name: " + subnet.getName() + " Eid Prefix: " + subnet.getCidr() + " Key: " + subnet.getUuid());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Deleting subnet's EID prefix from mapping service failed + Subnet: " + subnet.toString() + "Error: " + ExceptionUtils.getStackTrace(e));
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) OdlMappingserviceService(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceService) RemoveKeyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKeyInput) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)2 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)2 OdlMappingserviceService (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceService)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 AddKeyInput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInput)1 RemoveKeyInput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKeyInput)1