cloudstack-commits mailing list archives

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


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

Branch: refs/heads/dedicate-guest-vlan-ranges
Commit: e168204dc386f4dbb6a9a81d17cfe1481ba952b5
Parents: 405562f6
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Wed Apr 24 04:26:07 2013 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
Committed: Wed Apr 24 22:42:59 2013 +0530

----------------------------------------------------------------------
 api/src/com/cloud/async/AsyncJob.java              |    3 +-
 api/src/com/cloud/event/EventTypes.java            |    5 +
 api/src/com/cloud/network/NetworkService.java      |    2 +
 .../network/ReleaseDedicatedGuestVlanRangeCmd.java |   94 +++++++++++++++
 .../src/com/cloud/network/NetworkServiceImpl.java  |   22 ++++
 .../src/com/cloud/server/ManagementServerImpl.java |    1 +
 .../com/cloud/network/MockNetworkManagerImpl.java  |    6 +
 .../test/com/cloud/vpc/MockNetworkManagerImpl.java |    7 +
 8 files changed, 139 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e168204d/api/src/com/cloud/async/AsyncJob.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/async/AsyncJob.java b/api/src/com/cloud/async/AsyncJob.java
old mode 100644
new mode 100755
index 866429b..d384a7a
--- a/api/src/com/cloud/async/AsyncJob.java
+++ b/api/src/com/cloud/async/AsyncJob.java
@@ -50,7 +50,8 @@ public interface AsyncJob extends Identity, InternalIdentity {
         AutoScaleVmProfile,
         AutoScaleVmGroup,
         GlobalLoadBalancerRule,
-        AffinityGroup
+        AffinityGroup,
+        DedicatedGuestVlanRange
     }
 
     long getUserId();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e168204d/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index 0ee7f40..8478dbf 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -390,6 +390,9 @@ public class EventTypes {
     public static final String EVENT_AFFINITY_GROUP_REMOVE = "AG.REMOVE";
     public static final String EVENT_VM_AFFINITY_GROUP_UPDATE = "VM.AG.UPDATE";
 
+    // Dedicated guest vlan range
+    public static final String EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE  = "DEDICATED.GUESTVLANRANGE.RELEASE";
+
     static {
 
         // TODO: need a way to force author adding event types to declare the entity details
as well, with out braking
@@ -690,6 +693,8 @@ public class EventTypes {
         entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_UPDATE, AutoScaleVmGroup.class.getName());
         entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_ENABLE, AutoScaleVmGroup.class.getName());
         entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_DISABLE, AutoScaleVmGroup.class.getName());
+
+        entityEventDetails.put(EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE, GuestVlan.class.getName());
     }
 
     public static String getEntityForEvent (String eventName) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e168204d/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 fcfaad2..c7ce73f 100755
--- a/api/src/com/cloud/network/NetworkService.java
+++ b/api/src/com/cloud/network/NetworkService.java
@@ -121,6 +121,8 @@ public interface NetworkService {
 
     Pair<List<? extends GuestVlan>, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd
cmd);
 
+    boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId);
+
     Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long
physicalNetworkId);
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e168204d/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
new file mode 100755
index 0000000..76cb42d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
@@ -0,0 +1,94 @@
+// 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.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceInUseException;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+import org.apache.cloudstack.api.*;
+import org.apache.cloudstack.api.response.CounterResponse;
+import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.log4j.Logger;
+
+@APICommand(name = "releaseDedicatedGuestVlanRange", description = "Releases a dedicated
guest vlan range to the system", responseObject = SuccessResponse.class)
+public class ReleaseDedicatedGuestVlanRangeCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(ReleaseDedicatedGuestVlanRangeCmd.class.getName());
+    private static final String s_name = "releasededicatedguestvlanrangeresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=GuestVlanRangeResponse.class,
+            required=true, description="the ID of the dedicated guest vlan range")
+    private Long id;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.DedicatedGuestVlanRange;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Releasing a dedicated guest vlan range.";
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+
+    @Override
+    public void execute(){
+        UserContext.current().setEventDetails("Dedicated guest vlan range Id: " + id);
+        boolean result = _networkService.releaseDedicatedGuestVlanRange(getId());
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to release
dedicated guest vlan range");
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e168204d/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 b7410a9..0e3624c 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -2911,6 +2911,28 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
     }
 
     @Override
+    @ActionEvent(eventType = EventTypes.EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE, eventDescription
= "releasing" +
+            " dedicated guest vlan range", async = true)
+    @DB
+    public boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId) {
+
+        // Verify dedicated range exists
+        AccountGuestVlanMapVO dedicatedGuestVlan = _accountGuestVlanMapDao.findById(dedicatedGuestVlanRangeId);
+        if (dedicatedGuestVlan == null) {
+            InvalidParameterValueException ex = new InvalidParameterValueException("Dedicated
guest vlan with specified id doesn't exist in the system");
+            ex.addProxyObject(dedicatedGuestVlan, dedicatedGuestVlanRangeId, "dedicatedGuestVlanRangeId");
+            throw ex;
+        }
+
+        // Remove dedication for the guest vlan
+        if (_accountGuestVlanMapDao.remove(dedicatedGuestVlanRangeId)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    @Override
     public List<? extends Service> listNetworkServices(String providerName) {
 
         Provider provider = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e168204d/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 41476ec..b11b47f 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -2196,6 +2196,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         cmdList.add(UpdateStorageNetworkIpRangeCmd.class);
         cmdList.add(DedicateGuestVlanRangeCmd.class);
         cmdList.add(ListDedicatedGuestVlanRangesCmd.class);
+        cmdList.add(ReleaseDedicatedGuestVlanRangeCmd.class);
         cmdList.add(CreateDiskOfferingCmd.class);
         cmdList.add(CreateServiceOfferingCmd.class);
         cmdList.add(DeleteDiskOfferingCmd.class);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e168204d/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 4211bc4..4b2d066 100755
--- a/server/test/com/cloud/network/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java
@@ -348,6 +348,12 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
         return null;
     }
 
+    @Override
+    public boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId) {
+        // TODO Auto-generated method stub
+        return true;
+    }
+
         @Override
     public List<? extends Service> listNetworkServices(String providerName) {
         // TODO Auto-generated method stub

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e168204d/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 3f97a5e..fc6a476 100755
--- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
@@ -361,6 +361,13 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
         return null;
     }
 
+    @Override
+    public boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId) {
+        // TODO Auto-generated method stub
+        return true;
+
+    }
+
     /* (non-Javadoc)
      * @see com.cloud.network.NetworkService#listNetworkServices(java.lang.String)
      */


Mime
View raw message