Skip to content

Commit 2cd70d0

Browse files
committed
Merge branch 'master' into ui-cisco-asa1000v-support
2 parents ad8f106 + 4c0eecc commit 2cd70d0

102 files changed

Lines changed: 3810 additions & 1183 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/src/com/cloud/async/AsyncJob.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public enum Type {
5050
AutoScaleVmProfile,
5151
AutoScaleVmGroup,
5252
GlobalLoadBalancerRule,
53-
AffinityGroup
53+
AffinityGroup,
54+
DedicatedGuestVlanRange
5455
}
5556

5657
long getUserId();

api/src/com/cloud/event/EventTypes.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ public class EventTypes {
390390
public static final String EVENT_AFFINITY_GROUP_REMOVE = "AG.REMOVE";
391391
public static final String EVENT_VM_AFFINITY_GROUP_UPDATE = "VM.AG.UPDATE";
392392

393+
// Dedicated guest vlan range
394+
public static final String EVENT_GUEST_VLAN_RANGE_DEDICATE = "GUESTVLANRANGE.DEDICATE";
395+
public static final String EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE = "GUESTVLANRANGE.RELEASE";
396+
393397
static {
394398

395399
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
@@ -690,6 +694,9 @@ public class EventTypes {
690694
entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_UPDATE, AutoScaleVmGroup.class.getName());
691695
entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_ENABLE, AutoScaleVmGroup.class.getName());
692696
entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_DISABLE, AutoScaleVmGroup.class.getName());
697+
698+
entityEventDetails.put(EVENT_GUEST_VLAN_RANGE_DEDICATE, GuestVlan.class.getName());
699+
entityEventDetails.put(EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE, GuestVlan.class.getName());
693700
}
694701

695702
public static String getEntityForEvent (String eventName) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.network;
18+
19+
import org.apache.cloudstack.api.Identity;
20+
import org.apache.cloudstack.api.InternalIdentity;
21+
22+
public interface GuestVlan extends InternalIdentity, Identity {
23+
24+
public long getId();
25+
26+
public long getAccountId();
27+
28+
public String getGuestVlanRange();
29+
30+
public long getPhysicalNetworkId();
31+
}

api/src/com/cloud/network/NetworkService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import java.util.List;
2020

21+
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
22+
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
2123
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
2224
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
2325
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
@@ -29,6 +31,7 @@
2931
import com.cloud.exception.InsufficientCapacityException;
3032
import com.cloud.exception.ResourceAllocationException;
3133
import com.cloud.exception.ResourceUnavailableException;
34+
import com.cloud.network.GuestVlan;
3235
import com.cloud.network.Network.Service;
3336
import com.cloud.network.Networks.TrafficType;
3437
import com.cloud.user.Account;
@@ -114,6 +117,12 @@ PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkI
114117

115118
boolean deletePhysicalNetworkTrafficType(Long id);
116119

120+
GuestVlan dedicateGuestVlanRange(DedicateGuestVlanRangeCmd cmd);
121+
122+
Pair<List<? extends GuestVlan>, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd cmd);
123+
124+
boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId);
125+
117126
Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long physicalNetworkId);
118127

119128

