Bug:4995 vAdd molude: nemo-tools and remove the depency of cliche repositoty. 51/34051/1
authorJieHou <houjie1@huawei.com>
Wed, 3 Feb 2016 09:45:33 +0000 (17:45 +0800)
committerJieHou <houjie1@huawei.com>
Thu, 4 Feb 2016 07:43:28 +0000 (07:43 +0000)
-Modify the pom of NEMO to add the module: nemo-tools
-Remove the cliche which is not maintained.

Change-Id: I4d840612f7ae0c46b2b766cb91ff83290b3892d4
Signed-off-by: JieHou <houjie1@huawei.com>
13 files changed:
nemo-tools/sandbox/pom.xml
nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/Cli.java [deleted file]
nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/CmdExecutor.java
nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/EasyCli.java [deleted file]
nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/Main.java
nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/models/Cache.java
nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/models/Firewall.java
nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/models/Link.java
nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/models/Network.java
nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/models/Node.java
nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/models/VirtualMachine.java
nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/utils/FileUtils.java
pom.xml

index a53d5179cc563dcf1f42c52e1d3ad9629f33f806..b08ec37bbf77d5cbd3823b9c3b5fdcb598324196 100644 (file)
@@ -30,28 +30,9 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <cliche.version>1.0-SNAPSHOT</cliche.version>
     <ssh.version>262</ssh.version>
     <json.version>20090211</json.version>
-    <powermock.version>1.5.2</powermock.version>
   </properties>
 
   <dependencies>
