Rename static final variable 'logger' to 'LOG'
[lispflowmapping.git] / mappingservice / neutron / src / main / java / org / opendaylight / lispflowmapping / neutron / LispNeutronPortHandler.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.lispflowmapping.neutron;
10
11 import java.net.HttpURLConnection;
12
13 import org.opendaylight.neutron.spi.INeutronPortAware;
14 import org.opendaylight.neutron.spi.NeutronPort;
15
16 /**
17  * Lisp Service implementation of NeutronPortAware API
18  * Creation of a new port results adding the mapping for
19  * the port's IP addresses to the port's host_ip in the mapping service.
20  * Currently the NetronPort object does not carry the required information
21  * to achieve the port's host_ip. Once such extension is available
22  * this class shall be updated.
23  *
24  */
25 public class LispNeutronPortHandler extends LispNeutronService implements INeutronPortAware {
26
27
28         @Override
29         public int canCreatePort(NeutronPort port) {
30         LOG.info("Neutron canCreatePort : Port name: " + port.getName());
31
32         return HttpURLConnection.HTTP_OK;
33         }
34
35         @Override
36         public void neutronPortCreated(NeutronPort port) {
37                 // TODO Consider adding Port MAC -> Port fixed IP in MS
38                 // TODO Add Port fixed ip -> host ip mapping in MS - Requires extension of Port object
39
40         LOG.info("Neutron Port Created: Port name: " + port.getName() + " Port Fixed IP: " +
41                         ( port.getFixedIPs() != null ? port.getFixedIPs().get(0) : "No Fixed IP assigned" ));
42         LOG.debug("Neutron Port Created : " + port.toString());
43
44         }
45
46         @Override
47         public int canUpdatePort(NeutronPort delta, NeutronPort original) {
48                 // TODO Port IP and port's host ip is stored by Lisp Neutron Service. If there is change to these fields, the update needs to be processed.
49
50                 LOG.info("Neutron canUpdatePort : Port name: " + original.getName() + " Port Fixed IP: " +
51                                 ( original.getFixedIPs() != null ? original.getFixedIPs().get(0) : "No Fixed IP assigned" ));
52                 LOG.debug("Neutron canUpdatePort : original" + original.toString() + " delta : " + delta.toString());
53
54         return HttpURLConnection.HTTP_OK;
55         }
56
57         @Override
58         public void neutronPortUpdated(NeutronPort port) {
59                 // TODO Port IP and port's host ip is stored by Lisp Neutron Service. If there is change to these fields, the update needs to be processed.
60
61                 LOG.info("Neutron Port updated: Port name: " + port.getName() + " Port Fixed IP: " +
62                         ( port.getFixedIPs() != null ? port.getFixedIPs().get(0) : "No Fixed IP assigned" ));
63                 LOG.debug("Neutron Port Updated : " + port.toString());
64
65         }
66
67         @Override
68         public int canDeletePort(NeutronPort port) {
69                 // TODO Check if Port IPs are stored by Lisp Neutron Service. if not return error code.
70
71                 LOG.info("Neutron canDeletePort : Port name: " + port.getName() + " Port Fixed IP: " +
72                         ( port.getFixedIPs() != null ? port.getFixedIPs().get(0) : "No Fixed IP assigned" ));
73                 LOG.debug("Neutron canDeltePort: " + port.toString());
74
75                 return HttpURLConnection.HTTP_OK;
76         }
77
78         @Override
79         public void neutronPortDeleted(NeutronPort port) {
80                 // TODO if port ips existed in MapServer, delete them. Else, log error.
81
82                 LOG.info("Neutron Port Deleted: Port name: " + port.getName() + " Port Fixed IP: " +
83                         ( port.getFixedIPs() != null ? port.getFixedIPs().get(0) : "No Fixed IP assigned" ));
84                 LOG.debug("Neutron Port Deleted : " + port.toString());
85
86         }
87 }