add listPartitions osgi command

Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/3a43bac8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/3a43bac8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/3a43bac8

Branch: refs/heads/master
Commit: 3a43bac88ba33ac0e69516148bb38caf95ea136e
Parents: e6e772b
Author: Udara Liyanage <[email protected]>
Authored: Mon Jan 27 10:30:15 2014 -0500
Committer: Udara Liyanage <[email protected]>
Committed: Mon Jan 27 10:30:15 2014 -0500

----------------------------------------------------------------------
 .../autoscaler/commands/PartitionsCommands.java | 51 ++++++++++++++++++++
 1 file changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3a43bac8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/PartitionsCommands.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/PartitionsCommands.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/PartitionsCommands.java
new file mode 100644
index 0000000..93f22d6
--- /dev/null
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/PartitionsCommands.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one 
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+ * KIND, either express or implied.  See the License for the 
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.commands;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.stratos.autoscaler.partition.PartitionManager;
+import org.apache.stratos.cloud.controller.deployment.partition.Partition;
+import org.eclipse.osgi.framework.console.CommandInterpreter;
+import org.eclipse.osgi.framework.console.CommandProvider;
+ 
+public class PartitionsCommands implements CommandProvider{
+ 
+    public String getHelp() {
+        return "listPartitions - list partitions\n";
+    }
+ 
+    public void _listPartitions (CommandInterpreter ci){
+       String partitionId = ci.nextArgument();
+       
+       PartitionManager pm = PartitionManager.getInstance();
+       
+       if(StringUtils.isBlank(partitionId)){
+               Partition[] partitionArr = pm.getAllPartitions();
+               for(Partition partition : partitionArr){
+                       ci.println(partition.toString());
+               }
+       }else{
+               Partition partition = pm.getPartitionById(partitionId);
+               if(partition != null){  
+                       ci.println(partition);
+               }
+       }
+    }
+}
\ No newline at end of file

Reply via email to