You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ud...@apache.org on 2014/01/27 16:41:24 UTC

[2/3] git commit: add listDeploymentPolicies osgi command

add listDeploymentPolicies 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/e6e772b4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/e6e772b4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/e6e772b4

Branch: refs/heads/master
Commit: e6e772b41e1af13028199cca5bba6f31e75f7f33
Parents: 56faec2
Author: Udara Liyanage <ud...@wso2.com>
Authored: Mon Jan 27 10:29:36 2014 -0500
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Mon Jan 27 10:29:36 2014 -0500

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


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e6e772b4/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/DeploymentPolicyCommands.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/DeploymentPolicyCommands.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/DeploymentPolicyCommands.java
new file mode 100644
index 0000000..7b04698
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/DeploymentPolicyCommands.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.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.policy.PolicyManager;
+import org.eclipse.osgi.framework.console.CommandInterpreter;
+import org.eclipse.osgi.framework.console.CommandProvider;
+ 
+public class DeploymentPolicyCommands implements CommandProvider{
+ 
+    public String getHelp() {
+        return "listDeploymentPolicies - list Deployment policies\n";
+    }
+ 
+    public void _listDeploymentPolicies (CommandInterpreter ci){
+    	String policyId = ci.nextArgument();
+    	
+    	PolicyManager pm = PolicyManager.getInstance();
+    	
+    	if(StringUtils.isBlank(policyId)){
+    		DeploymentPolicy[] depPolicyArr = pm.getDeploymentPolicyList();
+        	for(DeploymentPolicy depPoolicy : depPolicyArr){
+        		ci.println(depPoolicy.toString());
+        	}
+    	}else{
+    		DeploymentPolicy asPolicy = pm.getDeploymentPolicy(policyId);
+    		if(asPolicy != null){
+    			ci.println(asPolicy);
+    		}
+    	}
+    }
+}
\ No newline at end of file