-    <dependency>
-      <groupId>org.powermock</groupId>
-      <artifactId>powermock-core</artifactId>
-      <version>${powermock.version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.powermock</groupId>
-      <artifactId>powermock-module-junit4</artifactId>
-      <version>${powermock.version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.powermock</groupId>
-      <artifactId>powermock-api-mockito</artifactId>
-      <version>${powermock.version}</version>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
@@ -68,11 +49,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <artifactId>commons-cli</artifactId>
       <version>${cli.version}</version>
     </dependency>
-    <dependency>
-      <groupId>com.googlecode.cliche</groupId>
-      <artifactId>cliche</artifactId>
-      <version>${cliche.version}</version>
-    </dependency>
     <dependency>
       <groupId>ch.ethz.ganymed</groupId>
       <artifactId>ganymed-ssh2</artifactId>
@@ -100,13 +76,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     </dependency>
   </dependencies>
 
-  <repositories>
-    <repository>
-      <id>cliche</id>
-      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
-    </repository>
-  </repositories>
-
   <scm>
     <connection>scm:git:ssh://git.opendaylight.org:29418/nemo.git</connection>
     <developerConnection>scm:git:ssh://git.opendaylight.org:29418/nemo.git</developerConnection>
diff --git a/nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/Cli.java b/nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/Cli.java
deleted file mode 100644 (file)
index 5914e28..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.nemo.tool.sandbox;
-
-import asg.cliche.Command;
-import asg.cliche.Shell;
-import asg.cliche.ShellDependent;
-
-/**
- * Created by hj on 12/9/15.
- */
-public class Cli implements ShellDependent {
-    private Shell shell;
-
-    public Cli() {
-
-    }
-
-    @Override
-    public void cliSetShell(Shell shell) {
-        this.shell = shell;
-    }
-
-    @Command
-    public void install() {
-        SandBoxManager.getInstance().createNetwork();
-    }
-
-    @Command
-    public void uninstall() {
-        SandBoxManager.getInstance().destroyNetwork();
-    }
-}
index 2f2383592d025832ee22346f0214b3da4064aee5..c738f8fb9195e5a40708f707dcc523f224a72953 100644 (file)
@@ -17,6 +17,8 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Created by hj on 12/9/15.
@@ -38,8 +40,7 @@ public class CmdExecutor {
                 return true;
             }
         } catch (IOException objException) {
-//            objException.printStackTrace();
-            log.error(objException);
+            log.error("Exceptions:",objException);
             if (null != sshConnection) {
                 sshConnection.close();
                 sshConnection = null;
@@ -77,8 +78,7 @@ public class CmdExecutor {
             return result;
 
         } catch (IOException objException) {
-//            objException.printStackTrace();
-            log.error(objException);
+            log.error("Exceptions:",objException);
         } finally {
             if (null != session) {
                 session.close();
diff --git a/nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/EasyCli.java b/nemo-tools/sandbox/src/main/java/org/opendaylight/nemo/tool/sandbox/EasyCli.java
deleted file mode 100644 (file)
index d1f08cd..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.nemo.tool.sandbox;
-
-import asg.cliche.Shell;
-import asg.cliche.ShellFactory;
-
-import java.io.IOException;
-
-/**
- * Created by hj on 12/9/15.
- */
-public class EasyCli {
-    private static Logger log = LoggerFactory.getLogger(EasyCli.class);
-    private Shell shell;
-
-    public EasyCli(String prompt,String hint,Object handler){
-        shell = ShellFactory.createConsoleShell(prompt, hint, handler);
-    }
-
-    public void add(Object handler){
-        shell.addMainHandler(handler,"");
-    }
-
-    public void run(){
-        try {
-            shell.commandLoop();
-        } catch (IOException e) {
-           log.error(e);
-        }
-    }
-}
index 7b70936f8f80fcd6a164413b64076d224ff1848d..dda9db93aefd5103018ae6c4ae01abce8490b3b3 100644 (file)
@@ -11,16 +11,43 @@ package org.opendaylight.nemo.tool.sandbox;
 import org.opendaylight.nemo.tool.sandbox.northbound.RestServer;
 import org.opendaylight.nemo.tool.sandbox.utils.PropertyLoader;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
 /**
  * Created by hj on 12/9/15.
  */
 public class Main {
-    public static void main(String []args){
+    public static void main(String[] args) {
         PropertyLoader.loadProperties("/sandbox.properties", "sandbox.properties does not exist.");
-        int northboundPort = Integer.parseInt(System.getProperty("north.port","10081"));
-        String socketAddress = "http://0.0.0.0:"+northboundPort+"/";
+        int northboundPort = Integer.parseInt(System.getProperty("north.port", "10081"));
+        String socketAddress = "http://0.0.0.0:" + northboundPort + "/";
         RestServer.start(socketAddress);
-        EasyCli easyCli = new EasyCli("sandbox","Authorized by Ip tech, Huawei",new Cli());
-        easyCli.run();
+        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+
+        while (true) {
+            System.out.println("Enter command to create or destroy physical network (0 to exit):");
+            System.out.println("start/stop");
+            try {
+                String s = br.readLine();
+
+                if (s.equals("start")) {
+                    SandBoxManager.getInstance().createNetwork();
+                    continue;
+                } else if ("stop".equals(s)) {
+                    SandBoxManager.getInstance().destroyNetwork();
+                    continue;
+                }
+                int i = Integer.parseInt(s);
+                if (i == 0) {
+                    System.exit(0);
+                }
+            } catch (NumberFormatException nfe) {
+                System.err.println("Invalid Format!");
+            }catch (IOException io){
+                io.printStackTrace();
+            }
+        }
     }
 }
index c0491db8da5b0e40156fe7cd47c8efbe95b12bd6..7673f42dbcbb389c140a40079e67932d66d209ac 100644 (file)
@@ -12,7 +12,8 @@ import org.opendaylight.nemo.tool.sandbox.CmdExecutor;
 
 import java.util.ArrayList;
 import java.util.List;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 /**
  * Created by hj on 12/8/15.
  */
@@ -41,7 +42,7 @@ public class Cache extends Host {
             CmdExecutor.sshExecute("ip netns del " + getName());
         } catch (Exception e) {
             // TODO Auto-generated catch block
-            log.error(e);
+            log.error("Exception:",e);
         }
     }
 }
index fbc3c8d592ed2aa91bcdfadc26b08afd1be8cf89..dc54c93479e1c6b8a1c15244bf438c8c1a25c04d 100644 (file)
@@ -12,7 +12,8 @@ import org.opendaylight.nemo.tool.sandbox.CmdExecutor;
 
 import java.util.ArrayList;
 import java.util.List;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 /**
  * Created by hj on 12/8/15.
  */
@@ -41,7 +42,7 @@ public class Firewall extends Host {
             CmdExecutor.sshExecute("ip netns del " + getName());
         } catch (Exception e) {
             // TODO Auto-generated catch block
-            log.error(e);
+            log.error("Exception:",e);
         }
     }
 }
index 3f896a252c1aad85ec13976f1166364d610f429a..39cd7a02b1015f229915c494385c4eff2b346d76 100644 (file)
@@ -9,7 +9,8 @@
 package org.opendaylight.nemo.tool.sandbox.models;
 
 import org.opendaylight.nemo.tool.sandbox.CmdExecutor;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 /**
  * Created by hj on 12/8/15.
  */
@@ -37,7 +38,7 @@ public class Link {
             CmdExecutor.sshExecute(linkAddCmd);
         } catch (Exception e) {
             // TODO Auto-generated catch block
-            log.error(e);
+            log.error("Exception:",e);
         }
     }
 
@@ -47,7 +48,7 @@ public class Link {
             CmdExecutor.sshExecute(linkDelCmd);
         } catch (Exception e) {
             // TODO Auto-generated catch block
-            log.error(e);
+            log.error("Exception:",e);
         }
     }
 
