Skip to content

Commit 278ef81

Browse files
committed
side-by-side VM sync management at manager level
1 parent 2d42b2d commit 278ef81

26 files changed

Lines changed: 2274 additions & 57 deletions

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ public enum Type {
213213
* UserBareMetal is only used for selecting VirtualMachineGuru, there is no
214214
* VM with this type. UserBareMetal should treat exactly as User.
215215
*/
216-
UserBareMetal(false);
216+
UserBareMetal(false),
217+
218+
/*
219+
* General VM type for queuing VM orchestration work
220+
*/
221+
Instance(false);
217222

218223
boolean _isUsedBySystem;
219224

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
// under the License.
1717
package org.apache.cloudstack.api;
1818

19+
import java.io.Serializable;
20+
1921
// This interface is a contract that getId() will give the internal
2022
// ID of an entity which extends this interface
2123
// Any class having an internal ID in db table/schema should extend this
2224
// For example, all ControlledEntity, OwnedBy would have an internal ID
2325

24-
public interface InternalIdentity {
26+
public interface InternalIdentity extends Serializable {
2527
long getId();
2628
}

api/src/org/apache/cloudstack/context/CallContext.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ public static CallContext register(long callingUserId, long callingAccountId) th
197197
}
198198
return register(user, account);
199199
}
200+
201+
public static CallContext register(long callingUserId, long callingAccountId, String contextId) throws CloudAuthenticationException {
202+
Account account = s_entityMgr.findById(Account.class, callingAccountId);
203+
if (account == null) {
204+
throw new CloudAuthenticationException("The account is no longer current.").add(Account.class, Long.toString(callingAccountId));
205+
}
206+
User user = s_entityMgr.findById(User.class, callingUserId);
207+
if (user == null) {
208+
throw new CloudAuthenticationException("The user is no longer current.").add(User.class, Long.toString(callingUserId));
209+
}
210+
return register(user, account, contextId);
211+
}
200212