api/src/com/cloud/network/rules/RulesService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public interface RulesService {
6767

6868
boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
6969

70-
boolean enableStaticNat(long ipAddressId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException;
70+
boolean enableStaticNat(long ipAddressId, long vmId, long networkId, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException;
7171

7272
PortForwardingRule getPortForwardigRule(long ruleId);
7373

api/src/com/cloud/vm/UserVmService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,6 @@ VirtualMachine migrateVirtualMachineWithVolume(Long vmId, Host destinationHost,
451451

452452
UserVm restoreVM(RestoreVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException;
453453

454-
UserVm upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;
454+
boolean upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;
455455

456456
}

api/src/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public class ApiConstants {
8585
public static final String GSLB_SERVICE_TYPE = "gslbservicetype";
8686
public static final String GSLB_STICKY_SESSION_METHOD = "gslbstickysessionmethodname";
8787
public static final String GUEST_CIDR_ADDRESS = "guestcidraddress";
88+
public static final String GUEST_VLAN_RANGE = "guestvlanrange";
8889
public static final String HA_ENABLE = "haenable";
8990
public static final String HOST_ID = "hostid";
9091
public static final String HOST_NAME = "hostname";
@@ -221,6 +222,7 @@ public class ApiConstants {
221222
public static final String VIRTUAL_MACHINE_ID = "virtualmachineid";
222223
public static final String VIRTUAL_MACHINE_IDS = "virtualmachineids";
223224
public static final String VLAN = "vlan";
225+
public static final String VLAN_RANGE = "vlanrange";
224226
public static final String REMOVE_VLAN="removevlan";
225227
public static final String VLAN_ID = "vlanid";
226228
public static final String VM_AVAILABLE = "vmavailable";

api/src/org/apache/cloudstack/api/ResponseGenerator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ public interface ResponseGenerator {
198198

199199
IPAddressResponse createIPAddressResponse(IpAddress ipAddress);
200200

201+
GuestVlanRangeResponse createDedicatedGuestVlanRangeResponse(GuestVlan result);
202+
201203
GlobalLoadBalancerResponse createGlobalLoadBalancerResponse(GlobalLoadBalancerRule globalLoadBalancerRule);
202204

203205
LoadBalancerResponse createLoadBalancerResponse(LoadBalancer loadBalancer);
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.cloudstack.api.command.admin.network;
20+
21+
import com.cloud.exception.ResourceAllocationException;
22+
import com.cloud.exception.ResourceUnavailableException;
23+
import com.cloud.network.GuestVlan;
24+
import com.cloud.user.Account;
25+
import org.apache.cloudstack.api.APICommand;
26+
import org.apache.cloudstack.api.ApiConstants;
27+
import org.apache.cloudstack.api.ApiErrorCode;
28+
import org.apache.cloudstack.api.BaseCmd;
29+
import org.apache.cloudstack.api.Parameter;
30+
import org.apache.cloudstack.api.ServerApiException;
31+
import org.apache.cloudstack.api.response.DomainResponse;
32+
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
33+
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
34+
import org.apache.cloudstack.api.response.ProjectResponse;
35+
import org.apache.log4j.Logger;
36+
37+
@APICommand(name = "dedicateGuestVlanRange", description="Dedicates a guest vlan range to an account", responseObject=GuestVlanRangeResponse.class)
38+
public class DedicateGuestVlanRangeCmd extends BaseCmd {
39+
public static final Logger s_logger = Logger.getLogger(DedicateGuestVlanRangeCmd.class.getName());
40+
41+
private static final String s_name = "dedicateguestvlanrangeresponse";
42+
43+
/////////////////////////////////////////////////////
44+
//////////////// API parameters /////////////////////
45+
/////////////////////////////////////////////////////
46+
47+
@Parameter(name=ApiConstants.VLAN_RANGE, type=CommandType.STRING, required=true,
48+
description="guest vlan range to be dedicated")
49+
private String vlan;
50+
51+
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, required=true,
52+
description="account who will own the VLAN")
53+
private String accountName;
54+
55+
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
56+
description="project who will own the VLAN")
57+
private Long projectId;
58+
59+
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class,
60+
required=true, description="domain ID of the account owning a VLAN")
61+
private Long domainId;
62+
63+
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID, entityType = PhysicalNetworkResponse.class,
64+
required=true, description="physical network ID of the vlan")
65+
private Long physicalNetworkId;
66+
67+
/////////////////////////////////////////////////////
68+
/////////////////// Accessors ///////////////////////
69+
/////////////////////////////////////////////////////
70+
71+
public String getVlan() {
72+
return vlan;
73+
}
74+
75+
public String getAccountName() {
76+
return accountName;
77+
}
78+
79+
public Long getDomainId() {
80+
return domainId;
81+
}
82+
83+
public Long getPhysicalNetworkId() {
84+
return physicalNetworkId;
85+
}
86+
87+
public Long getProjectId() {
88+
return projectId;
89+
}
90+
91+
/////////////////////////////////////////////////////
92+
/////////////// API Implementation///////////////////
93+
/////////////////////////////////////////////////////
94+
95+
@Override
96+
public String getCommandName() {
97+
return s_name;
98+
}
99+
100+
@Override
101+
public long getEntityOwnerId() {
102+
return Account.ACCOUNT_ID_SYSTEM;
103+
}
104+
105+
@Override
106+
public void execute() throws ResourceUnavailableException, ResourceAllocationException {
107+
GuestVlan result = _networkService.dedicateGuestVlanRange(this);
108+
if (result != null) {
109+
GuestVlanRangeResponse response = _responseGenerator.createDedicatedGuestVlanRangeResponse(result);
110+
response.setResponseName(getCommandName());
111+
response.setObjectName("dedicatedguestvlanrange");
112+
this.setResponseObject(response);
113+
} else {
114+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate guest vlan range");
115+
}
116+
}
117+
118+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.api.command.admin.network;
18+
19+
import com.cloud.network.GuestVlan;
20+
import com.cloud.user.Account;
21+
import com.cloud.utils.Pair;
22+
import org.apache.cloudstack.api.*;
23+
import org.apache.cloudstack.api.response.*;
24+
import org.apache.log4j.Logger;
25+
26+
import java.util.ArrayList;
27+
import java.util.List;
28+
29+
30+
@APICommand(name = "listDedicatedGuestVlanRanges", description="Lists dedicated guest vlan ranges", responseObject=GuestVlanRangeResponse.class)
31+
public class ListDedicatedGuestVlanRangesCmd extends BaseListCmd {
32+
public static final Logger s_logger = Logger.getLogger(ListDedicatedGuestVlanRangesCmd.class.getName());
33+
34+
private static final String s_name = "listdedicatedguestvlanrangesresponse";
35+
36+
/////////////////////////////////////////////////////
37+
//////////////// API parameters /////////////////////
38+
/////////////////////////////////////////////////////
39+
40+
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=GuestVlanRangeResponse.class,
41+
description="list dedicated guest vlan ranges by id")
42+
private Long id;
43+
44+
@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.")
45+
private String accountName;
46+
47+
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
48+
description="project who will own the guest VLAN range")
49+
private Long projectId;
50+
51+
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class,
52+
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.")
53+
private Long domainId;
54+
55+
@Parameter(name=ApiConstants.GUEST_VLAN_RANGE, type=CommandType.STRING, description="the dedicated guest vlan range")
56+
private String guestVlanRange;
57+
58+
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID, entityType = PhysicalNetworkResponse.class,
59+
description="physical network id of the guest VLAN range")
60+
private Long physicalNetworkId;
61+
62+
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
63+
description="zone of the guest VLAN range")
64+
private Long zoneId;
65+
66+
/////////////////////////////////////////////////////
67+
/////////////////// Accessors ///////////////////////
68+
/////////////////////////////////////////////////////
69+
70+
public Long getId() {
71+
return id;
72+
}
73+
74+
public String getAccountName() {
75+
return accountName;
76+
}
77+
78+
public Long getDomainId() {
79+
return domainId;
80+
}
81+
82+
public Long getProjectId() {
83+
return projectId;
84+
}
85+
86+
public String getGuestVlanRange() {
87+
return guestVlanRange;
88+
}
89+
90+
public Long getPhysicalNetworkId() {
91+
return physicalNetworkId;
92+
}
93+
94+
public Long getZoneId() {
95+
return zoneId;
96+
}
97+
98+
99+
/////////////////////////////////////////////////////
100+
/////////////// API Implementation///////////////////
101+
/////////////////////////////////////////////////////
102+
103+
@Override
104+
public String getCommandName() {
105+
return s_name;
106+
}
107+
108+
@Override
109+
public long getEntityOwnerId() {
110+
return Account.ACCOUNT_ID_SYSTEM;
111+
}
112+
113+
@Override
114+
public void execute(){
115+
Pair<List<? extends GuestVlan>, Integer> vlans = _networkService.listDedicatedGuestVlanRanges(this);
116+
ListResponse<GuestVlanRangeResponse> response = new ListResponse<GuestVlanRangeResponse>();
117+
List<GuestVlanRangeResponse> guestVlanResponses = new ArrayList<GuestVlanRangeResponse>();
118+
for (GuestVlan vlan : vlans.first()) {
119+
GuestVlanRangeResponse guestVlanResponse = _responseGenerator.createDedicatedGuestVlanRangeResponse(vlan);
120+
guestVlanResponse.setObjectName("dedicatedguestvlanrange");
121+
guestVlanResponses.add(guestVlanResponse);
122+
}
123+
124+
response.setResponses(guestVlanResponses, vlans.second());
125+
response.setResponseName(getCommandName());
126+
this.setResponseObject(response);
127+
}
128+
129+
}

0 commit comments

Comments
 (0)