Merge branch 'master' of https://github.com/OPENNETWORKINGLAB/ONOS
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/ILinkStorage.java b/src/main/java/net/onrc/onos/ofcontroller/core/ILinkStorage.java
index b56cfef..ce2379b 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/ILinkStorage.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/ILinkStorage.java
@@ -8,33 +8,33 @@
 public interface ILinkStorage extends INetMapStorage {
 	
     /*
-     * Link creation
-     */
-	public void update(Link link, DM_OPERATION op);
-	public void update(Link link, LinkInfo linkinfo, DM_OPERATION op);
-	public void update(List<Link> List, DM_OPERATION op);
-
-	/*
-	 *  Add Linkinfo
+	 * Init with Storage conf
 	 */
-	public void updateLink (Link link, LinkInfo linkinfo, DM_OPERATION op);
+	public void init(String conf);
 	
 	/*
-	 * Delete a single link
+	 * Generic operation method
+	 */
+	public void update(Link link, LinkInfo linkinfo, DM_OPERATION op);
+	
+	/*
+     * Link creation
+     */
+	public void addLink(Link link);
+	public void addLinks(List<Link> links);
+	
+	/*
+	 * Link deletion
 	 */
 	public void deleteLink(Link link);
+	public void deleteLinks(List<Link> links);
 
 	/*
-	 * Delete links associated with dpid and port 
+	 * Utility method to delete links associated with dpid and port 
 	 * If only dpid is used, All links associated for switch are removed
 	 * Useful for port up/down and also switch join/remove events
 	 */ 
 	public void deleteLinksOnPort(Long dpid, short port);
-	
-	/*
-	 * Delete a list of links
-	 */
-	public void deleteLinks(List<Link> links);
 
 	/*
 	 * Get Links from Storage
@@ -44,10 +44,6 @@
 	public List<Link> getLinks(Long dpid, short port);
 	public List<Link> getLinks(String dpid);
 	public List<Link> getActiveLinks();
-	
-	/*
-	 * Init with Storage conf
-	 */
-	public void init(String conf);
 
+	public LinkInfo getLinkInfo(Link link);
 }
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java b/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java
index 4fcebb2..bc50049 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java
@@ -12,6 +12,10 @@
 	}
 	
 	/*
+	 * Initialize
+	 */
+	public void init(String conf);
+	/*
 	 * Update the switch details
 	 */
 	public void update(String dpid,SwitchState state, DM_OPERATION op);
@@ -20,6 +24,10 @@
 	 */
 	public void addPort(String dpid, OFPhysicalPort port);
 	/*
+	 * Delete a port on a switch by num
+	 */
+	public void deletePort(String dpid, short port);
+	/*
 	 * Add a switch and all its associated ports
 	 */
 	public void addSwitch(IOFSwitch sw);
@@ -31,14 +39,6 @@
 	 * Delete switch and associated ports
 	 */
 	public void deleteSwitch(String dpid);