201213
public static void unregisterAll() {
202214
while ( unregister() != null ) {

engine/api/src/com/cloud/vm/VirtualMachineManager.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,31 @@ void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params
108108
void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
109109
ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
110110

111+
void orchestrateStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
112+
ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
113+
111114
void advanceStop(String vmUuid, boolean cleanupEvenIfUnableToStop) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;
112115

116+
void orchestrateStop(String vmUuid, boolean cleanupEvenIfUnableToStop) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;
117+
113118
void advanceExpunge(String vmUuid) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;
114119

115120
void destroy(String vmUuid) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException;
116121

117122
void migrateAway(String vmUuid, long hostId) throws InsufficientServerCapacityException;
118123

119124
void migrate(String vmUuid, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException;
125+
126+
void orchestrateMigrate(String vmUuid, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException;
120127

121128
void migrateWithStorage(String vmUuid, long srcId, long destId, Map<Volume, StoragePool> volumeToPool) throws ResourceUnavailableException, ConcurrentOperationException;
122-
129+
130+
void orchestrateMigrateWithStorage(String vmUuid, long srcId, long destId, Map<Volume, StoragePool> volumeToPool) throws ResourceUnavailableException, ConcurrentOperationException;
131+
123132
void reboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException;
124133

134+
void orchestrateReboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException;
135+
125136
void advanceReboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException,
126137
ConcurrentOperationException, OperationTimedoutException;
127138

@@ -137,6 +148,8 @@ void advanceReboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> param
137148
VirtualMachine findById(long vmId);
138149

139150
void storageMigration(String vmUuid, StoragePool storagePoolId);
151+
152+
void orchestrateStorageMigration(String vmUuid, StoragePool storagePoolId);
140153

141154
/**
142155
* @param vmInstance
@@ -161,7 +174,11 @@ void advanceReboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> param
161174
* @throws InsufficientCapacityException
162175
*/
163176
NicProfile addVmToNetwork(VirtualMachine vm, Network network, NicProfile requested) throws ConcurrentOperationException,
164-
ResourceUnavailableException, InsufficientCapacityException;
177+
ResourceUnavailableException, InsufficientCapacityException;
178+
179+
NicProfile orchestrateAddVmToNetwork(VirtualMachine vm, Network network, NicProfile requested) throws ConcurrentOperationException,
180+
ResourceUnavailableException, InsufficientCapacityException;
181+
165182

166183
/**
167184
* @param vm
@@ -172,6 +189,8 @@ NicProfile addVmToNetwork(VirtualMachine vm, Network network, NicProfile request
172189
*/
173190
boolean removeNicFromVm(VirtualMachine vm, Nic nic) throws ConcurrentOperationException, ResourceUnavailableException;
174191

192+
boolean orchestrateRemoveNicFromVm(VirtualMachine vm, Nic nic) throws ConcurrentOperationException, ResourceUnavailableException;
193+
175194
/**
176195
* @param vm
177196
* @param network
@@ -181,6 +200,8 @@ NicProfile addVmToNetwork(VirtualMachine vm, Network network, NicProfile request
181200
* @throws ConcurrentOperationException
182201
*/
183202
boolean removeVmFromNetwork(VirtualMachine vm, Network network, URI broadcastUri) throws ConcurrentOperationException, ResourceUnavailableException;
203+
204+
boolean orchestrateRemoveVmFromNetwork(VirtualMachine vm, Network network, URI broadcastUri) throws ConcurrentOperationException, ResourceUnavailableException;
184205

185206
/**
186207
* @param nic
@@ -196,12 +217,15 @@ NicProfile addVmToNetwork(VirtualMachine vm, Network network, NicProfile request
196217
*/
197218
VirtualMachineTO toVmTO(VirtualMachineProfile profile);
198219

199-
200220
VirtualMachine reConfigureVm(String vmUuid, ServiceOffering newServiceOffering, boolean sameHost) throws ResourceUnavailableException, ConcurrentOperationException;
221+
222+
VirtualMachine orchestrateReConfigureVm(String vmUuid, ServiceOffering newServiceOffering, boolean sameHost) throws ResourceUnavailableException, ConcurrentOperationException;
201223

202224
void findHostAndMigrate(String vmUuid, Long newSvcOfferingId, DeploymentPlanner.ExcludeList excludeHostList) throws InsufficientCapacityException,
203225
ConcurrentOperationException, ResourceUnavailableException;
204226

205227
void migrateForScale(String vmUuid, long srcHostId, DeployDestination dest, Long newSvcOfferingId) throws ResourceUnavailableException, ConcurrentOperationException;
228+
229+
void orchestrateMigrateForScale(String vmUuid, long srcHostId, DeployDestination dest, Long newSvcOfferingId) throws ResourceUnavailableException, ConcurrentOperationException;
206230

207231
}

engine/components-api/src/com/cloud/alert/AlertManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public interface AlertManager extends Manager {
5050
public static final short ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 24;
5151
public static final short ALERT_TYPE_LOCAL_STORAGE = 25;
5252
public static final short ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED = 26; // Generated when the resource limit exceeds the limit. Currently used for recurring snapshots only
53+
54+
public static final short ALERT_TYPE_SYNC = 27;
5355

5456
static final ConfigKey<Double> StorageCapacityThreshold = new ConfigKey<Double>(Double.class, "cluster.storage.capacity.notificationthreshold", "Alert", "0.75",
5557
"Percentage (as a value between 0 and 1) of storage utilization above which alerts will be sent about low storage available.", true, ConfigKey.Scope.Cluster, null);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.vm;
18+
19+
import java.io.Serializable;
20+
21+
public class VmWork implements Serializable {
22+
private static final long serialVersionUID = -6946320465729853589L;
23+
24+
long userId;
25+
long accountId;
26+
long vmId;
27+
28+
public VmWork(long userId, long accountId, long vmId) {
29+
this.userId = userId;
30+
this.accountId = accountId;
31+
this.vmId = vmId;
32+
}
33+
34+
public long getUserId() {
35+
return userId;
36+
}
37+
38+
public long getAccountId() {
39+
return accountId;
40+
}
41+
42+
public long getVmId() {
43+
return vmId;
44+
}
45+
}

engine/orchestration/resources/META-INF/cloudstack/core/spring-engine-orchestration-core-context.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@
6767

6868
<bean id="virtualMachineEntityImpl" class="org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl" />
6969

70+
<bean id="virtualMachinePowerStateSyncImpl" class="com.cloud.vm.VirtualMachinePowerStateSyncImpl" />
7071

7172
</beans>

0 commit comments

Comments
 (0)