You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mt...@apache.org on 2015/07/28 22:15:08 UTC

[22/50] git commit: updated refs/heads/sf-plugins to bcf1c72

Send selected zone and account to listSolidFireVirtualNetworks API command


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

Branch: refs/heads/sf-plugins
Commit: 9ca030841dd3ce5c79bbc666eea7ce515b510efe
Parents: 82567f7
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Wed Jul 8 19:45:54 2015 -0600
Committer: CloudStack <cloudstack@cloudstack-virtual-machine.(none)>
Committed: Tue Jul 28 13:42:42 2015 -0600

----------------------------------------------------------------------
 .../ListSolidFireVirtualNetworksCmd.java        |  8 +++++++-
 .../solidfire/ApiSolidFireService2.java         |  5 +++--
 .../solidfire/ApiSolidFireServiceImpl2.java     | 20 +++++++++++++++++---
 ui/plugins/sfSharedVolume/sfSharedVolume.js     | 10 ++++++++--
 4 files changed, 35 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ca03084/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 a8c0ccd..750f1c8 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
@@ -31,6 +31,7 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.helper.ApiHelper;
+import org.apache.cloudstack.api.response.AccountResponse;
 import org.apache.cloudstack.api.response.ApiSolidFireVirtualNetworkResponse;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
@@ -51,6 +52,11 @@ public class ListSolidFireVirtualNetworksCmd extends BaseListCmd {
     @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = ApiHelper.ZONE_ID_DESC)
     private Long _zoneId;
 
+    @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = ApiHelper.ACCOUNT_ID_DESC)
+    private long _accountId;
+
+    @Inject private ApiHelper _apiHelper;
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////
@@ -77,7 +83,7 @@ public class ListSolidFireVirtualNetworksCmd extends BaseListCmd {
                 }
             }
             else {
-                sfVirtualNetworks = _apiSolidFireService2.listSolidFireVirtualNetworks(_zoneId);
+                sfVirtualNetworks = _apiSolidFireService2.listSolidFireVirtualNetworks(_zoneId, _accountId);
             }
 
             ResponseView responseView = ApiHelper.instance().isRootAdmin() ? ResponseView.Full : ResponseView.Restricted;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ca03084/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 288b7f7..07f200a 100644
--- a/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireService2.java
+++ b/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireService2.java
@@ -44,8 +44,9 @@ public interface ApiSolidFireService2 extends PluggableService, Configurable {
 
     SfVirtualNetwork listSolidFireVirtualNetwork(long id);
 
-    // Long (instead of long) because it's optional and null is used to indicate that it's not present
-    List<SfVirtualNetwork> listSolidFireVirtualNetworks(Long zoneId);
+    // 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)
+    List<SfVirtualNetwork> listSolidFireVirtualNetworks(Long zoneId, Long accountId);
 
     SfVirtualNetwork createSolidFireVirtualNetwork(String clusterName, String name, String tag, String startIp, int size,
             String netmask, String svip, long accountId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ca03084/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 9af4ac2..d91febc 100644
--- a/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
+++ b/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
@@ -254,20 +254,34 @@ public class ApiSolidFireServiceImpl2 extends AdapterBase implements APIChecker,
     }
 
     @Override
-    public List<SfVirtualNetwork> listSolidFireVirtualNetworks(Long zoneId) {
+    public List<SfVirtualNetwork> listSolidFireVirtualNetworks(Long zoneId, Long accountId) {
         s_logger.info("listSolidFireVirtualNetworks invoked");
 
         final List<SfVirtualNetworkVO> sfVirtualNetworkVOs;
 
         if (ApiHelper.instance().isRootAdmin()) {
             if (zoneId != null) {
-                sfVirtualNetworkVOs = filterVirtualNetworksByZone(_sfVirtualNetworkDao.listAll(), zoneId);
+                if (accountId != null) {
+                    sfVirtualNetworkVOs = filterVirtualNetworksByZone(_sfVirtualNetworkDao.findByAccountId(accountId), zoneId);
+                }
+                else {
+                    sfVirtualNetworkVOs = filterVirtualNetworksByZone(_sfVirtualNetworkDao.listAll(), zoneId);
+                }
             }
             else {
-                sfVirtualNetworkVOs = _sfVirtualNetworkDao.listAll();
+                if (accountId != null) {
+                    sfVirtualNetworkVOs = _sfVirtualNetworkDao.findByAccountId(accountId);
+                }
+                else {
+                    sfVirtualNetworkVOs = _sfVirtualNetworkDao.listAll();
+                }
             }
         }
         else {
+            if (accountId != null && accountId != _apiHelper.getCallingAccount().getId()) {
+                throw new CloudRuntimeException("Only a root admin can specify an account other than his own.");
+            }
+
             if (zoneId != null) {
                 sfVirtualNetworkVOs = filterVirtualNetworksByZone(_sfVirtualNetworkDao.findByAccountId(ApiHelper.instance().getCallingAccount().getId()), zoneId);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ca03084/ui/plugins/sfSharedVolume/sfSharedVolume.js
----------------------------------------------------------------------
diff --git a/ui/plugins/sfSharedVolume/sfSharedVolume.js b/ui/plugins/sfSharedVolume/sfSharedVolume.js
index 0f55a5d..2d904cd 100644
--- a/ui/plugins/sfSharedVolume/sfSharedVolume.js
+++ b/ui/plugins/sfSharedVolume/sfSharedVolume.js
@@ -131,7 +131,7 @@
                           filteredAccountObjs = accountObjs;
                         }
                         else {
-                          for (int i = 0; i < accountObjs.length; i++) {
+                          for (i = 0; i < accountObjs.length; i++) {
                             var accountObj = accountObjs[i];
 
                             if (accountObj.domainid == g_domainid) {
@@ -155,9 +155,15 @@
                   validation: {
                     required: true
                   },
+                  dependsOn: ['availabilityZone', 'account'],
                   select: function(args) {
+                    var params = [];
+
+                    params.push("&zoneid=" + args.data.availabilityZone);
+                    params.push("&accountid=" + args.data.account);
+
                     $.ajax({
-                      url: createURL("listSolidFireVirtualNetworks"),
+                      url: createURL("listSolidFireVirtualNetworks" + params.join("")),
                       dataType: "json",
                       async: true,
                       success: function(json) {