*
*/
public class LispNeutronSubnetHandler extends LispNeutronService implements
- INeutronSubnetAware {
- private static final Integer SIX = Integer.valueOf(6);
-
- // The implementation for each of these services is resolved by the OSGi
- // Service Manager
- private volatile ILispNeutronService lispNeutronService;
-
- @Override
- public int canCreateSubnet(NeutronSubnet subnet) {
- LOG.info("Neutron canCreateSubnet : Subnet name: " + subnet.getName()
- + " Subnet Cidr: " + subnet.getCidr());
- LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
- if (SIX.equals(subnet.getIpVersion())) {
- return HttpURLConnection.HTTP_PARTIAL;
- }
- return HttpURLConnection.HTTP_OK;
- }
-
- /**
- * 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 neutronSubnetCreated(NeutronSubnet 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
-
- Eid eid = LispAddressUtil.asIpv4PrefixEid(subnet.getCidr());
-
- try {
-
- lispNeutronService.getMappingDbService().addKey(LispUtil.buildAddKeyInput(eid, subnet.getNetworkUUID()));
-
- LOG.debug("Neutron Subnet Added to MapServer : Subnet name: "
- + subnet.getName() + " EID Prefix: "
- + subnet.getCidr() + " Key: "
- + subnet.getNetworkUUID());
- } catch (Exception e) {
- LOG.error("Adding new subnet to lisp service mapping service failed. Subnet : "
- + subnet.toString() + "Error: " + ExceptionUtils.getStackTrace(e));
- }
+ INeutronSubnetAware {
+ private static final Integer SIX = Integer.valueOf(6);
+
+ // The implementation for each of these services is resolved by the OSGi
+ // Service Manager
+ private volatile ILispNeutronService lispNeutronService;
+
+ @Override
+ public int canCreateSubnet(NeutronSubnet subnet) {
+ LOG.info("Neutron canCreateSubnet : Subnet name: " + subnet.getName()
+ + " Subnet Cidr: " + subnet.getCidr());
+ LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
+ if (SIX.equals(subnet.getIpVersion())) {
+ return HttpURLConnection.HTTP_PARTIAL;
+ }
+ return HttpURLConnection.HTTP_OK;
+ }
+
+ /**
+ * 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 neutronSubnetCreated(NeutronSubnet 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
+
+ Eid eid = LispAddressUtil.asIpv4PrefixEid(subnet.getCidr());
+
+ try {
+
+ lispNeutronService.getMappingDbService().addKey(LispUtil.buildAddKeyInput(eid, subnet.getNetworkUUID()));
+
+ LOG.debug("Neutron Subnet Added to MapServer : Subnet name: "
+ + subnet.getName() + " EID Prefix: "
+ + subnet.getCidr() + " Key: "
+ + subnet.getNetworkUUID());
+ } catch (Exception e) {
+ LOG.error("Adding new subnet to lisp service mapping service failed. Subnet : "
+ + subnet.toString() + "Error: " + ExceptionUtils.getStackTrace(e));
+ }
LOG.info("Neutron Subnet Created request : Subnet name: "
+ subnet.getName() + " Subnet Cidr: " + subnet.getCidr());
- }
-
- /**
- * Method to check whether new Subnet can be created by LISP implementation
- * of Neutron service API. Since we store the Cidr part of the subnet as the
- * main key to the Lisp mapping service, we do not support updates to
- * subnets that change it's cidr.
- */
- @Override
- public int canUpdateSubnet(NeutronSubnet delta, NeutronSubnet original) {
- if (delta == null || original == null) {
- LOG.error("Neutron canUpdateSubnet rejected: subnet objects were null");
- return HttpURLConnection.HTTP_BAD_REQUEST;
- }
- LOG.info("Neutron canUpdateSubnet : Subnet name: " + original.getName()
- + " Subnet Cidr: " + original.getCidr());
- LOG.debug("Lisp Neutron Subnet update: original : "
- + original.toString() + " delta : " + delta.toString());
-
- // We do not accept a Subnet update that changes the cidr. If cider or
- // network UUID is changed, return error.
- if (!(original.getCidr().equals(delta.getCidr()))) {
- LOG.error("Neutron canUpdateSubnet rejected: Subnet name: "
- + original.getName() + " Subnet Cidr: "
- + original.getCidr());
- return HttpURLConnection.HTTP_CONFLICT;
- }
- return HttpURLConnection.HTTP_OK;
- }
-
- @Override
- public void neutronSubnetUpdated(NeutronSubnet subnet) {
- // Nothing to do here.
- }
-
- /**
- * Method to check if subnet can be deleted. Returns error only if subnet
- * does not exist in the lisp mapping service.
- */
- @Override
- public int canDeleteSubnet(NeutronSubnet subnet) {
- LOG.info("Neutron canDeleteSubnet : Subnet name: " + subnet.getName()
- + " Subnet Cidr: " + subnet.getCidr() + "Key: "
- + subnet.getNetworkUUID());
- LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
-
-
- return HttpURLConnection.HTTP_OK;
- }
-
- /**
- * Method removes the EID prefix and key associated with the deleted subnet
- * from Lisp mapping service.
- */
- @Override
- public void neutronSubnetDeleted(NeutronSubnet subnet) {
- LOG.info("Neutron Subnet Deleted Request : Subnet name: "
- + subnet.getName() + " Subnet Cidr: " + subnet.getCidr()
- + "Key: " + subnet.getNetworkUUID());
- LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
-
- // Determine the IANA code for the subnet IP version
- // Default is set to IPv4 for neutron subnets
-
- Eid eid = LispAddressUtil.asIpv4PrefixEid(subnet.getCidr());
+ }
+
+ /**
+ * Method to check whether new Subnet can be created by LISP implementation
+ * of Neutron service API. Since we store the Cidr part of the subnet as the
+ * main key to the Lisp mapping service, we do not support updates to
+ * subnets that change it's cidr.
+ */
+ @Override
+ public int canUpdateSubnet(NeutronSubnet delta, NeutronSubnet original) {
+ if (delta == null || original == null) {
+ LOG.error("Neutron canUpdateSubnet rejected: subnet objects were null");
+ return HttpURLConnection.HTTP_BAD_REQUEST;
+ }
+ LOG.info("Neutron canUpdateSubnet : Subnet name: " + original.getName()
+ + " Subnet Cidr: " + original.getCidr());
+ LOG.debug("Lisp Neutron Subnet update: original : "
+ + original.toString() + " delta : " + delta.toString());
+
+ // We do not accept a Subnet update that changes the cidr. If cider or
+ // network UUID is changed, return error.
+ if (!(original.getCidr().equals(delta.getCidr()))) {
+ LOG.error("Neutron canUpdateSubnet rejected: Subnet name: "
+ + original.getName() + " Subnet Cidr: "
+ + original.getCidr());
+ return HttpURLConnection.HTTP_CONFLICT;
+ }
+ return HttpURLConnection.HTTP_OK;
+ }
+
+ @Override
+ public void neutronSubnetUpdated(NeutronSubnet subnet) {
+ // Nothing to do here.
+ }
+
+ /**
+ * Method to check if subnet can be deleted. Returns error only if subnet
+ * does not exist in the lisp mapping service.
+ */
+ @Override
+ public int canDeleteSubnet(NeutronSubnet subnet) {
+ LOG.info("Neutron canDeleteSubnet : Subnet name: " + subnet.getName()
+ + " Subnet Cidr: " + subnet.getCidr() + "Key: "
+ + subnet.getNetworkUUID());
+ LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
+
+
+ return HttpURLConnection.HTTP_OK;
+ }
+
+ /**
+ * Method removes the EID prefix and key associated with the deleted subnet
+ * from Lisp mapping service.
+ */
+ @Override
+ public void neutronSubnetDeleted(NeutronSubnet subnet) {
+ LOG.info("Neutron Subnet Deleted Request : Subnet name: "
+ + subnet.getName() + " Subnet Cidr: " + subnet.getCidr()
+ + "Key: " + subnet.getNetworkUUID());
+ LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
+
+ // Determine the IANA code for the subnet IP version
+ // Default is set to IPv4 for neutron subnets
+
+ Eid eid = LispAddressUtil.asIpv4PrefixEid(subnet.getCidr());
try {
lispNeutronService.getMappingDbService().removeKey(LispUtil.buildRemoveKeyInput(eid));
- LOG.debug("Neutron Subnet Deleted from MapServer : Subnet name: "
- + subnet.getName() + " Eid Prefix: "
- + subnet.getCidr() + " Key: "
- + subnet.getNetworkUUID());
- } catch (Exception e) {
- LOG.error("Deleting subnet's EID prefix from mapping service failed + Subnet: "
- + subnet.toString() + "Error: " + ExceptionUtils.getStackTrace(e));
- }
- }
+ LOG.debug("Neutron Subnet Deleted from MapServer : Subnet name: "
+ + subnet.getName() + " Eid Prefix: "
+ + subnet.getCidr() + " Key: "
+ + subnet.getNetworkUUID());
+ } catch (Exception e) {
+ LOG.error("Deleting subnet's EID prefix from mapping service failed + Subnet: "
+ + subnet.toString() + "Error: " + ExceptionUtils.getStackTrace(e));
+ }
+ }
}