cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtutkow...@apache.org
Subject [43/50] git commit: updated refs/heads/sf-plugins to bcf1c72
Date Tue, 28 Jul 2015 20:15:29 GMT
Add and use an API to retrieve the virtual networks of a particular cluster

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

Branch: refs/heads/sf-plugins
Commit: cd4a863befd9b1e3810236c52bbb3d52e63080e1
Parents: 7f437bf5
Author: Mike Tutkowski <mike.tutkowski@solidfire.com>
Authored: Mon Jul 20 15:39:58 2015 -0600
Committer: CloudStack <cloudstack@cloudstack-virtual-machine.(none)>
Committed: Tue Jul 28 13:42:44 2015 -0600

----------------------------------------------------------------------
 .../ListSolidFireVirtualNetworksCmd.java        |  8 ++++-
 .../solidfire/ApiSolidFireService2.java         |  4 ++-
 .../solidfire/ApiSolidFireServiceImpl2.java     | 31 ++++++++++++++++++--
 ui/plugins/sfAdministration/sfAdministration.js |  4 +--
 4 files changed, 41 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd4a863b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/ListSolidFireVirtualNetworksCmd.java
----------------------------------------------------------------------
diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/ListSolidFireVirtualNetworksCmd.java
b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/ListSolidFireVirtualNetworksCmd.java
index 358dfe6..2f380e7 100644
--- a/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/ListSolidFireVirtualNetworksCmd.java
+++ b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/ListSolidFireVirtualNetworksCmd.java
@@ -49,6 +49,9 @@ public class ListSolidFireVirtualNetworksCmd extends BaseListCmd {
     @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ApiSolidFireVirtualNetworkResponse.class,
description = ApiHelper.VIRTUAL_NETWORK_ID_DESC)
     private Long _id;
 
+    @Parameter(name = ApiHelper.CLUSTER_NAME, type = CommandType.STRING, description = ApiHelper.SOLIDFIRE_CLUSTER_NAME_DESC,
required = true)
+    private String _clusterName;
+
     @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class,
description = ApiHelper.ZONE_ID_DESC)
     private Long _zoneId;
 
