cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtutkow...@apache.org
Subject [18/50] git commit: updated refs/heads/sf-plugins to 157efc3
Date Sat, 19 Sep 2015 01:31:24 GMT
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/620af9ca
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/620af9ca
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/620af9ca

Branch: refs/heads/sf-plugins
Commit: 620af9ca67d8620a6f713cb4d59ffa06a06e6a7a
Parents: 26af0a4
Author: Mike Tutkowski <mike.tutkowski@solidfire.com>
Authored: Wed Jul 8 19:45:54 2015 -0600
Committer: Mike Tutkowski <mike.tutkowski@solidfire.com>
Committed: Fri Sep 18 19:28:19 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/620af9ca/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/620af9ca/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/620af9ca/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/620af9ca/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) {


Mime
View raw message