Skip to content

Commit 6134f7d

Browse files
author
Alex Huang
committed
more file changes
1 parent b0acdbc commit 6134f7d

34 files changed

+723
-164
lines changed

core/src/com/cloud/host/Host.java renamed to api/src/com/cloud/host/Host.java

+2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
import java.util.Date;
2121

22+
import com.cloud.host.Status;
2223
import com.cloud.hypervisor.Hypervisor;
24+
import com.cloud.hypervisor.Hypervisor.Type;
2325

2426

2527
/**

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@
88
import com.cloud.network.Network.TrafficType;
99
import com.cloud.user.OwnedBy;
1010

11+
/**
12+
* A NetworkProfile defines the specifics of a network
13+
* owned by an account.
14+
*/
1115
public interface NetworkProfile extends OwnedBy {
1216

13-
long getId();
17+
/**
18+
* @return id of the network profile. Null means the network profile is not from the database.
19+
*/
20+
Long getId();
1421

1522
Mode getMode();
1623

@@ -23,4 +30,6 @@ public interface NetworkProfile extends OwnedBy {
2330
String getCidr();
2431

2532
void setCidr(String cidr);
33+
34+
long getNetworkOfferingId();
2635
}

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

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.util.Collection;
77
import java.util.List;
8+
import java.util.Map;
89

910
import com.cloud.exception.ConflictingNetworkSettingsException;
1011
import com.cloud.offering.NetworkOffering;
@@ -20,6 +21,8 @@
2021
*
2122
*/
2223
public interface NetworkProfiler extends Adapter {
24+
NetworkProfile convert(NetworkOffering offering, Map<String, String> params, Account owner);
25+
2326
List<? extends NetworkProfile> convert(Collection<? extends NetworkOffering> networkOfferings, Account owner);
2427
boolean check(VirtualMachine vm, ServiceOffering serviceOffering, Collection<? extends NetworkProfile> networkProfiles) throws ConflictingNetworkSettingsException;
2528
}

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
*/
44
package com.cloud.vm;
55

6+
import com.cloud.exception.InsufficientAddressCapacityException;
67
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
8+
import com.cloud.network.NetworkProfile;
79
import com.cloud.utils.Pair;
810
import com.cloud.utils.component.Adapter;
911

@@ -16,8 +18,10 @@
1618
*/
1719
public interface NetworkConcierge extends Adapter {
1820
String getUniqueName();
21+
22+
Nic allocate(VirtualMachine vm, NetworkProfile profile, Nic nic);
1923

20-
Pair<String, String> reserve(long vmId, NetworkCharacteristics ch) throws InsufficientVirtualNetworkCapcityException;
24+
Pair<String, String> reserve(long vmId, NetworkCharacteristics ch) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
2125

2226
boolean release(String uniqueName, String uniqueId);
2327
}

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

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package com.cloud.vm;
1919

20+
import com.cloud.network.Network.Mode;
21+
2022

2123
/**
2224
* Nic represents one nic on the VM.
@@ -50,4 +52,6 @@ enum State {
5052
long getInstanceId();
5153

5254
long getDeviceId();
55+
56+
Mode getMode();
5357
}

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class VmCharacteristics {
2929
Hypervisor.Type hypervisorType;
3030
VirtualMachine.Type type;
3131
Map<String, String> params;
32+
Long templateId;
3233

3334
public VmCharacteristics(VirtualMachine.Type type) {
3435
this.type = type;
@@ -38,6 +39,9 @@ public VirtualMachine.Type getType() {
3839
return type;
3940
}
4041

42+
public Long getTemplateId() {
43+
return templateId;
44+
}
4145

4246
public int getCores() {
4347
return core;
@@ -55,15 +59,21 @@ public Hypervisor.Type getHypervisorType() {
5559
return hypervisorType;
5660
}
5761

58-
public VmCharacteristics(long id, int core, int speed, long ram, Hypervisor.Type type, Map<String, String> params) {
62+
public VmCharacteristics(long id, int core, int speed, long ram, Long templateId, Hypervisor.Type type, Map<String, String> params) {
5963
this.core = core;
6064
this.speed = speed;
6165
this.ram = ram;
6266
this.hypervisorType = type;
6367
this.params = params;
6468
this.id = id;
69+
this.templateId = templateId;
6570
}
6671

6772
protected VmCharacteristics() {
6873
}
74+
75+
@Override
76+
public String toString() {
77+
return "VM-" + type + "-" + id;
78+
}
6979
}

core/src/com/cloud/agent/AgentManager.java

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.cloud.utils.Pair;
4545
import com.cloud.utils.component.Manager;
4646
import com.cloud.vm.VMInstanceVO;
47+
import com.cloud.vm.VmCharacteristics;
4748

4849
/**
4950
* AgentManager manages hosts. It directly coordinates between the
@@ -178,6 +179,8 @@ public interface AgentManager extends Manager {
178179
* @return
179180
*/
180181
Pair<HostPodVO, Long> findPod(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc, long userId, Set<Long> avoids);
182+
183+
Host findHost(VmCharacteristics vm, Set<? extends Host> avoids);
181184

182185
/**
183186
* Put the agent in maintenance mode.

core/src/com/cloud/dc/ClusterVO.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
import javax.persistence.Id;
2525
import javax.persistence.Table;
2626

27+
import com.cloud.org.Cluster;
2728
import com.cloud.utils.NumbersUtil;
2829

2930
@Entity
3031
@Table(name="cluster")
31-
public class ClusterVO {
32+
public class ClusterVO implements Cluster {
3233

3334
@Id
3435
@GeneratedValue(strategy = GenerationType.IDENTITY)

core/src/com/cloud/dc/DataCenterVO.java

+14-13
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828

2929
@Entity
3030
@Table(name="data_center")
31-
public class DataCenterVO {
31+
public class DataCenterVO implements DataCenter {
3232

3333
@Id
3434
@GeneratedValue(strategy=GenerationType.IDENTITY)
3535
@Column(name="id")
36-
private Long id = null;
36+
private long id;
3737

3838
@Column(name="name")
3939
private String name = null;
@@ -66,20 +66,20 @@ public class DataCenterVO {
6666
@TableGenerator(name="mac_address_sq", table="data_center", pkColumnName="id", valueColumnName="mac_address", allocationSize=1)
6767
private long macAddress = 1;
6868

69-
public DataCenterVO(Long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr) {
69+
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr) {
70+
this(name, description, dns1, dns2, dns3, dns4, vnet, guestCidr);
7071
this.id = id;
71-
this.name = name;
72-
this.description = description;
73-
this.dns1 = dns1;
74-
this.dns2 = dns2;
75-
this.internalDns1 = dns3;
76-
this.internalDns2 = dns4;
77-
this.vnet = vnet;
78-
this.guestNetworkCidr = guestCidr;
7972
}
8073

8174
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr) {
82-
this(null, name, description, dns1, dns2, dns3, dns4, vnet, guestCidr);
75+
this.name = name;
76+
this.description = description;
77+
this.dns1 = dns1;
78+
this.dns2 = dns2;
79+
this.internalDns1 = dns3;
80+
this.internalDns2 = dns4;
81+
this.vnet = vnet;
82+
this.guestNetworkCidr = guestCidr;
8383
}
8484

8585
public String getDescription() {
@@ -117,7 +117,8 @@ public String getInternalDns2() {
117117
protected DataCenterVO() {
118118
}
119119

120-
public Long getId() {
120+
@Override
121+
public long getId() {
121122
return id;
122123
}
123124

core/src/com/cloud/dc/HostPodVO.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
@Entity
3131
@Table(name = "host_pod_ref")
32-
public class HostPodVO {
32+
public class HostPodVO implements Pod {
3333
@Id
3434
@GeneratedValue(strategy = GenerationType.IDENTITY)
3535
long id;
@@ -67,7 +67,8 @@ public HostPodVO(String name, long dcId, String gateway, String cidrAddress, lon
6767
protected HostPodVO() {
6868
}
6969

70-
public long getId() {
70+
@Override
71+
public long getId() {
7172
return id;
7273
}
7374

core/src/com/cloud/offerings/NetworkOfferingVO.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
public class NetworkOfferingVO implements NetworkOffering {
3838
public final static String SystemVmPublicNetwork = "System-Vm-Public-Network";
3939
public final static String SystemVmGuestNetwork = "System-Vm-Guest-Network";
40-
public final static String SystemVmLinkLocalNetwork = "System-Vm-LinkLocal-Network";
40+
public final static String SystemVmControlNetwork = "System-Vm-Control-Network";
4141
public final static String SystemVmManagementNetwork = "System-Vm-Management-Network";
42+
public final static String SystemVmStorageNetwork = "System-Vm-Storage-Network";
4243

4344
@Id
4445
@GeneratedValue(strategy=GenerationType.IDENTITY)
@@ -71,6 +72,9 @@ public class NetworkOfferingVO implements NetworkOffering {
7172
@Column(name="system_only")
7273
boolean systemOnly;
7374

75+
@Column(name="tags")
76+
String tags;
77+
7478
@Column(name=GenericDao.REMOVED_COLUMN)
7579
Date removed;
7680

@@ -129,6 +133,14 @@ public Integer getConcurrentConnections() {
129133
return concurrentConnections;
130134
}
131135

136+
public String getTags() {
137+
return tags;
138+
}
139+
140+
public void setTags(String tags) {
141+
this.tags = tags;
142+
}
143+
132144
public NetworkOfferingVO() {
133145
}
134146

core/src/com/cloud/storage/StorageManager.java

+17
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.cloud.host.Host;
3434
import com.cloud.host.HostVO;
3535
import com.cloud.service.ServiceOfferingVO;
36+
import com.cloud.storage.Volume.VolumeType;
3637
import com.cloud.user.Account;
3738
import com.cloud.user.AccountVO;
3839
import com.cloud.utils.Pair;
@@ -314,4 +315,20 @@ public long createUserVM(Account account, VMInstanceVO vm,
314315
* @return
315316
*/
316317
public boolean cancelPrimaryStorageForMaintenance(long primaryStorageId, long userId);
318+
319+
/**
320+
* Allocates one volume.
321+
* @param <T>
322+
* @param type
323+
* @param offering
324+
* @param name
325+
* @param size
326+
* @param template
327+
* @param vm
328+
* @param account
329+
* @return VolumeVO a persisted volume.
330+
*/
331+
<T extends VMInstanceVO> VolumeVO allocate(VolumeType type, DiskOfferingVO offering, String name, Long size, VMTemplateVO template, T vm, AccountVO account);
332+
333+
<T extends VMInstanceVO> void create(T vm);
317334
}