index dd0dbae133ded17f487c6c821041086af56d3f4d..63fea32bbfcb3b4d819ce0b1d40d328c9e806c01 100644 (file)
@@ -20,7 +20,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-
 /**
  * Created by hj on 12/9/15.
  */
@@ -169,7 +168,7 @@ public class Network {
             return root;
         } catch (JSONException e) {
             // TODO Auto-generated catch block
-            log.error(e);
+            log.error("Exception:",e);
         }
         return null;
     }
@@ -201,7 +200,7 @@ public class Network {
             return nodeJson;
         } catch (Exception e) {
             // TODO Auto-generated catch block
-            log.error(e);
+            log.error("Exception:",e);
         }
         return null;
     }
@@ -249,7 +248,7 @@ public class Network {
             return root;
         } catch (JSONException e) {
             // TODO Auto-generated catch block
-            log.error(e);
+            log.error("Exception:",e);
         }
         return null;
     }
@@ -288,7 +287,7 @@ public class Network {
             return root;
         } catch (JSONException e) {
             // TODO Auto-generated catch block
-            log.error(e);
+            log.error("Exception:",e);
         }
         return null;
     }
@@ -330,7 +329,7 @@ public class Network {
             root.put("link", linkArray);
         } catch (JSONException e) {
             // TODO Auto-generated catch block
-            log.error(e);
+            log.error("Exception:",e);
             return null;
         }
         return root;
@@ -350,7 +349,7 @@ public class Network {
                 return linkNode;
             } catch (JSONException e) {
                 // TODO Auto-generated catch block
-                log.error(e);
+                log.error("Exception:",e);
             }
         }
         return null;
index 28c9b3477d0f2c7f303e6e391da924b3fed016a3..2dad54ff9145734c7f08a68470ba7d1018bd8078 100644 (file)
@@ -58,7 +58,7 @@ abstract public class Node {
             } catch (Exception e) {
                 log.error("Error while execute [{}].", command, name, nodeType);
                 // TODO Auto-generated catch block
-                log.error(e);
+                log.error("Exception:",e);
             }
         }
     }
index 1f74de621fb813033d0edf6a4c554eeb2b852534..d5a898e62adfb4de64827b0b852f7b930b14f2bc 100644 (file)
@@ -12,7 +12,8 @@ import org.opendaylight.nemo.tool.sandbox.CmdExecutor;
 
 import java.util.ArrayList;
 import java.util.List;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 /**
  * Created by hj on 12/8/15.
  */
@@ -41,7 +42,7 @@ public class VirtualMachine extends Host {
             CmdExecutor.sshExecute("ip netns del " + getName());
         } catch (Exception e) {
             // TODO Auto-generated catch block
-            log.error(e);
+            log.error("Exception:",e);
         }
     }
 }
index 644f79e225b5356daf91fc205fa4f494b3196401..a8dad680c486f9b119b6a3d0a1cc361888476273 100644 (file)
@@ -9,7 +9,8 @@
 package org.opendaylight.nemo.tool.sandbox.utils;
 
 import java.io.*;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 /**
  * Created by hj on 12/11/15.
  */
@@ -27,7 +28,7 @@ public class FileUtils {
             output.write(content);
             output.close();
         } catch (Exception e) {
-            log.error(e);
+            log.error("Exception:",e);
         }
     }
 }
diff --git a/pom.xml b/pom.xml
index 7d36a7e1af82e7ab2225410755aa4dcd9c9be0ef..0d898e36d279efc277e2ab605cd8a59dc4f069c2 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -35,6 +35,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <module>nemo-features</module>
     <module>nemo-karaf</module>
     <module>nemo-renderers</module>
+    <module>nemo-tools</module>
   </modules>
 
   <url>https://wiki.opendaylight.org/view/NEMO:Main</url>