cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From likit...@apache.org
Subject [1/7] git commit: updated refs/heads/dedicate-guest-vlan-ranges to 5f15f38
Date Thu, 25 Apr 2013 23:25:42 GMT
Updated Branches:
  refs/heads/dedicate-guest-vlan-ranges [created] 5f15f3881


guest-vlan: list


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

Branch: refs/heads/dedicate-guest-vlan-ranges
Commit: 405562f63ecfda570cb0bea11097e341c1ad235a
Parents: 75b1105
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Wed Apr 24 02:32:27 2013 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
Committed: Wed Apr 24 22:42:58 2013 +0530

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkService.java      |    3 +
 .../org/apache/cloudstack/api/ApiConstants.java    |    2 +-
 .../network/ListDedicatedGuestVlanRangesCmd.java   |  129 +++++++++++++++
 .../api/response/GuestVlanRangeResponse.java       |   18 ++-
 server/src/com/cloud/api/ApiResponseHelper.java    |    6 +-
 .../src/com/cloud/network/NetworkServiceImpl.java  |   76 +++++++++
 .../src/com/cloud/server/ManagementServerImpl.java |    1 +
 .../com/cloud/network/MockNetworkManagerImpl.java  |    7 +
 .../test/com/cloud/vpc/MockNetworkManagerImpl.java |    7 +
 9 files changed, 244 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/405562f6/api/src/com/cloud/network/NetworkService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java
index 54c7c6b..fcfaad2 100755
--- a/api/src/com/cloud/network/NetworkService.java
+++ b/api/src/com/cloud/network/NetworkService.java
@@ -19,6 +19,7 @@ package com.cloud.network;
 import java.util.List;
 
 import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
+import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
 import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
 import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
 import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
@@ -118,6 +119,8 @@ public interface NetworkService {
 
     GuestVlan dedicateGuestVlanRange(DedicateGuestVlanRangeCmd cmd);
 
+    Pair<List<? extends GuestVlan>, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd
cmd);
+
     Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long
physicalNetworkId);
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/405562f6/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index bf7f615..d57fe05 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -222,7 +222,7 @@ public class ApiConstants {
     public static final String VIRTUAL_MACHINE_ID = "virtualmachineid";
     public static final String VIRTUAL_MACHINE_IDS = "virtualmachineids";
     public static final String VLAN = "vlan";
-    public static final String VLAN = "vlanrange";
+    public static final String VLAN_RANGE = "vlanrange";
     public static final String REMOVE_VLAN="removevlan";
     public static final String VLAN_ID = "vlanid";
     public static final String VM_AVAILABLE = "vmavailable";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/405562f6/api/src/org/apache/cloudstack/api/command/admin/network/ListDedicatedGuestVlanRangesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ListDedicatedGuestVlanRangesCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/network/ListDedicatedGuestVlanRangesCmd.java
new file mode 100755
index 0000000..7f93efc
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/ListDedicatedGuestVlanRangesCmd.java
@@ -0,0 +1,129 @@
+// 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.cloudstack.api.command.admin.network;
+
+import com.cloud.network.GuestVlan;
+import com.cloud.user.Account;
+import com.cloud.utils.Pair;
+import org.apache.cloudstack.api.*;
+import org.apache.cloudstack.api.response.*;
+import org.apache.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+@APICommand(name = "listDedicatedGuestVlanRanges", description="Lists dedicated guest vlan
ranges", responseObject=GuestVlanRangeResponse.class)
+public class ListDedicatedGuestVlanRangesCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListDedicatedGuestVlanRangesCmd.class.getName());
+
+    private static final String s_name = "listdedicatedguestvlanrangesresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=GuestVlanRangeResponse.class,
+            description="list dedicated guest vlan ranges by id")
+    private Long id;
+
+    @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account
with which the guest VLAN range is associated. Must be used with the domainId parameter.")
+    private String accountName;
+
+    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
+            description="project who will own the guest VLAN range")
+    private Long projectId;
+
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class,
+            description="the domain ID with which the guest VLAN range is associated.  If
used with the account parameter, returns all guest VLAN ranges for that account in the specified
domain.")
+    private Long domainId;
+
+    @Parameter(name=ApiConstants.GUEST_VLAN_RANGE, type=CommandType.STRING, description="the
dedicated guest vlan range")
+    private String guestVlanRange;
+
+    @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID, entityType =
PhysicalNetworkResponse.class,
+            description="physical network id of the guest VLAN range")
+    private Long physicalNetworkId;
+
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
+            description="zone of the guest VLAN range")
+    private Long zoneId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public Long getProjectId() {
+        return projectId;
+    }
+
+    public String getGuestVlanRange() {
+        return guestVlanRange;
+    }
+
+    public Long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends GuestVlan>, Integer> vlans = _networkService.listDedicatedGuestVlanRanges(this);
+        ListResponse<GuestVlanRangeResponse> response = new ListResponse<GuestVlanRangeResponse>();
+        List<GuestVlanRangeResponse> guestVlanResponses = new ArrayList<GuestVlanRangeResponse>();
+        for (GuestVlan vlan : vlans.first()) {
+            GuestVlanRangeResponse guestVlanResponse = _responseGenerator.createDedicatedGuestVlanRangeResponse(vlan);
+            guestVlanResponse.setObjectName("dedicatedguestvlanrange");
+            guestVlanResponses.add(guestVlanResponse);
+        }
+
+        response.setResponses(guestVlanResponses, vlans.second());
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/405562f6/api/src/org/apache/cloudstack/api/response/GuestVlanRangeResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/GuestVlanRangeResponse.java b/api/src/org/apache/cloudstack/api/response/GuestVlanRangeResponse.java
index 2c4432c..a070d70 100755
--- a/api/src/org/apache/cloudstack/api/response/GuestVlanRangeResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/GuestVlanRangeResponse.java
@@ -28,7 +28,7 @@ import com.cloud.network.GuestVlan;
 @SuppressWarnings("unused")
 public class GuestVlanRangeResponse extends BaseResponse implements ControlledEntityResponse
{
     @SerializedName(ApiConstants.ID) @Param(description="the ID of the guest VLAN range")
-    private Long id;
+    private String id;
 