@@ -76,12 +79,15 @@ public class ListSolidFireVirtualNetworksCmd extends BaseListCmd {
             if (_id != null) {
                 sfVirtualNetworks = new ArrayList<>();
 
-                SfVirtualNetwork sfVirtualNetwork = _apiSolidFireService2.listSolidFireVirtualNetwork(_id);
+                SfVirtualNetwork sfVirtualNetwork = _apiSolidFireService2.listSolidFireVirtualNetworkById(_id);
 
                 if (sfVirtualNetwork != null) {
                     sfVirtualNetworks.add(sfVirtualNetwork);
                 }
             }
+            else if (_clusterName != null) {
+                sfVirtualNetworks = _apiSolidFireService2.listSolidFireVirtualNetworkByClusterName(_clusterName);
+            }
             else {
                 sfVirtualNetworks = _apiSolidFireService2.listSolidFireVirtualNetworks(_zoneId,
_accountId);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd4a863b/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireService2.java
----------------------------------------------------------------------
diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireService2.java
b/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireService2.java
index 07f200a..e6ed7d2 100644
--- a/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireService2.java
+++ b/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireService2.java
@@ -42,7 +42,9 @@ public interface ApiSolidFireService2 extends PluggableService, Configurable
{
 
     // ********** VLAN-related commands **********
 
-    SfVirtualNetwork listSolidFireVirtualNetwork(long id);
+    SfVirtualNetwork listSolidFireVirtualNetworkById(long id);
+
+    List<SfVirtualNetwork> listSolidFireVirtualNetworkByClusterName(String clusterName);
 
     // Long (instead of long) for both zoneId and accountId because they're optional and
null is used to indicate that they're not present
     // zoneId and accountId are not dependent upon one another (i.e. either one can be null,
both can be null, or both can be not be null)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd4a863b/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
----------------------------------------------------------------------
diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
b/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
index b626c67..208e62a 100644
--- a/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
+++ b/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
@@ -244,8 +244,8 @@ public class ApiSolidFireServiceImpl2 extends AdapterBase implements APIChecker,
     }
 
     @Override
-    public SfVirtualNetwork listSolidFireVirtualNetwork(long id) {
-        s_logger.info("listSolidFireVirtualNetwork invoked");
+    public SfVirtualNetwork listSolidFireVirtualNetworkById(long id) {
+        s_logger.info("listSolidFireVirtualNetworkById invoked");
 
         SfVirtualNetwork sfVirtualNetwork = getSfVirtualNetwork(id);
 
@@ -255,6 +255,17 @@ public class ApiSolidFireServiceImpl2 extends AdapterBase implements
APIChecker,
     }
 
     @Override
+    public List<SfVirtualNetwork> listSolidFireVirtualNetworkByClusterName(String clusterName)
{
+        s_logger.info("listSolidFireVirtualNetworkByClusterName invoked");
+
+        verifyRootAdmin();
+
+        SfCluster sfCluster = getSfCluster(clusterName);
+
+        return filterVirtualNetworksByCluster(_sfVirtualNetworkDao.listAll(), sfCluster.getId());
+    }
+
+    @Override
     public List<SfVirtualNetwork> listSolidFireVirtualNetworks(Long zoneId, Long accountId)
{
         s_logger.info("listSolidFireVirtualNetworks invoked");
 
@@ -979,6 +990,22 @@ public class ApiSolidFireServiceImpl2 extends AdapterBase implements
APIChecker,
         _accountDetailsDao.persist(accountDetail);
     }
 
+    private List<SfVirtualNetwork> filterVirtualNetworksByCluster(List<SfVirtualNetworkVO>
sfVirtualNetworkVOs, long clusterId) {
+        List<SfVirtualNetwork> sfVirtualNetworkVOsToReturn = new ArrayList<>();
+
+        if (sfVirtualNetworkVOs != null) {
+            for (SfVirtualNetworkVO sfVirtualNetworkVO : sfVirtualNetworkVOs) {
+                long sfClusterId = sfVirtualNetworkVO.getSfClusterId();
+
+                if (sfClusterId == clusterId) {
+                    sfVirtualNetworkVOsToReturn.add(sfVirtualNetworkVO);
+                }
+            }
+        }
+
+        return sfVirtualNetworkVOsToReturn;
+    }
+
     private List<SfVirtualNetworkVO> filterVirtualNetworksByZone(List<SfVirtualNetworkVO>
sfVirtualNetworkVOs, long zoneId) {
         List<SfVirtualNetworkVO> sfVirtualNetworkVOsToReturn = new ArrayList<>();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd4a863b/ui/plugins/sfAdministration/sfAdministration.js
----------------------------------------------------------------------
diff --git a/ui/plugins/sfAdministration/sfAdministration.js b/ui/plugins/sfAdministration/sfAdministration.js
index be1be98..46ac7f2 100644
--- a/ui/plugins/sfAdministration/sfAdministration.js
+++ b/ui/plugins/sfAdministration/sfAdministration.js
@@ -310,9 +310,9 @@
               account: { label: 'label.account' }
             },
             dataProvider: function(args) {
-              var virtualnetworkid = args.context.virtualnetwork[0].id;
+              var clustername = args.context.sfAdministration[0].name;
 
-              plugin.ui.apiCall('listSolidFireVirtualNetworks&' + virtualnetworkid, {
+              plugin.ui.apiCall('listSolidFireVirtualNetworks&clustername=' + clustername,
{
                 success: function(json) {
                   var sfvirtualnetworksfiltered = [];
                   var sfvirtualnetworks = json.listsolidfirevirtualnetworksresponse.sfvirtualnetwork;


Mime
View raw message