stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From saj...@apache.org
Subject [1/4] git commit: Adding public ip to topology, Fixing displaying LB Ip in list-members and in list-cartridges
Date Wed, 05 Feb 2014 05:54:59 GMT
Updated Branches:
  refs/heads/master b38d87cbd -> e103ab6d0


Adding public ip to topology, Fixing displaying LB Ip in list-members and in list-cartridges


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

Branch: refs/heads/master
Commit: cd2ad408ac5648c91e18de5c252f0e4c85012d90
Parents: bf48fbc
Author: Sajith Kariyawasam <sajith@wso2.com>
Authored: Mon Feb 3 14:30:38 2014 +0530
Committer: Sajith Kariyawasam <sajith@wso2.com>
Committed: Mon Feb 3 14:30:38 2014 +0530

----------------------------------------------------------------------
 .../stratos/cli/RestCommandLineService.java     | 224 +++++++++++++++++--
 .../stratos/cli/beans/topology/Member.java      |  10 +
 .../impl/CloudControllerServiceImpl.java        |   4 +-
 .../controller/topology/TopologyBuilder.java    |   3 +-
 .../messaging/domain/topology/Member.java       |  12 +-
 .../rest/endpoint/bean/topology/Member.java     |   1 +
 .../bean/util/converter/PojoConverter.java      |   5 +
 .../rest/endpoint/services/ServiceUtils.java    |   7 +
 .../rest/endpoint/services/StratosAdmin.java    |  28 +++
 9 files changed, 275 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cd2ad408/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
index 82a6112..4077283 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
@@ -52,7 +52,11 @@ import java.net.ConnectException;
 import java.net.SocketException;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
