Skip to content

Commit e27bb55

Browse files
author
Alex Huang
committed
Harmony among gurus
1 parent 8e54a40 commit e27bb55

80 files changed

Lines changed: 1241 additions & 1007 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/api/to/VirtualMachineTO.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import java.util.Map;
2121

2222
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
23+
import com.cloud.vm.VirtualMachine;
2324
import com.cloud.vm.VirtualMachine.Type;
24-
import com.cloud.vm.VirtualMachineProfile;
2525

2626
public class VirtualMachineTO {
2727
private long id;
@@ -39,25 +39,25 @@ public class VirtualMachineTO {
3939
String[] bootupScripts;
4040
boolean rebootOnCrash;
4141
Monitor monitor;
42-
42+
4343
VolumeTO[] disks;
4444
NicTO[] nics;
45-
46-
public VirtualMachineTO(VirtualMachineProfile profile, BootloaderType bootloader) {
47-
this.id = profile.getId();
48-
this.type = profile.getType();
49-
this.cpus = profile.getCpus();
50-
this.minRam = profile.getRam();
51-
this.maxRam = profile.getRam();
52-
this.speed = profile.getSpeed();
53-
this.os = profile.getOs();
54-
this.name = profile.getName();
45+
46+
public VirtualMachineTO(long id, String instanceName, VirtualMachine.Type type, int cpus, Integer speed, long minRam, long maxRam, BootloaderType bootloader, String os) {
47+
this.id = id;
48+
this.name = instanceName;
49+
this.type = type;
50+
this.cpus = cpus;
51+
this.speed = speed;
52+
this.minRam = minRam;
53+
this.maxRam = maxRam;
5554
this.bootloader = bootloader;
55+
this.os = os;
5656
}
5757

5858
protected VirtualMachineTO() {
5959
}
60-
60+
6161
public long getId() {
6262
return id;
6363
}
@@ -69,19 +69,19 @@ public void setId(long id) {
6969
public String getName() {
7070
return name;
7171
}
72-
72+
7373
public Monitor getMonitor() {
7474
return monitor;
7575
}
76-
76+
7777
public void setMonitor(Monitor monitor) {
7878
this.monitor = monitor;
7979
}
8080

8181
public void setName(String name) {
8282
this.name = name;
8383
}
84-
84+
8585
public Type getType() {
8686
return type;
8787
}
@@ -101,11 +101,11 @@ public int getCpus() {
101101
public void setCpus(int cpus) {
102102
this.cpus = cpus;
103103
}
104-
104+
105105
public Integer getSpeed() {
106106
return speed;
107107
}
108-
108+
109109
public long getMinRam() {
110110
return minRam;
111111
}
@@ -142,7 +142,7 @@ public String getOs() {
142142
public void setOs(String os) {
143143
this.os = os;
144144
}
145-
145+
146146
public String getBootArgs() {
147147
StringBuilder buf = new StringBuilder(bootArgs != null ? bootArgs : "");
148148
buf.append(" ");
@@ -155,9 +155,9 @@ public String getBootArgs() {
155155
public void setBootArgs(String bootArgs) {
156156
this.bootArgs = bootArgs;
157157
}
158-
158+
159159
public void setBootArgs(Map<String, String> bootParams) {
160-
StringBuilder buf = new StringBuilder();
160+
StringBuilder buf = new StringBuilder();
161161
for (Map.Entry<String, String> entry : bootParams.entrySet()) {
162162
buf.append(" ").append(entry.getKey()).append("=").append(entry.getValue());
163163
}
@@ -187,23 +187,23 @@ public NicTO[] getNics() {
187187
public void setNics(NicTO[] nics) {
188188
this.nics = nics;
189189
}
190-
190+
191191
public static interface Monitor {
192-
192+
193193
}
194-
194+
195195
public static class SshMonitor implements Monitor {
196196
String ip;
197197
int port;
198-
198+
199199
public String getIp() {
200200
return ip;
201201
}
202-
202+
203203
public int getPort() {
204204
return port;
205205
}
206-
206+
207207
public SshMonitor(String ip, int port) {
208208
this.ip = ip;
209209
this.port = port;

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,38 @@
1919

2020
public class DataCenterDeployment implements DeploymentPlan {
2121
long _dcId;
22-
int _count;
22+
Long _podId;
23+
Long _clusterId;
24+
Long _poolId;
2325

24-
public DataCenterDeployment(long dataCenterId, int count) {
26+
public DataCenterDeployment(long dataCenterId) {
27+
this(dataCenterId, null, null, null);
28+
}
29+
30+
public DataCenterDeployment(long dataCenterId, Long podId, Long clusterId, Long poolId) {
2531
_dcId = dataCenterId;
32+
_podId = podId;
33+
_clusterId = clusterId;
34+
_poolId = poolId;
2635
}
2736

2837
@Override
2938
public long getDataCenterId() {
3039
return _dcId;
3140
}
41+
42+
@Override
43+
public Long getPodId() {
44+
return _podId;
45+
}
46+
47+
@Override
48+
public Long getClusterId() {
49+
return _clusterId;
50+
}
3251

3352
@Override
34-
public int getCount() {
35-
return _count;
53+
public Long getPoolId() {
54+
return _poolId;
3655
}
3756
}

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,29 @@
1919

2020
/**
2121
* Describes how a VM should be deployed.
22-
*
2322
*/
2423
public interface DeploymentPlan {
2524
// TODO: This interface is not fully developed. It really
2625
// should be more complicated than this and allow a
27-
// number of parameters to be specified.
26+
// number of parameters to be specified.
27+
28+
/**
29+
* @return data center the VM should deploy in.
30+
*/
2831
public long getDataCenterId();
29-
public int getCount();
32+
33+
/**
34+
* @return pod the Vm should deploy in; null if no preference.
35+
*/
36+
public Long getPodId();
37+
38+
/**
39+
* @return cluster the VM should deploy in; null if no preference.
40+
*/
41+
public Long getClusterId();
42+
43+
/**
44+
* @return pool the VM should be created in; null if no preference.
45+
*/
46+
public Long getPoolId();
3047
}

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,20 @@
1717
*/
1818
package com.cloud.hypervisor;
1919

20-
import com.cloud.offering.ServiceOffering;
20+
import com.cloud.agent.api.to.VirtualMachineTO;
21+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
2122
import com.cloud.utils.component.Adapter;
2223
import com.cloud.vm.VirtualMachine;
2324
import com.cloud.vm.VirtualMachineProfile;
2425

2526
public interface HypervisorGuru extends Adapter {
26-
VirtualMachineProfile design(VirtualMachine vm, ServiceOffering offering);
27-
boolean check(VirtualMachineProfile profile);
27+
HypervisorType getHypervisorType();
28+
29+
/**
30+
* Convert from a virtual machine to the
31+
* virtual machine that the hypervisor expects.
32+
* @param vm
33+
* @return
34+
*/
35+
<T extends VirtualMachine> VirtualMachineTO implement(VirtualMachineProfile<T> vm);
2836
}

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

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.cloud.user.Account;
1313
import com.cloud.utils.component.Adapter;
1414
import com.cloud.vm.NicProfile;
15+
import com.cloud.vm.VirtualMachine;
1516
import com.cloud.vm.VirtualMachineProfile;
1617

1718
/**
@@ -21,14 +22,49 @@
2122
*
2223
*/
2324
public interface NetworkGuru extends Adapter {
25+
/**
26+
* Design a network configuration given the information.
27+
* @param offering network offering that contains the information.
28+
* @param plan where is this network configuration will be deployed.
29+
* @param userSpecified user specified parameters for this network configuration.
30+
* @param owner owner of this network configuration.
31+
* @return NetworkConfiguration
32+
*/
2433
NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration userSpecified, Account owner);
2534

26-
NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination);
27-
28-
NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
35+
/**
36+
* allocate a nic in this network. This method implementation cannot take a long time as
37+
* it is meant to allocate for the DB.
38+
* @param config configuration to allocate the nic in.
39+
* @param nic user specified
40+
* @param vm virtual machine the network configuraiton will be in.
41+
* @return NicProfile.
42+
* @throws InsufficientVirtualNetworkCapcityException
43+
* @throws InsufficientAddressCapacityException
44+
*/
45+
NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
2946

30-
String reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
47+
/**
48+
* Fully implement the network configuration as specified.
49+
* @param config network configuration
50+
* @param offering offering that the network configuration was based on.
51+
* @param destination where were deploying to.
52+
* @return a fully implemented NetworkConfiguration.
53+
*/
54+
NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination);
3155

56+
/**
57+
* reserve a nic for this VM in this network.
58+
* @param nic
59+
* @param config
60+
* @param vm
61+
* @param dest
62+
* @return
63+
* @throws InsufficientVirtualNetworkCapcityException
64+
* @throws InsufficientAddressCapacityException
65+
*/
66+
String reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
67+
3268
boolean release(String uniqueId);
3369

3470
void destroy(NetworkConfiguration config, NetworkOffering offering);

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
import com.cloud.exception.ResourceUnavailableException;
1111
import com.cloud.network.NetworkConfiguration;
1212
import com.cloud.offering.NetworkOffering;
13-
import com.cloud.user.Account;
1413
import com.cloud.utils.component.Adapter;
1514
import com.cloud.vm.NicProfile;
15+
import com.cloud.vm.ReservationContext;
16+
import com.cloud.vm.VirtualMachine;
1617
import com.cloud.vm.VirtualMachineProfile;
1718

1819
/**
@@ -25,11 +26,11 @@ public interface NetworkElement extends Adapter {
2526
* @param offering network offering that originated the network configuration.
2627
* @return true if network configuration is now usable; false if not; null if not handled by this element.
2728
*/
28-
boolean implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination dest, Account user) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
29+
boolean implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
2930

30-
boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, DeployDestination dest, Account user) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientNetworkCapacityException;
31+
boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientNetworkCapacityException;
3132

32-
boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user) throws ConcurrentOperationException, ResourceUnavailableException;
33+
boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
3334

34-
boolean shutdown(NetworkConfiguration config, NetworkOffering offering, Account user) throws ConcurrentOperationException, ResourceUnavailableException;
35+
boolean shutdown(NetworkConfiguration config, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
3536
}

api/src/com/cloud/template/VirtualMachineTemplate.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package com.cloud.template;
1919

2020
import com.cloud.acl.ControlledEntity;
21+
import com.cloud.storage.Storage.ImageFormat;
2122

2223
public interface VirtualMachineTemplate extends ControlledEntity {
2324

@@ -38,4 +39,7 @@ public static enum BootloaderType { PyGrub, HVM, External, CD };
3839
*/
3940
String getName();
4041

42+
ImageFormat getFormat();
43+
44+
boolean isRequiresHvm();
4145
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public enum Type {
5959
/**
6060
* @return the name of the virtual machine.
6161
*/
62-
public String getName();
62+
public String getHostName();
6363

6464
/**
6565
* @return the ip address of the virtual machine.
@@ -95,7 +95,7 @@ public enum Type {
9595
/**
9696
* @return pod id.
9797
*/
98-
public long getPodId();
98+
public Long getPodId();
9999

100100
/**
101101
* @return data center id.
@@ -111,7 +111,7 @@ public enum Type {
111111
* @return should HA be enabled for this machine?
112112
*/
113113
public boolean isHaEnabled();
114-
114+
115115
/**
116116
* @return date when machine was created
117117
*/

0 commit comments

Comments
 (0)