Merge pull request #414 from pberde/master

Port up/down will update port status to ACTIVE/INACTIVE.
diff --git a/README.md b/README.md
index 516091e..70683fb 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 ONOS (Open Networking Operating System)
 =======================================
 
-ONOS (Open Network Operating System) is an experimental distributed SDN OS. ONOS is under development. ONOS was announced and demonstrated at ONS'13.
+ONOS (Open Networking Operating System) is an experimental distributed SDN OS. ONOS is under development. ONOS was announced and demonstrated at ONS'13.
 
 Steps to download and setup development VM
 ==========================================
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java
index 6e42771..c37fad2 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java
@@ -207,7 +207,7 @@
     	IPortObject srcPort = dbop.searchPort(HexString.toHexString(dpid), port);
     	ISwitchObject srcSw = srcPort.getSwitch();
     	
-    	if(srcSw != null) {
+    	if(srcSw != null && srcPort != null) {
         	for(IPortObject dstPort : srcPort.getLinkedPorts()) {
         		ISwitchObject dstSw = dstPort.getSwitch();
         		Link link = new Link(HexString.toLong(srcSw.getDPID()),
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
index 126efb3..3374fa7 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
@@ -167,7 +167,11 @@
             	IPortObject p = op.searchPort(dpid, port.getPortNumber());
             	log.info("SwitchStorage:addPort dpid:{} port:{}", dpid, port.getPortNumber());
             	if (p != null) {
-            		log.error("SwitchStorage:addPort dpid:{} port:{} exists", dpid, port.getPortNumber());
+            		log.error("SwitchStorage:addPort dpid:{} port:{} exists setting as ACTIVE", dpid, port.getPortNumber());
+            		p.setState("ACTIVE");
+            		p.setPortState(port.getState());
+            		p.setDesc(port.getName());
+            		op.commit();
             	} else {
             		p = op.newPort(dpid, port.getPortNumber());
             		p.setState("ACTIVE");
@@ -200,9 +204,8 @@
             if (sw != null) {
             	IPortObject p = op.searchPort(dpid, port);
                 if (p != null) {
-            		log.info("SwitchStorage:deletePort dpid:{} port:{} found and deleted", dpid, port);
-            		sw.removePort(p);
-            		op.removePort(p);
+            		log.info("SwitchStorage:deletePort dpid:{} port:{} found and set INACTIVE", dpid, port);
+            		p.setState("INACTIVE");
             		op.commit();
             	}
             }