+
+import jline.internal.Log;
 
 public class RestCommandLineService {
 
@@ -65,6 +69,7 @@ public class RestCommandLineService {
     private final String listAvailableCartridgesRestEndpoint = "/stratos/admin/cartridge/list";
     private final String describeAvailableCartridgeRestEndpoint = "/stratos/admin/cartridge/list/";
     private final String listSubscribedCartridgesRestEndpoint = "/stratos/admin/cartridge/list/subscribed";
+    private final String listSubscribedCartridgeInfoRestEndpoint = "/stratos/admin/cartridge/info/";
     private final String listClusterRestEndpoint = "/stratos/admin/cluster/";
     private final String subscribCartridgeRestEndpoint = "/stratos/admin/cartridge/subscribe";
     private final String addTenantEndPoint = "/stratos/admin/tenant";
@@ -396,37 +401,124 @@ public class RestCommandLineService {
         }
     }
 
-    public void listMembersOfCluster(String cartridgeType, String alias) throws CommandException
{
+    
+    // Lists subscribed cartridge info (from alias)
+    public void listSubscribedCartridgeInfo(final boolean full, String alias) throws CommandException
{
         DefaultHttpClient httpClient = new DefaultHttpClient();
         try {
-            HttpResponse response = restClientService.doGet(httpClient, restClientService.getUrl()
+ listClusterRestEndpoint
-                    + cartridgeType + "/" + alias,
-                    restClientService.getUsername(), restClientService.getPassword());
+            HttpResponse response = restClientService.doGet(httpClient, restClientService.getUrl()
+ listSubscribedCartridgeInfoRestEndpoint
+            		+"info/"+alias, restClientService.getUsername(), restClientService.getPassword());
 
             String responseCode = "" + response.getStatusLine().getStatusCode();
             if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
-                System.out.println("Error occured while listing members of a cluster");
+                System.out.println("Error occured while listing subscribe cartridges");
                 return;
             }
 
             String resultString = getHttpResponseString(response);
-            String tmp;
-            if(resultString.startsWith("{\"cluster\"")) {
-               tmp = resultString.substring("{\"cluster\"".length() + 1, resultString.length()-1);
-               resultString = tmp;
-            }
+
             GsonBuilder gsonBuilder = new GsonBuilder();
             Gson gson = gsonBuilder.create();
+            Cartridge cartridge = gson.fromJson(resultString, Cartridge.class);
 
-            Cluster cluster = gson.fromJson(resultString, Cluster.class);
+            if (cartridge == null) {
+                System.out.println("Cartridge is null");
+                return;
+            }
+            // Get LB IP s
+            final Set<String> lbIpList = getLbIpList(cartridge, httpClient);
+            Cartridge[] cartridges = new Cartridge[1];
+            cartridges[0] = cartridge;
+
+            RowMapper<Cartridge> cartridgeMapper = new RowMapper<Cartridge>()
{
+
+                public String[] getData(Cartridge cartridge) {
+                    String[] data = full ? new String[10] : new String[7];
+                    data[0] = cartridge.getCartridgeType();
+                    data[1] = cartridge.getDisplayName();
+                    data[2] = cartridge.getVersion();
+                    data[3] = cartridge.isMultiTenant() ? "Multi-Tenant" : "Single-Tenant";
+                    data[4] = cartridge.getCartridgeAlias();
+                    data[5] = cartridge.getStatus();
+                    data[6] = cartridge.isMultiTenant() ? "N/A" : String.valueOf(cartridge.getActiveInstances());
+                    if (full) {
+                        data[7] = getAccessURLs(cartridge);
+                        data[8] = cartridge.getRepoURL() != null ? cartridge.getRepoURL()
: "";
+                    }
+                    data[9] = lbIpList.toString();
+                    return data;
+                }
+            };
+
+            List<String> headers = new ArrayList<String>();
+            headers.add("Type");
+            headers.add("Name");
+            headers.add("Version");
+            headers.add("Tenancy Model");
+            headers.add("Alias");
+            headers.add("Status");
+            headers.add("Running Instances");
+            if (full) {
+                headers.add("Access URL(s)");
+                headers.add("Repo URL");
+            }
+            headers.add("LoadBalancer Ip");
+            
+            
+            // Display Database info as well..
+            
+            System.out.println("Subscribed Cartridges Info ************ : [TODO database
info]");
+            CommandLineUtils.printTable(cartridges, cartridgeMapper, headers.toArray(new
String[headers.size()]));
+            System.out.println();
+        } catch (Exception e) {
+            handleException("Exception in listing subscribe cartridges", e);
+        } finally {
+            httpClient.getConnectionManager().shutdown();
+        }
+    }
+    
+    
+    private Set<String> getLbIpList(Cartridge cartridge, DefaultHttpClient httpClient)
{
+    	
+    	Set<String> lbIpSet = new HashSet<String>();
+    	Member[] members = getMembers(cartridge.getCartridgeType(), cartridge.getCartridgeAlias(),
httpClient);
+    	
+    	Set<String> lbClusterIdSet = new HashSet<String>();
+    	
+    	for (Member member : members) {
+			lbClusterIdSet.add(member.getLbClusterId());
+		}
+    	
+        // Invoke  cluster/{clusterId}
+        for (String clusterId : lbClusterIdSet) {
+        	HttpResponse responseCluster = restClientService.doGet(httpClient, restClientService.getUrl()
+ listClusterRestEndpoint
+                    +"clusterId/"+ clusterId,
+                    restClientService.getUsername(), restClientService.getPassword());
+            String resultStringCluster = getHttpResponseString(responseCluster);
+            
+            Cluster cluster = getClusterObjectFromString(resultStringCluster);
 
             if (cluster == null) {
                 System.out.println("Subscribe cartridge list is null");
-                return;
+                return null;
             }
 
-            Member[] members = new Member[cluster.getMember().size()];
-            members = cluster.getMember().toArray(members);
+            Member[] lbMembers = new Member[cluster.getMember().size()];
+            lbMembers = cluster.getMember().toArray(lbMembers);
+           
+            for (Member lbMember : lbMembers) {
+            	lbIpSet.add(lbMember.getMemberPublicIp());
+			}
+		}
+
+		return lbIpSet;
+	}
+
+	public void listMembersOfCluster(String cartridgeType, String alias) throws CommandException
{
+        DefaultHttpClient httpClient = new DefaultHttpClient();
+        try {
+
+        	Member[] members = getMembers(cartridgeType, alias, httpClient);
 
             if (members.length == 0) {
                 if (logger.isDebugEnabled()) {
@@ -439,7 +531,7 @@ public class RestCommandLineService {
             RowMapper<Member> memberMapper = new RowMapper<Member>() {
 
                 public String[] getData(Member member) {
-                    String[] data = new String[7];
+                    String[] data = new String[8];
                     data[0] = member.getServiceName();
                     data[1] = member.getClusterId();
                     data[2] = member.getNetworkPartitionId();
@@ -447,6 +539,7 @@ public class RestCommandLineService {
                     data[4] = member.getMemberIp();
                     data[5] = member.getStatus().toString();
                     data[6] = member.getLbClusterId() != null ? member.getLbClusterId() :
"";
+                    data[7] = member.getMemberPublicIp().toString();
                     return data;
                 }
             };
@@ -459,11 +552,22 @@ public class RestCommandLineService {
             headers.add("MemberIp");
             headers.add("Status");
             headers.add("LBCluster");
+            headers.add("MemberPublicIp");
 
             System.out.println("List of members in the [cluster]: " + alias);
             CommandLineUtils.printTable(members, memberMapper, headers.toArray(new String[headers.size()]));
 
             System.out.println("List of LB members for the [cluster]: " + "TODO" );
+            
+            // Invoke  cluster/{clusterId}
+            for (Member m : members) {
+            	HttpResponse responseCluster = restClientService.doGet(httpClient, restClientService.getUrl()
+ listClusterRestEndpoint
+                        +"clusterId/"+ m.getLbClusterId(),
+                        restClientService.getUsername(), restClientService.getPassword());
+                String resultStringCluster = getHttpResponseString(responseCluster);    
           
+                printLBs(resultStringCluster);                
+			}
+            
         } catch (Exception e) {
             handleException("Exception in listing subscribe cartridges", e);
         } finally {
@@ -471,7 +575,95 @@ public class RestCommandLineService {
         }
     }
 
-    // This method does the cartridge subscription
+	private Member[] getMembers(String cartridgeType, String alias,
+			DefaultHttpClient httpClient) {
+		HttpResponse response = restClientService.doGet(httpClient, restClientService.getUrl()
+ listClusterRestEndpoint
+		        + cartridgeType + "/" + alias,
+		        restClientService.getUsername(), restClientService.getPassword());
+
+		String responseCode = "" + response.getStatusLine().getStatusCode();
+		if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+		    System.out.println("Error occured while listing members of a cluster");
+		    return null;
+		}
+
+		Cluster cluster = getClusterObjectFromString(getHttpResponseString(response));
+		
+		 if (cluster == null) {
+             System.out.println("Subscribe cartridge list is null");
+             return null;
+         }
+
+         Member[] members = new Member[cluster.getMember().size()];
+         members = cluster.getMember().toArray(members);
+         
+		return members;
+	}
+
+	private Cluster getClusterObjectFromString(String resultString) {
+		String tmp;
+		if(resultString.startsWith("{\"cluster\"")) {
+		   tmp = resultString.substring("{\"cluster\"".length() + 1, resultString.length()-1);
+		   resultString = tmp;
+		}
+		GsonBuilder gsonBuilder = new GsonBuilder();
+		Gson gson = gsonBuilder.create();
+
+		Cluster cluster = gson.fromJson(resultString, Cluster.class);
+		return cluster;
+	}
+
+    private void printLBs(String resultString) {
+    	
+    	Cluster cluster = getClusterObjectFromString(resultString);
+
+        if (cluster == null) {
+            System.out.println("Subscribe cartridge list is null");
+            return;
+        }
+
+        Member[] members = new Member[cluster.getMember().size()];
+        members = cluster.getMember().toArray(members);
+
+        if (members.length == 0) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("No subscribed cartridges found");
+            }
+            System.out.println("There are no subscribed cartridges");
+            return;
+        }
+
+        RowMapper<Member> memberMapper = new RowMapper<Member>() {
+
+            public String[] getData(Member member) {
+                String[] data = new String[8];
+                data[0] = member.getServiceName();
+                data[1] = member.getClusterId();
+                data[2] = member.getNetworkPartitionId();
+                data[3] = member.getPartitionId();
+                data[4] = member.getMemberIp();
+                data[5] = member.getStatus().toString();
+                data[6] = member.getLbClusterId() != null ? member.getLbClusterId() : "";
+                data[7] = member.getMemberPublicIp().toString();
+                return data;
+            }
+        };
+
+        List<String> headers = new ArrayList<String>();
+        headers.add("ServiceName");
+        headers.add("ClusterId");
+        headers.add("NewtworkPartitionId");
+        headers.add("PartitionId");
+        headers.add("MemberIp");
+        headers.add("Status");
+        headers.add("LBCluster");
+        headers.add("MemberPublicIp");
+        
+        CommandLineUtils.printTable(members, memberMapper, headers.toArray(new String[headers.size()]));
+		
+	}
+
+	// This method does the cartridge subscription
     public void subscribe(String cartridgeType, String alias, String externalRepoURL, boolean
privateRepo, String username,
                           String password, String dataCartridgeType, String dataCartridgeAlias,
String asPolicy, String depPolicy)
             throws CommandException {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cd2ad408/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/topology/Member.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/topology/Member.java
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/topology/Member.java
index dff17bc..a08dd81 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/topology/Member.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/topology/Member.java
@@ -10,6 +10,7 @@ public class Member {
     private String status;
     private String memberIp;
     private String lbClusterId;
+    private String memberPublicIp;
 
     public String getServiceName() {
         return serviceName;
@@ -74,4 +75,13 @@ public class Member {
     public void setLbClusterId(String lbClusterId) {
         this.lbClusterId = lbClusterId;
     }
+
+	public String getMemberPublicIp() {
+		return memberPublicIp;
+	}
+
+	public void setMemberPublicIp(String memberPublicIp) {
+		this.memberPublicIp = memberPublicIp;
+	}   
+    
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cd2ad408/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 39f5cf0..1e713d7 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -497,6 +497,7 @@ public class CloudControllerServiceImpl implements CloudControllerService
{
 
             String clusterId = memberContext.getClusterId();
             Partition partition = memberContext.getPartition();
+            String publicIp = null;
 
             try{
 
@@ -520,6 +521,7 @@ public class CloudControllerServiceImpl implements CloudControllerService
{
                     if (node.getPublicAddresses() != null &&
                         node.getPublicAddresses().iterator().hasNext()) {
                         ip = node.getPublicAddresses().iterator().next();
+                        publicIp = ip;
                         memberContext.setPublicIpAddress(ip);
                         log.info("Public IP Address has been set. " + memberContext.toString());
                     }
@@ -541,7 +543,7 @@ public class CloudControllerServiceImpl implements CloudControllerService
{
 
                     // trigger topology
                     TopologyBuilder.handleMemberSpawned(memberID, cartridgeType, clusterId,
memberContext.getNetworkPartitionId(),
-                            partition.getId(), ip, memberContext.getLbClusterId());
+                            partition.getId(), ip, memberContext.getLbClusterId(),publicIp);
 
                     // update the topology with the newly spawned member
                     // publish data

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cd2ad408/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index db55845..353d15c 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -172,7 +172,7 @@ public class TopologyBuilder {
     }
 
     public static void handleMemberSpawned(String memberId, String serviceName, String clusterId,
-                                           String networkPartitionId, String partitionId,
String privateIp, String lbClusterId) {
+                                           String networkPartitionId, String partitionId,
String privateIp, String lbClusterId, String publicIp) {
         //adding the new member to the cluster after it is successfully started in IaaS.
         Topology topology = TopologyManager.getTopology();
         Service service = topology.getService(serviceName);
@@ -188,6 +188,7 @@ public class TopologyBuilder {
             member.setStatus(MemberStatus.Created);
             member.setMemberIp(privateIp);
             member.setLbClusterId(lbClusterId);
+            member.setMemberPublicIp(publicIp);
             cluster.addMember(member);
             TopologyManager.updateTopology(topology);
         } finally {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cd2ad408/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
index 061a41c..b942e2e 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
@@ -42,7 +42,8 @@ public class Member implements Serializable {
     private final String networkPartitionId;
     private final String partitionId;
     private final String memberId;
-
+    
+    private String memberPublicIp;
     private MemberStatus status;
     private String memberIp;
     @XmlJavaTypeAdapter(MapAdapter.class)
@@ -145,5 +146,14 @@ public class Member implements Serializable {
     public String getNetworkPartitionId() {
         return networkPartitionId;
     }
+
+	public String getMemberPublicIp() {
+		return memberPublicIp;
+	}
+
+	public void setMemberPublicIp(String memberPublicIp) {
+		this.memberPublicIp = memberPublicIp;
+	}
+    
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cd2ad408/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Member.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Member.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Member.java
index 236aae4..0600b9f 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Member.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Member.java
@@ -13,5 +13,6 @@ public class Member {
     public String status;
     public String memberIp;
     public String lbClusterId;
+    public String memberPublicIp;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cd2ad408/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
index 7b13094..4927a57 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
@@ -310,6 +310,11 @@ public class PojoConverter {
             } else {
                 member.memberIp = tmp.getMemberIp();
             }
+            if(tmp.getMemberPublicIp() == null) {
+            	member.memberPublicIp = "NULL";
+            } else {
+            	member.memberPublicIp = tmp.getMemberPublicIp();
+            }
             member.serviceName = tmp.getServiceName();
             member.status = tmp.getStatus().toString();
             cluster1.member.add(member);

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cd2ad408/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 1ecd048..9436a0d 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -531,6 +531,13 @@ public class ServiceUtils {
         return cartridges;
     }
 
+    
+    static Cartridge getSubscription(String cartridgeAlias, ConfigurationContext configurationContext)
throws ADCException {
+    	return getCartridgeFromSubscription(cartridgeSubsciptionManager.getCartridgeSubscription(ApplicationManagementUtil.
+                    getTenantId(configurationContext), cartridgeAlias));
+    	
+    }
+    
     private static Cartridge getCartridgeFromSubscription (CartridgeSubscription subscription)
throws ADCException {
 
         Cartridge cartridge = new Cartridge();

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cd2ad408/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
index 82f40c1..7c87778 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
@@ -267,6 +267,15 @@ public class StratosAdmin extends AbstractAdmin {
         // Following is very important when working with axis2
         return cartridgeList.isEmpty() ? new Cartridge[0] : cartridgeList.toArray(new Cartridge[cartridgeList.size()]);
     }
+    
+    @GET
+    @Path("/cartridge/info/{subscriptionAlias}")
+    @Produces("application/json")
+    @Consumes("application/json")
+    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+    public Cartridge getCartridgeInfo(@PathParam("subscriptionAlias") String subscriptionAlias)
throws ADCException {
+        return ServiceUtils.getSubscription(subscriptionAlias, getConfigContext());
+    }
 
     @POST
     @Path("/cartridge/subscribe")
@@ -324,6 +333,25 @@ public class StratosAdmin extends AbstractAdmin {
 
         return ServiceUtils.getCluster(cartridgeType, subscriptionAlias, getConfigContext());
     }
+    
+    @GET
+    @Path("/cluster/clusterId/{clusterId}")
+    @Produces("application/json")
+    @Consumes("application/json")
+    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+    public Cluster getCluster(@PathParam("clusterId") String clusterId) throws ADCException
{
+    	log.info("--- clusterID -- " + clusterId);
+    	Cluster cluster = null;
+        Cluster[] clusters = ServiceUtils.getClustersForTenant(getConfigContext());
+        for (Cluster clusterObj : clusters) {
+			if (clusterObj.clusterId.equals(clusterId)){
+				cluster = clusterObj;
+				log.info(" -- CLuster is returned -- ");
+				break;
+			}
+		}
+        return cluster;
+    }
 
     @POST
     @Path("/cartridge/unsubscribe")


Mime
View raw message