Skip to content

Commit 1325014

Browse files
author
Alex Huang
committed
Changed VirtualMachineProfile to be non-generic. From here on VirtualMachineManager will only manage vm instance. It doesn't understand the difference between different types of VMs. This makes the vmsync code to be generic across all vms.
1 parent 7928963 commit 1325014

111 files changed

Lines changed: 548 additions & 1552 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/agent/manager/allocator/HostAllocator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public interface HostAllocator extends Adapter {
4747
* @return List<Host> List of hosts that are suitable for VM allocation
4848
**/
4949

50-
public List<Host> allocateTo(VirtualMachineProfile<?extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo);
50+
public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo);
5151

5252
/**
5353
* Determines which physical hosts are suitable to
@@ -62,7 +62,7 @@ public interface HostAllocator extends Adapter {
6262
* @return List<Host> List of hosts that are suitable for VM allocation
6363
**/
6464

65-
public List<Host> allocateTo(VirtualMachineProfile<?extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity);
65+
public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity);
6666

6767
/**
6868
* Determines which physical hosts are suitable to
@@ -77,7 +77,7 @@ public interface HostAllocator extends Adapter {
7777
* @param boolean considerReservedCapacity (default should be true, set to false if host capacity calculation should not look at reserved capacity)
7878
* @return List<Host> List of hosts that are suitable for VM allocation
7979
**/
80-
public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, List<? extends Host> hosts,
80+
public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, List<? extends Host> hosts,
8181
int returnUpTo, boolean considerReservedCapacity);
8282

8383
public static int RETURN_UPTO_ALL = -1;

api/src/com/cloud/deploy/DeploymentClusterPlanner.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
import java.util.List;
2020

21-
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
2221
import com.cloud.exception.InsufficientServerCapacityException;
23-
import com.cloud.vm.VirtualMachine;
2422
import com.cloud.vm.VirtualMachineProfile;
2523

2624
/**
@@ -38,10 +36,10 @@ public interface DeploymentClusterPlanner extends DeploymentPlanner {
3836
* avoid these data centers, pods, clusters, or hosts.
3937
* @return DeployDestination for that virtual machine.
4038
*/
41-
List<Long> orderClusters(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid)
39+
List<Long> orderClusters(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeList avoid)
4240
throws InsufficientServerCapacityException;
4341