     @SerializedName(ApiConstants.ACCOUNT) @Param(description="the account of the guest VLAN
range")
     private String accountName;
@@ -48,8 +48,14 @@ public class GuestVlanRangeResponse extends BaseResponse implements ControlledEn
     @SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the guest
vlan range")
     private String projectName;
 
+    @SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network
of the guest vlan range")
+    private Long physicalNetworkId;
 
-    public void setId(Long id) {
+    @SerializedName(ApiConstants.ZONE_ID) @Param(description="the zone of the guest vlan
range")
+    private Long zoneId;
+
+
+    public void setId(String id) {
         this.id = id;
     }
 
@@ -77,4 +83,12 @@ public class GuestVlanRangeResponse extends BaseResponse implements ControlledEn
         this.projectName = projectName;
     }
 
+    public void setPhysicalNetworkId(Long physicalNetworkId) {
+        this.physicalNetworkId = physicalNetworkId;
+    }
+
+    public void setZoneId(Long zoneId) {
+        this.zoneId = zoneId;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/405562f6/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index b508058..fc68179 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -2738,8 +2738,7 @@ public class ApiResponseHelper implements ResponseGenerator {
     public GuestVlanRangeResponse createDedicatedGuestVlanRangeResponse(GuestVlan vlan) {
         GuestVlanRangeResponse guestVlanRangeResponse = new GuestVlanRangeResponse();
 
-        guestVlanRangeResponse.setId(vlan.getId());
-        // set uuid
+        guestVlanRangeResponse.setId(vlan.getUuid());
         Long accountId= ApiDBUtils.getAccountIdForGuestVlan(vlan.getId());
         Account owner = ApiDBUtils.findAccountById(accountId);
         if (owner != null) {
@@ -2747,6 +2746,9 @@ public class ApiResponseHelper implements ResponseGenerator {
             populateDomain(guestVlanRangeResponse, owner.getDomainId());
         }
         guestVlanRangeResponse.setGuestVlanRange(vlan.getGuestVlanRange());
+        guestVlanRangeResponse.setPhysicalNetworkId(vlan.getPhysicalNetworkId());
+        PhysicalNetworkVO physicalNetwork = ApiDBUtils.findPhysicalNetworkById(vlan.getPhysicalNetworkId());
+        guestVlanRangeResponse.setZoneId(physicalNetwork.getDataCenterId());
 
         return guestVlanRangeResponse;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/405562f6/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index ef74a00..b7410a9 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -86,6 +86,7 @@ import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
+import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
 import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
 import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
 import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
@@ -2835,6 +2836,81 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
     }
 
     @Override
+    public Pair<List<? extends GuestVlan>, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd
cmd) {
+        Long id = cmd.getId();
+        String accountName = cmd.getAccountName();
+        Long domainId = cmd.getDomainId();
+        Long projectId = cmd.getProjectId();
+        String guestVlanRange = cmd.getGuestVlanRange();
+        Long physicalNetworkId = cmd.getPhysicalNetworkId();
+        Long zoneId = cmd.getZoneId();
+
+        Long accountId = null;
+        if (accountName != null && domainId != null) {
+            if (projectId != null) {
+                throw new InvalidParameterValueException("Account and projectId can't be
specified together");
+            }
+            Account account = _accountDao.findActiveAccount(accountName, domainId);
+            if (account == null) {
+                InvalidParameterValueException ex = new InvalidParameterValueException("Unable
to find account " + accountName);
+                ex.addProxyObject("domain", domainId, "domainId");
+                throw ex;
+            } else {
+                accountId = account.getId();
+            }
+        }
+
+        // set project information
+        if (projectId != null) {
+            Project project = _projectMgr.getProject(projectId);
+            if (project == null) {
+                InvalidParameterValueException ex = new InvalidParameterValueException("Unable
to find project by id " + projectId);
+                ex.addProxyObject(project, projectId, "projectId");
+                throw ex;
+            }
+            accountId = project.getProjectAccountId();
+        }
+
+
+        SearchBuilder<AccountGuestVlanMapVO> sb = _accountGuestVlanMapDao.createSearchBuilder();
+        sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
+        sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
+        sb.and("guestVlanRange", sb.entity().getGuestVlanRange(), SearchCriteria.Op.EQ);
+        sb.and("physicalNetworkId", sb.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ);
+
+        if (zoneId != null) {
+            SearchBuilder<PhysicalNetworkVO> physicalnetworkSearch = _physicalNetworkDao.createSearchBuilder();
+            physicalnetworkSearch.and("zoneId", physicalnetworkSearch.entity().getDataCenterId(),
SearchCriteria.Op.EQ);
+            sb.join("physicalnetworkSearch", physicalnetworkSearch, sb.entity().getPhysicalNetworkId(),
physicalnetworkSearch.entity().getId(), JoinBuilder.JoinType.INNER);
+        }
+
+        SearchCriteria<AccountGuestVlanMapVO> sc = sb.create();
+        if (id != null) {
+            sc.setParameters("id", id);
+        }
+
+        if (accountId != null) {
+            sc.setParameters("accountId", accountId);
+        }
+
+        if (guestVlanRange != null) {
+            sc.setParameters("guestVlanRange", guestVlanRange);
+        }
+
+        if (physicalNetworkId != null) {
+            sc.setParameters("physicalNetworkId", physicalNetworkId);
+        }
+
+        if (zoneId != null) {
+            sc.setJoinParameters("physicalnetworkSearch", "zoneId", zoneId);
+        }
+
+        Filter searchFilter = new Filter(AccountGuestVlanMapVO.class, "id", true, cmd.getStartIndex(),
cmd.getPageSizeVal());
+        Pair<List<AccountGuestVlanMapVO>, Integer> result = _accountGuestVlanMapDao.searchAndCount(sc,
searchFilter);
+        return new Pair<List<? extends GuestVlan>, Integer>(result.first(), result.second());
+    }
+
+    @Override
     public List<? extends Service> listNetworkServices(String providerName) {
 
         Provider provider = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/405562f6/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index d3b35c1..41476ec 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -2195,6 +2195,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         cmdList.add(UpdatePhysicalNetworkCmd.class);
         cmdList.add(UpdateStorageNetworkIpRangeCmd.class);
         cmdList.add(DedicateGuestVlanRangeCmd.class);
+        cmdList.add(ListDedicatedGuestVlanRangesCmd.class);
         cmdList.add(CreateDiskOfferingCmd.class);
         cmdList.add(CreateServiceOfferingCmd.class);
         cmdList.add(DeleteDiskOfferingCmd.class);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/405562f6/server/test/com/cloud/network/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java
index 498ec2b..4211bc4 100755
--- a/server/test/com/cloud/network/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java
@@ -56,6 +56,7 @@ import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.VirtualMachineProfileImpl;
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
+import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
 import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
 import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
 import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
@@ -342,6 +343,12 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
     }
 
     @Override
+    public Pair<List<? extends GuestVlan>, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd
cmd) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+        @Override
     public List<? extends Service> listNetworkServices(String providerName) {
         // TODO Auto-generated method stub
         return null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/405562f6/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
index 0af299b..3f97a5e 100755
--- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
@@ -60,6 +60,7 @@ import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.VirtualMachineProfileImpl;
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
+import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
 import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
 import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
 import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
@@ -354,6 +355,12 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
         return null;
     }
 
+    @Override
+    public Pair<List<? extends GuestVlan>, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd
cmd) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
     /* (non-Javadoc)
      * @see com.cloud.network.NetworkService#listNetworkServices(java.lang.String)
      */


Mime
View raw message