core/src/com/cloud/storage/VolumeVO.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ public long getSize() {
296296
return size;
297297
}
298298

299-
public void setSize(long size) {
299+
@Override
300+
public void setSize(long size) {
300301
this.size = size;
301302
}
302303

@@ -402,7 +403,8 @@ public void setDiskOfferingId(long diskOfferingId) {
402403
this.diskOfferingId = diskOfferingId;
403404
}
404405

405-
public Long getTemplateId() {
406+
@Override
407+
public Long getTemplateId() {
406408
return templateId;
407409
}
408410

@@ -435,7 +437,8 @@ public void setStorageResourceType(Storage.StorageResourceType storageResourceTy
435437
this.storageResourceType = storageResourceType2;
436438
}
437439

438-
public Long getPoolId() {
440+
@Override
441+
public Long getPoolId() {
439442
return poolId;
440443
}
441444

@@ -455,7 +458,8 @@ public Date getUpdated() {
455458
return updated;
456459
}
457460

458-
public State getState() {
461+
@Override
462+
public State getState() {
459463
return state;
460464
}
461465

core/src/com/cloud/storage/dao/VolumeDaoImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@
3030

3131
import com.cloud.async.AsyncInstanceCreateStatus;
3232
import com.cloud.storage.Volume;
33-
import com.cloud.storage.VolumeVO;
3433
import com.cloud.storage.Volume.MirrorState;
3534
import com.cloud.storage.Volume.VolumeType;
35+
import com.cloud.storage.VolumeVO;
3636
import com.cloud.utils.Pair;
3737
import com.cloud.utils.db.DB;
3838
import com.cloud.utils.db.GenericDaoBase;
3939
import com.cloud.utils.db.GenericSearchBuilder;
4040
import com.cloud.utils.db.SearchBuilder;
4141
import com.cloud.utils.db.SearchCriteria;
42-
import com.cloud.utils.db.Transaction;
4342
import com.cloud.utils.db.SearchCriteria.Func;
4443
import com.cloud.utils.db.SearchCriteria.Op;
44+
import com.cloud.utils.db.Transaction;
4545
import com.cloud.utils.exception.CloudRuntimeException;
4646

4747
@Local(value=VolumeDao.class) @DB(txn=false)

0 commit comments

Comments
 (0)