44-
PlannerResourceUsage getResourceUsage(VirtualMachineProfile<? extends VirtualMachine> vmProfile,
42+
PlannerResourceUsage getResourceUsage(VirtualMachineProfile vmProfile,
4543
DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException;
4644

4745
}

api/src/com/cloud/deploy/DeploymentPlanner.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.cloud.org.Cluster;
3030
import com.cloud.storage.StoragePool;
3131
import com.cloud.utils.component.Adapter;
32-
import com.cloud.vm.VirtualMachine;
3332
import com.cloud.vm.VirtualMachineProfile;
3433

3534
/**
@@ -48,7 +47,7 @@ public interface DeploymentPlanner extends Adapter {
4847
* @return DeployDestination for that virtual machine.
4948
*/
5049
@Deprecated
51-
DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException;
50+
DeployDestination plan(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException;
5251

5352
/**
5453
* check() is called right before the virtual machine starts to make sure
@@ -65,7 +64,7 @@ public interface DeploymentPlanner extends Adapter {
6564
* @return true if it's okay to start; false if not. If false, the exclude list will include what should be
6665
* excluded.
6766
*/
68-
boolean check(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, DeployDestination dest, ExcludeList exclude);
67+
boolean check(VirtualMachineProfile vm, DeploymentPlan plan, DeployDestination dest, ExcludeList exclude);
6968

7069
/**
7170
* canHandle is called before plan to determine if the plan can do the allocation. Planers should be exclusive so
@@ -80,7 +79,7 @@ public interface DeploymentPlanner extends Adapter {
8079
* avoid these data centers, pods, clusters, or hosts.
8180
* @return true if it's okay to allocate; false or not
8281
*/
83-
boolean canHandle(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid);
82+
boolean canHandle(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeList avoid);
8483

8584
public enum AllocationAlgorithm {
8685
random,

api/src/com/cloud/hypervisor/HypervisorGuru.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public interface HypervisorGuru extends Adapter {
3636
* @param vm
3737
* @return
3838
*/
39-
<T extends VirtualMachine> VirtualMachineTO implement(VirtualMachineProfile<T> vm);
39+
VirtualMachineTO implement(VirtualMachineProfile vm);
4040

4141
/**
4242
* Give hypervisor guru opportunity to decide if certain command needs to be delegated to other host, mainly to secondary storage VM host

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public interface NetworkMigrationResponder {
3838
* @param context
3939
* @return true when operation was successful.
4040
*/
41-
public boolean prepareMigration(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context);
41+
public boolean prepareMigration(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context);
4242

4343
/**
4444
* Cancel for migration preparation.
@@ -52,7 +52,7 @@ public interface NetworkMigrationResponder {
5252
* @param src The context nic migrates from.
5353
* @param dst The context nic migrates to.
5454
*/
55-
public void rollbackMigration(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext src, ReservationContext dst);
55+
public void rollbackMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst);
5656

5757
/**
5858
* Commit the migration resource.
@@ -66,5 +66,5 @@ public interface NetworkMigrationResponder {
6666
* @param src the context nic migrates from.
6767
* @param dst the context nic migrates to.
6868
*/
69-
public void commitMigration(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext src, ReservationContext dst);
69+
public void commitMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst);
7070
}

api/src/com/cloud/network/element/DhcpServiceProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import com.cloud.vm.VirtualMachineProfile;
2828

2929
public interface DhcpServiceProvider extends NetworkElement {
30-
boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
31-
boolean configDhcpSupportForSubnet(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
30+
boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
31+
boolean configDhcpSupportForSubnet(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
3232
boolean removeDhcpSupportForSubnet(Network network) throws ResourceUnavailableException;
3333
}

api/src/com/cloud/network/element/NetworkElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ boolean implement(Network network, NetworkOffering offering, DeployDestination d
7171
* @throws ResourceUnavailableException
7272
* @throws InsufficientNetworkCapacityException
7373
*/
74-
boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
74+
boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm,
7575
DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
7676
ResourceUnavailableException, InsufficientCapacityException;
7777

@@ -85,7 +85,7 @@ boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends
8585
* @throws ConcurrentOperationException
8686
* @throws ResourceUnavailableException
8787
*/
88-
boolean release(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
88+
boolean release(Network network, NicProfile nic, VirtualMachineProfile vm,
8989
ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
9090

9191
/**

api/src/com/cloud/network/element/UserDataServiceProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import com.cloud.vm.VirtualMachineProfile;
2828

2929
public interface UserDataServiceProvider extends NetworkElement {
30-
public boolean addPasswordAndUserdata(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
31-
boolean savePassword(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws ResourceUnavailableException;
32-
boolean saveUserData(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws ResourceUnavailableException;
33-
boolean saveSSHKey(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, String SSHPublicKey) throws ResourceUnavailableException;
30+
public boolean addPasswordAndUserdata(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
31+
boolean savePassword(Network network, NicProfile nic, VirtualMachineProfile vm) throws ResourceUnavailableException;
32+
boolean saveUserData(Network network, NicProfile nic, VirtualMachineProfile vm) throws ResourceUnavailableException;
33+
boolean saveSSHKey(Network network, NicProfile nic, VirtualMachineProfile vm, String SSHPublicKey) throws ResourceUnavailableException;
3434
}

api/src/com/cloud/network/guru/NetworkGuru.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public interface NetworkGuru extends Adapter {
127127
* @throws InsufficientAddressCapacityException if there are not addresses
128128
* to be assigned.
129129
*/
130-
NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException;
130+
NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException;
131131

132132
/**
133133
* Once a guest network is implemented, then the virtual machine must
@@ -147,7 +147,7 @@ public interface NetworkGuru extends Adapter {
147147
* @throws ConcurrentOperationException if there are multiple operations
148148
* happening on this guest network or vm.
149149
*/
150-
void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException;
150+
void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException;
151151

152152
/**
153153
* When a virtual machine is stopped, the NetworkGuru is informed via the
@@ -158,7 +158,7 @@ public interface NetworkGuru extends Adapter {
158158
* @param reservationId reservation id passed to it in the ReservationContext
159159
* @return true if release is successful or false if unsuccessful.
160160
*/
161-
boolean release(NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, String reservationId);
161+
boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId);
162162

163163
/**
164164
* When a virtual machine is destroyed, the NetworkGuru is informed via
@@ -169,7 +169,7 @@ public interface NetworkGuru extends Adapter {
169169
* @param nic nic that the vm was using to access the guest network.
170170
* @param vm virtual machine being destroyed.
171171
*/
172-
void deallocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm);
172+
void deallocate(Network network, NicProfile nic, VirtualMachineProfile vm);
173173

174174
/**
175175
* @deprecated This method should not be here in the first place. What does this really mean? Is it always persisted

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22-
import com.cloud.agent.api.to.DataTO;
2322
import com.cloud.agent.api.to.DiskTO;
24-
import com.cloud.agent.api.to.VolumeTO;
2523
import com.cloud.hypervisor.Hypervisor.HypervisorType;
2624
import com.cloud.offering.ServiceOffering;
2725
import com.cloud.template.VirtualMachineTemplate;
@@ -33,10 +31,8 @@
3331
* on what the virtual machine profile should look like before it is
3432
* actually started on the hypervisor.
3533
*
36-
* @param <T>
37-
* a VirtualMachine
3834
*/
39-
public interface VirtualMachineProfile<T extends VirtualMachine> {
35+
public interface VirtualMachineProfile {
4036

4137
public static class Param {
4238

@@ -69,7 +65,7 @@ public String getName() {
6965
/**
7066
* @return the virtual machine that backs up this profile.
7167
*/
72-
T getVirtualMachine();
68+
VirtualMachine getVirtualMachine();
7369

7470
/**
7571
* @return service offering for this virtual machine.

0 commit comments

Comments
 (0)