Skip to content

Commit 9d158dc

Browse files
author
Alex Huang
committed
Removed the async create status for volume now that our customers don't use it
1 parent 304d1cb commit 9d158dc

21 files changed

Lines changed: 99 additions & 210 deletions

File tree

agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@
171171
import com.cloud.storage.Storage.ImageFormat;
172172
import com.cloud.storage.StorageLayer;
173173
import com.cloud.storage.Volume;
174-
import com.cloud.storage.Volume.VolumeType;
175174
import com.cloud.storage.template.Processor;
176175
import com.cloud.storage.template.Processor.FormatInfo;
177176
import com.cloud.storage.template.QCOW2Processor;
@@ -1708,7 +1707,7 @@ private synchronized Answer execute(PrepareForMigrationCommand cmd) {
17081707
/*setup disks, e.g for iso*/
17091708
VolumeTO[] volumes = vm.getDisks();
17101709
for (VolumeTO volume : volumes) {
1711-
if (volume.getType() == Volume.VolumeType.ISO) {
1710+
if (volume.getType() == Volume.Type.ISO) {
17121711
getVolumePath(conn, volume);
17131712
}
17141713
}
@@ -2109,7 +2108,7 @@ protected synchronized StartAnswer execute(StartCommand cmd) {
21092108
}
21102109

21112110
private String getVolumePath(Connect conn, VolumeTO volume) throws LibvirtException, URISyntaxException {
2112-
if (volume.getType() == Volume.VolumeType.ISO && volume.getPath() != null) {
2111+
if (volume.getType() == Volume.Type.ISO && volume.getPath() != null) {
21132112
StorageVol vol = _storageResource.getVolumeFromURI(conn, volume.getPath());
21142113
return vol.getPath();
21152114
} else {
@@ -2123,7 +2122,7 @@ private void createVbd(Connect conn, VirtualMachineTO vmSpec, String vmName, Lib
21232122

21242123
DiskDef.diskBus diskBusType = getGuestDiskModel(vmSpec.getOs());
21252124
DiskDef disk = new DiskDef();
2126-
if (volume.getType() == VolumeType.ISO) {
2125+
if (volume.getType() == Volume.Type.ISO) {
21272126
if (volPath == null) {
21282127
/*Add iso as placeholder*/
21292128
disk.defISODisk(null);
@@ -2137,7 +2136,7 @@ private void createVbd(Connect conn, VirtualMachineTO vmSpec, String vmName, Lib
21372136
}
21382137

21392138
//Centos doesn't support scsi hotplug. For other host OSes, we attach the disk after the vm is running, so that we can hotplug it.
2140-
if (volume.getType() == VolumeType.DATADISK && diskBusType != DiskDef.diskBus.VIRTIO) {
2139+
if (volume.getType() == Volume.Type.DATADISK && diskBusType != DiskDef.diskBus.VIRTIO) {
21412140
disk.setAttachDeferred(true);
21422141
}
21432142

@@ -2155,7 +2154,7 @@ private void createVbd(Connect conn, VirtualMachineTO vmSpec, String vmName, Lib
21552154
}
21562155
}
21572156

2158-
private VolumeTO getVolume(VirtualMachineTO vmSpec, VolumeType type) {
2157+
private VolumeTO getVolume(VirtualMachineTO vmSpec, Volume.Type type) {
21592158
VolumeTO volumes[] = vmSpec.getDisks();
21602159
for (VolumeTO volume : volumes) {
21612160
if (volume.getType() == type) {
@@ -2169,7 +2168,7 @@ private void createPatchVbd(Connect conn, String vmName, LibvirtVMDef vm, Virtua
21692168

21702169
List<DiskDef> disks = vm.getDevices().getDisks();
21712170
DiskDef rootDisk = disks.get(0);
2172-
VolumeTO rootVol = getVolume(vmSpec, VolumeType.ROOT);
2171+
VolumeTO rootVol = getVolume(vmSpec, Volume.Type.ROOT);
21732172
StoragePool pool = _storageResource.getStoragePool(conn, rootVol.getPoolUuid());
21742173
StorageVol tmplVol = _storageResource.createTmplDataDisk(conn, pool, 10L * 1024 * 1024);
21752174
String datadiskPath = tmplVol.getKey();
@@ -3258,8 +3257,9 @@ private boolean add_network_rules(String vmName, String vmId, String guestIP, St
32583257
cmd.add("--vmmac", mac);
32593258
cmd.add("--vif", vif);
32603259
cmd.add("--brname", brname);
3261-
if (rules != null)
3262-
cmd.add("--rules", newRules);
3260+
if (rules != null) {
3261+
cmd.add("--rules", newRules);
3262+
}
32633263
String result = cmd.execute();
32643264
if (result != null) {
32653265
return false;

api/src/com/cloud/agent/api/to/VolumeTO.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ protected VolumeTO() {
3131
private String mountPoint;
3232
private String path;
3333
private long size;
34-
private Volume.VolumeType type;
34+
private Volume.Type type;
3535
private Storage.StorageResourceType resourceType;
3636
private StoragePoolType storagePoolType;
3737
private String storagePoolUuid;
3838
private long deviceId;
3939
private String chainInfo;
4040
private String guestOsType;
4141

42-
public VolumeTO(long id, Volume.VolumeType type, Storage.StorageResourceType resourceType, StoragePoolType poolType,
42+
public VolumeTO(long id, Volume.Type type, Storage.StorageResourceType resourceType, StoragePoolType poolType,
4343
String poolUuid, String name, String mountPoint, String path, long size, String chainInfo) {
4444
this.id = id;
4545
this.name= name;
@@ -53,7 +53,7 @@ public VolumeTO(long id, Volume.VolumeType type, Storage.StorageResourceType res
5353
this.chainInfo = chainInfo;
5454
}
5555

56-
public VolumeTO(long id, Volume.VolumeType type, Storage.StorageResourceType resourceType, StoragePoolType poolType,
56+
public VolumeTO(long id, Volume.Type type, Storage.StorageResourceType resourceType, StoragePoolType poolType,
5757
String poolUuid, String name, String mountPoint, String path, long size, String chainInfo, String guestOsType) {
5858
this.id = id;
5959
this.name= name;
@@ -107,7 +107,7 @@ public long getSize() {
107107
return size;
108108
}
109109

110-
public Volume.VolumeType getType() {
110+
public Volume.Type getType() {
111111
return type;
112112
}
113113

api/src/com/cloud/storage/Volume.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@
2222
import java.util.Set;
2323

2424
import com.cloud.acl.ControlledEntity;
25-
import com.cloud.async.AsyncInstanceCreateStatus;
2625
import com.cloud.template.BasedOn;
2726
import com.cloud.utils.fsm.FiniteState;
2827
import com.cloud.utils.fsm.StateMachine;
2928

3029

3130
public interface Volume extends ControlledEntity, BasedOn {
32-
enum VolumeType {UNKNOWN, ROOT, SWAP, DATADISK, ISO};
31+
enum Type {UNKNOWN, ROOT, SWAP, DATADISK, ISO};
3332

3433
enum State implements FiniteState<State, Event> {
3534
Allocated("The volume is allocated but has not been created yet."),
@@ -119,7 +118,7 @@ enum Event {
119118

120119
long getDataCenterId();
121120

122-
VolumeType getVolumeType();
121+
Type getVolumeType();
123122

124123
Storage.StorageResourceType getStorageResourceType();
125124

@@ -132,7 +131,6 @@ enum Event {
132131
Long getDeviceId();
133132

134133
Date getCreated();
135-
AsyncInstanceCreateStatus getStatus();
136134

137135
long getDiskOfferingId();
138136

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class DiskProfile {
3131
private long size;
3232
private String[] tags;
33-
private Volume.VolumeType type;
33+
private Volume.Type type;
3434
private String name;
3535
private boolean useLocalStorage;
3636
private boolean recreatable;
@@ -43,7 +43,7 @@ public class DiskProfile {
4343
protected DiskProfile() {
4444
}
4545

46-
public DiskProfile(long volumeId, Volume.VolumeType type, String name, long diskOfferingId, long size, String[] tags, boolean useLocalStorage, boolean recreatable, Long templateId) {
46+
public DiskProfile(long volumeId, Volume.Type type, String name, long diskOfferingId, long size, String[] tags, boolean useLocalStorage, boolean recreatable, Long templateId) {
4747
this.type = type;
4848
this.name = name;
4949
this.size = size;
@@ -91,7 +91,7 @@ public String[] getTags() {
9191
/**
9292
* @return type of volume.
9393
*/
94-
public Volume.VolumeType getType() {
94+
public Volume.Type getType() {
9595
return type;
9696
}
9797

core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@
175175
import com.cloud.storage.Storage.ImageFormat;
176176
import com.cloud.storage.Storage.StoragePoolType;
177177
import com.cloud.storage.Volume;
178-
import com.cloud.storage.Volume.VolumeType;
179178
import com.cloud.storage.VolumeVO;
180179
import com.cloud.storage.resource.StoragePoolResource;
181180
import com.cloud.storage.template.TemplateInfo;
@@ -292,8 +291,9 @@ protected boolean cleanupHaltedVms(Connection conn) throws XenAPIException, XmlR
292291
for (Map.Entry<VM, VM.Record> entry : vms.entrySet()) {
293292
VM vm = entry.getKey();
294293
VM.Record vmRec = entry.getValue();
295-
if ( vmRec.isATemplate || vmRec.isControlDomain )
294+
if ( vmRec.isATemplate || vmRec.isControlDomain ) {
296295
continue;
296+
}
297297

298298
if (VmPowerState.HALTED.equals(vmRec.powerState) && vmRec.affinity.equals(host)) {
299299
try {
@@ -690,7 +690,7 @@ protected void prepareISO(Connection conn, String vmName) throws XmlRpcException
690690
}
691691

692692
protected VDI mount(Connection conn, String vmName, VolumeTO volume) throws XmlRpcException, XenAPIException {
693-
if (volume.getType() == VolumeType.ISO) {
693+
if (volume.getType() == Volume.Type.ISO) {
694694

695695
String isopath = volume.getPath();
696696
if (isopath == null) {
@@ -721,7 +721,7 @@ protected VDI mount(Connection conn, String vmName, VolumeTO volume) throws XmlR
721721
}
722722

723723
protected VBD createVbd(Connection conn, VolumeTO volume, String vmName, VM vm, BootloaderType bootLoaderType) throws XmlRpcException, XenAPIException {
724-
VolumeType type = volume.getType();
724+
Volume.Type type = volume.getType();
725725

726726
VDI vdi = mount(conn, vmName, volume);
727727

@@ -732,17 +732,17 @@ protected VBD createVbd(Connection conn, VolumeTO volume, String vmName, VM vm,
732732
} else {
733733
vbdr.empty = true;
734734
}
735-
if (type == VolumeType.ROOT && bootLoaderType == BootloaderType.PyGrub) {
735+
if (type == Volume.Type.ROOT && bootLoaderType == BootloaderType.PyGrub) {
736736
vbdr.bootable = true;
737-
}else if(type == VolumeType.ISO && bootLoaderType == BootloaderType.CD) {
737+
}else if(type == Volume.Type.ISO && bootLoaderType == BootloaderType.CD) {
738738
vbdr.bootable = true;
739739
}
740740

741741
vbdr.userdevice = Long.toString(volume.getDeviceId());
742-
if (volume.getType() == VolumeType.ISO) {
742+
if (volume.getType() == Volume.Type.ISO) {
743743
vbdr.mode = Types.VbdMode.RO;
744744
vbdr.type = Types.VbdType.CD;
745-
} else if (volume.getType() == VolumeType.ROOT) {
745+
} else if (volume.getType() == Volume.Type.ROOT) {
746746
vbdr.mode = Types.VbdMode.RW;
747747
vbdr.type = Types.VbdType.DISK;
748748
vbdr.unpluggable = false;
@@ -825,7 +825,7 @@ protected VM createVmFromTemplate(Connection conn, VirtualMachineTO vmSpec, Host
825825
if (vmSpec.getBootloader() == BootloaderType.CD) {
826826
VolumeTO [] disks = vmSpec.getDisks();
827827
for (VolumeTO disk : disks) {
828-
if (disk.getType() == Volume.VolumeType.ISO && disk.getOsType() != null) {
828+
if (disk.getType() == Volume.Type.ISO && disk.getOsType() != null) {
829829
String isoGuestOsName = getGuestOsType(disk.getOsType(), vmSpec.getBootloader() == BootloaderType.CD);
830830
if (!isoGuestOsName.equals(guestOsTypeName)) {
831831
vmSpec.setBootloader(BootloaderType.PyGrub);
@@ -970,8 +970,9 @@ private HashMap<String, String> parseDefaultOvsRuleComamnd(String str) {
970970
c = c.startsWith("/") ? c.substring(1) : c;
971971
c = c.endsWith("/") ? c.substring(0, c.length() - 1) : c;
972972
String[] p = c.split(";");
973-
if (p.length != 2)
973+
if (p.length != 2) {
974974
continue;
975+
}
975976
if (p[0].equalsIgnoreCase("vlans")) {
976977
p[1] = p[1].replace("@", "[");
977978
p[1] = p[1].replace("#", "]");

0 commit comments

Comments
 (0)