-	/*
-	 * Delete a port on a switch by num
-	 */
-	public void deletePort(String dpid, short port);
-	/*
-	 * Initialize
-	 */
-	public void init(String conf);
 	
 
 }
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 8ee346b..753563e 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
@@ -20,32 +20,117 @@
 import com.tinkerpop.pipes.transform.PathPipe;
 
 /**
- * This is the class for storing the information of links into CassandraDB
+ * This is the class for storing the information of links into GraphDB
  */
 public class LinkStorageImpl implements ILinkStorage {
 	
 	protected static Logger log = LoggerFactory.getLogger(LinkStorageImpl.class);
 	protected GraphDBOperation dbop;
 
+	
+	/**
+	 * Initialize the object. Open LinkStorage using given configuration file.
+	 * @param conf Path (absolute path for now) to configuration file.
+	 */
+	@Override
+	public void init(String conf) {
+		this.dbop = new GraphDBOperation(conf);
+	}
+
 	/**
 	 * Update a record in the LinkStorage in a way provided by op.
 	 * @param link Record of a link to be updated.
 	 * @param op Operation to be done.
 	 */
 	@Override
-	public void update(Link link, DM_OPERATION op) {
-		update(link, (LinkInfo)null, op);
+	public void update(Link link, LinkInfo linkinfo, DM_OPERATION op) {
+		switch (op) {
+		case CREATE:
+		case INSERT:
+			addLinkImpl(link,op);
+			break;
+		case UPDATE:
+			if (linkinfo != null) {
+				setLinkInfo(link, linkinfo);
+			} else {
+				deleteLinkInfo(link);
+			}
+			break;
+		case DELETE:
+			deleteLink(link);
+			break;
+		}
 	}
 
+	@Override
+	public void addLink(Link link) {
+		addLinkImpl(link, DM_OPERATION.INSERT);
+	}
+	
 	/**
 	 * Update multiple records in the LinkStorage in a way provided by op.
 	 * @param links List of records to be updated.
 	 * @param op Operation to be done.
 	 */
 	@Override
-	public void update(List<Link> links, DM_OPERATION op) {
+	public void addLinks(List<Link> links) {
 		for (Link lt: links) {
-			update(lt, (LinkInfo)null, op);
+			addLinkImpl(lt, DM_OPERATION.INSERT);
+		}
+	}
+
+	/**
+		 * Delete a record in the LinkStorage.
+		 * @param lt Record to be deleted.
+		 */
+		@Override
+		public void deleteLink(Link lt) {
+			IPortObject vportSrc = null, vportDst = null;
+			
+			log.debug("deleteLink(): {}", lt);
+			
+	        try {
+	            // get source port vertex
+	         	String dpid = HexString.toHexString(lt.getSrc());
+	         	short port = lt.getSrcPort();
+	         	vportSrc = dbop.searchPort(dpid, port);
+	            
+	            // get dst port vertex
+	         	dpid = HexString.toHexString(lt.getDst());
+	         	port = lt.getDstPort();
+	         	vportDst = dbop.searchPort(dpid, port);
+	     		// FIXME: This needs to remove all edges
+	         	
+	         	if (vportSrc != null && vportDst != null) {
+	         		vportSrc.removeLink(vportDst);
+	        		dbop.commit();
+	            	log.debug("deleteLink(): deleted edges src {} dst {}", new Object[]{
+	            			lt, vportSrc, vportDst});
+	            	
+	        		// TODO publish DELETE_LINK event here
+	            } else {
+	            	log.error("deleteLink(): failed invalid vertices {} src {} dst {}", new Object[]{lt, vportSrc, vportDst});
+	            	dbop.rollback();
+	            }
+	         	
+	        } catch (TitanException e) {
+	            /*
+	             * retry till we succeed?
+	             */
+	        	log.error("deleteLink(): titan exception {} {}", new Object[]{lt, e.toString()});
+	        	dbop.rollback();
+	        	e.printStackTrace();
+	        }
+		}
+
+	/**
+	 * Delete multiple records in LinkStorage.
+	 * @param links List of records to be deleted.
+	 */
+	@Override
+	public void deleteLinks(List<Link> links) {
+		for (Link lt : links) {
+			deleteLink(lt);
 		}
 	}
 
@@ -55,30 +140,28 @@
 	 * @param linkinfo Meta-information of a link to be updated.
 	 * @param op Operation to be done.
 	 */
-	@Override
-	public void update(Link link, LinkInfo linkinfo, DM_OPERATION op) {
-		switch (op) {
-		case UPDATE:
-		case CREATE:
-		case INSERT:
-			updateLink(link, linkinfo, op);
-			break;
-		case DELETE:
-			deleteLink(link);
-			break;
-		}
+	private void setLinkInfo(Link link, LinkInfo linkinfo) {
+		// TODO implement this
+		
+		// TODO publish UPDATE_LINK event here
 	}
 	
+	private void deleteLinkInfo(Link link) {
+		// TODO implement this
+		
+		// TODO publish UPDATE_LINK event here
+	}
+
 	/**
 	 * Perform INSERT/CREATE/UPDATE operation to update the LinkStorage.
 	 * @param lt Record of a link to be updated.
 	 * @param linkinfo Meta-information of a link to be updated.
 	 * @param op Operation to be done. (only INSERT/CREATE/UPDATE is acceptable)
 	 */
-	public void updateLink(Link lt, LinkInfo linkinfo, DM_OPERATION op) {
+	private void addLinkImpl(Link lt, DM_OPERATION op) {
 		IPortObject vportSrc = null, vportDst = null;
 	
-		log.trace("updateLink(): op {} {} {}", new Object[]{op, lt, linkinfo});
+		log.trace("updateLink(): op {} {}", new Object[]{op, lt});
 		
         try {
             // get source port vertex
@@ -101,7 +184,6 @@
             	}
 
             	if (currLinks.contains(vportDst)) {
-            		// TODO: update linkinfo
             		if (op.equals(DM_OPERATION.INSERT) || op.equals(DM_OPERATION.CREATE)) {
             			log.debug("addOrUpdateLink(): failed link exists {} {} src {} dst {}", 
             					new Object[]{op, lt, vportSrc, vportDst});
@@ -111,6 +193,8 @@
 
             		dbop.commit();
             		log.debug("updateLink(): link added {} {} src {} dst {}", new Object[]{op, lt, vportSrc, vportDst});
+            		
+            		// TODO publish ADD_LINK event here
             	}
             } else {
             	log.error("updateLink(): failed invalid vertices {} {} src {} dst {}", new Object[]{op, lt, vportSrc, vportDst});
@@ -126,78 +210,11 @@
 	}
 	
 	/**
-	 * Delete multiple records in LinkStorage.
-	 * @param links List of records to be deleted.
-	 */
-	@Override
-	public void deleteLinks(List<Link> links) {
-
-		for (Link lt : links) {
-			deleteLink(lt);
-		}
-	}
-	
-	/**
-	 * Delete a record in the LinkStorage.
-	 * @param lt Record to be deleted.
-	 */
-	@Override
-	public void deleteLink(Link lt) {
-		IPortObject vportSrc = null, vportDst = null;
-		
-		log.debug("deleteLink(): {}", lt);
-		
-        try {
-            // get source port vertex
-         	String dpid = HexString.toHexString(lt.getSrc());
-         	short port = lt.getSrcPort();
-         	vportSrc = dbop.searchPort(dpid, port);
-            
-            // get dst port vertex
-         	dpid = HexString.toHexString(lt.getDst());
-         	port = lt.getDstPort();
-         	vportDst = dbop.searchPort(dpid, port);
-     		// FIXME: This needs to remove all edges
-         	
-         	if (vportSrc != null && vportDst != null) {
-/*
-        		int count = 0;
-         		for (Edge e : vportSrc.asVertex().getEdges(Direction.OUT)) {
-         			log.debug("deleteLink(): {} in {} out {}", 
-         					new Object[]{e.getLabel(), e.getVertex(Direction.IN), e.getVertex(Direction.OUT)});
-         			if (e.getLabel().equals("link") && e.getVertex(Direction.IN).equals(vportDst)) {
-         				graph.removeEdge(e);
-         				count++;
-         			}
-         		}
-*/
-         		vportSrc.removeLink(vportDst);
-        		dbop.commit();
-            	log.debug("deleteLink(): deleted edges src {} dst {}", new Object[]{
-            			lt, vportSrc, vportDst});
-            	
-            } else {
-            	log.error("deleteLink(): failed invalid vertices {} src {} dst {}", new Object[]{lt, vportSrc, vportDst});
-            	dbop.rollback();
-            }
-         	
-        } catch (TitanException e) {
-            /*
-             * retry till we succeed?
-             */
-        	log.error("deleteLink(): titan exception {} {}", new Object[]{lt, e.toString()});
-        	dbop.rollback();
-        	e.printStackTrace();
-        }
-	}
-
-	/**
 	 * Get list of all links connected to the port specified by given DPID and port number.
 	 * @param dpid DPID of desired port.
 	 * @param port Port number of desired port.
 	 * @return List of links. Empty list if no port was found.
 	 */
-	// TODO: Fix me
 	@Override
 	public List<Link> getLinks(Long dpid, short port) {
     	List<Link> links = new ArrayList<Link>();
@@ -221,24 +238,13 @@
 	}
 	
 	/**
-	 * Initialize the object. Open LinkStorage using given configuration file.
-	 * @param conf Path (absolute path for now) to configuration file.
-	 */
-	@Override
-	public void init(String conf) {
-		//TODO extract the DB location from properties
-		this.dbop = new GraphDBOperation(conf);
-	}
-
-	/**
 	 * Delete records of the links connected to the port specified by given DPID and port number.
 	 * @param dpid DPID of desired port.
 	 * @param port Port number of desired port.
 	 */
-	// TODO: Fix me
 	@Override
 	public void deleteLinksOnPort(Long dpid, short port) {
-		List<Link> linksToDelete = getLinks(dpid,port);
+		List<Link> linksToDelete = getLinks(dpid, port);
 		
 		for(Link l : linksToDelete) {
 			deleteLink(l);
@@ -250,7 +256,6 @@
 	 * @param dpid DPID of desired switch.
 	 * @return List of links. Empty list if no port was found.
 	 */
-	// TODO: Fix me
 	@Override
 	public List<Link> getLinks(String dpid) {
 		List<Link> links = new ArrayList<Link>();
@@ -302,12 +307,34 @@
 		return links;
 	}
 	
+	@Override
+	public LinkInfo getLinkInfo(Link link) {
+		// TODO implement this
+		return null;
+	}
+
+	/**
+	 * Finalize the object.
+	 */
+	public void finalize() {
+		close();
+	}
+
+	/**
+	 * Close LinkStorage.
+	 */
+	@Override
+	public void close() {
+		// TODO Auto-generated method stub
+//		graph.shutdown();		
+	}
+
+	// TODO should be moved to TopoLinkServiceImpl (never used in this class)
 	static class ExtractLink implements PipeFunction<PathPipe<Vertex>, Link> {
 	
 		@SuppressWarnings("unchecked")
 		@Override
 		public Link compute(PathPipe<Vertex> pipe ) {
-			// TODO Auto-generated method stub
 			long s_dpid = 0;
 			long d_dpid = 0;
 			short s_port = 0;
@@ -328,22 +355,6 @@
 			return l;
 		}
 	}
-	
-	/**
-	 * Finalize the object.
-	 */
-	public void finalize() {
-		close();
-	}
-
-	/**
-	 * Close LinkStorage.
-	 */
-	@Override
-	public void close() {
-		// TODO Auto-generated method stub
-//		graph.shutdown();		
-	}
 
 
 }
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 b7c97f8..d9f24e0 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
@@ -1,5 +1,8 @@
 package net.onrc.onos.ofcontroller.core.internal;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import net.floodlightcontroller.core.IOFSwitch;
 import net.onrc.onos.graph.GraphDBConnection;
 import net.onrc.onos.graph.GraphDBOperation;
@@ -55,6 +58,7 @@
 				sw.setState(state.toString());
 				op.commit();
 				log.info("SwitchStorage:setStatus dpid:{} state: {} done", dpid, state);
+			    // TODO publish UPDATE_SWITCH event here
 			}
 		} catch(Exception e) {
 			e.printStackTrace();
@@ -64,43 +68,6 @@
 	}
 
 	/***
-	 * This function is for adding the switch into the DB.
-	 * @param dpid The switch dpid you want to add into the DB.
-	 */
-	@Override
-	public void addSwitch(String dpid) {
-		
-		log.info("SwitchStorage:addSwitch(): dpid {} ", dpid);
-		try {
-			ISwitchObject sw = newSwitch(dpid);
-			if ( sw == null ) throw new RuntimeException();
-            op.commit();
-		} catch (Exception e) {
-			e.printStackTrace();
-			op.rollback();
-			log.info("SwitchStorage:addSwitch dpid:{} failed", dpid);
-		}
-	}
-	
-	private ISwitchObject newSwitch(String dpid) {
-		ISwitchObject sw = op.searchSwitch(dpid);
-		if (sw != null) {
-			//If existing the switch. set The SW state ACTIVE. 
-			log.info("SwitchStorage:newSwitch dpid:{} already exists", dpid);
-			sw.setState(SwitchState.ACTIVE.toString());
-		} else {
-			sw = op.newSwitch(dpid);
-			if (sw != null) {
-				sw.setState(SwitchState.ACTIVE.toString());
-				log.info("SwitchStorage:newSwitch dpid:{} added", dpid);
-			} else {
-				log.error("switchStorage:newSwitch dpid:{} failed -> newSwitch failed", dpid);
-			}
-		}
-		return sw;
-	}
-	
-	/***
 	 * This function is for updating the switch into the DB.
 	 * @param dpid The switch dpid you want to update from the DB
 	 * @param state The state of the switch like ACTIVE, INACTIVE
@@ -109,20 +76,193 @@
 	@Override
 	public void update(String dpid, SwitchState state, DM_OPERATION dmope) {
 		log.info("SwitchStorage:update dpid:{} state: {} ", dpid, state);
-        switch(dmope) {
-        	case UPDATE:
-        	case INSERT:
-        	case CREATE:
-                addSwitch(dpid);
-                if (state != SwitchState.ACTIVE) {
-                	setStatus(dpid, state);
-                }
-                break;
-        	case DELETE:
-                deleteSwitch(dpid);
-                break;
-        	default:
-        }
+	    switch(dmope) {
+	    	case UPDATE:
+	    	case INSERT:
+	    	case CREATE:
+	            addSwitch(dpid);
+	            if (state != SwitchState.ACTIVE) {
+	            	setStatus(dpid, state);
+	            }
+	            break;
+	    	case DELETE:
+	            deleteSwitch(dpid);
+	            break;
+	    	default:
+	    }
+	}
+
+	/***
+	 * This function is for adding the switch port into the DB.
+	 * @param dpid The switch dpid that has the port.
+	 * @param port The port you want to add the switch.
+	 */
+	@Override
+	public void addPort(String dpid, OFPhysicalPort port) {
+		
+	   if(((OFPortConfig.OFPPC_PORT_DOWN.getValue() & port.getConfig()) > 0) ||
+	    					((OFPortState.OFPPS_LINK_DOWN.getValue() & port.getState()) > 0)) {
+		     deletePort(dpid, port.getPortNumber());
+	         return;  
+	   }
+	
+		try {
+			ISwitchObject sw = op.searchSwitch(dpid);
+	
+	        if (sw != null) {
+	        	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 setting as ACTIVE", dpid, port.getPortNumber());
+	        		p.setState("ACTIVE");
+	        		p.setPortState(port.getState());
+	        		p.setDesc(port.getName());
+	        		op.commit();
+	        		
+	    		    // TODO publish UPDATE_PORT event here
+	        	} else {
+	        		p = op.newPort(dpid, port.getPortNumber());
+	        		p.setState("ACTIVE");
+	        		p.setPortState(port.getState());
+	        		p.setDesc(port.getName());
+	        		sw.addPort(p);
+	        		op.commit();
+	        		
+	    		    // TODO publish ADD_PORT event here
+	        	}
+	        } else {
+	    		log.error("SwitchStorage:addPort dpid:{} port:{} : failed switch does not exist", dpid, port.getPortNumber());
+	        }
+		} catch (Exception e) {
+			e.printStackTrace();
+			op.rollback();
+			log.error("SwitchStorage:addPort dpid:{} port:{} failed", dpid, port.getPortNumber());
+		}	
+	
+	}
+
+	/***
+	 * This function is for deleting the switch port from the DB.
+	 * @param dpid The switch dpid that has the port.
+	 * @param port The port you want to delete the switch.
+	 */
+	@Override
+	public void deletePort(String dpid, short port) {
+		try {
+			ISwitchObject sw = op.searchSwitch(dpid);
+	
+	        if (sw != null) {
+	        	IPortObject p = op.searchPort(dpid, port);
+	            if (p != null) {
+	        		log.info("SwitchStorage:deletePort dpid:{} port:{} found and set INACTIVE", dpid, port);
+	        		p.setState("INACTIVE");
+	        		op.commit();
+	    		    // TODO publish DELETE_PORT event here
+	        	}
+	        }
+		} catch (Exception e) {
+			e.printStackTrace();
+			op.rollback();
+			log.info("SwitchStorage:deletePort dpid:{} port:{} failed", dpid, port);
+		}	
+	}
+
+	@Override
+	public void addSwitch(IOFSwitch sw) {
+		String dpid = sw.getStringId();
+		log.info("SwitchStorage:addSwitch(): dpid {} ", dpid);
+		
+		ISwitchObject curr = op.searchSwitch(dpid);
+		if (curr != null) {
+			//If existing the switch. set The SW state ACTIVE. 
+			log.info("SwitchStorage:addSwitch dpid:{} already exists", dpid);
+			setSwitchStateImpl(curr, SwitchState.ACTIVE);
+		} else {
+			curr = addSwitchImpl(dpid);
+		}
+
+		try {
+			List<IPortObject> added_ports = new ArrayList<IPortObject>();
+			List<IPortObject> updated_ports = new ArrayList<IPortObject>();
+			for (OFPhysicalPort port: sw.getPorts()) {
+				IPortObject p = op.searchPort(dpid, port.getPortNumber());
+				if (p != null) {
+		    		log.error("SwitchStorage:addPort dpid:{} port:{} exists", dpid, port.getPortNumber());
+		    		p.setState("ACTIVE");
+		    		p.setPortState(port.getState());
+		    		p.setDesc(port.getName());
+		    		
+		       		added_ports.add(p);
+				} else {
+		    		p = op.newPort(dpid, port.getPortNumber());
+		    		p.setState("ACTIVE");
+		    		p.setPortState(port.getState());
+		    		p.setDesc(port.getName());           		
+		    		curr.addPort(p);
+		    		
+		       		updated_ports.add(p);
+				}         		
+			}
+	
+			op.commit();
+		    
+		    // TODO publish ADD_PORT event here
+		    // TODO publish UPDATE_PORT event here
+		} catch (Exception e) {
+			e.printStackTrace();
+			op.rollback();
+			log.info("SwitchStorage:addSwitch dpid:{} failed", dpid);
+		}		
+	}
+
+	/***
+	 * This function is for adding the switch into the DB.
+	 * @param dpid The switch dpid you want to add into the DB.
+	 */
+	@Override
+	public void addSwitch(String dpid) {
+		log.info("SwitchStorage:addSwitch(): dpid {} ", dpid);
+		
+		ISwitchObject sw = op.searchSwitch(dpid);
+		if (sw != null) {
+			//If existing the switch. set The SW state ACTIVE. 
+			log.info("SwitchStorage:addSwitch dpid:{} already exists", dpid);
+			setSwitchStateImpl(sw, SwitchState.ACTIVE);
+		} else {
+			addSwitchImpl(dpid);
+		}
+	}
+	
+	private ISwitchObject addSwitchImpl(String dpid) {
+		try {
+			ISwitchObject sw = op.newSwitch(dpid);
+			if (sw != null) {
+				sw.setState(SwitchState.ACTIVE.toString());
+				log.info("SwitchStorage:addSwitchImpl dpid:{} added", dpid);
+			} else {
+				log.error("switchStorage:addSwitchImpl dpid:{} failed", dpid);
+				throw new RuntimeException();
+			}
+
+            op.commit();
+            
+            // TODO publish ADD_SWITCH event here
+    		return sw;
+		} catch (Exception e) {
+			e.printStackTrace();
+			op.rollback();
+			log.info("SwitchStorage:addSwitchImpl dpid:{} failed", dpid);
+			return null;
+		}
+	}
+	
+	private void setSwitchStateImpl(ISwitchObject sw, SwitchState state) {
+		if (sw != null && state != null) {
+			sw.setState(state.toString());
+            op.commit();
+            
+			// TODO publish UPDATE_SWITCH event here
+		}
 	}
 
 	/***
@@ -137,6 +277,8 @@
             	op.removeSwitch(sw);
             	op.commit();
             	log.info("SwitchStorage:DeleteSwitch dpid:{} done", dpid);
+
+            	// TODO publish DELETE_SWITCH event here
             }
 		} catch (Exception e) {
 			e.printStackTrace();
@@ -145,105 +287,5 @@
 		}
 
 	}
-
-	/***
-	 * This function is for adding the switch port into the DB.
-	 * @param dpid The switch dpid that has the port.
-	 * @param port The port you want to add the switch.
-	 */
-	@Override
-	public void addPort(String dpid, OFPhysicalPort port) {
-		
-       if(((OFPortConfig.OFPPC_PORT_DOWN.getValue() & port.getConfig()) > 0) ||
-        					((OFPortState.OFPPS_LINK_DOWN.getValue() & port.getState()) > 0)) {
-    	     deletePort(dpid, port.getPortNumber());
-             return;  
-       }
-
-		try {
-			ISwitchObject sw = op.searchSwitch(dpid);
-
-            if (sw != null) {
-            	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 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");
-            		p.setPortState(port.getState());
-            		p.setDesc(port.getName());
-            		sw.addPort(p);
-            		op.commit();
-            	}
-            } else {
-        		log.error("SwitchStorage:addPort dpid:{} port:{} : failed switch does not exist", dpid, port.getPortNumber());
-            }
-		} catch (Exception e) {
-			e.printStackTrace();
-			op.rollback();
-			log.error("SwitchStorage:addPort dpid:{} port:{} failed", dpid, port.getPortNumber());
-		}	
-
-	}
 	
-	/***
-	 * This function is for deleting the switch port from the DB.
-	 * @param dpid The switch dpid that has the port.
-	 * @param port The port you want to delete the switch.
-	 */
-	@Override
-	public void deletePort(String dpid, short port) {
-		try {
-			ISwitchObject sw = op.searchSwitch(dpid);
-
-            if (sw != null) {
-            	IPortObject p = op.searchPort(dpid, port);
-                if (p != null) {
-            		log.info("SwitchStorage:deletePort dpid:{} port:{} found and set INACTIVE", dpid, port);
-            		p.setState("INACTIVE");
-            		op.commit();
-            	}
-            }
-		} catch (Exception e) {
-			e.printStackTrace();
-			op.rollback();
-			log.info("SwitchStorage:deletePort dpid:{} port:{} failed", dpid, port);
-		}	
-	}
-
-	@Override
-	public void addSwitch(IOFSwitch sw) {
-		// TODO Auto-generated method stub
-		String dpid = sw.getStringId();
-		log.info("SwitchStorage:addSwitch(): dpid {} ", dpid);
-		try {
-			ISwitchObject switchObject = newSwitch(dpid);
-        	for (OFPhysicalPort port: sw.getPorts()) {
-        		IPortObject p = op.searchPort(dpid, port.getPortNumber());
-        		if (p != null) {
-            		log.error("SwitchStorage:addPort dpid:{} port:{} exists", dpid, port.getPortNumber());
-            		p.setState("ACTIVE");
-            		p.setPortState(port.getState());
-            		p.setDesc(port.getName());
-            	} else {
-            		p = op.newPort(dpid, port.getPortNumber());
-            		p.setState("ACTIVE");
-            		p.setPortState(port.getState());
-            		p.setDesc(port.getName());           		
-            		switchObject.addPort(p);
-            	}         		
-        	}
-            op.commit();
-		} catch (Exception e) {
-			e.printStackTrace();
-			op.rollback();
-			log.info("SwitchStorage:addSwitch dpid:{} failed", dpid);
-		}		
-		
-	}
 }
\ No newline at end of file
diff --git a/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/NetworkGraphPublisher.java b/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/NetworkGraphPublisher.java
index 6db2009..852cbb8 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/NetworkGraphPublisher.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/NetworkGraphPublisher.java
@@ -41,6 +41,7 @@
 import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl;
 import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryListener;
 import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryService;
+import net.onrc.onos.ofcontroller.linkdiscovery.LinkInfo;
 import net.onrc.onos.registry.controller.IControllerRegistryService;
 import net.onrc.onos.registry.controller.IControllerRegistryService.ControlChangeCallback;
 import net.onrc.onos.registry.controller.RegistryException;
@@ -137,18 +138,20 @@
 		switch (update.getOperation()) {
 			case LINK_REMOVED:
 				log.debug("LinkDiscoveryUpdate(): Removing link {}", lt);
-				linkStore.update(lt, DM_OPERATION.DELETE);
+				linkStore.deleteLink(lt);
 				// TODO: Move network map link removal here
 				// reconcile paths here
 //				IPortObject srcPort = conn.utils().searchPort(conn, HexString.toHexString(update.getSrc()), update.getSrcPort());
 				break;
 			case LINK_UPDATED:
 				log.debug("LinkDiscoveryUpdate(): Updating link {}", lt);
-				linkStore.update(lt, DM_OPERATION.UPDATE);
+				LinkInfo linfo = linkStore.getLinkInfo(lt);
+				// TODO update "linfo" using portState derived using "update"
+				linkStore.update(lt, linfo, DM_OPERATION.UPDATE);
 				break;
 			case LINK_ADDED:
 				log.debug("LinkDiscoveryUpdate(): Adding link {}", lt);
-				linkStore.update(lt, DM_OPERATION.INSERT);
+				linkStore.addLink(lt);
 				break;
 					
 			default:
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImplTest.java b/src/test/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImplTest.java
index 9b1c4d6..2d0e0d0 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImplTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImplTest.java
@@ -1,8 +1,6 @@
 package net.onrc.onos.ofcontroller.core.internal;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -134,12 +132,41 @@
 		linkStorage.close();
 	}
 	
+
+	/**
+	 * Test if {@link LinkStorageImpl#addLink(Link)} can correctly creates a Link.
+	 */
+	@Test
+	public void testAddLink() {
+		Link linkToCreate = createFeasibleLink();
+		Link linkToVerify = createFeasibleLink();
+		
+		//Use the link storage API to add the link
+		linkStorage.addLink(linkToCreate);
+		doTestLinkExist(linkToVerify);
+	}
+	
+	/**
+	 * Test if {@link LinkStorageImpl#update(List, DM_OPERATION)} can correctly creates multiple Links.
+	 */
+	@Test
+	public void testAddLinks() {
+		List<Link> linksToCreate = createFeasibleLinks();
+		List<Link> linksToVerify = createFeasibleLinks();
+	
+		// Test creation of new links
+		linkStorage.addLinks(linksToCreate);
+		for(Link l : linksToVerify) {
+			doTestLinkExist(l);
+		}
+	}
+
 	// TODO: remove @Ignore after UPDATE method is implemented
 	/**
-	 * Test if {@link LinkStorageImpl#update(Link, LinkInfo, DM_OPERATION)} can correctly updates LinkInfo for a Link.
+	 * Test if {@link LinkStorageImpl#updateLinkInfo(Link, LinkInfo, DM_OPERATION)} can correctly updates LinkInfo for a Link.
 	 */
 	@Ignore @Test
-	public void testUpdate_UpdateSingleLink() {
+	public void testUpdate_Update() {
 		Link linkToUpdate= createExistingLink();
 		long currentTime = System.currentTimeMillis();
 		LinkInfo infoToUpdate = createFeasibleLinkInfo(currentTime);
@@ -154,12 +181,12 @@
 	 * Test if {@link LinkStorageImpl#update(Link, DM_OPERATION)} can correctly creates a Link.
 	 */
 	@Test
-	public void testUpdate_CreateSingleLink() {
+	public void testUpdate_Create() {
 		Link linkToCreate = createFeasibleLink();
 		Link linkToVerify = createFeasibleLink();
 		
 		//Use the link storage API to add the link
-		linkStorage.update(linkToCreate, ILinkStorage.DM_OPERATION.CREATE);
+		linkStorage.update(linkToCreate, null, ILinkStorage.DM_OPERATION.CREATE);
 		doTestLinkExist(linkToVerify);
 	}
 
@@ -167,12 +194,12 @@
 	 * Test if {@link LinkStorageImpl#update(Link, DM_OPERATION)}can correctly inserts a Link.
 	 */
 	@Test
-	public void testUpdate_InsertSingleLink(){
+	public void testUpdate_Insert(){
 		Link linkToInsert = createFeasibleLink();
 		Link linkToVerify = createFeasibleLink();
 		
 		//Use the link storage API to add the link
-		linkStorage.update(linkToInsert, ILinkStorage.DM_OPERATION.INSERT);
+		linkStorage.update(linkToInsert, null, ILinkStorage.DM_OPERATION.INSERT);
 		doTestLinkExist(linkToVerify);
 	}
 	
@@ -180,125 +207,16 @@
 	 * Test if {@link LinkStorageImpl#update(Link, DM_OPERATION)} can correctly deletes a Link.
 	 */
 	@Test
-	public void testUpdate_DeleteSingleLink(){
+	public void testUpdate_Delete(){
 		Link linkToDelete = createExistingLink();
 		Link linkToVerify = createExistingLink();
 
 		// Test deletion of existing link
-		linkStorage.update(linkToDelete, DM_OPERATION.DELETE);
+		linkStorage.update(linkToDelete, null, DM_OPERATION.DELETE);
 		doTestLinkNotExist(linkToVerify);
 	}
 
 	/**
-	 * Test if {@link LinkStorageImpl#update(List, DM_OPERATION)} can correctly creates multiple Links.
-	 */
-	@Test
-	public void testUpdate_CreateLinks(){
-		List<Link> linksToCreate = createFeasibleLinks();
-		List<Link> linksToVerify = createFeasibleLinks();
-
-		// Test creation of new links
-		linkStorage.update(linksToCreate, ILinkStorage.DM_OPERATION.CREATE);
-		for(Link l : linksToVerify) {
-			doTestLinkExist(l);
-		}
-	}
-
-	/**
-	 * Test if {@link LinkStorageImpl#update(List, DM_OPERATION)} can correctly inserts multiple Links.
-	 */
-	@Test
-	public void testUpdate_InsertLinks(){
-		List<Link> linksToInsert = createFeasibleLinks();
-		List<Link> linksToVerify = createFeasibleLinks();
-		
-		// Test insertion of new links
-		linkStorage.update(linksToInsert, ILinkStorage.DM_OPERATION.INSERT);
-		for(Link l : linksToVerify) {
-			doTestLinkExist(l);
-		}
-	}
-	
-	/**
-	 * Test if  {@link LinkStorageImpl#update(List, DM_OPERATION)} can correctly deletes multiple Links.
-	 */
-	@Test
-	public void testUpdate_DeleteLinks(){
-		List<Link> linksToDelete = createExistingLinks();
-		List<Link> linksToVerify = createExistingLinks();
-		
-		// Test deletion of existing links
-		linkStorage.update(linksToDelete, ILinkStorage.DM_OPERATION.DELETE);
-		for(Link l : linksToVerify) {
-			doTestLinkNotExist(l);
-		}
-	}
-	
-	// TODO: remove @Ignore after UPDATE method is implemented
-	/**
-	 * Test if {@link LinkStorageImpl#updateLink(Link, LinkInfo, DM_OPERATION)} can correctly updates LinkInfo for a Link.
-	 */
-	@Ignore @Test
-	public void testUpdateLink_Update() {
-		Link linkToUpdate= createExistingLink();
-		long currentTime = System.currentTimeMillis();
-		LinkInfo infoToUpdate = createFeasibleLinkInfo(currentTime);
-		LinkInfo infoToVerify = createFeasibleLinkInfo(currentTime);
-
-		linkStorage.updateLink(linkToUpdate, infoToUpdate, ILinkStorage.DM_OPERATION.UPDATE);
-		
-		doTestLinkHasStateOf(linkToUpdate, infoToVerify);
-	}
-	
-	/**
-	 * Test if {@link LinkStorageImpl#updateLink(Link, LinkInfo, DM_OPERATION)} can correctly creates a Link.
-	 */
-	@Test
-	public void testUpdateLink_Create() {
-		Link linkToCreate = createFeasibleLink();
-		Link linkToVerify = createFeasibleLink();
-		
-		//Use the link storage API to add the link
-		linkStorage.updateLink(linkToCreate, null, ILinkStorage.DM_OPERATION.CREATE);
-		doTestLinkExist(linkToVerify);
-	}
-	
-	/**
-	 * Test if {@link LinkStorageImpl#updateLink(Link, LinkInfo, DM_OPERATION)} can correctly inserts a Link.
-	 */
-	@Test
-	public void testUpdateLink_Insert() {
-		Link linkToInsert = createFeasibleLink();
-		Link linkToVerify = createFeasibleLink();
-		
-		//Use the link storage API to add the link
-		linkStorage.updateLink(linkToInsert, null, ILinkStorage.DM_OPERATION.INSERT);
-
-		doTestLinkExist(linkToVerify);
-	}
-	
-	// TODO: Check if addOrUpdateLink() should accept DELETE operation. If not, remove this test.
-	/**
-	 * Test if {@link LinkStorageImpl#updateLink(Link, LinkInfo, DM_OPERATION)} can correctly deletes a Link.
-	 */
-	@Ignore @Test
-	public void testUpdateLink_Delete() {
-		Link linkToDelete = createExistingLink();
-		Link linkToVerify = createExistingLink();
-
-		// Test deletion of existing link
-		linkStorage.updateLink(linkToDelete, null, DM_OPERATION.DELETE);
-		doTestLinkNotExist(linkToVerify);
-		
-		linkToDelete = createFeasibleLink();
-		linkToVerify = createFeasibleLink();
-
-		// Test deletion of not-existing link
-		linkStorage.updateLink(linkToDelete, null, DM_OPERATION.DELETE);
-		doTestLinkNotExist(linkToVerify);
-	}
-	
-	/**
 	 * Test if {@link LinkStorageImpl#getLinks(Long, short)} can correctly return Links connected to specific DPID and port.
 	 */
 	@Test
@@ -392,6 +310,14 @@
 		
 		doTestLinkNotExist(linkToVerify);
 	}
+	
+	/**
+	 * Test if {@link LinkStorageImpl#getLinkInfo(Link)} can delete Links.
+	 */
+	@Ignore @Test
+	public void testGetLinkInfo() {
+		fail("not yet implemented");
+	}
 
 	/**
 	 * Test if specific link exists
diff --git a/start-onos-embedded.sh b/start-onos-embedded.sh
index afe8f85..8688f69 100755
--- a/start-onos-embedded.sh
+++ b/start-onos-embedded.sh
@@ -4,7 +4,7 @@
 if [ -z "${ONOS_HOME}" ]; then
         ONOS_HOME=`dirname $0`
 fi
-ONOS_LOGBACK="${ONOS_HOME}/logback.xml"
+ONOS_LOGBACK="${ONOS_HOME}/logback.`hostname`.xml"
 LOGDIR=${ONOS_HOME}/onos-logs
 ONOS_LOG="${LOGDIR}/onos.`hostname`.log"
 PCAP_LOG="${LOGDIR}/onos.`hostname`.pcap"
@@ -96,6 +96,7 @@
 
   # XXX MVN has to run at the project top dir..
   cd ${ONOS_HOME}
+  echo "${MVN} exec:exec -Dexec.executable=\"java\" -Dexec.args=\"${JVM_OPTS} -Dlogback.configurationFile=${ONOS_LOGBACK} -cp %classpath ${MAIN_CLASS} -cf ${ONOS_HOME}/conf/onos-embedded.properties\""
   ${MVN} exec:exec -Dexec.executable="java" -Dexec.args="${JVM_OPTS} -Dlogback.configurationFile=${ONOS_LOGBACK} -cp %classpath ${MAIN_CLASS} -cf ${ONOS_HOME}/conf/onos-embedded.properties" > ${LOGDIR}/onos.stdout 2>${LOGDIR}/onos.stderr &
 
   echo "Waiting for ONOS to start..."
diff --git a/test-network/mininet/network.py b/test-network/mininet/network.py
new file mode 100755
index 0000000..0eb519a
--- /dev/null
+++ b/test-network/mininet/network.py
@@ -0,0 +1,175 @@
+#!/usr/bin/python
+
+"""
+Start up a Simple topology
+"""
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info, error, warn, debug
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+from mininet.link import Link, TCLink
+
+from sys import exit
+import os.path
+from subprocess import Popen, STDOUT, PIPE
+
+import sys
+
+NR_NODES=10  #; Switches per rigonal networks
+
+class MyController( Controller ):
+    def __init__( self, name, ip='127.0.0.1', port=6633, **kwargs):
+        """Init.
+           name: name to give controller
+           ip: the IP address where the remote controller is
+           listening
+           port: the port where the remote controller is listening"""
+        Controller.__init__( self, name, ip=ip, port=port, **kwargs )
+
+    def start( self ):
+        "Overridden to do nothing."
+        return
+
+    def stop( self ):
+        "Overridden to do nothing."
+        return
+
+    def checkListening( self ):
+        "Warn if remote controller is not accessible"
+        listening = self.cmd( "echo A | telnet -e A %s %d" %
+                              ( self.ip, self.port ) )
+        if 'Unable' in listening:
+            warn( "Unable to contact the remote controller"
+                  " at %s:%d\n" % ( self.ip, self.port ) )
+
+class SDNTopo( Topo ):
+    "SDN Topology"
+
+    def __init__( self, *args, **kwargs ):
+        Topo.__init__( self, *args, **kwargs )
+        sw1 = self.addSwitch('sw1', dpid='0000000000000101')
+        sw2 = self.addSwitch('sw2', dpid='0000000000000102')
+        sw3 = self.addSwitch('sw3', dpid='0000000000000103')
+        sw4 = self.addSwitch('sw4', dpid='0000000000000104')
+        sw5 = self.addSwitch('sw5', dpid='0000000000000105')
+        sw6 = self.addSwitch('sw6', dpid='0000000000000106')
+
+        self.addLink( sw1, sw2 )
+        self.addLink( sw1, sw6 )
+        self.addLink( sw2, sw3 )
+        self.addLink( sw3, sw4 )
+        self.addLink( sw3, sw6 )
+        self.addLink( sw4, sw5 )
+        self.addLink( sw5, sw6 )
+        self.addLink( sw4, sw6 )
+
+        switches=[]
+        for n in range(2, 9):
+            NWID=n 
+            switch = []
+            host = []
+            for i in range (NR_NODES):
+                name_suffix = '%02d' % NWID + "." + '%02d' % (int(i)+1)
+                dpid_suffix = '%02x' % NWID + '%02x' % (int(i)+1)
+                dpid = '0000' + '0000' + '0000' + dpid_suffix
+                sw = self.addSwitch('sw'+name_suffix, dpid=dpid)
+                switch.append(sw)
+
+            for i in range (NR_NODES):
+                host.append(self.addHost( 'host%d.%d' % (n,int(i)+1) ))
+
+            for i in range (NR_NODES):
+                self.addLink(host[i], switch[i])
+
+            for i in range (1, NR_NODES):
+                self.addLink(switch[0], switch[i])
+
+            switches.append(switch)
+
+        self.addLink(switches[8-2][0],sw1)
+        self.addLink(switches[2-2][0],sw2)
+        self.addLink(switches[3-2][0],sw3)
+        self.addLink(switches[4-2][0],sw4)
+        self.addLink(switches[5-2][0],sw4)
+        self.addLink(switches[6-2][0],sw5)
+        self.addLink(switches[7-2][0],sw6)
+
+
+def startsshd( host ):
+    "Start sshd on host"
+    info( '*** Starting sshd\n' )
+    name, intf, ip = host.name, host.defaultIntf(), host.IP()
+    banner = '/tmp/%s.banner' % name
+    host.cmd( 'echo "Welcome to %s at %s" >  %s' % ( name, ip, banner ) )
+    host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+    info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+    for h in hosts:
+        startsshd( h )
+
+def stopsshd( ):
+    "Stop *all* sshd processes with a custom banner"
+    info( '*** Shutting down stale sshd/Banner processes ',
+          quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def sdnnet(opt):
+#    os.system('/home/ubuntu/openflow/controller/controller ptcp: &')
+#    os.system('/home/ubuntu/openflow/controller/controller ptcp:7000 &')
+
+    topo = SDNTopo()
+    info( '*** Creating network\n' )
+#    net = Mininet( topo=topo, controller=RemoteController )
+    net = Mininet( topo=topo, controller=MyController, link=TCLink)
+#    dc = DebugController('c3', ip='127.0.0.1', port=7000)
+#    net.addController(dc)
+#    net.addController(controller=RemoteController)
+#    host1, host2, host3, host4, host5, host6 = net.get( 'host1', 'host2', 'host3', 'host4', 'host5', 'host6')
+
+    ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+    sw1 = net.get('sw1')
+    sw2 = net.get('sw2')
+    sw3 = net.get('sw3')
+    sw4 = net.get('sw4')
+    sw5 = net.get('sw5')
+    sw6 = net.get('sw6')
+
+    hosts = []
+    for n in range(2, 9):
+        host = []
+        for i in range (NR_NODES):
+            host.append(net.get( 'host%d.%d' % (n, int(i)+1) ))
+        hosts.append(host)
+
+    net.start()
+
+    for n in range(2, 9):
+        for i in range (NR_NODES):
+            hosts[n-2][i].defaultIntf().setIP('192.168.%d.%d/16' % (n,(int(i)+1))) 
+            hosts[n-2][i].defaultIntf().setMAC('00:00:%02x:%02x:%02x:%02x' % (192,168,n,(int(i)+1))) 
+
+        for i in range (NR_NODES):
+            for k in range (2,9):
+                for h in range (NR_NODES):
+                    hosts[n-2][i].setARP('192.168.%d.%d' % (k, (int(h)+1)), '00:00:%02x:%02x:%02x:%02x' % (192,168,k,(int(h)+1))) 
+
+    stopsshd ()
+    for n in range(2, 9):
+        startsshds ( hosts[n-2] )
+
+    if opt=="cli":
+        CLI(net)
+        stopsshd()
+        net.stop()
+
+if __name__ == '__main__':
+    setLogLevel( 'info' )
+    if len(sys.argv) == 1:
+      sdnnet("cli")
+    elif len(sys.argv) == 2 and sys.argv[1] == "-n":
+      sdnnet("nocli")
+    else:
+      print "%s [-n]" % sys.argv[0]