mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss
This commit is contained in:
commit
9dd6f95f26
@ -134,6 +134,7 @@ import com.cloud.agent.api.storage.CreateAnswer;
|
||||
import com.cloud.agent.api.storage.CreateCommand;
|
||||
import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
|
||||
import com.cloud.agent.api.storage.CreatePrivateTemplateCommand;
|
||||
import com.cloud.agent.api.storage.DestroyCommand;
|
||||
import com.cloud.agent.api.storage.DownloadAnswer;
|
||||
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
|
||||
import com.cloud.agent.api.to.StoragePoolTO;
|
||||
@ -1116,6 +1117,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
return execute((MaintainCommand) cmd);
|
||||
} else if (cmd instanceof CreateCommand) {
|
||||
return execute((CreateCommand) cmd);
|
||||
} else if (cmd instanceof DestroyCommand) {
|
||||
return execute((DestroyCommand) cmd);
|
||||
} else if (cmd instanceof PrimaryStorageDownloadCommand) {
|
||||
return execute((PrimaryStorageDownloadCommand) cmd);
|
||||
} else if (cmd instanceof CreatePrivateTemplateCommand) {
|
||||
@ -1189,10 +1192,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
s_logger.debug(result);
|
||||
return new CreateAnswer(cmd, result);
|
||||
}
|
||||
|
||||
vol = createVolume(primaryPool, tmplVol);
|
||||
|
||||
LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID.randomUUID().toString(), tmplVol.getInfo().capacity, volFormat.QCOW2, tmplVol.getPath(), volFormat.QCOW2);
|
||||
s_logger.debug(volDef.toString());
|
||||
vol = primaryPool.storageVolCreateXML(volDef.toString(), 0);
|
||||
if (vol == null) {
|
||||
return new Answer(cmd, false, " Can't create storage volume on storage pool");
|
||||
}
|
||||
@ -1226,24 +1228,68 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Answer execute(DestroyCommand cmd) {
|
||||
VolumeTO vol = cmd.getVolume();
|
||||
|
||||
try {
|
||||
StorageVol volume = getVolume(vol.getPath());
|
||||
if (volume == null) {
|
||||
s_logger.debug("Failed to find the volume: " + vol.getPath());
|
||||
return new Answer(cmd, true, "Success");
|
||||
}
|
||||
volume.delete(0);
|
||||
volume.free();
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.debug("Failed to delete volume: " + e.toString());
|
||||
return new Answer(cmd, false, e.toString());
|
||||
}
|
||||
return new Answer(cmd, true, "Success");
|
||||
}
|
||||
|
||||
protected ManageSnapshotAnswer execute(final ManageSnapshotCommand cmd) {
|
||||
String snapshotName = cmd.getSnapshotName();
|
||||
String VolPath = cmd.getVolumePath();
|
||||
String snapshotPath = cmd.getSnapshotPath();
|
||||
String vmName = cmd.getVmName();
|
||||
try {
|
||||
StorageVol vol = getVolume(VolPath);
|
||||
if (vol == null) {
|
||||
return new ManageSnapshotAnswer(cmd, false, null);
|
||||
DomainInfo.DomainState state = null;
|
||||
Domain vm = null;
|
||||
if (vmName != null) {
|
||||
try {
|
||||
vm = getDomain(cmd.getVmName());
|
||||
state = vm.getInfo().state;
|
||||
} catch (LibvirtException e) {
|
||||
|
||||
}
|
||||
}
|
||||
Domain vm = getDomain(cmd.getVmName());
|
||||
String vmUuid = vm.getUUIDString();
|
||||
Object[] args = new Object[] {snapshotName, vmUuid};
|
||||
String snapshot = SnapshotXML.format(args);
|
||||
s_logger.debug(snapshot);
|
||||
if (cmd.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) {
|
||||
vm.snapshotCreateXML(snapshot);
|
||||
|
||||
if (state == DomainInfo.DomainState.VIR_DOMAIN_RUNNING) {
|
||||
String vmUuid = vm.getUUIDString();
|
||||
Object[] args = new Object[] {snapshotName, vmUuid};
|
||||
String snapshot = SnapshotXML.format(args);
|
||||
s_logger.debug(snapshot);
|
||||
if (cmd.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) {
|
||||
vm.snapshotCreateXML(snapshot);
|
||||
} else {
|
||||
DomainSnapshot snap = vm.snapshotLookupByName(snapshotName);
|
||||
snap.delete(0);
|
||||
}
|
||||
} else {
|
||||
DomainSnapshot snap = vm.snapshotLookupByName(snapshotName);
|
||||
snap.delete(0);
|
||||
/*VM is not running, create a snapshot by ourself*/
|
||||
final Script command = new Script(_manageSnapshotPath, _timeout, s_logger);
|
||||
if (cmd.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) {
|
||||
command.add("-c", VolPath);
|
||||
} else {
|
||||
command.add("-d", snapshotPath);
|
||||
}
|
||||
|
||||
command.add("-n", snapshotName);
|
||||
String result = command.execute();
|
||||
if (result != null) {
|
||||
s_logger.debug("Failed to manage snapshot: " + result);
|
||||
return new ManageSnapshotAnswer(cmd, false, "Failed to manage snapshot: " + result);
|
||||
}
|
||||
}
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.debug("Failed to manage snapshot: " + e.toString());
|
||||
@ -1260,28 +1306,52 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
String snapshotName = cmd.getSnapshotName();
|
||||
String snapshotPath = cmd.getSnapshotUuid();
|
||||
String snapshotDestPath = null;
|
||||
String vmName = cmd.getVmName();
|
||||
|
||||
try {
|
||||
StoragePool secondaryStoragePool = getNfsSPbyURI(_conn, new URI(secondaryStoragePoolURL));
|
||||
String ssPmountPath = _mountPoint + File.separator + secondaryStoragePool.getUUIDString();
|
||||
snapshotDestPath = ssPmountPath + File.separator + dcId + File.separator + "snapshots" + File.separator + accountId + File.separator + volumeId;
|
||||
final Script command = new Script(_manageSnapshotPath, _timeout, s_logger);
|
||||
Script command = new Script(_manageSnapshotPath, _timeout, s_logger);
|
||||
command.add("-b", snapshotPath);
|
||||
command.add("-n", snapshotName);
|
||||
command.add("-p", snapshotDestPath);
|
||||
command.add("-t", snapshotName);
|
||||
String result = command.execute();
|
||||
if (result != null) {
|
||||
s_logger.debug("Failed to backup snaptshot: " + result);
|
||||
return new BackupSnapshotAnswer(cmd, false, result, null);
|
||||
}
|
||||
/*Delete the snapshot on primary*/
|
||||
Domain vm = getDomain(cmd.getVmName());
|
||||
String vmUuid = vm.getUUIDString();
|
||||
Object[] args = new Object[] {snapshotName, vmUuid};
|
||||
String snapshot = SnapshotXML.format(args);
|
||||
s_logger.debug(snapshot);
|
||||
DomainSnapshot snap = vm.snapshotLookupByName(snapshotName);
|
||||
snap.delete(0);
|
||||
|
||||
DomainInfo.DomainState state = null;
|
||||
Domain vm = null;
|
||||
if (vmName != null) {
|
||||
try {
|
||||
vm = getDomain(cmd.getVmName());
|
||||
state = vm.getInfo().state;
|
||||
} catch (LibvirtException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (state == DomainInfo.DomainState.VIR_DOMAIN_RUNNING) {
|
||||
String vmUuid = vm.getUUIDString();
|
||||
Object[] args = new Object[] {snapshotName, vmUuid};
|
||||
String snapshot = SnapshotXML.format(args);
|
||||
s_logger.debug(snapshot);
|
||||
DomainSnapshot snap = vm.snapshotLookupByName(snapshotName);
|
||||
snap.delete(0);
|
||||
} else {
|
||||
command = new Script(_manageSnapshotPath, _timeout, s_logger);
|
||||
command.add("-d", snapshotPath);
|
||||
command.add("-n", snapshotName);
|
||||
result = command.execute();
|
||||
if (result != null) {
|
||||
s_logger.debug("Failed to backup snapshot: " + result);
|
||||
return new BackupSnapshotAnswer(cmd, false, "Failed to backup snapshot: " + result, null);
|
||||
}
|
||||
}
|
||||
} catch (LibvirtException e) {
|
||||
return new BackupSnapshotAnswer(cmd, false, e.toString(), null);
|
||||
} catch (URISyntaxException e) {
|
||||
@ -1357,7 +1427,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
try {
|
||||
secondaryPool = getNfsSPbyURI(_conn, new URI(cmd.getSecondaryStoragePoolURL()));
|
||||
/*TODO: assuming all the storage pools mounted under _mountPoint, the mount point should be got from pool.dumpxml*/
|
||||
String templatePath = _mountPoint + File.separator + secondaryPool.getUUIDString() + File.separator + templateInstallFolder;
|
||||
String templatePath = _mountPoint + File.separator + secondaryPool.getUUIDString() + File.separator + templateInstallFolder;
|
||||
File f = new File(templatePath);
|
||||
if (!f.exists()) {
|
||||
f.mkdirs();
|
||||
}
|
||||
String tmplPath = templateInstallFolder + File.separator + tmplFileName;
|
||||
Script command = new Script(_createTmplPath, _timeout, s_logger);
|
||||
command.add("-t", templatePath);
|
||||
@ -1404,38 +1478,58 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
}
|
||||
protected CreatePrivateTemplateAnswer execute(CreatePrivateTemplateCommand cmd) {
|
||||
String secondaryStorageURL = cmd.getSecondaryStorageURL();
|
||||
String snapshotUUID = cmd.getSnapshotPath();
|
||||
|
||||
StoragePool secondaryStorage = null;
|
||||
StoragePool privateTemplStorage = null;
|
||||
StorageVol privateTemplateVol = null;
|
||||
StorageVol snapshotVol = null;
|
||||
try {
|
||||
String templateFolder = cmd.getAccountId() + File.separator + cmd.getTemplateId() + File.separator;
|
||||
String templateInstallFolder = "/template/tmpl/" + templateFolder;
|
||||
|
||||
|
||||
secondaryStorage = getNfsSPbyURI(_conn, new URI(secondaryStorageURL));
|
||||
/*TODO: assuming all the storage pools mounted under _mountPoint, the mount point should be got from pool.dumpxml*/
|
||||
String mountPath = _mountPoint + File.separator + secondaryStorage.getUUIDString() + templateInstallFolder;
|
||||
File mpfile = new File(mountPath);
|
||||
String tmpltPath = _mountPoint + File.separator + secondaryStorage.getUUIDString() + templateInstallFolder;
|
||||
File mpfile = new File(tmpltPath);
|
||||
if (!mpfile.exists()) {
|
||||
mpfile.mkdir();
|
||||
mpfile.mkdirs();
|
||||
}
|
||||
|
||||
Script command = new Script(_createTmplPath, _timeout, s_logger);
|
||||
command.add("-f", cmd.getSnapshotPath());
|
||||
command.add("-c", cmd.getSnapshotName());
|
||||
command.add("-t", tmpltPath);
|
||||
command.add("-n", cmd.getUniqueName() + ".qcow2");
|
||||
command.add("-s");
|
||||
String result = command.execute();
|
||||
|
||||
// Create a SR for the secondary storage installation folder
|
||||
privateTemplStorage = getNfsSPbyURI(_conn, new URI(secondaryStorageURL + templateInstallFolder));
|
||||
snapshotVol = getVolume(snapshotUUID);
|
||||
|
||||
LibvirtStorageVolumeDef vol = new LibvirtStorageVolumeDef(UUID.randomUUID().toString(), snapshotVol.getInfo().capacity, volFormat.QCOW2, null, null);
|
||||
s_logger.debug(vol.toString());
|
||||
privateTemplateVol = copyVolume(privateTemplStorage, vol, snapshotVol);
|
||||
if (result != null) {
|
||||
s_logger.debug("failed to create template: " + result);
|
||||
return new CreatePrivateTemplateAnswer(cmd,
|
||||
false,
|
||||
result,
|
||||
null,
|
||||
0,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put(StorageLayer.InstanceConfigKey, _storage);
|
||||
Processor qcow2Processor = new QCOW2Processor();
|
||||
|
||||
qcow2Processor.configure("QCOW2 Processor", params);
|
||||
|
||||
FormatInfo info = qcow2Processor.process(tmpltPath, null, cmd.getUniqueName());
|
||||
|
||||
TemplateLocation loc = new TemplateLocation(_storage, tmpltPath);
|
||||
loc.create(1, true, cmd.getUniqueName());
|
||||
loc.addFormat(info);
|
||||
loc.save();
|
||||
|
||||
return new CreatePrivateTemplateAnswer(cmd,
|
||||
true,
|
||||
null,
|
||||
templateInstallFolder + privateTemplateVol.getName(),
|
||||
privateTemplateVol.getInfo().capacity/1024*1024, /*in Mega unit*/
|
||||
privateTemplateVol.getName(),
|
||||
templateInstallFolder + cmd.getUniqueName() + ".qcow2",
|
||||
info.virtualSize,
|
||||
cmd.getUniqueName(),
|
||||
ImageFormat.QCOW2);
|
||||
} catch (URISyntaxException e) {
|
||||
return new CreatePrivateTemplateAnswer(cmd,
|
||||
@ -1454,7 +1548,31 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
0,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
} catch (InternalErrorException e) {
|
||||
return new CreatePrivateTemplateAnswer(cmd,
|
||||
false,
|
||||
e.toString(),
|
||||
null,
|
||||
0,
|
||||
null,
|
||||
null);
|
||||
} catch (IOException e) {
|
||||
return new CreatePrivateTemplateAnswer(cmd,
|
||||
false,
|
||||
e.toString(),
|
||||
null,
|
||||
0,
|
||||
null,
|
||||
null);
|
||||
} catch (ConfigurationException e) {
|
||||
return new CreatePrivateTemplateAnswer(cmd,
|
||||
false,
|
||||
e.toString(),
|
||||
null,
|
||||
0,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
private StoragePool getNfsSPbyURI(Connect conn, URI uri) throws LibvirtException {
|
||||
@ -1586,7 +1704,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
pool.getHostAddress(), pool.getPath(), targetPath);
|
||||
File tpFile = new File(targetPath);
|
||||
if (!tpFile.exists()) {
|
||||
tpFile.mkdir();
|
||||
tpFile.mkdirs();
|
||||
}
|
||||
StoragePool sp = null;
|
||||
try {
|
||||
@ -2361,7 +2479,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
Iterator<Map.Entry<String, String>> itr = entrySet.iterator();
|
||||
while (itr.hasNext()) {
|
||||
Map.Entry<String, String> entry = itr.next();
|
||||
if (entry.getValue().equalsIgnoreCase(sourceFile)) {
|
||||
if ((entry.getValue() != null) && (entry.getValue().equalsIgnoreCase(sourceFile))) {
|
||||
diskDev = entry.getKey();
|
||||
break;
|
||||
}
|
||||
@ -2942,9 +3060,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
}
|
||||
|
||||
private String getHypervisorPath() {
|
||||
File f =new File("/usr/bin/cloud-qemu-kvm");
|
||||
File f =new File("/usr/bin/cloud-qemu-system-x86_64");
|
||||
if (f.exists()) {
|
||||
return "/usr/bin/cloud-qemu-kvm";
|
||||
return "/usr/bin/cloud-qemu-system-x86_64";
|
||||
} else {
|
||||
if (_conn == null)
|
||||
return null;
|
||||
@ -3098,7 +3216,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
brName = setVnetBrName(vnetId);
|
||||
String vnetDev = "vtap" + vnetId;
|
||||
createVnet(vnetId, _pifs.first());
|
||||
vnetNic.defBridgeNet(brName, vnetDev, guestMac, interfaceDef.nicModel.VIRTIO);
|
||||
vnetNic.defBridgeNet(brName, null, guestMac, interfaceDef.nicModel.VIRTIO);
|
||||
}
|
||||
nics.add(vnetNic);
|
||||
|
||||
@ -3114,7 +3232,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
brName = setVnetBrName(vnetId);
|
||||
String vnetDev = "vtap" + vnetId;
|
||||
createVnet(vnetId, _pifs.second());
|
||||
pubNic.defBridgeNet(brName, vnetDev, pubMac, interfaceDef.nicModel.VIRTIO);
|
||||
pubNic.defBridgeNet(brName, null, pubMac, interfaceDef.nicModel.VIRTIO);
|
||||
}
|
||||
nics.add(pubNic);
|
||||
return nics;
|
||||
@ -3166,7 +3284,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
String datadiskPath = tmplVol.getKey();
|
||||
|
||||
diskDef hda = new diskDef();
|
||||
hda.defFileBasedDisk(rootkPath, "vda", diskDef.diskBus.IDE, diskDef.diskFmtType.QCOW2);
|
||||
hda.defFileBasedDisk(rootkPath, "hda", diskDef.diskBus.IDE, diskDef.diskFmtType.QCOW2);
|
||||
disks.add(hda);
|
||||
|
||||
diskDef hdb = new diskDef();
|
||||
@ -3248,7 +3366,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
|
||||
File logPath = new File("/var/run/cloud");
|
||||
if (!logPath.exists()) {
|
||||
logPath.mkdir();
|
||||
logPath.mkdirs();
|
||||
}
|
||||
|
||||
cleanup_rules_for_dead_vms();
|
||||
@ -3502,6 +3620,22 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
}
|
||||
}
|
||||
|
||||
private StorageVol createVolume(StoragePool destPool, StorageVol tmplVol) throws LibvirtException {
|
||||
if (isCentosHost()) {
|
||||
LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID.randomUUID().toString(), tmplVol.getInfo().capacity, volFormat.QCOW2, null, null);
|
||||
s_logger.debug(volDef.toString());
|
||||
StorageVol vol = destPool.storageVolCreateXML(volDef.toString(), 0);
|
||||
|
||||
/*create qcow2 image based on the name*/
|
||||
Script.runSimpleBashScript("qemu-img create -f qcow2 -b " + tmplVol.getPath() + " " + vol.getPath() );
|
||||
return vol;
|
||||
} else {
|
||||
LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID.randomUUID().toString(), tmplVol.getInfo().capacity, volFormat.QCOW2, tmplVol.getPath(), volFormat.QCOW2);
|
||||
s_logger.debug(volDef.toString());
|
||||
return destPool.storageVolCreateXML(volDef.toString(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
private StorageVol getVolume(StoragePool pool, String volKey) {
|
||||
StorageVol vol = null;
|
||||
try {
|
||||
|
||||
@ -94,6 +94,8 @@ public class LibvirtDomainXMLParser extends LibvirtXMLParser {
|
||||
} else if (qName.equalsIgnoreCase("disk")) {
|
||||
diskMaps.put(diskDev, diskFile);
|
||||
_disk = false;
|
||||
diskFile = null;
|
||||
diskDev = null;
|
||||
} else if (qName.equalsIgnoreCase("description")) {
|
||||
_desc = false;
|
||||
}
|
||||
|
||||
@ -44,6 +44,7 @@ public class Network {
|
||||
Native,
|
||||
Vlan,
|
||||
Vswitch,
|
||||
LinkLocal,
|
||||
Vnet;
|
||||
};
|
||||
|
||||
@ -54,7 +55,7 @@ public class Network {
|
||||
Public,
|
||||
Guest,
|
||||
Storage,
|
||||
LinkLocal,
|
||||
Control,
|
||||
Vpn,
|
||||
Management
|
||||
};
|
||||
|
||||
@ -22,16 +22,26 @@ public class Storage {
|
||||
QCOW2(true, true, false),
|
||||
RAW(false, false, false),
|
||||
VHD(true, true, true),
|
||||
ISO(false, false, false);
|
||||
ISO(false, false, false),
|
||||
VMDK(true, true, true, "vmw.tar");
|
||||
|
||||
private final boolean thinProvisioned;
|
||||
private final boolean supportSparse;
|
||||
private final boolean supportSnapshot;
|
||||
private final String fileExtension;
|
||||
|
||||
private ImageFormat(boolean thinProvisioned, boolean supportSparse, boolean supportSnapshot) {
|
||||
this.thinProvisioned = thinProvisioned;
|
||||
this.supportSparse = supportSparse;
|
||||
this.supportSnapshot = supportSnapshot;
|
||||
fileExtension = null;
|
||||
}
|
||||
|
||||
private ImageFormat(boolean thinProvisioned, boolean supportSparse, boolean supportSnapshot, String fileExtension) {
|
||||
this.thinProvisioned = thinProvisioned;
|
||||
this.supportSparse = supportSparse;
|
||||
this.supportSnapshot = supportSnapshot;
|
||||
this.fileExtension = fileExtension;
|
||||
}
|
||||
|
||||
public boolean isThinProvisioned() {
|
||||
@ -47,7 +57,10 @@ public class Storage {
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
return toString().toLowerCase();
|
||||
if(fileExtension == null)
|
||||
return toString().toLowerCase();
|
||||
|
||||
return fileExtension;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -107,6 +107,10 @@
|
||||
<property name="meld.home" location="/usr/local/bin" />
|
||||
<property name="assertion" value="-da" />
|
||||
|
||||
<!-- directories for patches -->
|
||||
<property name="kvm.patch.dist.dir" location="${dist.dir}/patches/kvm" />
|
||||
<property name="xenserver.patch.dist.dir" location="${dist.dir}/patches/xenserver" />
|
||||
|
||||
<!-- directories for testing -->
|
||||
<property name="test.target.dir" location="${target.dir}/test" />
|
||||
<property name="test.classes.dir" location="${test.target.dir}/classes" />
|
||||
@ -519,7 +523,8 @@
|
||||
|
||||
|
||||
<target name="build-kvm-domr-patch" depends="-init">
|
||||
<tar destfile="${dist.dir}/patch.tar">
|
||||
<mkdir dir="${kvm.patch.dist.dir}" />
|
||||
<tar destfile="${kvm.patch.dist.dir}/patch.tar">
|
||||
<tarfileset dir="${base.dir}/patches/kvm" filemode="755">
|
||||
<include name="**/*"/>
|
||||
<exclude name="**/.classpath" />
|
||||
@ -531,8 +536,26 @@
|
||||
<exclude name="**/.project" />
|
||||
</tarfileset>
|
||||
</tar>
|
||||
<gzip destfile="${dist.dir}/patch.tgz" src="${dist.dir}/patch.tar"/>
|
||||
<delete file="${dist.dir}/patch.tar"/>
|
||||
<gzip destfile="${kvm.patch.dist.dir}/patch.tgz" src="${kvm.patch.dist.dir}/patch.tar"/>
|
||||
<delete file="${kvm.patch.dist.dir}/patch.tar"/>
|
||||
</target>
|
||||
|
||||
<target name="build-xenserver-domr-patch" depends="-init">
|
||||
<mkdir dir="${xenserver.patch.dist.dir}" />
|
||||
<tar destfile="${xenserver.patch.dist.dir}/patch.tar">
|
||||
<tarfileset dir="${base.dir}/patches/xenserver" filemode="755">
|
||||
<include name="**/*"/>
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
</tarfileset>
|
||||
<tarfileset dir="${base.dir}/patches/shared" filemode="755">
|
||||
<include name="**/*"/>
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
</tarfileset>
|
||||
</tar>
|
||||
<gzip destfile="${xenserver.patch.dist.dir}/patch.tgz" src="${xenserver.patch.dist.dir}/patch.tar"/>
|
||||
<delete file="${xenserver.patch.dist.dir}/patch.tar"/>
|
||||
</target>
|
||||
|
||||
<target name="help">
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
</target>
|
||||
|
||||
<target name="deploy-server" depends="deploy-common" >
|
||||
<copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/vms" file="${dist.dir}/systemvm.zip" />
|
||||
<copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/vms" file="${dist.dir}/systemvm.iso" />
|
||||
</target>
|
||||
|
||||
<target name="deploy-common" >
|
||||
@ -114,7 +114,6 @@
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/scripts/vm/hypervisor/xenserver" file="${dist.dir}/patch.tgz" />
|
||||
<touch file="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/scripts/vm/hypervisor/xenserver/version"/>
|
||||
<echo file="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/scripts/vm/hypervisor/xenserver/version" append="false" message="${version}.${build.number}"/>
|
||||
<copy overwrite="true" todir="${server.deploy.to.dir}/conf">
|
||||
@ -169,11 +168,18 @@
|
||||
<available file="${setup.db.dir}/override/templates.xenserver.sql" />
|
||||
</condition>
|
||||
|
||||
<condition property="vmware.templates.file" value="override/templates.vmware.sql" else="templates.vmware.sql">
|
||||
<available file="${setup.db.dir}/override/templates.vmware.sql" />
|
||||
</condition>
|
||||
|
||||
<condition property="templates.file" value="${kvm.templates.file}" else="${xenserver.templates.file}" >
|
||||
<condition property="templates.file.intermediate" value="${kvm.templates.file}" else="${xenserver.templates.file}" >
|
||||
<isset property="KVM"/>
|
||||
</condition>
|
||||
|
||||
<condition property="templates.file" value="${vmware.templates.file}" else="${templates.file.intermediate}" >
|
||||
<isset property="vmware"/>
|
||||
</condition>
|
||||
|
||||
<echo message="deploydb ${server-setup.file} ${templates.file} ${DBROOTPW}" />
|
||||
<exec dir="${setup.db.dir}" executable="bash">
|
||||
<arg value="deploy-db-dev.sh" />
|
||||
|
||||
@ -94,7 +94,7 @@
|
||||
|
||||
<target name="package-agent" depends="-init-package, package-oss-systemvm, build-kvm-domr-patch, package-agent-common">
|
||||
<zip destfile="${dist.dir}/agent.zip" duplicate="preserve" update="true">
|
||||
<zipfileset dir="${dist.dir}" prefix="scripts/vm/hypervisor/kvm">
|
||||
<zipfileset dir="${kvm.patch.dist.dir}" prefix="scripts/vm/hypervisor/kvm">
|
||||
<include name="patch.tgz" />
|
||||
</zipfileset>
|
||||
<zipfileset dir="${dist.dir}" prefix="vms" filemode="555">
|
||||
@ -103,6 +103,18 @@
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="package-oss-systemvm-iso" depends="-init-package, package-oss-systemvm, build-xenserver-domr-patch">
|
||||
<exec executable="mkisofs" dir="${dist.dir}">
|
||||
<arg value="-quiet"/>
|
||||
<arg value="-r"/>
|
||||
<arg value="-o"/>
|
||||
<arg value="systemvm.iso"/>
|
||||
<arg value="systemvm.zip"/>
|
||||
<arg value="patches/xenserver/patch.tgz"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
|
||||
<target name="package-agent-simulator" depends="-init-package">
|
||||
<delete file="${dist.dir}/agent-simulator.zip" />
|
||||
<zip destfile="${dist.dir}/agent-simulator.zip" duplicate="preserve">
|
||||
@ -123,7 +135,7 @@
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="build-all" depends="build-opensource, build-kvm-domr-patch, build-ui, build-war-oss, package-oss-systemvm">
|
||||
<target name="build-all" depends="build-opensource, build-kvm-domr-patch, build-ui, build-war-oss, package-oss-systemvm-iso">
|
||||
</target>
|
||||
|
||||
<target name="build-war-oss" depends="-init-package" description="Compile the GWT client UI and builds WAR file.">
|
||||
|
||||
@ -139,6 +139,7 @@ listSystemVms=com.cloud.api.commands.ListSystemVMsCmd;1
|
||||
updateConfiguration=com.cloud.api.commands.UpdateCfgCmd;1
|
||||
listConfigurations=com.cloud.api.commands.ListCfgsByCmd;1
|
||||
addConfig=com.cloud.api.commands.AddConfigCmd;15
|
||||
listCapabilities=com.cloud.api.commands.ListCapabilitiesCmd;15
|
||||
|
||||
#### pod commands
|
||||
createPod=com.cloud.api.commands.CreatePodCmd;1
|
||||
@ -207,4 +208,4 @@ listNetworkGroups=com.cloud.api.commands.ListNetworkGroupsCmd;11
|
||||
|
||||
registerPreallocatedLun=com.cloud.server.api.commands.RegisterPreallocatedLunCmd;1
|
||||
deletePreallocatedLun=com.cloud.server.api.commands.DeletePreallocatedLunCmd;1
|
||||
listPreallocatedLuns=com.cloud.api.commands.ListPreallocatedLunsCmd;1
|
||||
listPreallocatedLuns=com.cloud.api.commands.ListPreallocatedLunsCmd;1
|
||||
|
||||
@ -110,7 +110,9 @@
|
||||
<dao name="GuestOSDao" class="com.cloud.storage.dao.GuestOSDaoImpl"/>
|
||||
<dao name="GuestOSCategoryDao" class="com.cloud.storage.dao.GuestOSCategoryDaoImpl"/>
|
||||
<dao name="ClusterDao" class="com.cloud.dc.dao.ClusterDaoImpl"/>
|
||||
|
||||
<dao name="NetworkProfileDao" class="com.cloud.network.dao.NetworkProfileDaoImpl"/>
|
||||
<dao name="NetworkOfferingDao" class="com.cloud.offerings.dao.NetworkOfferingDaoImpl"/>
|
||||
|
||||
<adapters key="com.cloud.agent.manager.allocator.HostAllocator">
|
||||
<adapter name="FirstFitRouting" class="com.cloud.agent.manager.allocator.impl.FirstFitRoutingAllocator"/>
|
||||
<adapter name="FirstFit" class="com.cloud.agent.manager.allocator.impl.FirstFitAllocator"/>
|
||||
@ -215,8 +217,9 @@
|
||||
<dao name="IP Addresses configuration server" class="com.cloud.network.dao.IPAddressDaoImpl"/>
|
||||
<dao name="Datacenter IP Addresses configuration server" class="com.cloud.dc.dao.DataCenterIpAddressDaoImpl"/>
|
||||
<dao name="domain router" class="com.cloud.vm.dao.DomainRouterDaoImpl"/>
|
||||
<dao name="host zone configuration server" class="com.cloud.dc.dao.DataCenterDaoImpl">
|
||||
</dao>
|
||||
<dao name="host zone configuration server" class="com.cloud.dc.dao.DataCenterDaoImpl"/>
|
||||
<dao name="Console Proxy" class="com.cloud.vm.dao.ConsoleProxyDaoImpl"/>
|
||||
<dao name="Secondary Storage VM" class="com.cloud.vm.dao.SecondaryStorageVmDaoImpl"/>
|
||||
<dao name="host pod configuration server" class="com.cloud.dc.dao.HostPodDaoImpl">
|
||||
</dao>
|
||||
<dao name="PodVlanMap configuration server" class="com.cloud.dc.dao.PodVlanMapDaoImpl"/>
|
||||
|
||||
38
cloud.spec
38
cloud.spec
@ -481,46 +481,17 @@ fi
|
||||
%doc README.html
|
||||
%doc debian/copyright
|
||||
|
||||
%if %{_premium}
|
||||
|
||||
%files agent-scripts
|
||||
%defattr(-,root,root,-)
|
||||
%{_libdir}/%{name}/agent/scripts/*
|
||||
%{_libdir}/%{name}/agent/vms/systemvm.zip
|
||||
%{_libdir}/%{name}/agent/vms/systemvm.iso
|
||||
%doc README
|
||||
%doc INSTALL
|
||||
%doc HACKING
|
||||
%doc README.html
|
||||
%doc debian/copyright
|
||||
|
||||
%else
|
||||
|
||||
%files agent-scripts
|
||||
%defattr(-,root,root,-)
|
||||
%{_libdir}/%{name}/agent/scripts/installer/*
|
||||
%{_libdir}/%{name}/agent/scripts/network/domr/*.sh
|
||||
%{_libdir}/%{name}/agent/scripts/storage/*.sh
|
||||
%{_libdir}/%{name}/agent/scripts/storage/zfs/*
|
||||
%{_libdir}/%{name}/agent/scripts/storage/qcow2/*
|
||||
%{_libdir}/%{name}/agent/scripts/storage/secondary/*
|
||||
%{_libdir}/%{name}/agent/scripts/util/*
|
||||
%{_libdir}/%{name}/agent/scripts/vm/*.sh
|
||||
%{_libdir}/%{name}/agent/scripts/vm/storage/nfs/*
|
||||
%{_libdir}/%{name}/agent/scripts/vm/storage/iscsi/*
|
||||
%{_libdir}/%{name}/agent/scripts/vm/network/*
|
||||
%{_libdir}/%{name}/agent/scripts/vm/hypervisor/*.sh
|
||||
%{_libdir}/%{name}/agent/scripts/vm/hypervisor/kvm/*
|
||||
%{_libdir}/%{name}/agent/scripts/vm/hypervisor/xen/*
|
||||
%{_libdir}/%{name}/agent/vms/systemvm.zip
|
||||
%{_libdir}/%{name}/agent/scripts/vm/hypervisor/xenserver/*
|
||||
%doc README
|
||||
%doc INSTALL
|
||||
%doc HACKING
|
||||
%doc README.html
|
||||
%doc debian/copyright
|
||||
|
||||
%endif
|
||||
|
||||
%files daemonize
|
||||
%defattr(-,root,root,-)
|
||||
%attr(755,root,root) %{_bindir}/%{name}-daemonize
|
||||
@ -591,12 +562,12 @@ fi
|
||||
%{_datadir}/%{name}/setup/create-index-fk.sql
|
||||
%{_datadir}/%{name}/setup/create-schema.sql
|
||||
%{_datadir}/%{name}/setup/server-setup.sql
|
||||
%{_datadir}/%{name}/setup/templates.kvm.sql
|
||||
%{_datadir}/%{name}/setup/templates.xenserver.sql
|
||||
%{_datadir}/%{name}/setup/templates.*.sql
|
||||
%{_datadir}/%{name}/setup/deploy-db-dev.sh
|
||||
%{_datadir}/%{name}/setup/server-setup.xml
|
||||
%{_datadir}/%{name}/setup/data-20to21.sql
|
||||
%{_datadir}/%{name}/setup/index-20to21.sql
|
||||
%{_datadir}/%{name}/setup/index-212to213.sql
|
||||
%{_datadir}/%{name}/setup/postprocess-20to21.sql
|
||||
%{_datadir}/%{name}/setup/schema-20to21.sql
|
||||
%doc README
|
||||
@ -724,8 +695,7 @@ fi
|
||||
%{_javadir}/%{name}-server-extras.jar
|
||||
%{_sysconfdir}/%{name}/management/commands-ext.properties
|
||||
%{_sysconfdir}/%{name}/management/components-premium.xml
|
||||
%{_libdir}/%{name}/agent/scripts/vm/hypervisor/xenserver/*
|
||||
%{_libdir}/%{name}/agent/vms/systemvm-premium.zip
|
||||
%{_libdir}/%{name}/agent/vms/systemvm-premium.iso
|
||||
%{_datadir}/%{name}/setup/create-database-premium.sql
|
||||
%{_datadir}/%{name}/setup/create-schema-premium.sql
|
||||
%doc README
|
||||
|
||||
@ -28,6 +28,16 @@ public class PrimaryStorageDownloadCommand extends AbstractDownloadCommand {
|
||||
String localPath;
|
||||
String poolUuid;
|
||||
long poolId;
|
||||
|
||||
//
|
||||
// Temporary hacking to make vmware work quickly, expose NFS raw information to allow
|
||||
// agent do quick copy over NFS.
|
||||
//
|
||||
// provide storage URL (it contains all information to help agent resource to mount the
|
||||
// storage if needed, example of such URL may be as following
|
||||
// nfs://192.168.10.231/export/home/kelven/vmware-test/secondary
|
||||
String secondaryStorageUrl;
|
||||
String primaryStorageUrl;
|
||||
|
||||
protected PrimaryStorageDownloadCommand() {
|
||||
}
|
||||
@ -54,6 +64,22 @@ public class PrimaryStorageDownloadCommand extends AbstractDownloadCommand {
|
||||
return localPath;
|
||||
}
|
||||
|
||||
public void setSecondaryStorageUrl(String url) {
|
||||
secondaryStorageUrl = url;
|
||||
}
|
||||
|
||||
public String getSecondaryStorageUrl() {
|
||||
return secondaryStorageUrl;
|
||||
}
|
||||
|
||||
public void setPrimaryStorageUrl(String url) {
|
||||
primaryStorageUrl = url;
|
||||
}
|
||||
|
||||
public String getPrimaryStorageUrl() {
|
||||
return primaryStorageUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return true;
|
||||
|
||||
@ -118,6 +118,11 @@ public class EventTypes {
|
||||
public static final String EVENT_SERVICE_OFFERING_EDIT = "SERVICE.OFFERING.EDIT";
|
||||
public static final String EVENT_SERVICE_OFFERING_DELETE = "SERVICE.OFFERING.DELETE";
|
||||
|
||||
// Disk Offerings
|
||||
public static final String EVENT_DISK_OFFERING_CREATE = "DISK.OFFERING.CREATE";
|
||||
public static final String EVENT_DISK_OFFERING_EDIT = "DISK.OFFERING.EDIT";
|
||||
public static final String EVENT_DISK_OFFERING_DELETE = "DISK.OFFERING.DELETE";
|
||||
|
||||
// Pods
|
||||
public static final String EVENT_POD_CREATE = "POD.CREATE";
|
||||
public static final String EVENT_POD_EDIT = "POD.EDIT";
|
||||
|
||||
@ -152,6 +152,7 @@ import com.cloud.host.Host.Type;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.network.Network.BroadcastDomainType;
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
import com.cloud.hypervisor.xen.resource.XenServerConnectionPool.XenServerConnection;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
@ -700,7 +701,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
||||
Pair<Network, String> getNetworkForTraffic(Connection conn, TrafficType type) throws XenAPIException, XmlRpcException {
|
||||
if (type == TrafficType.Guest) {
|
||||
return new Pair<Network, String>(Network.getByUuid(conn, _host.guestNetwork), _host.guestPif);
|
||||
} else if (type == TrafficType.LinkLocal) {
|
||||
} else if (type == TrafficType.Control) {
|
||||
return new Pair<Network, String>(Network.getByUuid(conn, _host.linkLocalNetwork), null);
|
||||
} else if (type == TrafficType.Management) {
|
||||
return new Pair<Network, String>(Network.getByUuid(conn, _host.privateNetwork), _host.privatePif);
|
||||
@ -1063,29 +1064,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
||||
}
|
||||
|
||||
protected Answer execute(ModifySshKeysCommand cmd) {
|
||||
String publickey = cmd.getPubKey();
|
||||
String privatekey = cmd.getPrvKey();
|
||||
|
||||
com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_host.ip, 22);
|
||||
try {
|
||||
sshConnection.connect(null, 60000, 60000);
|
||||
if (!sshConnection.authenticateWithPassword(_username, _password)) {
|
||||
throw new Exception("Unable to authenticate");
|
||||
}
|
||||
SCPClient scp = new SCPClient(sshConnection);
|
||||
|
||||
scp.put(publickey.getBytes(), "id_rsa.pub", "/opt/xensource/bin", "0600");
|
||||
scp.put(privatekey.getBytes(), "id_rsa", "/opt/xensource/bin", "0600");
|
||||
scp.put(privatekey.getBytes(), "id_rsa.cloud", "/root/.ssh", "0600");
|
||||
return new Answer(cmd);
|
||||
|
||||
} catch (Exception e) {
|
||||
String msg = " scp ssh key failed due to " + e.toString() + " - " + e.getMessage();
|
||||
s_logger.warn(msg);
|
||||
} finally {
|
||||
sshConnection.close();
|
||||
}
|
||||
return new Answer(cmd, false, "modifySshkeys failed");
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
private boolean doPingTest(final String computingHostIp) {
|
||||
@ -3187,13 +3166,6 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
||||
|
||||
Ternary<SR, VDI, VolumeVO> mount = mounts.get(0);
|
||||
|
||||
if (!patchSystemVm(mount.second(), vmName)) { // FIXME make this
|
||||
// nonspecific
|
||||
String msg = "patch system vm failed";
|
||||
s_logger.warn(msg);
|
||||
return msg;
|
||||
}
|
||||
|
||||
Set<VM> templates = VM.getByNameLabel(conn, "CentOS 5.3");
|
||||
if (templates.size() == 0) {
|
||||
templates = VM.getByNameLabel(conn, "CentOS 5.3 (64-bit)");
|
||||
@ -3232,6 +3204,17 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
||||
vbdr.type = Types.VbdType.DISK;
|
||||
VBD.create(conn, vbdr);
|
||||
|
||||
|
||||
/* create CD-ROM VBD */
|
||||
VBD.Record cdromVBDR = new VBD.Record();
|
||||
cdromVBDR.VM = vm;
|
||||
cdromVBDR.empty = true;
|
||||
cdromVBDR.bootable = false;
|
||||
cdromVBDR.userdevice = "3";
|
||||
cdromVBDR.mode = Types.VbdMode.RO;
|
||||
cdromVBDR.type = Types.VbdType.CD;
|
||||
VBD cdromVBD = VBD.create(conn, cdromVBDR);
|
||||
cdromVBD.insert(conn, VDI.getByUuid(conn, _host.systemvmisouuid));
|
||||
|
||||
/* create VIF0 */
|
||||
VIF.Record vifr = new VIF.Record();
|
||||
@ -3508,8 +3491,6 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
||||
s_logger.debug("Slave logon successful. session= " + slaveSession);
|
||||
}
|
||||
Host host = Host.getByUuid(slaveConn, _host.uuid);
|
||||
|
||||
|
||||
for (int i = 0; i < params.length; i += 2) {
|
||||
args.put(params[i], params[i + 1]);
|
||||
}
|
||||
@ -4013,7 +3994,38 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
||||
try {
|
||||
Host myself = Host.getByUuid(conn, _host.uuid);
|
||||
_host.pool = getPoolUuid();
|
||||
|
||||
boolean findsystemvmiso = false;
|
||||
Set<SR> srs = SR.getByNameLabel(conn, "XenServer Tools");
|
||||
if( srs.size() != 1 ) {
|
||||
throw new CloudRuntimeException("There are " + srs.size() + " SRs with name XenServer Tools");
|
||||
}
|
||||
SR sr = srs.iterator().next();
|
||||
sr.scan(conn);
|
||||
|
||||
SR.Record srr = sr.getRecord(conn);
|
||||
_host.systemvmisouuid = null;
|
||||
for( VDI vdi : srr.VDIs ) {
|
||||
VDI.Record vdir = vdi.getRecord(conn);
|
||||
if(vdir.nameLabel.contains("systemvm-premium")){
|
||||
_host.systemvmisouuid = vdir.uuid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( _host.systemvmisouuid == null ) {
|
||||
for( VDI vdi : srr.VDIs ) {
|
||||
VDI.Record vdir = vdi.getRecord(conn);
|
||||
if(vdir.nameLabel.contains("systemvm")){
|
||||
_host.systemvmisouuid = vdir.uuid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( _host.systemvmisouuid == null ) {
|
||||
throw new CloudRuntimeException("can not find systemvmiso");
|
||||
}
|
||||
|
||||
String name = "cloud-private";
|
||||
if (_privateNetworkName != null) {
|
||||
name = _privateNetworkName;
|
||||
@ -4344,17 +4356,13 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
||||
scp.put(f, d, p);
|
||||
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new CloudRuntimeException("Unable to setup the server correctly", e);
|
||||
} finally {
|
||||
sshConnection.close();
|
||||
}
|
||||
try {
|
||||
// wait 2 seconds before call plugin
|
||||
Thread.sleep(2000);
|
||||
} catch (final InterruptedException ex) {
|
||||
|
||||
}
|
||||
if (!setIptables()) {
|
||||
s_logger.warn("set xenserver Iptable failed");
|
||||
}
|
||||
@ -6639,6 +6647,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
||||
// the resource first connects to XenServer. These UUIDs do
|
||||
// not change over time.
|
||||
protected class XenServerHost {
|
||||
public String systemvmisouuid;
|
||||
public String uuid;
|
||||
public String ip;
|
||||
public String publicNetwork;
|
||||
|
||||
@ -1836,14 +1836,14 @@ public interface ManagementServer {
|
||||
* @param tags Comma separated string to indicate special tags for the disk offering.
|
||||
* @return the created disk offering, null if failed to create
|
||||
*/
|
||||
DiskOfferingVO createDiskOffering(long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException;
|
||||
DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException;
|
||||
|
||||
/**
|
||||
* Delete a disk offering
|
||||
* @param id id of the disk offering to delete
|
||||
* @return true if deleted, false otherwise
|
||||
*/
|
||||
boolean deleteDiskOffering(long id);
|
||||
boolean deleteDiskOffering(long userId, long id);
|
||||
|
||||
/**
|
||||
* Update a disk offering
|
||||
@ -2187,4 +2187,5 @@ public interface ManagementServer {
|
||||
|
||||
boolean checkIfMaintenable(long hostId);
|
||||
|
||||
Map<String, String> listCapabilities();
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ public class DownloadManagerImpl implements DownloadManager {
|
||||
}
|
||||
|
||||
// add options common to ISO and template
|
||||
String extension = dnld.getFormat().toString().toLowerCase();
|
||||
String extension = dnld.getFormat().getFileExtension();
|
||||
String templateName = "";
|
||||
if( extension.equals("iso")) {
|
||||
templateName = jobs.get(jobId).getTmpltName().trim().replace(" ", "_");
|
||||
@ -353,6 +353,7 @@ public class DownloadManagerImpl implements DownloadManager {
|
||||
try {
|
||||
info = processor.process(templatePath, null, templateName);
|
||||
} catch (InternalErrorException e) {
|
||||
s_logger.error("Template process exception ", e);
|
||||
return e.toString();
|
||||
}
|
||||
if (info != null) {
|
||||
@ -781,6 +782,11 @@ public class DownloadManagerImpl implements DownloadManager {
|
||||
processor = new QCOW2Processor();
|
||||
processor.configure("QCOW2 Processor", params);
|
||||
processors.add(processor);
|
||||
|
||||
processor = new VmdkProcessor();
|
||||
processor.configure("VMDK Processor", params);
|
||||
processors.add(processor);
|
||||
|
||||
// Add more processors here.
|
||||
threadPool = Executors.newFixedThreadPool(numInstallThreads);
|
||||
return true;
|
||||
|
||||
69
core/src/com/cloud/storage/template/VmdkProcessor.java
Normal file
69
core/src/com/cloud/storage/template/VmdkProcessor.java
Normal file
@ -0,0 +1,69 @@
|
||||
package com.cloud.storage.template;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.storage.StorageLayer;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
|
||||
public class VmdkProcessor implements Processor {
|
||||
private static final Logger s_logger = Logger.getLogger(VmdkProcessor.class);
|
||||
|
||||
String _name;
|
||||
StorageLayer _storage;
|
||||
|
||||
@Override
|
||||
public FormatInfo process(String templatePath, ImageFormat format, String templateName) throws InternalErrorException {
|
||||
if (format != null) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("We currently don't handle conversion from " + format + " to VMDK.");
|
||||
return null;
|
||||
}
|
||||
|
||||
s_logger.info("Template processing. templatePath: " + templatePath + ", templateName: " + templateName);
|
||||
String templateFilePath = templatePath + File.separator + templateName + "." + ImageFormat.VMDK.getFileExtension();
|
||||
if (!_storage.exists(templateFilePath)) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Unable to find the vmware template file: " + templateFilePath);
|
||||
return null;
|
||||
}
|
||||
|
||||
FormatInfo info = new FormatInfo();
|
||||
info.format = ImageFormat.VMDK;
|
||||
info.filename = templateName + "." + ImageFormat.VMDK.getFileExtension();
|
||||
info.size = _storage.getSize(templateFilePath);
|
||||
info.virtualSize = info.size;
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
_storage = (StorageLayer)params.get(StorageLayer.InstanceConfigKey);
|
||||
if (_storage == null) {
|
||||
throw new ConfigurationException("Unable to get storage implementation");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -80,4 +80,5 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long> {
|
||||
List<VMInstanceVO> listByHostIdTypes(long hostid, VirtualMachine.Type... types);
|
||||
|
||||
List<VMInstanceVO> listUpByHostIdTypes(long hostid, VirtualMachine.Type... types);
|
||||
List<VMInstanceVO> listByZoneIdAndType(long zoneId, VirtualMachine.Type type);
|
||||
}
|
||||
|
||||
@ -51,6 +51,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
protected final SearchBuilder<VMInstanceVO> HostSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> LastHostSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> ZoneSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> ZoneVmTypeSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> ZoneTemplateNonExpungedSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> NameLikeSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> StateChangeSearch;
|
||||
@ -79,6 +80,11 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
ZoneSearch = createSearchBuilder();
|
||||
ZoneSearch.and("zone", ZoneSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
ZoneSearch.done();
|
||||
|
||||
ZoneVmTypeSearch = createSearchBuilder();
|
||||
ZoneVmTypeSearch.and("zone", ZoneVmTypeSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
ZoneVmTypeSearch.and("type", ZoneVmTypeSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||
ZoneVmTypeSearch.done();
|
||||
|
||||
ZoneTemplateNonExpungedSearch = createSearchBuilder();
|
||||
ZoneTemplateNonExpungedSearch.and("zone", ZoneTemplateNonExpungedSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
@ -193,6 +199,15 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
return listActiveBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMInstanceVO> listByZoneIdAndType(long zoneId, VirtualMachine.Type type) {
|
||||
SearchCriteria<VMInstanceVO> sc = ZoneVmTypeSearch.create();
|
||||
sc.setParameters("zone", zoneId);
|
||||
sc.setParameters("type", type.toString());
|
||||
return listActiveBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<VMInstanceVO> listNonExpungedByZoneAndTemplate(long zoneId, long templateId) {
|
||||
SearchCriteria<VMInstanceVO> sc = ZoneTemplateNonExpungedSearch.create();
|
||||
|
||||
4
debian/cloud-setup.install
vendored
4
debian/cloud-setup.install
vendored
@ -4,11 +4,11 @@
|
||||
/usr/share/cloud/setup/create-index-fk.sql
|
||||
/usr/share/cloud/setup/create-schema.sql
|
||||
/usr/share/cloud/setup/server-setup.sql
|
||||
/usr/share/cloud/setup/templates.kvm.sql
|
||||
/usr/share/cloud/setup/templates.xenserver.sql
|
||||
/usr/share/cloud/setup/templates.*.sql
|
||||
/usr/share/cloud/setup/deploy-db-dev.sh
|
||||
/usr/share/cloud/setup/server-setup.xml
|
||||
/usr/share/cloud/setup/data-20to21.sql
|
||||
/usr/share/cloud/setup/index-20to21.sql
|
||||
/usr/share/cloud/setup/index-212to213.sql
|
||||
/usr/share/cloud/setup/postprocess-20to21.sql
|
||||
/usr/share/cloud/setup/schema-20to21.sql
|
||||
|
||||
24
patches/xenserver/etc/sysconfig/iptables-domr
Normal file
24
patches/xenserver/etc/sysconfig/iptables-domr
Normal file
@ -0,0 +1,24 @@
|
||||
*nat
|
||||
:PREROUTING ACCEPT [0:0]
|
||||
:POSTROUTING ACCEPT [0:0]
|
||||
:OUTPUT ACCEPT [0:0]
|
||||
COMMIT
|
||||
*filter
|
||||
:INPUT DROP [0:0]
|
||||
:FORWARD DROP [0:0]
|
||||
:OUTPUT ACCEPT [0:0]
|
||||
-A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
-A INPUT -i eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
-A INPUT -i eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
-A INPUT -p icmp -j ACCEPT
|
||||
-A INPUT -i lo -j ACCEPT
|
||||
-A INPUT -i eth0 -p udp -m udp --dport 67 -j ACCEPT
|
||||
-A INPUT -i eth0 -p udp -m udp --dport 53 -j ACCEPT
|
||||
-A INPUT -i eth1 -p tcp -m state --state NEW --dport 3922 -j ACCEPT
|
||||
-A INPUT -i eth0 -p tcp -m state --state NEW --dport 8080 -j ACCEPT
|
||||
-A INPUT -i eth0 -p tcp -m state --state NEW --dport 80 -j ACCEPT
|
||||
-A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
-A FORWARD -i eth0 -o eth2 -j ACCEPT
|
||||
-A FORWARD -i eth2 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
COMMIT
|
||||
|
||||
1
patches/xenserver/root/.ssh/authorized_keys
Normal file
1
patches/xenserver/root/.ssh/authorized_keys
Normal file
@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA3VD1tGRDn3stlJvPNXmQZdQCNjqcfY+xlitd5q0n3KYqJ5OBrty3/00XBUdLt31TbQ4dv+GR7uEr+ex7rm0jjmTFKV4rHYPi882CuC5+bkBp5R4k+mpcyKbxb+IoNS9ItbiExQxMiiRQpHvNem0GGnNFO3lElRPwUFs8evTvZu5HcTj4k4RJLJ66jeIGJ3sMAJ03SICGwfEZjrsyeOMwJk7cH8WNeuNzxzoZd9v02eI0lHdK9O5z7FwrxvRBbzsmJ0EwuhbH8pR7WR6kGLTNP9KEwtrnzV1LYWd+rFoSeh6ImExG7fma3Ldydg8CPTQsjvCEQUxiuV1/x5am5VJlUw== root@r-6-TEST
|
||||
121
patches/xenserver/root/patchsystemvm.sh
Executable file
121
patches/xenserver/root/patchsystemvm.sh
Executable file
@ -0,0 +1,121 @@
|
||||
#/bin/bash
|
||||
# $Id: patchsystemvm.sh 10800 2010-07-16 13:48:39Z edison $ $HeadURL: svn://svn.lab.vmops.com/repos/branches/2.1.x/java/scripts/vm/hypervisor/xenserver/prepsystemvm.sh $
|
||||
|
||||
#set -x
|
||||
logfile="/var/log/patchsystemvm.log"
|
||||
#
|
||||
# To use existing console proxy .zip-based package file
|
||||
#
|
||||
patch_console_proxy() {
|
||||
local patchfile=$1
|
||||
rm /usr/local/cloud/systemvm -rf
|
||||
mkdir -p /usr/local/cloud/systemvm
|
||||
echo "All" | unzip $patchfile -d /usr/local/cloud/systemvm >$logfile 2>&1
|
||||
find /usr/local/cloud/systemvm/ -name \*.sh | xargs chmod 555
|
||||
return 0
|
||||
}
|
||||
|
||||
consoleproxy_svcs() {
|
||||
chkconfig cloud on
|
||||
chkconfig postinit on
|
||||
chkconfig domr_webserver off
|
||||
chkconfig haproxy off ;
|
||||
chkconfig dnsmasq off
|
||||
chkconfig sshd on
|
||||
chkconfig httpd off
|
||||
chkconfig nfs off
|
||||
chkconfig nfslock off
|
||||
chkconfig rpcbind off
|
||||
chkconfig rpcidmap off
|
||||
cp /etc/sysconfig/iptables-consoleproxy /etc/sysconfig/iptables
|
||||
mkdir -p /var/log/cloud
|
||||
}
|
||||
|
||||
secstorage_svcs() {
|
||||
chkconfig cloud on
|
||||
chkconfig postinit on
|
||||
chkconfig domr_webserver off
|
||||
chkconfig haproxy off ;
|
||||
chkconfig dnsmasq off
|
||||
chkconfig sshd on
|
||||
chkconfig httpd off
|
||||
cp /etc/sysconfig/iptables-secstorage /etc/sysconfig/iptables
|
||||
mkdir -p /var/log/cloud
|
||||
}
|
||||
|
||||
routing_svcs() {
|
||||
chkconfig cloud off
|
||||
chkconfig domr_webserver on ;
|
||||
chkconfig haproxy on ;
|
||||
chkconfig dnsmasq on
|
||||
chkconfig sshd on
|
||||
chkconfig nfs off
|
||||
chkconfig nfslock off
|
||||
chkconfig rpcbind off
|
||||
chkconfig rpcidmap off
|
||||
cp /etc/sysconfig/iptables-domr /etc/sysconfig/iptables
|
||||
}
|
||||
|
||||
CMDLINE=$(cat /proc/cmdline)
|
||||
TYPE="router"
|
||||
|
||||
for i in $CMDLINE
|
||||
do
|
||||
# search for foo=bar pattern and cut out foo
|
||||
KEY=$(echo $i | cut -d= -f1)
|
||||
VALUE=$(echo $i | cut -d= -f2)
|
||||
case $KEY in
|
||||
type)
|
||||
TYPE=$VALUE
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$TYPE" == "consoleproxy" ] || [ "$TYPE" == "secstorage" ] && [ -f /media/cdrom/systemvm.zip ]
|
||||
then
|
||||
patch_console_proxy /media/cdrom/systemvm.zip
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to apply patch systemvm\n" >$logfile
|
||||
exit 5
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#empty known hosts
|
||||
echo "" > /root/.ssh/known_hosts
|
||||
|
||||
if [ "$TYPE" == "router" ]
|
||||
then
|
||||
routing_svcs
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to execute routing_svcs\n" >$logfile
|
||||
exit 6
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "$TYPE" == "consoleproxy" ]
|
||||
then
|
||||
consoleproxy_svcs
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to execute consoleproxy_svcs\n" >$logfile
|
||||
exit 7
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$TYPE" == "secstorage" ]
|
||||
then
|
||||
secstorage_svcs
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to execute secstorage_svcs\n" >$logfile
|
||||
exit 8
|
||||
fi
|
||||
fi
|
||||
|
||||
exit $?
|
||||
136
python/incubation/cloud-web-ipallocator
Executable file
136
python/incubation/cloud-web-ipallocator
Executable file
@ -0,0 +1,136 @@
|
||||
#! /usr/bin/python
|
||||
import web
|
||||
import socket, struct
|
||||
import cloud_utils
|
||||
from cloud_utils import Command
|
||||
urls = ("/ipallocator", "ipallocator")
|
||||
app = web.application(urls, globals())
|
||||
|
||||
augtool = Command("augtool")
|
||||
service = Command("service")
|
||||
class dhcp:
|
||||
_instance = None
|
||||
def __init__(self):
|
||||
self.availIP=[]
|
||||
self.router=None
|
||||
self.netmask=None
|
||||
self.initialized=False
|
||||
|
||||
options = augtool.match("/files/etc/dnsmasq.conf/dhcp-option").stdout.strip()
|
||||
for option in options.splitlines():
|
||||
if option.find("option:router") != -1:
|
||||
self.router = option.split("=")[1].strip().split(",")[1]
|
||||
print self.router
|
||||
|
||||
dhcp_range = augtool.get("/files/etc/dnsmasq.conf/dhcp-range").stdout.strip()
|
||||
dhcp_start = dhcp_range.split("=")[1].strip().split(",")[0]
|
||||
dhcp_end = dhcp_range.split("=")[1].strip().split(",")[1]
|
||||
self.netmask = dhcp_range.split("=")[1].strip().split(",")[2]
|
||||
print dhcp_start, dhcp_end, self.netmask
|
||||
|
||||
start_ip_num = self.ipToNum(dhcp_start);
|
||||
end_ip_num = self.ipToNum(dhcp_end)
|
||||
print start_ip_num, end_ip_num
|
||||
|
||||
for ip in range(start_ip_num, end_ip_num + 1):
|
||||
self.availIP.append(ip)
|
||||
print self.availIP[0], self.availIP[len(self.availIP) - 1]
|
||||
|
||||
#load the ip already allocated
|
||||
self.reloadAllocatedIP()
|
||||
|
||||
def ipToNum(self, ip):
|
||||
return struct.unpack("!I", socket.inet_aton(ip))[0]
|
||||
|
||||
def numToIp(self, num):
|
||||
return socket.inet_ntoa(struct.pack('!I', num))
|
||||
|
||||
def getFreeIP(self):
|
||||
if len(self.availIP) > 0:
|
||||
ip = self.numToIp(self.availIP[0])
|
||||
self.availIP.remove(self.availIP[0])
|
||||
return ip
|
||||
else:
|
||||
return None
|
||||
|
||||
def getNetmask(self):
|
||||
return self.netmask
|
||||
|
||||
def getRouter(self):
|
||||
return self.router
|
||||
|
||||
def getInstance():
|
||||
if not dhcp._instance:
|
||||
dhcp._instance = dhcp()
|
||||
return dhcp._instance
|
||||
getInstance = staticmethod(getInstance)
|
||||
|
||||
def reloadAllocatedIP(self):
|
||||
dhcp_hosts = augtool.match("/files/etc/dnsmasq.conf/dhcp-host").stdout.strip().splitlines()
|
||||
|
||||
for host in dhcp_hosts:
|
||||
if host.find("dhcp-host") != -1:
|
||||
allocatedIP = self.ipToNum(host.split("=")[1].strip().split(",")[1])
|
||||
if allocatedIP in self.availIP:
|
||||
self.availIP.remove(allocatedIP)
|
||||
|
||||
def allocateIP(self, mac):
|
||||
newIP = self.getFreeIP()
|
||||
dhcp_host = augtool.match("/files/etc/dnsmasq.conf/dhcp-host").stdout.strip()
|
||||
cnt = len(dhcp_host.splitlines()) + 1
|
||||
script = """set %s %s
|
||||
save"""%("/files/etc/dnsmasq.conf/dhcp-host[" + str(cnt) + "]", str(mac) + "," + newIP)
|
||||
augtool < script
|
||||
#reset dnsmasq
|
||||
service("dnsmasq", "restart", stdout=None, stderr=None)
|
||||
return newIP
|
||||
|
||||
def releaseIP(self, ip):
|
||||
dhcp_host = augtool.match("/files/etc/dnsmasq.conf/dhcp-host").stdout.strip()
|
||||
path = None
|
||||
for host in dhcp_host.splitlines():
|
||||
if host.find(ip) != -1:
|
||||
path = host.split("=")[0].strip()
|
||||
|
||||
if path == None:
|
||||
print "Can't find " + str(ip) + " in conf file"
|
||||
return None
|
||||
|
||||
print path
|
||||
script = """rm %s
|
||||
save"""%(path)
|
||||
augtool < script
|
||||
|
||||
#reset dnsmasq
|
||||
service("dnsmasq", "restart", stdout=None, stderr=None)
|
||||
|
||||
class ipallocator:
|
||||
def GET(self):
|
||||
try:
|
||||
user_data = web.input()
|
||||
command = user_data.command
|
||||
print "Processing: " + command
|
||||
|
||||
dhcpInit = dhcp.getInstance()
|
||||
|
||||
if command == "getIpAddr":
|
||||
mac = user_data.mac
|
||||
zone_id = user_data.dc
|
||||
pod_id = user_data.pod
|
||||
print mac, zone_id, pod_id
|
||||
freeIP = dhcpInit.allocateIP(mac)
|
||||
if not freeIP:
|
||||
return "0,0,0"
|
||||
print "Find an available IP: " + freeIP
|
||||
|
||||
return freeIP + "," + dhcpInit.getNetmask() + "," + dhcpInit.getRouter()
|
||||
elif command == "releaseIpAddr":
|
||||
ip = user_data.ip
|
||||
zone_id = user_data.dc
|
||||
pod_id = user_data.pod
|
||||
dhcpInit.releaseIP(ip)
|
||||
except:
|
||||
return None
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
@ -80,6 +80,20 @@ create_from_file() {
|
||||
fi
|
||||
}
|
||||
|
||||
create_from_snapshot() {
|
||||
local tmpltImg=$1
|
||||
local snapshotName=$2
|
||||
local tmpltfs=$3
|
||||
local tmpltname=$4
|
||||
|
||||
cloud-qemu-img convert -f qcow2 -O qcow2 -s $snapshotName $tmpltImg /$tmpltfs/$tmpltname >& /dev/null
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to create template /$tmplfs/$tmpltname from snapshot $snapshotName on disk $tmpltImg "
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
tflag=
|
||||
nflag=
|
||||
fflag=
|
||||
@ -89,8 +103,9 @@ hvm=false
|
||||
cleanup=false
|
||||
dflag=
|
||||
cflag=
|
||||
snapshotName=
|
||||
|
||||
while getopts 'uht:n:f:s:c:d:' OPTION
|
||||
while getopts 'uht:n:f:sc:d:' OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
t) tflag=1
|
||||
@ -103,10 +118,10 @@ do
|
||||
tmpltimg="$OPTARG"
|
||||
;;
|
||||
s) sflag=1
|
||||
volsize="$OPTARG"
|
||||
sflag=1
|
||||
;;
|
||||
c) cflag=1
|
||||
cksum="$OPTARG"
|
||||
snapshotName="$OPTARG"
|
||||
;;
|
||||
d) dflag=1
|
||||
descr="$OPTARG"
|
||||
@ -119,12 +134,6 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$tflag$nflag$fflag" != "111" ]
|
||||
then
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d /$tmpltfs ]
|
||||
then
|
||||
@ -148,7 +157,12 @@ then
|
||||
printf "failed to uncompress $tmpltimg\n"
|
||||
fi
|
||||
|
||||
create_from_file $tmpltfs $tmpltimg $tmpltname
|
||||
if [ "$sflag" == "1" ]
|
||||
then
|
||||
create_from_snapshot $tmpltimg $snapshotName $tmpltfs $tmpltname
|
||||
else
|
||||
create_from_file $tmpltfs $tmpltimg $tmpltname
|
||||
fi
|
||||
|
||||
touch /$tmpltfs/template.properties
|
||||
echo -n "" > /$tmpltfs/template.properties
|
||||
|
||||
@ -16,13 +16,20 @@ create_snapshot() {
|
||||
local snapshotname=$2
|
||||
local failed=0
|
||||
|
||||
qemu-img snapshot -c $snapshotname $disk
|
||||
if [ ! -f $disk ]
|
||||
then
|
||||
failed=1
|
||||
printf "No disk $disk exist\n" >&2
|
||||
return $failed
|
||||
fi
|
||||
|
||||
cloud-qemu-img snapshot -c $snapshotname $disk
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
failed=1
|
||||
failed=2
|
||||
printf "***Failed to create snapshot $snapshotname for path $disk\n" >&2
|
||||
qemu-img snapshot -d $snapshotname $disk
|
||||
cloud-qemu-img snapshot -d $snapshotname $disk
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
@ -34,21 +41,24 @@ create_snapshot() {
|
||||
}
|
||||
|
||||
destroy_snapshot() {
|
||||
local backupSnapDir=$1
|
||||
local disk=$1
|
||||
local snapshotname=$2
|
||||
local failed=0
|
||||
|
||||
if [ -f $backupSnapDir/$snapshotname ]
|
||||
if [ ! -f $disk ]
|
||||
then
|
||||
rm -f $backupSnapDir/$snapshotname
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "***Failed to delete snapshot $snapshotname for path $backupSnapDir\n" >&2
|
||||
failed=1
|
||||
fi
|
||||
failed=1
|
||||
printf "No disk $disk exist\n" >&2
|
||||
return $failed
|
||||
fi
|
||||
|
||||
cloud-qemu-img snapshot -d $snapshotname $disk
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
failed=2
|
||||
printf "Failed to delete snapshot $snapshotname for path $disk\n" >&2
|
||||
fi
|
||||
|
||||
return $failed
|
||||
}
|
||||
|
||||
@ -71,6 +81,7 @@ backup_snapshot() {
|
||||
local disk=$1
|
||||
local snapshotname=$2
|
||||
local destPath=$3
|
||||
local destName=$4
|
||||
|
||||
if [ ! -d $destPath ]
|
||||
then
|
||||
@ -90,7 +101,7 @@ backup_snapshot() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
cloud-qemu-img convert -f qcow2 -O qcow2 -s $snapshotname $disk $destPath/$snapshotname >& /dev/null
|
||||
cloud-qemu-img convert -f qcow2 -O qcow2 -s $snapshotname $disk $destPath/$destName >& /dev/null
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to backup $snapshotname for disk $disk to $destPath" >&2
|
||||
@ -107,8 +118,9 @@ bflag=
|
||||
nflag=
|
||||
pathval=
|
||||
snapshot=
|
||||
tmplName=
|
||||
|
||||
while getopts 'c:d:r:n:b:p:' OPTION
|
||||
while getopts 'c:d:r:n:b:p:t:' OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
c) cflag=1
|
||||
@ -128,6 +140,8 @@ do
|
||||
;;
|
||||
p) destPath="$OPTARG"
|
||||
;;
|
||||
t) tmplName="$OPTARG"
|
||||
;;
|
||||
?) usage
|
||||
;;
|
||||
esac
|
||||
@ -144,7 +158,7 @@ then
|
||||
exit $?
|
||||
elif [ "$bflag" == "1" ]
|
||||
then
|
||||
backup_snapshot $pathval $snapshot $destPath
|
||||
backup_snapshot $pathval $snapshot $destPath $tmplName
|
||||
exit $?
|
||||
elif [ "$rflag" == "1" ]
|
||||
then
|
||||
|
||||
@ -174,4 +174,4 @@ done
|
||||
#install_cloud_agent $dflag
|
||||
#install_cloud_consoleP $dflag
|
||||
cloud_agent_setup $host $zone $pod $guid
|
||||
cloud_consoleP_setup $host $zone $pod
|
||||
#cloud_consoleP_setup $host $zone $pod
|
||||
|
||||
27
scripts/vm/hypervisor/xenserver/id_rsa.cloud
Normal file
27
scripts/vm/hypervisor/xenserver/id_rsa.cloud
Normal file
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEogIBAAKCAQEA3VD1tGRDn3stlJvPNXmQZdQCNjqcfY+xlitd5q0n3KYqJ5OB
|
||||
rty3/00XBUdLt31TbQ4dv+GR7uEr+ex7rm0jjmTFKV4rHYPi882CuC5+bkBp5R4k
|
||||
+mpcyKbxb+IoNS9ItbiExQxMiiRQpHvNem0GGnNFO3lElRPwUFs8evTvZu5HcTj4
|
||||
k4RJLJ66jeIGJ3sMAJ03SICGwfEZjrsyeOMwJk7cH8WNeuNzxzoZd9v02eI0lHdK
|
||||
9O5z7FwrxvRBbzsmJ0EwuhbH8pR7WR6kGLTNP9KEwtrnzV1LYWd+rFoSeh6ImExG
|
||||
7fma3Ldydg8CPTQsjvCEQUxiuV1/x5am5VJlUwIBIwKCAQEA0KtrUk/n/MSYsLAp
|
||||
xLRyNB+qUGMl1Xjao4f5cxhKJ8/emlfgrC8xI+mZXL+QiG7ZoVZz0ixzprcMNMkG
|
||||
5kmlLnxE3dxxy18Xz+2nIq9+hTVrKHuB82uZT3jVAxcP96GcU5C3snlPeu8KNK8+
|
||||
FFgqU3P/cpbo5FSgwMsNI3k5fkyffYtmBdtjZhWXJqnA9+bMdCmYEKyQFWp18LvV
|
||||
pjGx1jLFZTx9+aDz7gdIk21zbVXmwQmnS1fVKJEByTMvokpvdJUvDedvpgqGqX/g
|
||||
IXkTXe49pYhYwxVguLK6FXyQBwOuUsnur2A79T3wBvzEMozkYLkEG/zcw0fyo3iC
|
||||
fdzc6wKBgQD2gq+kUc2r/+xE+smIej2ICvFZZlSh1ko2tVmVUHuuuMCuBt054Dq9
|
||||
mf8/yIbXSvVtuBMJ+jewVnKfhucEQKf6E1jBdQShezlomFLOQ8cFQJhT6tAwJl/k
|
||||
TR+OjeTuOcBknkE8nstNt7hAkZxY6h/Lu54OM9AkXyZ9skx7gHh+IwKBgQDl1f09
|
||||
YkoM9rqXM8lMKjF0z81T4ACCaFUA6ZKjSZelyG+azJDlRFNWX1In3Kq6aInpZPzs
|
||||
owwIS9tjkXIaLR1wDJ+K8IGJQ19sqCzv3/kBCDXA6mqXkkPR80xRi4wuZ3lETOdL
|
||||
OBXPffuQaKxk32esqsxK6As1LgH4+048JS23EQKBgQCpCSf7pc7cV7f0yTm8q5fo
|
||||
QgSVEvg0da87dQo6gFTPlKFhY8rl25X+WvgrvLQ726D6x12DLzwhJVXpu5cY2+Dl
|
||||
/qNC0+XrEqsF5MsRGIh4oVKCr6SzTYOVPDLlaJz7IElpkRbKe4QYCPNfecpLmTpf
|
||||
0Rvse0zlvZa8l4Tm+QIqmwKBgBOzQZeMFPnMAV1q1r1is8gvEZl5maTHHTqXrXu1
|
||||
2cxhoyqGkBOmxVCL09eH8WBvXEc0irUyjAC2C32QH7kZz1K/QOAF/Hl6zao6TP6e
|
||||
K0k7N861AdJ6QFPTBoqlj6w0wUBeXPfRm3gvXrSbQfoEhTqvjdqI6wSO6jnpp57B
|
||||
W7CbAoGABFHMVXEyT3SliMSRtiCuDOrtl9E/aiOByPulXolqth5WDSel31Lz+iY7
|
||||
ldOLNQO/oononTStdd0fDGChl3WXBSOToJJ/HjIWH05bDY9n2EDAyZvmaW9rX3JQ
|
||||
pH9c/1vlD9lxDEBvq4JXmTtdL0Ho00F5vVHnWnwINtfx6c5BIjg=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@ -18,9 +18,12 @@ nfs.py=/opt/xensource/sm
|
||||
patch.tgz=..,0775,/opt/xensource/bin
|
||||
vmops=..,0755,/etc/xapi.d/plugins
|
||||
vmopsSnapshot=..,0755,/etc/xapi.d/plugins
|
||||
systemvm-premium.zip=../../../../../vms,0755,/opt/xensource/bin
|
||||
hostvmstats.py=..,0755,/opt/xensource/sm
|
||||
xs_cleanup.sh=..,0755,/opt/xensource/bin
|
||||
systemvm-premium.iso=../../../../../vms,0644,/opt/xensource/packages/iso
|
||||
systemvm.iso=../../../../../vms,0644,/opt/xensource/packages/iso
|
||||
hostvmstats.py=..,0755,/opt/xensource/sm
|
||||
id_rsa.cloud=..,0600,/opt/xensource/bin
|
||||
id_rsa.cloud=..,0600,/root/.ssh
|
||||
network_info.sh=..,0755,/opt/xensource/bin
|
||||
prepsystemvm.sh=..,0755,/opt/xensource/bin
|
||||
setupxenserver.sh=..,0755,/opt/xensource/bin
|
||||
|
||||
@ -153,7 +153,8 @@ public class AlertManagerImpl implements AlertManager {
|
||||
smtpDebug = Boolean.parseBoolean(smtpDebugStr);
|
||||
}
|
||||
|
||||
_emailAlert = new EmailAlert(emailAddresses, smtpHost, smtpPort, useAuth, smtpUsername, smtpPassword, emailSender, smtpDebug);
|
||||
_emailAlert = new EmailAlert(emailAddresses, smtpHost, smtpPort, useAuth, smtpUsername, smtpPassword, emailSender, smtpDebug);
|
||||
_emailAlert = null;
|
||||
|
||||
String storageCapacityThreshold = configs.get("storage.capacity.threshold");
|
||||
String cpuCapacityThreshold = configs.get("cpu.capacity.threshold");
|
||||
|
||||
@ -29,6 +29,7 @@ import com.cloud.api.ServerApiException;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public class CreateDiskOfferingCmd extends BaseCmd {
|
||||
@ -61,7 +62,7 @@ public class CreateDiskOfferingCmd extends BaseCmd {
|
||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
// FIXME: add domain-private disk offerings
|
||||
// Account account = (Account)params.get(BaseCmd.Properties.ACCOUNT_OBJ.getName());
|
||||
// Long userId = (Long)params.get(BaseCmd.Properties.USER_ID.getName());
|
||||
Long userId = (Long)params.get(BaseCmd.Properties.USER_ID.getName());
|
||||
Long domainId = (Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
|
||||
String name = (String)params.get(BaseCmd.Properties.NAME.getName());
|
||||
String displayText = (String)params.get(BaseCmd.Properties.DISPLAY_TEXT.getName());
|
||||
@ -74,11 +75,15 @@ public class CreateDiskOfferingCmd extends BaseCmd {
|
||||
// }
|
||||
if (domainId == null) {
|
||||
domainId = DomainVO.ROOT_DOMAIN;
|
||||
}
|
||||
|
||||
if (userId == null) {
|
||||
userId = Long.valueOf(User.UID_SYSTEM);
|
||||
}
|
||||
|
||||
DiskOfferingVO diskOffering = null;
|
||||
try {
|
||||
diskOffering = getManagementServer().createDiskOffering(domainId.longValue(), name, displayText, numGB.intValue(),tags);
|
||||
diskOffering = getManagementServer().createDiskOffering(userId, domainId.longValue(), name, displayText, numGB.intValue(),tags);
|
||||
} catch (InvalidParameterValueException ex) {
|
||||
throw new ServerApiException (BaseCmd.VM_INVALID_PARAM_ERROR, ex.getMessage());
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import org.apache.log4j.Logger;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public class DeleteDiskOfferingCmd extends BaseCmd {
|
||||
@ -36,7 +37,8 @@ public class DeleteDiskOfferingCmd extends BaseCmd {
|
||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
||||
|
||||
static {
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ID, Boolean.TRUE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ID, Boolean.TRUE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.USER_ID, Boolean.FALSE));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -48,7 +50,12 @@ public class DeleteDiskOfferingCmd extends BaseCmd {
|
||||
|
||||
@Override
|
||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
Long id = (Long)params.get(BaseCmd.Properties.ID.getName());
|
||||
Long id = (Long)params.get(BaseCmd.Properties.ID.getName());
|
||||
Long userId = (Long)params.get(BaseCmd.Properties.USER_ID.getName());
|
||||
|
||||
if (userId == null) {
|
||||
userId = Long.valueOf(User.UID_SYSTEM);
|
||||
}
|
||||
|
||||
//verify input parameters
|
||||
DiskOfferingVO disk = getManagementServer().findDiskOfferingById(id);
|
||||
@ -56,7 +63,7 @@ public class DeleteDiskOfferingCmd extends BaseCmd {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a disk offering with id " + id);
|
||||
}
|
||||
|
||||
boolean result = getManagementServer().deleteDiskOffering(id);
|
||||
boolean result = getManagementServer().deleteDiskOffering(userId, id);
|
||||
|
||||
List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.SUCCESS.getName(), Boolean.valueOf(result).toString()));
|
||||
|
||||
@ -16,8 +16,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -36,206 +36,204 @@ import com.cloud.user.UserStatisticsVO;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.State;
|
||||
|
||||
public class ListAccountsCmd extends BaseCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(ListAccountsCmd.class.getName());
|
||||
private static final String s_name = "listaccountsresponse";
|
||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
||||
|
||||
static {
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ID, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.NAME, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ACCOUNT_TYPE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.STATE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.IS_CLEANUP_REQUIRED, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.KEYWORD, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ACCOUNT_OBJ, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ACCOUNT, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.DOMAIN_ID, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGESIZE, Boolean.FALSE));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
public List<Pair<Enum, Boolean>> getProperties() {
|
||||
return s_properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
Long id = (Long)params.get(BaseCmd.Properties.ID.getName());
|
||||
Account account = (Account)params.get(BaseCmd.Properties.ACCOUNT_OBJ.getName());
|
||||
Long domainId = (Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
|
||||
Long type = (Long)params.get(BaseCmd.Properties.ACCOUNT_TYPE.getName());
|
||||
String state = (String)params.get(BaseCmd.Properties.STATE.getName());
|
||||
Boolean needCleanup = (Boolean)params.get(BaseCmd.Properties.IS_CLEANUP_REQUIRED.getName());
|
||||
Integer page = (Integer)params.get(BaseCmd.Properties.PAGE.getName());
|
||||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
String keyword = (String)params.get(BaseCmd.Properties.KEYWORD.getName());
|
||||
boolean isAdmin = false;
|
||||
Long accountId = null;
|
||||
|
||||
String accountName = null;
|
||||
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
accountName = (String)params.get(BaseCmd.Properties.NAME.getName());
|
||||
isAdmin = true;
|
||||
if (domainId == null) {
|
||||
// default domainId to the admin's domain
|
||||
domainId = ((account == null) ? Domain.ROOT_DOMAIN : account.getDomainId());
|
||||
} else if (account != null) {
|
||||
if (!getManagementServer().isChildDomain(account.getDomainId(), domainId)) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid domain id (" + domainId + ") given, unable to list accounts");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
accountName = (String)params.get(BaseCmd.Properties.ACCOUNT.getName());
|
||||
accountId = account.getId();
|
||||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
if (pageNum > 0) {
|
||||
startIndex = Long.valueOf(pageSizeNum * (pageNum-1));
|
||||
}
|
||||
}
|
||||
Criteria c = new Criteria("id", Boolean.TRUE, startIndex, Long.valueOf(pageSizeNum));
|
||||
if (isAdmin == true) {
|
||||
c.addCriteria(Criteria.ID, id);
|
||||
if (keyword == null) {
|
||||
c.addCriteria(Criteria.ACCOUNTNAME, accountName);
|
||||
c.addCriteria(Criteria.DOMAINID, domainId);
|
||||
c.addCriteria(Criteria.TYPE, type);
|
||||
c.addCriteria(Criteria.STATE, state);
|
||||
c.addCriteria(Criteria.ISCLEANUPREQUIRED, needCleanup);
|
||||
} else {
|
||||
c.addCriteria(Criteria.KEYWORD, keyword);
|
||||
}
|
||||
} else {
|
||||
c.addCriteria(Criteria.ID, accountId);
|
||||
}
|
||||
|
||||
List<AccountVO> accounts = getManagementServer().searchForAccounts(c);
|
||||
|
||||
List<Pair<String, Object>> accountTags = new ArrayList<Pair<String, Object>>();
|
||||
Object[] aTag = new Object[accounts.size()];
|
||||
int i = 0;
|
||||
for (AccountVO accountO : accounts) {
|
||||
boolean accountIsAdmin = (accountO.getType() == Account.ACCOUNT_TYPE_ADMIN);
|
||||
|
||||
if ((accountO.getRemoved() == null)&&(accountO.getId() != 1)) {
|
||||
List<Pair<String, Object>> accountData = new ArrayList<Pair<String, Object>>();
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.valueOf(accountO.getId()).toString()));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), accountO.getAccountName()));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT_TYPE.getName(), Short.valueOf(accountO.getType()).toString()));
|
||||
Domain domain = getManagementServer().findDomainIdById(accountO.getDomainId());
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(domain.getId())));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), domain.getName()));
|
||||
|
||||
//get network stat
|
||||
List<UserStatisticsVO> stats = getManagementServer().listUserStatsBy(accountO.getId());
|
||||
if (stats == null) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Internal error searching for user stats");
|
||||
}
|
||||
|
||||
long bytesSent = 0;
|
||||
long bytesReceived = 0;
|
||||
for (UserStatisticsVO stat : stats) {
|
||||
long rx = stat.getNetBytesReceived() + stat.getCurrentBytesReceived();
|
||||
long tx = stat.getNetBytesSent() + stat.getCurrentBytesSent();
|
||||
bytesReceived = bytesReceived + Long.valueOf(rx);
|
||||
bytesSent = bytesSent + Long.valueOf(tx);
|
||||
}
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.BYTES_RECEIVED.getName(), Long.valueOf(bytesReceived).toString()));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.BYTES_SENT.getName(), Long.valueOf(bytesSent).toString()));
|
||||
|
||||
// Get resource limits and counts
|
||||
|
||||
long vmLimit = getManagementServer().findCorrectResourceLimit(ResourceType.user_vm, accountO.getId());
|
||||
String vmLimitDisplay = (accountIsAdmin || vmLimit == -1) ? "Unlimited" : String.valueOf(vmLimit);
|
||||
long vmTotal = getManagementServer().getResourceCount(ResourceType.user_vm, accountO.getId());
|
||||
String vmAvail = (accountIsAdmin || vmLimit == -1) ? "Unlimited" : String.valueOf(vmLimit - vmTotal);
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VM_LIMIT.getName(), vmLimitDisplay));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VM_TOTAL.getName(), vmTotal));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VM_AVAIL.getName(), vmAvail));
|
||||
|
||||
long ipLimit = getManagementServer().findCorrectResourceLimit(ResourceType.public_ip, accountO.getId());
|
||||
String ipLimitDisplay = (accountIsAdmin || ipLimit == -1) ? "Unlimited" : String.valueOf(ipLimit);
|
||||
long ipTotal = getManagementServer().getResourceCount(ResourceType.public_ip, accountO.getId());
|
||||
String ipAvail = (accountIsAdmin || ipLimit == -1) ? "Unlimited" : String.valueOf(ipLimit - ipTotal);
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.IP_LIMIT.getName(), ipLimitDisplay));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.IP_TOTAL.getName(), ipTotal));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.IP_AVAIL.getName(), ipAvail));
|
||||
|
||||
long volumeLimit = getManagementServer().findCorrectResourceLimit(ResourceType.volume, accountO.getId());
|
||||
String volumeLimitDisplay = (accountIsAdmin || volumeLimit == -1) ? "Unlimited" : String.valueOf(volumeLimit);
|
||||
long volumeTotal = getManagementServer().getResourceCount(ResourceType.volume, accountO.getId());
|
||||
String volumeAvail = (accountIsAdmin || volumeLimit == -1) ? "Unlimited" : String.valueOf(volumeLimit - volumeTotal);
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VOLUME_LIMIT.getName(), volumeLimitDisplay));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VOLUME_TOTAL.getName(), volumeTotal));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VOLUME_AVAIL.getName(), volumeAvail));
|
||||
|
||||
long snapshotLimit = getManagementServer().findCorrectResourceLimit(ResourceType.snapshot, accountO.getId());
|
||||
String snapshotLimitDisplay = (accountIsAdmin || snapshotLimit == -1) ? "Unlimited" : String.valueOf(snapshotLimit);
|
||||
long snapshotTotal = getManagementServer().getResourceCount(ResourceType.snapshot, accountO.getId());
|
||||
String snapshotAvail = (accountIsAdmin || snapshotLimit == -1) ? "Unlimited" : String.valueOf(snapshotLimit - snapshotTotal);
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.SNAPSHOT_LIMIT.getName(), snapshotLimitDisplay));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.SNAPSHOT_TOTAL.getName(), snapshotTotal));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.SNAPSHOT_AVAIL.getName(), snapshotAvail));
|
||||
|
||||
long templateLimit = getManagementServer().findCorrectResourceLimit(ResourceType.template, accountO.getId());
|
||||
String templateLimitDisplay = (accountIsAdmin || templateLimit == -1) ? "Unlimited" : String.valueOf(templateLimit);
|
||||
long templateTotal = getManagementServer().getResourceCount(ResourceType.template, accountO.getId());
|
||||
String templateAvail = (accountIsAdmin || templateLimit == -1) ? "Unlimited" : String.valueOf(templateLimit - templateTotal);
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.TEMPLATE_LIMIT.getName(), templateLimitDisplay));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.TEMPLATE_TOTAL.getName(), templateTotal));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.TEMPLATE_AVAIL.getName(), templateAvail));
|
||||
|
||||
// Get stopped and running VMs
|
||||
|
||||
int vmStopped = 0;
|
||||
int vmRunning = 0;
|
||||
|
||||
Long[] accountIds = new Long[1];
|
||||
accountIds[0] = accountO.getId();
|
||||
|
||||
Criteria c1 = new Criteria();
|
||||
c1.addCriteria(Criteria.ACCOUNTID, accountIds);
|
||||
List<? extends UserVm> virtualMachines = getManagementServer().searchForUserVMs(c1);
|
||||
|
||||
//get Running/Stopped VMs
|
||||
for (Iterator<? extends UserVm> iter = virtualMachines.iterator(); iter.hasNext();) {
|
||||
// count how many stopped/running vms we have
|
||||
UserVm vm = iter.next();
|
||||
|
||||
if (vm.getState() == State.Stopped) {
|
||||
vmStopped++;
|
||||
} else if (vm.getState() == State.Running) {
|
||||
vmRunning++;
|
||||
}
|
||||
}
|
||||
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VM_STOPPED.getName(), vmStopped));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VM_RUNNING.getName(), vmRunning));
|
||||
|
||||
//show this info to admins only
|
||||
if (isAdmin == true) {
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.STATE.getName(), accountO.getState()));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.IS_CLEANUP_REQUIRED.getName(), Boolean.valueOf(accountO.getNeedsCleanup()).toString()));
|
||||
}
|
||||
|
||||
aTag[i++] = accountData;
|
||||
}
|
||||
}
|
||||
Pair<String, Object> accountTag = new Pair<String, Object>("account", aTag);
|
||||
accountTags.add(accountTag);
|
||||
return accountTags;
|
||||
}
|
||||
}
|
||||
|
||||
public class ListAccountsCmd extends BaseCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(ListAccountsCmd.class.getName());
|
||||
private static final String s_name = "listaccountsresponse";
|
||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
||||
|
||||
static {
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ID, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.NAME, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ACCOUNT_TYPE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.STATE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.IS_CLEANUP_REQUIRED, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.KEYWORD, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ACCOUNT_OBJ, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ACCOUNT, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.DOMAIN_ID, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGESIZE, Boolean.FALSE));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
public List<Pair<Enum, Boolean>> getProperties() {
|
||||
return s_properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
Long id = (Long)params.get(BaseCmd.Properties.ID.getName());
|
||||
Account account = (Account)params.get(BaseCmd.Properties.ACCOUNT_OBJ.getName());
|
||||
Long domainId = (Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
|
||||
Long type = (Long)params.get(BaseCmd.Properties.ACCOUNT_TYPE.getName());
|
||||
String state = (String)params.get(BaseCmd.Properties.STATE.getName());
|
||||
Boolean needCleanup = (Boolean)params.get(BaseCmd.Properties.IS_CLEANUP_REQUIRED.getName());
|
||||
Integer page = (Integer)params.get(BaseCmd.Properties.PAGE.getName());
|
||||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
String keyword = (String)params.get(BaseCmd.Properties.KEYWORD.getName());
|
||||
boolean isAdmin = false;
|
||||
Long accountId = null;
|
||||
|
||||
String accountName = null;
|
||||
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
accountName = (String)params.get(BaseCmd.Properties.NAME.getName());
|
||||
isAdmin = true;
|
||||
if (domainId == null) {
|
||||
// default domainId to the admin's domain
|
||||
domainId = ((account == null) ? Domain.ROOT_DOMAIN : account.getDomainId());
|
||||
} else if (account != null) {
|
||||
if (!getManagementServer().isChildDomain(account.getDomainId(), domainId)) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid domain id (" + domainId + ") given, unable to list accounts");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
accountName = (String)params.get(BaseCmd.Properties.ACCOUNT.getName());
|
||||
accountId = account.getId();
|
||||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
if (pageNum > 0) {
|
||||
startIndex = Long.valueOf(pageSizeNum * (pageNum-1));
|
||||
}
|
||||
}
|
||||
Criteria c = new Criteria("id", Boolean.TRUE, startIndex, Long.valueOf(pageSizeNum));
|
||||
if (isAdmin == true) {
|
||||
c.addCriteria(Criteria.ID, id);
|
||||
if (keyword == null) {
|
||||
c.addCriteria(Criteria.ACCOUNTNAME, accountName);
|
||||
c.addCriteria(Criteria.DOMAINID, domainId);
|
||||
c.addCriteria(Criteria.TYPE, type);
|
||||
c.addCriteria(Criteria.STATE, state);
|
||||
c.addCriteria(Criteria.ISCLEANUPREQUIRED, needCleanup);
|
||||
} else {
|
||||
c.addCriteria(Criteria.KEYWORD, keyword);
|
||||
}
|
||||
} else {
|
||||
c.addCriteria(Criteria.ID, accountId);
|
||||
}
|
||||
|
||||
List<AccountVO> accounts = getManagementServer().searchForAccounts(c);
|
||||
|
||||
List<Pair<String, Object>> accountTags = new ArrayList<Pair<String, Object>>();
|
||||
Object[] aTag = new Object[accounts.size()];
|
||||
int i = 0;
|
||||
for (AccountVO accountO : accounts) {
|
||||
boolean accountIsAdmin = (accountO.getType() == Account.ACCOUNT_TYPE_ADMIN);
|
||||
|
||||
List<Pair<String, Object>> accountData = new ArrayList<Pair<String, Object>>();
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.valueOf(accountO.getId()).toString()));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), accountO.getAccountName()));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT_TYPE.getName(), Short.valueOf(accountO.getType()).toString()));
|
||||
Domain domain = getManagementServer().findDomainIdById(accountO.getDomainId());
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(domain.getId())));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), domain.getName()));
|
||||
|
||||
//get network stat
|
||||
List<UserStatisticsVO> stats = getManagementServer().listUserStatsBy(accountO.getId());
|
||||
if (stats == null) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Internal error searching for user stats");
|
||||
}
|
||||
|
||||
long bytesSent = 0;
|
||||
long bytesReceived = 0;
|
||||
for (UserStatisticsVO stat : stats) {
|
||||
long rx = stat.getNetBytesReceived() + stat.getCurrentBytesReceived();
|
||||
long tx = stat.getNetBytesSent() + stat.getCurrentBytesSent();
|
||||
bytesReceived = bytesReceived + Long.valueOf(rx);
|
||||
bytesSent = bytesSent + Long.valueOf(tx);
|
||||
}
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.BYTES_RECEIVED.getName(), Long.valueOf(bytesReceived).toString()));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.BYTES_SENT.getName(), Long.valueOf(bytesSent).toString()));
|
||||
|
||||
// Get resource limits and counts
|
||||
|
||||
long vmLimit = getManagementServer().findCorrectResourceLimit(ResourceType.user_vm, accountO.getId());
|
||||
String vmLimitDisplay = (accountIsAdmin || vmLimit == -1) ? "Unlimited" : String.valueOf(vmLimit);
|
||||
long vmTotal = getManagementServer().getResourceCount(ResourceType.user_vm, accountO.getId());
|
||||
String vmAvail = (accountIsAdmin || vmLimit == -1) ? "Unlimited" : String.valueOf(vmLimit - vmTotal);
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VM_LIMIT.getName(), vmLimitDisplay));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VM_TOTAL.getName(), vmTotal));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VM_AVAIL.getName(), vmAvail));
|
||||
|
||||
long ipLimit = getManagementServer().findCorrectResourceLimit(ResourceType.public_ip, accountO.getId());
|
||||
String ipLimitDisplay = (accountIsAdmin || ipLimit == -1) ? "Unlimited" : String.valueOf(ipLimit);
|
||||
long ipTotal = getManagementServer().getResourceCount(ResourceType.public_ip, accountO.getId());
|
||||
String ipAvail = (accountIsAdmin || ipLimit == -1) ? "Unlimited" : String.valueOf(ipLimit - ipTotal);
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.IP_LIMIT.getName(), ipLimitDisplay));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.IP_TOTAL.getName(), ipTotal));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.IP_AVAIL.getName(), ipAvail));
|
||||
|
||||
long volumeLimit = getManagementServer().findCorrectResourceLimit(ResourceType.volume, accountO.getId());
|
||||
String volumeLimitDisplay = (accountIsAdmin || volumeLimit == -1) ? "Unlimited" : String.valueOf(volumeLimit);
|
||||
long volumeTotal = getManagementServer().getResourceCount(ResourceType.volume, accountO.getId());
|
||||
String volumeAvail = (accountIsAdmin || volumeLimit == -1) ? "Unlimited" : String.valueOf(volumeLimit - volumeTotal);
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VOLUME_LIMIT.getName(), volumeLimitDisplay));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VOLUME_TOTAL.getName(), volumeTotal));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VOLUME_AVAIL.getName(), volumeAvail));
|
||||
|
||||
long snapshotLimit = getManagementServer().findCorrectResourceLimit(ResourceType.snapshot, accountO.getId());
|
||||
String snapshotLimitDisplay = (accountIsAdmin || snapshotLimit == -1) ? "Unlimited" : String.valueOf(snapshotLimit);
|
||||
long snapshotTotal = getManagementServer().getResourceCount(ResourceType.snapshot, accountO.getId());
|
||||
String snapshotAvail = (accountIsAdmin || snapshotLimit == -1) ? "Unlimited" : String.valueOf(snapshotLimit - snapshotTotal);
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.SNAPSHOT_LIMIT.getName(), snapshotLimitDisplay));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.SNAPSHOT_TOTAL.getName(), snapshotTotal));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.SNAPSHOT_AVAIL.getName(), snapshotAvail));
|
||||
|
||||
long templateLimit = getManagementServer().findCorrectResourceLimit(ResourceType.template, accountO.getId());
|
||||
String templateLimitDisplay = (accountIsAdmin || templateLimit == -1) ? "Unlimited" : String.valueOf(templateLimit);
|
||||
long templateTotal = getManagementServer().getResourceCount(ResourceType.template, accountO.getId());
|
||||
String templateAvail = (accountIsAdmin || templateLimit == -1) ? "Unlimited" : String.valueOf(templateLimit - templateTotal);
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.TEMPLATE_LIMIT.getName(), templateLimitDisplay));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.TEMPLATE_TOTAL.getName(), templateTotal));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.TEMPLATE_AVAIL.getName(), templateAvail));
|
||||
|
||||
// Get stopped and running VMs
|
||||
|
||||
int vmStopped = 0;
|
||||
int vmRunning = 0;
|
||||
|
||||
Long[] accountIds = new Long[1];
|
||||
accountIds[0] = accountO.getId();
|
||||
|
||||
Criteria c1 = new Criteria();
|
||||
c1.addCriteria(Criteria.ACCOUNTID, accountIds);
|
||||
List<? extends UserVm> virtualMachines = getManagementServer().searchForUserVMs(c1);
|
||||
|
||||
//get Running/Stopped VMs
|
||||
for (Iterator<? extends UserVm> iter = virtualMachines.iterator(); iter.hasNext();) {
|
||||
// count how many stopped/running vms we have
|
||||
UserVm vm = iter.next();
|
||||
|
||||
if (vm.getState() == State.Stopped) {
|
||||
vmStopped++;
|
||||
} else if (vm.getState() == State.Running) {
|
||||
vmRunning++;
|
||||
}
|
||||
}
|
||||
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VM_STOPPED.getName(), vmStopped));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.VM_RUNNING.getName(), vmRunning));
|
||||
|
||||
//show this info to admins only
|
||||
if (isAdmin == true) {
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.STATE.getName(), accountO.getState()));
|
||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.IS_CLEANUP_REQUIRED.getName(), Boolean.valueOf(accountO.getNeedsCleanup()).toString()));
|
||||
}
|
||||
|
||||
aTag[i++] = accountData;
|
||||
}
|
||||
Pair<String, Object> accountTag = new Pair<String, Object>("account", aTag);
|
||||
accountTags.add(accountTag);
|
||||
return accountTags;
|
||||
}
|
||||
}
|
||||
|
||||
58
server/src/com/cloud/api/commands/ListCapabilitiesCmd.java
Normal file
58
server/src/com/cloud/api/commands/ListCapabilitiesCmd.java
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public class ListCapabilitiesCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListCapabilitiesCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listcapabilitiesresponse";
|
||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
||||
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
public List<Pair<Enum, Boolean>> getProperties() {
|
||||
return s_properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
Map<String, String> capabilities = null;
|
||||
capabilities = getManagementServer().listCapabilities();
|
||||
|
||||
Iterator<String> iterator = capabilities.keySet().iterator();
|
||||
List<Pair<String, Object>> capabilityPair = new ArrayList<Pair<String, Object>>();
|
||||
while (iterator.hasNext()) {
|
||||
String capability = iterator.next();
|
||||
capabilityPair.add(new Pair<String, Object>(capability, capabilities.get(capability)));
|
||||
}
|
||||
return capabilityPair;
|
||||
}
|
||||
}
|
||||
5
server/src/com/cloud/api/commands/ListVolumesCmd.java
Normal file → Executable file
5
server/src/com/cloud/api/commands/ListVolumesCmd.java
Normal file → Executable file
@ -185,8 +185,9 @@ public class ListVolumesCmd extends BaseCmd{
|
||||
volumeData.add(new Pair<String, Object>(BaseCmd.Properties.VIRTUAL_MACHINE_ID.getName(), vm.getId()));
|
||||
volumeData.add(new Pair<String, Object>(BaseCmd.Properties.VIRTUAL_MACHINE_NAME.getName(), vm.getName()));
|
||||
volumeData.add(new Pair<String, Object>(BaseCmd.Properties.VIRTUAL_MACHINE_DISPLAYNAME.getName(), vm.getName()));
|
||||
volumeData.add(new Pair<String, Object>(BaseCmd.Properties.VIRTUAL_MACHINE_STATE.getName(), vm.getState()));
|
||||
}
|
||||
volumeData.add(new Pair<String, Object>(BaseCmd.Properties.VIRTUAL_MACHINE_STATE.getName(), vm.getState()));
|
||||
volumeData.add(new Pair<String, Object>(BaseCmd.Properties.DEVICE_ID.getName(), volume.getDeviceId()));
|
||||
}
|
||||
|
||||
// Show the virtual size of the volume
|
||||
long virtualSizeInBytes = volume.getSize();
|
||||
|
||||
@ -146,6 +146,7 @@ public enum Config {
|
||||
DirectAttachNetworkExternalAPIURL("Advanced", ManagementServer.class, String.class, "direct.attach.network.externalIpAllocator.url", null, "Direct-attach VMs using external DHCP server (API url)", null),
|
||||
DirectAttachUntaggedVlanEnabled("Advanced", ManagementServer.class, String.class, "direct.attach.untagged.vlan.enabled", "false", "Indicate whether the system supports direct-attached untagged vlan", "true,false"),
|
||||
CheckPodCIDRs("Advanced", ManagementServer.class, String.class, "check.pod.cidrs", "true", "If true, different pods must belong to different CIDR subnets.", "true,false"),
|
||||
MD5Hashed("Advanced", ManagementServer.class, Boolean.class, "security.password.md5hashed", "true", "If set to false password is sent in clear text or else md5hashed", null),
|
||||
|
||||
// XenServer
|
||||
VmAllocationAlgorithm("Advanced", ManagementServer.class, String.class, "vm.allocation.algorithm", "random", "If 'random', hosts within a pod will be randomly considered for VM/volume allocation. If 'firstfit', they will be considered on a first-fit basis.", null),
|
||||
|
||||
@ -99,7 +99,14 @@ public interface ConfigurationManager extends Manager {
|
||||
* @param size
|
||||
* @return ID
|
||||
*/
|
||||
DiskOfferingVO createDiskOffering(long domainId, String name, String description, int numGibibytes, String tags);
|
||||
DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags);
|
||||
|
||||
/**
|
||||
* Deletes a disk offering
|
||||
* @param userId
|
||||
* @param diskOfferingId
|
||||
*/
|
||||
boolean deleteDiskOffering(long userId, long diskOfferingId);
|
||||
|
||||
/**
|
||||
* Creates a new pod
|
||||
|
||||
@ -57,6 +57,7 @@ import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.SecondaryStorage;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.UserVO;
|
||||
@ -66,9 +67,14 @@ import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Local(value={ConfigurationManager.class})
|
||||
@ -91,6 +97,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
@Inject AccountDao _accountDao;
|
||||
@Inject EventDao _eventDao;
|
||||
@Inject UserDao _userDao;
|
||||
@Inject ConsoleProxyDao _consoleDao;
|
||||
@Inject SecondaryStorageVmDao _secStorageDao;
|
||||
public boolean _premium;
|
||||
|
||||
@Override
|
||||
@ -665,13 +673,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
throw new InvalidParameterValueException("A zone with ID: " + zoneId + " does not exist.");
|
||||
}
|
||||
|
||||
// If DNS values are being changed, make sure there are no VMs in this zone
|
||||
if (dns1 != null || dns2 != null || internalDns1 != null || internalDns2 != null) {
|
||||
if (zoneHasVMs(zoneId)) {
|
||||
throw new InternalErrorException("The zone is not editable because there are VMs in the zone.");
|
||||
}
|
||||
}
|
||||
|
||||
// If the Vnet range is being changed, make sure there are no allocated VNets
|
||||
if (vnetRange != null) {
|
||||
if (zoneHasAllocatedVnets(zoneId)) {
|
||||
@ -679,22 +680,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
}
|
||||
}
|
||||
|
||||
//To modify a zone, we need to make sure there are no domr's associated with it
|
||||
//1. List all the domain router objs
|
||||
//2. Check if any of these has the current data center associated
|
||||
//3. If yes, throw exception
|
||||
//4, If no, edit
|
||||
List<DomainRouterVO> allDomainRoutersAvailable = _domrDao.listAll();
|
||||
|
||||
for(DomainRouterVO domR : allDomainRoutersAvailable)
|
||||
{
|
||||
if(domR.getDataCenterId() == zoneId)
|
||||
{
|
||||
throw new InternalErrorException("The zone is not editable because there are domR's associated with the zone.");
|
||||
}
|
||||
}
|
||||
|
||||
//5. Reached here, hence editable
|
||||
|
||||
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||
String oldZoneName = zone.getName();
|
||||
@ -703,6 +688,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
newZoneName = oldZoneName;
|
||||
}
|
||||
|
||||
boolean dnsUpdate = false;
|
||||
|
||||
if(dns1 != null || dns2 != null){
|
||||
dnsUpdate = true;
|
||||
}
|
||||
|
||||
if (dns1 == null) {
|
||||
dns1 = zone.getDns1();
|
||||
}
|
||||
@ -742,6 +733,48 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
_zoneDao.addVnet(zone.getId(), begin, end);
|
||||
}
|
||||
|
||||
if(dnsUpdate){
|
||||
|
||||
//Update dns for domRs in zone
|
||||
|
||||
List<DomainRouterVO> DomainRouters = _domrDao.listByDataCenter(zoneId);
|
||||
|
||||
for(DomainRouterVO domR : DomainRouters)
|
||||
{
|
||||
domR.setDns1(dns1);
|
||||
domR.setDns2(dns2);
|
||||
_domrDao.update(domR.getId(), domR);
|
||||
}
|
||||
|
||||
//Update dns for console proxies in zone
|
||||
List<VMInstanceVO> ConsoleProxies = _vmInstanceDao.listByZoneIdAndType(zoneId, VirtualMachine.Type.ConsoleProxy);
|
||||
|
||||
for(VMInstanceVO consoleVm : ConsoleProxies)
|
||||
{
|
||||
ConsoleProxyVO proxy = _consoleDao.findById(consoleVm.getId());
|
||||
if( proxy!= null ){
|
||||
proxy.setDns1(dns1);
|
||||
proxy.setDns2(dns2);
|
||||
_consoleDao.update(proxy.getId(), proxy);
|
||||
}
|
||||
}
|
||||
|
||||
//Update dns for secondary storage Vms in zone
|
||||
List<VMInstanceVO> storageVms = _vmInstanceDao.listByZoneIdAndType(zoneId, VirtualMachine.Type.SecondaryStorageVm);
|
||||
|
||||
for(VMInstanceVO storageVm : storageVms)
|
||||
{
|
||||
SecondaryStorageVmVO secStorageVm = _secStorageDao.findById(storageVm.getId());
|
||||
if( secStorageVm!= null ){
|
||||
secStorageVm.setDns1(dns1);
|
||||
secStorageVm.setDns2(dns2);
|
||||
_secStorageDao.update(secStorageVm.getId(), secStorageVm);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_EDIT, "Successfully edited zone with name: " + zone.getName() + ".", "dcId=" + zone.getId(), "dns1=" + dns1, "dns2=" + dns2, "internalDns1=" + internalDns1, "internalDns2=" + internalDns2, "vnetRange=" + vnetRange, "guestCidr=" + guestCidr);
|
||||
|
||||
return zone;
|
||||
@ -881,6 +914,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
}
|
||||
|
||||
if (_diskOfferingDao.update(diskOfferingId, diskOffering)) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_DISK_OFFERING_EDIT, "Successfully updated disk offering with name: " + diskOffering.getName() + ".", "doId=" + diskOffering.getId(), "name=" + diskOffering.getName(),
|
||||
"displayText=" + diskOffering.getDisplayText(), "diskSize=" + diskOffering.getDiskSize(),"tags=" + diskOffering.getTags());
|
||||
return _diskOfferingDao.findById(diskOfferingId);
|
||||
} else {
|
||||
return null;
|
||||
@ -891,7 +926,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
ServiceOfferingVO offering = _serviceOfferingDao.findById(serviceOfferingId);
|
||||
|
||||
if (_serviceOfferingDao.remove(serviceOfferingId)) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_EDIT, "Successfully deleted service offering with name: " + offering.getName(), "soId=" + serviceOfferingId, "name=" + offering.getName(),
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_DELETE, "Successfully deleted service offering with name: " + offering.getName(), "soId=" + serviceOfferingId, "name=" + offering.getName(),
|
||||
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtualized));
|
||||
return true;
|
||||
} else {
|
||||
@ -899,11 +934,32 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
}
|
||||
}
|
||||
|
||||
public DiskOfferingVO createDiskOffering(long domainId, String name, String description, int numGibibytes, String tags) {
|
||||
public DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags) {
|
||||
long diskSize = numGibibytes * 1024;
|
||||
tags = cleanupTags(tags);
|
||||
DiskOfferingVO newDiskOffering = new DiskOfferingVO(domainId, name, description, diskSize,tags);
|
||||
return _diskOfferingDao.persist(newDiskOffering);
|
||||
|
||||
if ((newDiskOffering = _diskOfferingDao.persist(newDiskOffering)) != null) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_DISK_OFFERING_CREATE, "Successfully created new disk offering with name: "
|
||||
+ name + ".", "doId=" + newDiskOffering.getId(), "name=" + name, "diskSize=" + diskSize, "description="
|
||||
+ description, "tags=" + tags);
|
||||
return newDiskOffering;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean deleteDiskOffering(long userId, long diskOfferingId) {
|
||||
DiskOfferingVO offering = _diskOfferingDao.findById(diskOfferingId);
|
||||
|
||||
if (_diskOfferingDao.remove(diskOfferingId)) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_DISK_OFFERING_DELETE, "Successfully deleted disk offering with name: "
|
||||
+ offering.getName(), "doId=" + offering.getId(), "name=" + offering.getName(), "diskSize=" + offering.getDiskSize(),
|
||||
"description=" + offering.getDisplayText(), "tags=" + offering.getTags());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String changePrivateIPRange(boolean add, long podId, String startIP, String endIP) throws InvalidParameterValueException {
|
||||
|
||||
@ -2357,7 +2357,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
||||
_publicNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_publicNetworkOffering);
|
||||
_managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmManagementNetwork, TrafficType.Management, null);
|
||||
_managementNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_managementNetworkOffering);
|
||||
_linkLocalNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmLinkLocalNetwork, TrafficType.LinkLocal, null);
|
||||
_linkLocalNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmLinkLocalNetwork, TrafficType.Control, null);
|
||||
_linkLocalNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_linkLocalNetworkOffering);
|
||||
|
||||
_capacityScanScheduler.scheduleAtFixedRate(getCapacityScanTask(), STARTUP_DELAY, _capacityScanInterval, TimeUnit.MILLISECONDS);
|
||||
|
||||
@ -52,16 +52,16 @@ import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.xen.resource.CitrixResourceBase;
|
||||
import com.cloud.hypervisor.xen.resource.XcpServerResource;
|
||||
import com.cloud.hypervisor.xen.resource.XenServerConnectionPool;
|
||||
import com.cloud.hypervisor.xen.resource.XenServerResource;
|
||||
import com.cloud.hypervisor.xen.resource.XenServerConnectionPool;
|
||||
import com.cloud.resource.Discoverer;
|
||||
import com.cloud.resource.DiscovererBase;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.storage.Storage.FileSystem;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Storage.FileSystem;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
import com.cloud.storage.template.TemplateInfo;
|
||||
@ -386,7 +386,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.0"))
|
||||
return new XenServerResource();
|
||||
|
||||
String msg = "Only support XCP 0.1.1 and Xerver 5.6.0, but this one is " + prodBrand + " " + prodVersion;
|
||||
String msg = "Only support XCP 0.1.1 and XenServer 5.6.0, but this one is " + prodBrand + " " + prodVersion;
|
||||
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, msg, msg);
|
||||
s_logger.debug(msg);
|
||||
throw new RuntimeException(msg);
|
||||
|
||||
@ -102,6 +102,7 @@ import com.cloud.network.Network.TrafficType;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkProfileDao;
|
||||
import com.cloud.network.dao.SecurityGroupVMMapDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
@ -193,6 +194,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
||||
@Inject ServiceOfferingDao _serviceOfferingDao = null;
|
||||
@Inject UserStatisticsDao _statsDao = null;
|
||||
@Inject NetworkOfferingDao _networkOfferingDao = null;
|
||||
@Inject NetworkProfileDao _networkProfileDao = null;
|
||||
|
||||
Adapters<NetworkProfiler> _networkProfilers;
|
||||
|
||||
@ -1835,7 +1837,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
||||
_publicNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_publicNetworkOffering);
|
||||
_managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmManagementNetwork, TrafficType.Management, null);
|
||||
_managementNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_managementNetworkOffering);
|
||||
_linkLocalNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmLinkLocalNetwork, TrafficType.LinkLocal, null);
|
||||
_linkLocalNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmLinkLocalNetwork, TrafficType.Control, null);
|
||||
_linkLocalNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_linkLocalNetworkOffering);
|
||||
_guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmGuestNetwork, TrafficType.Guest, GuestIpType.Virtualized);
|
||||
_guestNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_guestNetworkOffering);
|
||||
@ -1848,6 +1850,29 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setupNetworkProfiles(List<NetworkOfferingVO> offerings, AccountVO account) {
|
||||
List<? extends NetworkProfile> profiles = null;
|
||||
for (NetworkProfiler profiler : _networkProfilers) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Sending network profiles to " + profiler.getName());
|
||||
}
|
||||
profiles = profiler.convert(offerings, account);
|
||||
if (profiles != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (profiles == null) {
|
||||
s_logger.debug("Unable to resolve the network profiles");
|
||||
throw new CloudRuntimeException("Uanble to convert network offerings to network profiles for that account");
|
||||
}
|
||||
|
||||
for (NetworkProfile profile : profiles) {
|
||||
NetworkProfileVO vo = new NetworkProfileVO(profile, account.getId());
|
||||
vo = _networkProfileDao.persist(vo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@ -1861,10 +1886,13 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
||||
offerings.add(_guestNetworkOffering);
|
||||
offerings.add(_linkLocalNetworkOffering);
|
||||
offerings.add(_managementNetworkOffering);
|
||||
|
||||
for (NetworkProfiler profiler : _networkProfilers) {
|
||||
List<? extends NetworkProfile> profiles = profiler.convert(offerings, _accountMgr.getSystemAccount());
|
||||
}
|
||||
|
||||
// try {
|
||||
// setupNetworkProfiles(offerings, _accountMgr.getSystemAccount());
|
||||
//} catch (Exception e) {
|
||||
// s_logger.warn("Unable to setup the system network profiles");
|
||||
//return false;
|
||||
//}
|
||||
_executor.scheduleAtFixedRate(new RouterCleanupTask(), _routerCleanupInterval, _routerCleanupInterval, TimeUnit.SECONDS);
|
||||
_executor.scheduleAtFixedRate(new NetworkUsageTask(), _routerStatsInterval, _routerStatsInterval, TimeUnit.SECONDS);
|
||||
return true;
|
||||
|
||||
@ -57,8 +57,8 @@ public class NetworkProfileVO implements OwnedBy {
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
TrafficType trafficType;
|
||||
|
||||
@Column(name="vlanIds")
|
||||
String vlanIds;
|
||||
@Column(name="vlan_id")
|
||||
Long vlanId;
|
||||
|
||||
@Column(name="gateway")
|
||||
String gateway;
|
||||
@ -69,6 +69,10 @@ public class NetworkProfileVO implements OwnedBy {
|
||||
public NetworkProfileVO() {
|
||||
}
|
||||
|
||||
public NetworkProfileVO(NetworkProfile that, long accountId) {
|
||||
this(accountId, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType());
|
||||
}
|
||||
|
||||
public NetworkProfileVO(long accountId, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType) {
|
||||
this.accountId = accountId;
|
||||
this.trafficType = trafficType;
|
||||
@ -129,4 +133,11 @@ public class NetworkProfileVO implements OwnedBy {
|
||||
this.cidr = cidr;
|
||||
}
|
||||
|
||||
public Long getVlanId() {
|
||||
return vlanId;
|
||||
}
|
||||
|
||||
public void setVlanId(Long vlanId) {
|
||||
this.vlanId = vlanId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ public class NetworkProfilerImpl extends AdapterBase implements NetworkProfiler
|
||||
|
||||
@Override
|
||||
public List<? extends NetworkProfile> convert(Collection<? extends NetworkOffering> networkOfferings, Account owner) {
|
||||
List<NetworkProfileVO> profiles = _profileDao.listBy(owner.getId());
|
||||
for (NetworkOffering offering : networkOfferings) {
|
||||
}
|
||||
return null;
|
||||
|
||||
@ -17,9 +17,11 @@
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.NetworkProfileVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface NetworkProfileDao extends GenericDao<NetworkProfileVO, Long> {
|
||||
|
||||
List<NetworkProfileVO> listBy(long accountId);
|
||||
}
|
||||
|
||||
@ -17,8 +17,11 @@
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.network.Network.BroadcastDomainType;
|
||||
import com.cloud.network.Network.Mode;
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
import com.cloud.network.NetworkProfileVO;
|
||||
@ -29,6 +32,7 @@ import com.cloud.utils.db.SearchCriteria;
|
||||
@Local(value=NetworkProfileDao.class)
|
||||
public class NetworkProfileDaoImpl extends GenericDaoBase<NetworkProfileVO, Long> implements NetworkProfileDao {
|
||||
final SearchBuilder<NetworkProfileVO> ProfileSearch;
|
||||
final SearchBuilder<NetworkProfileVO> AccountSearch;
|
||||
|
||||
protected NetworkProfileDaoImpl() {
|
||||
super();
|
||||
@ -38,10 +42,28 @@ public class NetworkProfileDaoImpl extends GenericDaoBase<NetworkProfileVO, Long
|
||||
ProfileSearch.and("trafficType", ProfileSearch.entity().getTrafficType(), SearchCriteria.Op.EQ);
|
||||
ProfileSearch.and("cidr", ProfileSearch.entity().getCidr(), SearchCriteria.Op.EQ);
|
||||
ProfileSearch.and("broadcastType", ProfileSearch.entity().getBroadcastDomainType(), SearchCriteria.Op.EQ);
|
||||
ProfileSearch.done();
|
||||
|
||||
AccountSearch = createSearchBuilder();
|
||||
AccountSearch.and("account", AccountSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
AccountSearch.done();
|
||||
}
|
||||
|
||||
public NetworkProfileVO findBy(TrafficType trafficType, Mode mode, long accountId) {
|
||||
public NetworkProfileVO findBy(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastType, long accountId) {
|
||||
SearchCriteria<NetworkProfileVO> sc = ProfileSearch.create();
|
||||
sc.setParameters("account", accountId);
|
||||
sc.setParameters("trafficType", trafficType);
|
||||
sc.setParameters("broadcastType", broadcastType);
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkProfileVO> listBy(long accountId) {
|
||||
SearchCriteria<NetworkProfileVO> sc = AccountSearch.create();
|
||||
sc.setParameters("account", accountId);
|
||||
|
||||
return listActiveBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,10 +142,10 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
_configMgr.createServiceOffering(User.UID_SYSTEM, "Small Instance, Virtual Networking", 1, 512, 500, "Small Instance, Virtual Networking, $0.05 per hour", false, false, true, null);
|
||||
_configMgr.createServiceOffering(User.UID_SYSTEM, "Medium Instance, Virtual Networking", 1, 1024, 1000, "Medium Instance, Virtual Networking, $0.10 per hour", false, false, true, null);
|
||||
// Save default disk offerings
|
||||
_configMgr.createDiskOffering(DomainVO.ROOT_DOMAIN, "Small", "Small Disk, 5 GB", 5, null);
|
||||
_configMgr.createDiskOffering(DomainVO.ROOT_DOMAIN, "Medium", "Medium Disk, 20 GB", 20, null);
|
||||
_configMgr.createDiskOffering(DomainVO.ROOT_DOMAIN, "Large", "Large Disk, 100 GB", 100, null);
|
||||
_configMgr.createDiskOffering(DomainVO.ROOT_DOMAIN, "Private", "Private Disk", 0, null);
|
||||
_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Small", "Small Disk, 5 GB", 5, null);
|
||||
_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Medium", "Medium Disk, 20 GB", 20, null);
|
||||
_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Large", "Large Disk, 100 GB", 100, null);
|
||||
_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Private", "Private Disk", 0, null);
|
||||
|
||||
//Add default manual snapshot policy
|
||||
SnapshotPolicyVO snapPolicy = new SnapshotPolicyVO(0L, "00", "GMT", (short)4, 0);
|
||||
|
||||
@ -4402,6 +4402,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
SearchBuilder<AccountVO> sb = _accountDao.createSearchBuilder();
|
||||
sb.and("accountName", sb.entity().getAccountName(), SearchCriteria.Op.LIKE);
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
sb.and("nid", sb.entity().getId(), SearchCriteria.Op.NEQ);
|
||||
sb.and("type", sb.entity().getType(), SearchCriteria.Op.EQ);
|
||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
||||
sb.and("needsCleanup", sb.entity().getNeedsCleanup(), SearchCriteria.Op.EQ);
|
||||
@ -4433,6 +4434,9 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
// I want to join on user_vm.domain_id = domain.id where domain.path like 'foo%'
|
||||
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
|
||||
sc.setParameters("nid", 1L);
|
||||
} else {
|
||||
sc.setParameters("nid", 1L);
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
@ -6832,14 +6836,14 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiskOfferingVO createDiskOffering(long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException {
|
||||
public DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException {
|
||||
if (numGibibytes!=0 && numGibibytes < 1) {
|
||||
throw new InvalidParameterValueException("Please specify a disk size of at least 1 Gb.");
|
||||
} else if (numGibibytes > _maxVolumeSizeInGb) {
|
||||
throw new InvalidParameterValueException("The maximum size for a disk is " + _maxVolumeSizeInGb + " Gb.");
|
||||
}
|
||||
|
||||
return _configMgr.createDiskOffering(domainId, name, description, numGibibytes, tags);
|
||||
return _configMgr.createDiskOffering(userId, domainId, name, description, numGibibytes, tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -6848,8 +6852,8 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDiskOffering(long id) {
|
||||
return _diskOfferingDao.remove(Long.valueOf(id));
|
||||
public boolean deleteDiskOffering(long userId, long id) {
|
||||
return _configMgr.deleteDiskOffering(userId, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -8590,6 +8594,26 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> listCapabilities() {
|
||||
Map<String, String> capabilities = new HashMap<String, String>();
|
||||
|
||||
String networkGroupsEnabled = _configs.get("direct.attach.network.groups.enabled");
|
||||
if(networkGroupsEnabled == null)
|
||||
networkGroupsEnabled = "false";
|
||||
|
||||
capabilities.put("networkGroupsEnabled", networkGroupsEnabled);
|
||||
|
||||
final Class<?> c = this.getClass();
|
||||
String fullVersion = c.getPackage().getImplementationVersion();
|
||||
String version = "unknown";
|
||||
if(fullVersion.length() > 0){
|
||||
version = fullVersion.substring(0,fullVersion.lastIndexOf("."));
|
||||
}
|
||||
capabilities.put("cloudStackVersion", version);
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -281,7 +281,8 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
private void sendResponse(HttpServletResponse resp, String content) {
|
||||
try {
|
||||
try {
|
||||
resp.setContentType("text/html");
|
||||
resp.getWriter().print(content);
|
||||
} catch(IOException e) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
|
||||
@ -939,10 +939,12 @@ public class StorageManagerImpl implements StorageManager {
|
||||
if (vmId != null) {
|
||||
VMInstanceVO vmInstance = _vmInstanceDao.findById(vmId);
|
||||
if (vmInstance != null) {
|
||||
return vmInstance.getHostId();
|
||||
Long hostId = vmInstance.getHostId();
|
||||
if (hostId != null && !avoidHosts.contains(vmInstance.getHostId()))
|
||||
return hostId;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
/*Can't find the vm where host resides on(vm is destroyed? or volume is detached from vm), randomly choose a host to send the cmd */
|
||||
}
|
||||
List<StoragePoolHostVO> poolHosts = _poolHostDao.listByHostStatus(poolVO.getId(), Status.Up);
|
||||
Collections.shuffle(poolHosts);
|
||||
@ -1062,6 +1064,8 @@ public class StorageManagerImpl implements StorageManager {
|
||||
String hypervisoType = configDao.getValue("hypervisor.type");
|
||||
if (hypervisoType.equalsIgnoreCase("KVM")) {
|
||||
_hypervisorType = Hypervisor.Type.KVM;
|
||||
} else if(hypervisoType.equalsIgnoreCase("vmware")) {
|
||||
_hypervisorType = Hypervisor.Type.VmWare;
|
||||
}
|
||||
_agentMgr.registerForHostEvents(new StoragePoolMonitor(this, _hostDao, _storagePoolDao), true, false, true);
|
||||
|
||||
@ -1256,6 +1260,8 @@ public class StorageManagerImpl implements StorageManager {
|
||||
if (hypervisorType == null) {
|
||||
if (_hypervisorType == Hypervisor.Type.KVM) {
|
||||
hypervisorType = Hypervisor.Type.KVM;
|
||||
} else if(_hypervisorType == Hypervisor.Type.VmWare) {
|
||||
hypervisorType = Hypervisor.Type.VmWare;
|
||||
} else {
|
||||
s_logger.debug("Couldn't find a host to serve in the server pool");
|
||||
return null;
|
||||
|
||||
@ -70,7 +70,8 @@ public class StoragePoolMonitor implements Listener {
|
||||
public boolean processConnect(HostVO host, StartupCommand cmd) {
|
||||
if (cmd instanceof StartupRoutingCommand) {
|
||||
StartupRoutingCommand scCmd = (StartupRoutingCommand)cmd;
|
||||
if (scCmd.getHypervisorType() == Hypervisor.Type.XenServer || scCmd.getHypervisorType() == Hypervisor.Type.KVM) {
|
||||
if (scCmd.getHypervisorType() == Hypervisor.Type.XenServer || scCmd.getHypervisorType() == Hypervisor.Type.KVM ||
|
||||
scCmd.getHypervisorType() == Hypervisor.Type.VmWare) {
|
||||
List<StoragePoolVO> pools = _poolDao.listBy(host.getDataCenterId(), host.getPodId(), host.getClusterId());
|
||||
for (StoragePoolVO pool : pools) {
|
||||
Long hostId = host.getId();
|
||||
|
||||
@ -287,7 +287,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
|
||||
}
|
||||
txn.commit();
|
||||
|
||||
VolumeVO volume = _volsDao.findById(volumeId);
|
||||
VolumeVO volume = _volsDao.lock(volumeId, true);
|
||||
|
||||
if (!shouldRunSnapshot(userId, volume, policyIds)) {
|
||||
// A null snapshot is interpreted as snapshot creation failed which is what we want to indicate
|
||||
@ -477,7 +477,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
|
||||
_snapshotDao.update(snapshot.getId(), snapshot);
|
||||
|
||||
long volumeId = snapshot.getVolumeId();
|
||||
VolumeVO volume = _volsDao.findById(volumeId);
|
||||
VolumeVO volume = _volsDao.lock(volumeId, true);
|
||||
|
||||
String primaryStoragePoolNameLabel = _storageMgr.getPrimaryStorageNameLabel(volume);
|
||||
Long dcId = volume.getDataCenterId();
|
||||
|
||||
@ -223,7 +223,13 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
return templateStoragePoolRef;
|
||||
}
|
||||
String url = origUrl + "/" + templateHostRef.getInstallPath();
|
||||
PrimaryStorageDownloadCommand dcmd = new PrimaryStorageDownloadCommand(template.getUniqueName(), url, template.getFormat(), template.getAccountId(), pool.getId(), pool.getUuid());
|
||||
PrimaryStorageDownloadCommand dcmd = new PrimaryStorageDownloadCommand(template.getUniqueName(), url, template.getFormat(),
|
||||
template.getAccountId(), pool.getId(), pool.getUuid());
|
||||
HostVO secondaryStorageHost = _hostDao.findSecondaryStorageHost(pool.getDataCenterId());
|
||||
assert(secondaryStorageHost != null);
|
||||
dcmd.setSecondaryStorageUrl(secondaryStorageHost.getStorageUrl());
|
||||
// TODO temporary hacking, hard-coded to NFS primary data store
|
||||
dcmd.setPrimaryStorageUrl("nfs://" + pool.getHostAddress() + pool.getPath());
|
||||
|
||||
for (StoragePoolHostVO vo : vos) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
||||
@ -686,6 +686,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
}
|
||||
|
||||
boolean started = false;
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
|
||||
@ -736,6 +737,11 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
VolumeVO vol = rootVols.get(0);
|
||||
|
||||
List<VolumeVO> vols = _volsDao.findCreatedByInstance(vm.getId());
|
||||
List<VolumeVO> vos = new ArrayList<VolumeVO>();
|
||||
/*compete with take snapshot*/
|
||||
for (VolumeVO userVmVol : vols) {
|
||||
vos.add(_volsDao.lock(userVmVol.getId(), true));
|
||||
}
|
||||
|
||||
Answer answer = null;
|
||||
int retry = _retry;
|
||||
@ -2215,7 +2221,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
@Override @DB
|
||||
public SnapshotVO createTemplateSnapshot(long userId, long volumeId) {
|
||||
SnapshotVO createdSnapshot = null;
|
||||
VolumeVO volume = _volsDao.findById(volumeId);
|
||||
VolumeVO volume = _volsDao.lock(volumeId, true);
|
||||
|
||||
Long id = null;
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ except ImportError:
|
||||
#---------------------- option parsing and command line checks ------------------------
|
||||
|
||||
|
||||
usage = """%prog user:password@mysqlhost:port <kvm|xenserver> [--deploy-as=rootuser:rootpassword] [--auto=/path/to/server-setup.xml]
|
||||
usage = """%prog user:password@mysqlhost:port <kvm|xenserver|vmware> [--deploy-as=rootuser:rootpassword] [--auto=/path/to/server-setup.xml]
|
||||
|
||||
This command sets up the CloudStack Management Server and CloudStack Usage Server database configuration (connection credentials and host information) based on the first argument.
|
||||
|
||||
@ -224,7 +224,7 @@ def setupconfigfile(fn,myipaddr,username,password,host,port):
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if len(args) != 2: e("Wrong number of arguments")
|
||||
if args[1] not in ["xenserver","kvm"]: e("You need to specify either xenserver or kvm after the database credentials")
|
||||
if args[1] not in ["xenserver","kvm","vmware"]: e("You need to specify either xenserver or kvm or vmware after the database credentials")
|
||||
virttech = args[1]
|
||||
|
||||
user,password,host,port= get_creds(parser,options,args)
|
||||
|
||||
@ -63,7 +63,6 @@ ALTER TABLE `cloud`.`storage_pool_details` ADD INDEX `i_storage_pool_details__na
|
||||
|
||||
ALTER TABLE `cloud`.`user` ADD INDEX `i_user__secret_key_removed`(`secret_key`, `removed`);
|
||||
ALTER TABLE `cloud`.`user` ADD INDEX `i_user__removed`(`removed`);
|
||||
ALTER TABLE `cloud`.`user` ADD UNIQUE `i_user__username__removed`(`username`, `removed`);
|
||||
ALTER TABLE `cloud`.`user` ADD UNIQUE `i_user__api_key`(`api_key`);
|
||||
ALTER TABLE `cloud`.`user` ADD CONSTRAINT `fk_user__account_id` FOREIGN KEY `fk_user__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `cloud`.`user` ADD INDEX `i_user__account_id`(`account_id`);
|
||||
|
||||
@ -95,6 +95,7 @@ CREATE TABLE `cloud`.`network_profiles` (
|
||||
`gateway` varchar(15) NOT NULL COMMENT 'gateway for this network profile',
|
||||
`cidr` varchar(32) NOT NULL COMMENT 'network cidr',
|
||||
`mode` varchar(32) NOT NULL COMMENT 'How to retrieve ip address in this network',
|
||||
`vlan_id` bigint unsigned NULL COMMENT 'vlan id if the broadcast_domain_type is the vlan',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
2
setup/db/index-212to213.sql
Normal file
2
setup/db/index-212to213.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE `cloud`.`user` DROP KEY `i_user__username__removed`;
|
||||
|
||||
83
setup/db/templates.vmware.sql
Normal file
83
setup/db/templates.vmware.sql
Normal file
@ -0,0 +1,83 @@
|
||||
INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones)
|
||||
VALUES (1, 'routing', 'SystemVM Template', 0, now(), 'ext3', 0, 64, 1, 'http://nfs1.lab.vmops.com/templates/vmware/dummydomr.tar.bz2', '54c578d2c02759de4a9a8be7bd533df1', 0, 'SystemVM Template', 'VMDK', 47, 0, 1);
|
||||
|
||||
INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones)
|
||||
VALUES (2, 'fedora11-x86', 'Fedora11-x86', 1, now(), 'ext3', 0, 32, 1, 'http://nfs1.lab.vmops.com/templates/vmware/fedora11-x86.tar.bz2', '7957ff05cae838689eb53c7600b2fbe4', 0, 'Fedora 11 x86', 'VMDK', 47, 1, 1);
|
||||
|
||||
INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (1, 'Windows');
|
||||
INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (2, 'Linux');
|
||||
INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (3, 'Novell Netware');
|
||||
INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (4, 'Solaris');
|
||||
INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (5, 'Other');
|
||||
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (1, 1, 'Microsoft Windows 7(32-bit)', 'Microsoft Windows 7(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (2, 1, 'Microsoft Windows 7(64-bit)', 'Microsoft Windows 7(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (3, 1, 'Microsoft Windows Server 2008 R2(64-bit)', 'Microsoft Windows Server 2008 R2(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (4, 1, 'Microsoft Windows Server 2008(32-bit)', 'Microsoft Windows Server 2008(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (5, 1, 'Microsoft Windows Server 2008(64-bit)', 'Windows Windows Server 2008(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (6, 1, 'Microsoft Windows Server 2003, Enterprise Edition (32-bit)', 'Microsoft Windows Server 2003, Enterprise Edition (32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (7, 1, 'Microsoft Windows Server 2003, Enterprise Edition (64-bit)', 'Microsoft Windows Server 2003, Enterprise Edition (64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (8, 1, 'Microsoft Windows Server 2003, Datacenter Edition (32-bit)', 'Microsoft Windows Server 2003, Datacenter Edition (32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (9, 1, 'Microsoft Windows Server 2003, Datacenter Edition (64-bit)', 'Microsoft Windows Server 2003, Datacenter Edition (64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (10, 1, 'Microsoft Windows Server 2003, Standard Edition (32-bit)', 'Microsoft Windows Server 2003, Standard Edition (32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (11, 1, 'Microsoft Windows Server 2003, Standard Edition (64-bit)', 'Microsoft Windows Server 2003, Standard Edition (64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (12, 1, 'Microsoft Windows Server 2003, Web Edition', 'Microsoft Windows Server 2003, Web Edition');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (13, 1, 'Microsoft Small Bussiness Server 2003', 'Microsoft Small Bussiness Server 2003');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (14, 1, 'Microsoft Windows Vista (32-bit)', 'Microsoft Windows Vista (32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (15, 1, 'Microsoft Windows Vista (64-bit)', 'Microsoft Windows Vista (64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (16, 1, 'Microsoft Windows XP Professional (32-bit)', 'Microsoft Windows XP Professional (32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (17, 1, 'Microsoft Windows XP Professional (64-bit)', 'Microsoft Windows XP Professional (64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (18, 1, 'Microsoft Windows 2000 Advanced Server', 'Microsoft Windows 2000 Advanced Server');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (19, 1, 'Microsoft Windows 2000 Server', 'Microsoft Windows 2000 Server');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (20, 1, 'Microsoft Windows 2000 Professional', 'Microsoft Windows 2000 Professional');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (21, 1, 'Microsoft Windows 98', 'Microsoft Windows 98');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (22, 1, 'Microsoft Windows 95', 'Microsoft Windows 95');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (23, 1, 'Microsoft Windows NT 4', 'Microsoft Windows NT 4');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (24, 1, 'Microsoft Windows 3.1', 'Microsoft Windows 3.1');
|
||||
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (25, 2, 'Red Hat Enterprise Linux 5(32-bit)', 'Red Hat Enterprise Linux 5(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (26, 2, 'Red Hat Enterprise Linux 5(64-bit)', 'Red Hat Enterprise Linux 5(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (27, 2, 'Red Hat Enterprise Linux 4(32-bit)', 'Red Hat Enterprise Linux 4(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (28, 2, 'Red Hat Enterprise Linux 4(64-bit)', 'Red Hat Enterprise Linux 4(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (29, 2, 'Red Hat Enterprise Linux 3(32-bit)', 'Red Hat Enterprise Linux 3(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (30, 2, 'Red Hat Enterprise Linux 3(64-bit)', 'Red Hat Enterprise Linux 3(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (31, 2, 'Red Hat Enterprise Linux 2', 'Red Hat Enterprise Linux 2');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (32, 2, 'Suse Linux Enterprise 11(32-bit)', 'Suse Linux Enterprise 11(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (33, 2, 'Suse Linux Enterprise 11(64-bit)', 'Suse Linux Enterprise 11(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (34, 2, 'Suse Linux Enterprise 10(32-bit)', 'Suse Linux Enterprise 10(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (35, 2, 'Suse Linux Enterprise 10(64-bit)', 'Suse Linux Enterprise 10(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (36, 2, 'Suse Linux Enterprise 8/9(32-bit)', 'Suse Linux Enterprise 8/9(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (37, 2, 'Suse Linux Enterprise 8/9(64-bit)', 'Suse Linux Enterprise 8/9(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (38, 2, 'Open Enterprise Server', 'Open Enterprise Server');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (39, 2, 'Asianux 3(32-bit)', 'Asianux 3(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (40, 2, 'Asianux 3(64-bit)', 'Asianux 3(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (41, 2, 'Debian GNU/Linux 5(32-bit)', 'Debian GNU/Linux 5(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (42, 2, 'Debian GNU/Linux 5(64-bit)', 'Debian GNU/Linux 5(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (43, 2, 'Debian GNU/Linux 4(32-bit)', 'Debian GNU/Linux 4(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (44, 2, 'Debian GNU/Linux 4(64-bit)', 'Debian GNU/Linux 4(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (45, 2, 'Ubuntu Linux (32-bit)', 'Ubuntu Linux (32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (46, 2, 'Ubuntu Linux (64-bit)', 'Ubuntu Linux (64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (47, 2, 'Other 2.6x Linux (32-bit)', 'Other 2.6x Linux (32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (48, 2, 'Other 2.6x Linux (64-bit)', 'Other 2.6x Linux (64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (49, 2, 'Other Linux (32-bit)', 'Other Linux (32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (50, 2, 'Other Linux (64-bit)', 'Other Linux (64-bit)');
|
||||
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (51, 3, 'Novell Netware 6.x', 'Novell Netware 6.x');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (52, 3, 'Novell Netware 5.1', 'Novell Netware 5.1');
|
||||
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (53, 4, 'Sun Solaris 10(32-bit)', 'Sun Solaris 10(32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (54, 4, 'Sun Solaris 10(64-bit)', 'Sun Solaris 10(64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (55, 4, 'Sun Solaris 9(Experimental)', 'Sun Solaris 9(Experimental)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (56, 4, 'Sun Solaris 8(Experimental)', 'Sun Solaris 8(Experimental)');
|
||||
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (57, 5, 'FreeBSD (32-bit)', 'FreeBSD (32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (58, 5, 'FreeBSD (64-bit)', 'FreeBSD (64-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (59, 5, 'OS/2', 'OS/2');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (60, 5, 'SCO OpenServer 5', 'SCO OpenServer 5');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (61, 5, 'SCO UnixWare 7', 'SCO UnixWare 7');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (62, 5, 'DOS', 'DOS');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (63, 5, 'Other (32-bit)', 'Other (32-bit)');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (64, 5, 'Other (64-bit)', 'Other (64-bit)');
|
||||
|
||||
-- temporarily added for vmware, will be moved when vmware support is fully in-place
|
||||
INSERT INTO `cloud`.`host_master`(`type`, `service_address`, `admin`, `password`) VALUES('VSphere', 'vsphere-1.lab.vmops.com', 'Administrator', 'Suite219');
|
||||
@ -72,6 +72,4 @@ INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (58,
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (59, 7, 'Other install media', 'Ubuntu');
|
||||
INSERT INTO `cloud`.`guest_os` (id, category_id, name, display_name) VALUES (60, 7, 'Other install media', 'Other');
|
||||
|
||||
-- temporarily added for vmware, will be moved when vmware support is fully in-place
|
||||
INSERT INTO `cloud`.`host_master`(`type`, `service_address`, `admin`, `password`) VALUES('VSphere', 'vsphere-1.lab.vmops.com', 'Administrator', 'Suite219');
|
||||
|
||||
|
||||
17
ui/index.html → ui/index.jsp
Normal file → Executable file
17
ui/index.html → ui/index.jsp
Normal file → Executable file
@ -1,3 +1,9 @@
|
||||
<%@ page import="java.util.Date" %>
|
||||
|
||||
<%
|
||||
long milliseconds = new Date().getTime();
|
||||
%>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
@ -5,11 +11,10 @@
|
||||
<meta http-equiv='cache-control' content='no-cache'>
|
||||
<meta http-equiv='expires' content='0'>
|
||||
<meta http-equiv='pragma' content='no-cache'>
|
||||
<meta name="version" content="@VERSION@" />
|
||||
<meta name="version" content="1.9.1.13" />
|
||||
|
||||
<title>cloud.com - User Console</title>
|
||||
|
||||
|
||||
<!-- Style Sheet -->
|
||||
<link rel= "stylesheet" href="css/main.css" type="text/css" />
|
||||
<link rel= "stylesheet" href="css/jquery-ui-1.8.2.custom.css" type="text/css" />
|
||||
@ -38,12 +43,12 @@
|
||||
<script type="text/javascript" src="scripts/jquery.md5.js"></script>
|
||||
|
||||
<!-- Callback script for Single Signon -->
|
||||
<script type="text/javascript" src="scripts/cloud.core.callbacks.js"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.core.callbacks.js?t=<%=milliseconds%>"></script>
|
||||
|
||||
<!-- cloud.com scripts -->
|
||||
<script type="text/javascript" src="scripts/cloud.logger.js"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.core.js"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.core.init.js"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.logger.js?t=<%=milliseconds%>"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.core.js?t=<%=milliseconds%>"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.core.init.js?t=<%=milliseconds%>"></script>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
|
||||
6
ui/content/tab_accounts.html → ui/jsp/tab_accounts.jsp
Normal file → Executable file
6
ui/content/tab_accounts.html → ui/jsp/tab_accounts.jsp
Normal file → Executable file
@ -1,4 +1,8 @@
|
||||
<script type="text/javascript" src="scripts/cloud.core.accounts.js"></script>
|
||||
<%@ page import="java.util.Date" %>
|
||||
<%
|
||||
long milliseconds = new Date().getTime();
|
||||
%>
|
||||
<script type="text/javascript" src="scripts/cloud.core.accounts.js?t=<%=milliseconds%>"></script>
|
||||
|
||||
<!-- Accounts -->
|
||||
<div class="maincontent" style="display:block;" id="submenu_content_account">
|
||||
6
ui/content/tab_configuration.html → ui/jsp/tab_configuration.jsp
Normal file → Executable file
6
ui/content/tab_configuration.html → ui/jsp/tab_configuration.jsp
Normal file → Executable file
@ -1,4 +1,8 @@
|
||||
<script type="text/javascript" src="scripts/cloud.core.configuration.js"></script>
|
||||
<%@ page import="java.util.Date" %>
|
||||
<%
|
||||
long milliseconds = new Date().getTime();
|
||||
%>
|
||||
<script type="text/javascript" src="scripts/cloud.core.configuration.js?t=<%=milliseconds%>"></script>
|
||||
|
||||
<!-- Content Panel -->
|
||||
<!-- Submenu -->
|
||||
0
ui/content/tab_dashboard.html → ui/jsp/tab_dashboard.jsp
Normal file → Executable file
0
ui/content/tab_dashboard.html → ui/jsp/tab_dashboard.jsp
Normal file → Executable file
7
ui/jsp/tab_domains.jsp
Normal file → Executable file
7
ui/jsp/tab_domains.jsp
Normal file → Executable file
@ -1,5 +1,8 @@
|
||||
|
||||
<script type="text/javascript" src="scripts/cloud.core.domains.js"></script>
|
||||
<%@ page import="java.util.Date" %>
|
||||
<%
|
||||
long milliseconds = new Date().getTime();
|
||||
%>
|
||||
<script type="text/javascript" src="scripts/cloud.core.domains.js?t=<%=milliseconds%>"></script>
|
||||
|
||||
<!-- Content Panel -->
|
||||
<div class="maincontent" style="display:block;" id="submenu_content_domains">
|
||||
|
||||
6
ui/content/tab_events.html → ui/jsp/tab_events.jsp
Normal file → Executable file
6
ui/content/tab_events.html → ui/jsp/tab_events.jsp
Normal file → Executable file
@ -1,4 +1,8 @@
|
||||
<script type="text/javascript" src="scripts/cloud.core.events.js"></script>
|
||||
<%@ page import="java.util.Date" %>
|
||||
<%
|
||||
long milliseconds = new Date().getTime();
|
||||
%>
|
||||
<script type="text/javascript" src="scripts/cloud.core.events.js?t=<%=milliseconds%>"></script>
|
||||
|
||||
<!-- Content Panel -->
|
||||
<!-- Submenus -->
|
||||
6
ui/content/tab_hosts.html → ui/jsp/tab_hosts.jsp
Normal file → Executable file
6
ui/content/tab_hosts.html → ui/jsp/tab_hosts.jsp
Normal file → Executable file
@ -1,4 +1,8 @@
|
||||
<script type="text/javascript" src="scripts/cloud.core.hosts.js"></script>
|
||||
<%@ page import="java.util.Date" %>
|
||||
<%
|
||||
long milliseconds = new Date().getTime();
|
||||
%>
|
||||
<script type="text/javascript" src="scripts/cloud.core.hosts.js?t=<%=milliseconds%>"></script>
|
||||
|
||||
<div class="maincontent" id="submenu_content_routing" style="display:block">
|
||||
<div id="maincontent_title">
|
||||
9
ui/content/tab_instances.html → ui/jsp/tab_instances.jsp
Normal file → Executable file
9
ui/content/tab_instances.html → ui/jsp/tab_instances.jsp
Normal file → Executable file
@ -1,4 +1,8 @@
|
||||
<script type="text/javascript" src="scripts/cloud.core.instances.js"></script>
|
||||
<%@ page import="java.util.Date" %>
|
||||
<%
|
||||
long milliseconds = new Date().getTime();
|
||||
%>
|
||||
<script type="text/javascript" src="scripts/cloud.core.instances.js?t=<%=milliseconds%>"></script>
|
||||
|
||||
<!-- Content Panel -->
|
||||
<!-- Submenu -->
|
||||
@ -704,8 +708,7 @@
|
||||
<h2>
|
||||
<strong>Step 3:</strong> Optional</h2>
|
||||
<p>
|
||||
To create a new instance, please first select a zone you wish to have your virtual
|
||||
instance hosted on.</p>
|
||||
You can choose to name and group your virtual machine for easy identification. You can also choose additional data storage. (These options can be added at any time.) </p>
|
||||
</div>
|
||||
<div class="rev_wizmid_contentbox">
|
||||
<div class="rev_tempsearchpanel">
|
||||
6
ui/content/tab_networking.html → ui/jsp/tab_networking.jsp
Normal file → Executable file
6
ui/content/tab_networking.html → ui/jsp/tab_networking.jsp
Normal file → Executable file
@ -1,4 +1,8 @@
|
||||
<script type="text/javascript" src="scripts/cloud.core.network.js"></script>
|
||||
<%@ page import="java.util.Date" %>
|
||||
<%
|
||||
long milliseconds = new Date().getTime();
|
||||
%>
|
||||
<script type="text/javascript" src="scripts/cloud.core.network.js?t=<%=milliseconds%>"></script>
|
||||
<!-- Content Panel -->
|
||||
<!-- Submenus -->
|
||||
<div class="submenu_links">
|
||||
6
ui/content/tab_storage.html → ui/jsp/tab_storage.jsp
Normal file → Executable file
6
ui/content/tab_storage.html → ui/jsp/tab_storage.jsp
Normal file → Executable file
@ -1,4 +1,8 @@
|
||||
<script type="text/javascript" src="scripts/cloud.core.storage.js"></script>
|
||||
<%@ page import="java.util.Date" %>
|
||||
<%
|
||||
long milliseconds = new Date().getTime();
|
||||
%>
|
||||
<script type="text/javascript" src="scripts/cloud.core.storage.js?t=<%=milliseconds%>"></script>
|
||||
|
||||
<div class="submenu_links">
|
||||
<div class="submenu_links_on" id="submenu_pool">
|
||||
6
ui/content/tab_templates.html → ui/jsp/tab_templates.jsp
Normal file → Executable file
6
ui/content/tab_templates.html → ui/jsp/tab_templates.jsp
Normal file → Executable file
@ -1,4 +1,8 @@
|
||||
<script type="text/javascript" src="scripts/cloud.core.templates.js"></script>
|
||||
<%@ page import="java.util.Date" %>
|
||||
<%
|
||||
long milliseconds = new Date().getTime();
|
||||
%>
|
||||
<script type="text/javascript" src="scripts/cloud.core.templates.js?t=<%=milliseconds%>"></script>
|
||||
|
||||
<div class="submenu_links">
|
||||
<div class="submenu_links_on" id="submenu_template">Template</div>
|
||||
@ -1244,7 +1244,7 @@ function showConfigurationTab() {
|
||||
|
||||
dialogEditService.find("#service_name").text(svcName);
|
||||
dialogEditService.find("#edit_service_name").val(svcName);
|
||||
dialogEditService.find("#edit_service_display").val(template.find("#service_display").text());
|
||||
dialogEditService.find("#edit_service_display").val(template.find("#service_displaytext").text());
|
||||
dialogEditService.find("#edit_service_offerha").val(toBooleanValue(template.find("#service_offerha").text()));
|
||||
|
||||
dialogEditService
|
||||
@ -1260,9 +1260,9 @@ function showConfigurationTab() {
|
||||
|
||||
var moreCriteria = [];
|
||||
var name = trim(thisDialog.find("#edit_service_name").val());
|
||||
moreCriteria.push("&name="+encodeURIComponent(name));
|
||||
moreCriteria.push("&name="+encodeURIComponent(escape(name)));
|
||||
var displaytext = trim(thisDialog.find("#edit_service_display").val());
|
||||
moreCriteria.push("&displayText="+encodeURIComponent(displaytext));
|
||||
moreCriteria.push("&displayText="+encodeURIComponent(escape(displaytext)));
|
||||
var offerha = trim(thisDialog.find("#edit_service_offerha").val());
|
||||
moreCriteria.push("&offerha="+offerha);
|
||||
|
||||
@ -1316,17 +1316,17 @@ function showConfigurationTab() {
|
||||
function serviceJSONToTemplate(json, template) {
|
||||
template.attr("id", "service_"+json.id);
|
||||
(index++ % 2 == 0)? template.addClass("smallrow_even"): template.addClass("smallrow_odd");
|
||||
template.data("svcId", json.id).data("svcName", sanitizeXSS(json.name));
|
||||
template.data("svcId", json.id).data("svcName", sanitizeXSS(unescape(json.name)));
|
||||
|
||||
template.find("#service_id").text(json.id);
|
||||
template.find("#service_name").text(json.name);
|
||||
template.find("#service_displaytext").text(json.displaytext);
|
||||
template.find("#service_name").text(unescape(json.name));
|
||||
template.find("#service_displaytext").text(unescape(json.displaytext));
|
||||
template.find("#service_storagetype").text(json.storagetype);
|
||||
template.find("#service_cpu").text(json.cpunumber + " x " + convertHz(json.cpuspeed));
|
||||
template.find("#service_memory").text(convertBytes(parseInt(json.memory)*1024*1024));
|
||||
template.find("#service_offerha").text(toBooleanText(json.offerha));
|
||||
template.find("#service_networktype").text(toNetworkType(json.usevirtualnetwork));
|
||||
template.find("#service_tags").text(json.tags);
|
||||
template.find("#service_tags").text(unescape(json.tags));
|
||||
|
||||
setDateField(json.created, template.find("#service_created"));
|
||||
}
|
||||
@ -1454,10 +1454,10 @@ function showConfigurationTab() {
|
||||
|
||||
var array1 = [];
|
||||
var name = trim(thisDialog.find("#add_service_name").val());
|
||||
array1.push("&name="+encodeURIComponent(name));
|
||||
array1.push("&name="+encodeURIComponent(escape(name)));
|
||||
|
||||
var display = trim(thisDialog.find("#add_service_display").val());
|
||||
array1.push("&displayText="+encodeURIComponent(display));
|
||||
array1.push("&displayText="+encodeURIComponent(escape(display)));
|
||||
|
||||
var storagetype = trim(thisDialog.find("#add_service_storagetype").val());
|
||||
array1.push("&storageType="+storagetype);
|
||||
@ -1480,7 +1480,7 @@ function showConfigurationTab() {
|
||||
|
||||
var tags = trim(thisDialog.find("#add_service_tags").val());
|
||||
if(tags != null && tags.length > 0)
|
||||
array1.push("&tags="+encodeURIComponent(tags));
|
||||
array1.push("&tags="+encodeURIComponent(escape(tags)));
|
||||
|
||||
thisDialog.dialog("close");
|
||||
$.ajax({
|
||||
@ -1544,17 +1544,17 @@ function showConfigurationTab() {
|
||||
|
||||
var array1 = [];
|
||||
var name = trim(thisDialog.find("#add_disk_name").val());
|
||||
array1.push("&name="+encodeURIComponent(name));
|
||||
array1.push("&name="+encodeURIComponent(escape(name)));
|
||||
|
||||
var description = trim(thisDialog.find("#add_disk_description").val());
|
||||
array1.push("&displaytext="+encodeURIComponent(description));
|
||||
array1.push("&displaytext="+encodeURIComponent(escape(description)));
|
||||
|
||||
var disksize = trim(thisDialog.find("#add_disk_disksize").val());
|
||||
array1.push("&disksize="+disksize);
|
||||
|
||||
var tags = trim(thisDialog.find("#add_disk_tags").val());
|
||||
if(tags != null && tags.length > 0)
|
||||
array1.push("&tags="+encodeURIComponent(tags));
|
||||
array1.push("&tags="+encodeURIComponent(escape(tags)));
|
||||
|
||||
thisDialog.dialog("close");
|
||||
$.ajax({
|
||||
@ -1649,7 +1649,7 @@ function showConfigurationTab() {
|
||||
var dialogBox = $(this);
|
||||
dialogBox.dialog("close");
|
||||
$.ajax({
|
||||
data: createURL("command=updateDiskOffering&name="+encodeURIComponent(name)+"&displayText="+encodeURIComponent(display)+"&id="+diskId+"&response=json"),
|
||||
data: createURL("command=updateDiskOffering&name="+encodeURIComponent(escape(name))+"&displayText="+encodeURIComponent(escape(display))+"&id="+diskId+"&response=json"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
template.find("#disk_description").text(display);
|
||||
@ -1699,15 +1699,14 @@ function showConfigurationTab() {
|
||||
} else {
|
||||
template.addClass("smallrow_odd");
|
||||
}
|
||||
template.data("diskId", json.id).data("diskName", sanitizeXSS(json.name));
|
||||
template.data("diskId", json.id).data("diskName", sanitizeXSS(unescape(json.name)));
|
||||
|
||||
template.find("#disk_id").text(json.id);
|
||||
template.find("#disk_name").text(json.name);
|
||||
template.find("#disk_description").text(json.displaytext);
|
||||
template.find("#disk_name").text(unescape(json.name));
|
||||
template.find("#disk_description").text(unescape(json.displaytext));
|
||||
template.find("#disk_disksize").text(convertBytes(json.disksize));
|
||||
template.find("#disk_tags").text(json.tags);
|
||||
template.find("#disk_domain").text(json.domain);
|
||||
template.find("#disk_ismirrored").text(json.ismirrored);
|
||||
template.find("#disk_tags").text(unescape(json.tags));
|
||||
template.find("#disk_domain").text(unescape(json.domain));
|
||||
}
|
||||
|
||||
function listDiskOfferings() {
|
||||
|
||||
@ -66,7 +66,7 @@ function showDomainsTab() {
|
||||
|
||||
function drawTree(id, level, container) {
|
||||
$.ajax({
|
||||
data: "command=listDomainChildren&id="+id+"&response=json&pageSize=-1",
|
||||
data: createURL("command=listDomainChildren&id="+id+"&response=json&pageSize=-1"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
@ -321,7 +321,7 @@ function showDomainsTab() {
|
||||
rightPanelSearchResult.show();
|
||||
var keyword = searchInput.val();
|
||||
$.ajax({
|
||||
data: "command=listDomains&keyword="+keyword+"&response=json&pageSize=-1", //pageSize=-1 will return all items (no limitation)
|
||||
data: createURL("command=listDomains&keyword="+keyword+"&response=json&pageSize=-1"), //pageSize=-1 will return all items (no limitation)
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
@ -350,7 +350,7 @@ function showDomainsTab() {
|
||||
function drawRootNode(rootDomainId) {
|
||||
treeContentBox.empty();
|
||||
$.ajax({
|
||||
data: "command=listDomains&id="+rootDomainId+"&response=json&pageSize=-1", //pageSize=-1 will return all items (no limitation)
|
||||
data: createURL("command=listDomains&id="+rootDomainId+"&response=json&pageSize=-1"), //pageSize=-1 will return all items (no limitation)
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
||||
@ -569,7 +569,7 @@ function showHostsTab() {
|
||||
} else if (state == "Maintenance") {
|
||||
template.find(".grid_links").find("#host_action_reconnect_container, #host_action_enable_maint_container").hide();
|
||||
} else if (state == "Disconnected") {
|
||||
template.find(".grid_links").find("#host_action_reconnect_container, #host_action_enable_maint_container, #host_action_cancel_maint_container, #host_action_remove_container").hide();
|
||||
template.find(".grid_links").find("#host_action_reconnect_container, #host_action_enable_maint_container, #host_action_cancel_maint_container").hide();
|
||||
} else {
|
||||
alert("Unsupported Host State: " + state);
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ $(document).ready(function() {
|
||||
mainContainer = $("#maincontentarea");
|
||||
|
||||
// Tab Links, dashboard is the initial active tab
|
||||
mainContainer.load("content/tab_dashboard.html");
|
||||
mainContainer.load("jsp/tab_dashboard.jsp");
|
||||
|
||||
// Default AJAX Setup
|
||||
$.ajaxSetup({
|
||||
@ -285,31 +285,31 @@ $(document).ready(function() {
|
||||
if (tabId == "menutab_dashboard_user" || tabId == "menutab_dashboard_root" || tabId == "menutab_dashboard_domain") {
|
||||
showDashboardTab();
|
||||
} else if (tabId == "menutab_vm") {
|
||||
mainContainer.load("content/tab_instances.html", function() {
|
||||
mainContainer.load("jsp/tab_instances.jsp", function() {
|
||||
showInstancesTab(tab.data("domainId"), tab.data("account"));
|
||||
});
|
||||
} else if (tabId == "menutab_networking") {
|
||||
mainContainer.load("content/tab_networking.html", function() {
|
||||
mainContainer.load("jsp/tab_networking.jsp", function() {
|
||||
showNetworkingTab(tab.data("domainId"), tab.data("account"));
|
||||
});
|
||||
} else if (tabId == "menutab_templates") {
|
||||
mainContainer.load("content/tab_templates.html", function() {
|
||||
mainContainer.load("jsp/tab_templates.jsp", function() {
|
||||
showTemplatesTab();
|
||||
});
|
||||
} else if (tabId == "menutab_events") {
|
||||
mainContainer.load("content/tab_events.html", function() {
|
||||
mainContainer.load("jsp/tab_events.jsp", function() {
|
||||
showEventsTab(tab.data("showEvents"));
|
||||
});
|
||||
} else if (tabId == "menutab_hosts") {
|
||||
mainContainer.load("content/tab_hosts.html", function() {
|
||||
mainContainer.load("jsp/tab_hosts.jsp", function() {
|
||||
showHostsTab();
|
||||
});
|
||||
} else if (tabId == "menutab_storage") {
|
||||
mainContainer.load("content/tab_storage.html", function() {
|
||||
mainContainer.load("jsp/tab_storage.jsp", function() {
|
||||
showStorageTab(tab.data("domainId"), tab.data("targetTab"));
|
||||
});
|
||||
} else if (tabId == "menutab_accounts") {
|
||||
mainContainer.load("content/tab_accounts.html", function() {
|
||||
mainContainer.load("jsp/tab_accounts.jsp", function() {
|
||||
showAccountsTab(tab.data("domainId"));
|
||||
});
|
||||
} else if (tabId == "menutab_domain") {
|
||||
@ -317,7 +317,7 @@ $(document).ready(function() {
|
||||
showDomainsTab();
|
||||
});
|
||||
} else if (tabId == "menutab_configuration") {
|
||||
mainContainer.load("content/tab_configuration.html", function() {
|
||||
mainContainer.load("jsp/tab_configuration.jsp", function() {
|
||||
showConfigurationTab();
|
||||
});
|
||||
} else {
|
||||
@ -342,7 +342,7 @@ $(document).ready(function() {
|
||||
|
||||
// Dashboard Tab
|
||||
function showDashboardTab() {
|
||||
mainContainer.load("content/tab_dashboard.html", function() {
|
||||
mainContainer.load("jsp/tab_dashboard.jsp", function() {
|
||||
$(".header_topright #header_username").text($.cookie("username"));
|
||||
|
||||
if (isAdmin()) {
|
||||
|
||||
@ -576,7 +576,7 @@ function showInstancesTab(p_domainId, p_account) {
|
||||
|
||||
if (offerings != null && offerings.length > 0) {
|
||||
for (var i = 0; i < offerings.length; i++) {
|
||||
var option = $("<option value='" + offerings[i].id + "'>" + sanitizeXSS(offerings[i].displaytext) + "</option>").data("name", offerings[i].name);
|
||||
var option = $("<option value='" + offerings[i].id + "'>" + sanitizeXSS(unescape(offerings[i].displaytext)) + "</option>").data("name", sanitizeXSS(unescape(offerings[i].name)));
|
||||
offeringSelect.append(option);
|
||||
}
|
||||
}
|
||||
@ -611,7 +611,7 @@ function showInstancesTab(p_domainId, p_account) {
|
||||
vmInstance.find(".row_loading").show();
|
||||
vmInstance.find(".loadingmessage_container .loadingmessage_top p").html("Your virtual instance has been upgraded. Please restart your virtual instance for the new service offering to take effect.");
|
||||
vmInstance.find(".loadingmessage_container").fadeIn("slow");
|
||||
vmInstance.find("#vm_service").html("<strong>Service:</strong> " + sanitizeXSS(result.virtualmachine[0].serviceofferingname));
|
||||
vmInstance.find("#vm_service").html("<strong>Service:</strong> " + sanitizeXSS(unescape(result.virtualmachine[0].serviceofferingname)));
|
||||
if (result.virtualmachine[0].haenable =='true') {
|
||||
vmInstance.find("#vm_ha").html("<strong>HA:</strong> Enabled");
|
||||
vmInstance.find("#vm_action_ha").text("Disable HA");
|
||||
@ -1109,7 +1109,7 @@ function showInstancesTab(p_domainId, p_account) {
|
||||
instanceTemplate.find("#vm_ip_address").html("<strong>IP Address:</strong> " + instanceJSON.ipaddress);
|
||||
instanceTemplate.find("#vm_zone").html("<strong>Zone:</strong> " + sanitizeXSS(instanceJSON.zonename));
|
||||
instanceTemplate.find("#vm_template").html("<strong>Template:</strong> " + sanitizeXSS(instanceJSON.templatename));
|
||||
instanceTemplate.find("#vm_service").html("<strong>Service:</strong> " + sanitizeXSS(instanceJSON.serviceofferingname));
|
||||
instanceTemplate.find("#vm_service").html("<strong>Service:</strong> " + sanitizeXSS(unescape(instanceJSON.serviceofferingname)));
|
||||
if (instanceJSON.haenable =='true') {
|
||||
instanceTemplate.find("#vm_ha").html("<strong>HA:</strong> Enabled");
|
||||
instanceTemplate.find("#vm_action_ha").text("Disable HA");
|
||||
@ -1277,7 +1277,7 @@ function showInstancesTab(p_domainId, p_account) {
|
||||
continue;
|
||||
var checked = "checked";
|
||||
if (first == false) checked = "";
|
||||
var listItem = $("<li><input class='radio' type='radio' name='service' id='service' value='"+offerings[i].id+"'" + checked + "/><label style='width:500px;font-size:11px;' for='service'>"+sanitizeXSS(offerings[i].displaytext)+"</label></li>");
|
||||
var listItem = $("<li><input class='radio' type='radio' name='service' id='service' value='"+offerings[i].id+"'" + checked + "/><label style='width:500px;font-size:11px;' for='service'>"+sanitizeXSS(unescape(offerings[i].displaytext))+"</label></li>");
|
||||
$("#wizard_service_offering").append(listItem);
|
||||
first = false;
|
||||
}
|
||||
@ -1306,14 +1306,14 @@ function showInstancesTab(p_domainId, p_account) {
|
||||
var html =
|
||||
"<li>"
|
||||
+"<input class='radio' type='radio' name='rootdisk' id='rootdisk' value='"+offerings[i].id+"'" + ((i==0)?"checked":"") + "/>"
|
||||
+"<label style='width:500px;font-size:11px;' for='disk'>"+sanitizeXSS(offerings[i].displaytext)+"</label>"
|
||||
+"<label style='width:500px;font-size:11px;' for='disk'>"+sanitizeXSS(unescape(offerings[i].displaytext))+"</label>"
|
||||
+"</li>";
|
||||
$("#wizard_root_disk_offering").append(html);
|
||||
|
||||
var html2 =
|
||||
"<li>"
|
||||
+"<input class='radio' type='radio' name='datadisk' id='datadisk' value='"+offerings[i].id+"'" + "/>"
|
||||
+"<label style='width:500px;font-size:11px;' for='disk'>"+sanitizeXSS(offerings[i].displaytext)+"</label>"
|
||||
+"<label style='width:500px;font-size:11px;' for='disk'>"+sanitizeXSS(unescape(offerings[i].displaytext))+"</label>"
|
||||
+"</li>";
|
||||
$("#wizard_data_disk_offering").append(html2);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
package com.cloud.utils;
|
||||
|
||||
import java.net.URI;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -235,14 +236,12 @@ public class DateUtil {
|
||||
throw new CloudRuntimeException("Incorrect interval: "+type.toString());
|
||||
}
|
||||
|
||||
|
||||
return scheduleTime.getTime();
|
||||
}
|
||||
|
||||
|
||||
// test only
|
||||
public static void main(String[] args) {
|
||||
|
||||
TimeZone localTimezone = Calendar.getInstance().getTimeZone();
|
||||
TimeZone gmtTimezone = TimeZone.getTimeZone("GMT");
|
||||
TimeZone estTimezone = TimeZone.getTimeZone("EST");
|
||||
|
||||
3
wscript
3
wscript
@ -759,6 +759,9 @@ def deploydb_xenserver(ctx):
|
||||
def deploydb_kvm(ctx):
|
||||
"""re-deploys the database using the MySQL connection information and the KVM templates.sql"""
|
||||
return deploydb(ctx,"kvm")
|
||||
def deploydb_vmware(ctx):
|
||||
"""re-deploys the database using the MySQL connection information and the KVM templates.sql"""
|
||||
return deploydb(ctx,"vmware")
|
||||
|
||||
def run(args):
|
||||
"""runs the management server"""
|
||||
|
||||
101
wscript_build
101
wscript_build
@ -229,21 +229,22 @@ def tar_up(task):
|
||||
z.close()
|
||||
return 0
|
||||
|
||||
if bld.env.DISTRO != "Windows":
|
||||
for virttech in [ _basename(x) for x in _glob(_join("patches","*")) ]:
|
||||
if virttech == "shared":
|
||||
continue
|
||||
patchfiles = filelist('patches/%s/** patches/shared/**'%virttech,src=True,bld=True,dir=False,flat=True)
|
||||
tgen = bld(
|
||||
rule = tar_up,
|
||||
source = patchfiles,
|
||||
target = '%s-patch.tgz'%virttech,
|
||||
name = '%s-patch_tgz'%virttech,
|
||||
root = "patches/%s"%virttech,
|
||||
rename = lambda x: re.sub(".subst$","",x),
|
||||
after = 'patchsubst',
|
||||
)
|
||||
bld.process_after(tgen)
|
||||
for virttech in [ _basename(x) for x in _glob(_join("patches","*")) ]:
|
||||
if virttech == "shared":
|
||||
continue
|
||||
patchfiles = filelist('patches/%s/** patches/shared/**'%virttech,src=True,bld=True,dir=False,flat=True)
|
||||
tgen = bld(
|
||||
rule = tar_up,
|
||||
source = patchfiles,
|
||||
target = '%s-patch.tgz'%virttech,
|
||||
name = '%s-patch_tgz'%virttech,
|
||||
root = "patches/%s"%virttech,
|
||||
rename = lambda x: re.sub(".subst$","",x),
|
||||
after = 'patchsubst',
|
||||
)
|
||||
bld.process_after(tgen)
|
||||
if virttech != "xenserver":
|
||||
# xenserver uses the patch.tgz file later to make an ISO, so we do not need to install it
|
||||
bld.install_as("${AGENTLIBDIR}/scripts/vm/hypervisor/%s/patch.tgz"%virttech, "%s-patch.tgz"%virttech)
|
||||
|
||||
# ================== End creation of patch.tgz's ====================
|
||||
@ -338,6 +339,8 @@ def zip_up(task):
|
||||
z.close()
|
||||
return 0
|
||||
|
||||
bld.path.ensure_dir_node_from_path("target/oss")
|
||||
bld.path.ensure_dir_node_from_path("target/premium")
|
||||
if bld.env.DISTRO not in ["Windows","Mac"]:
|
||||
tgen = bld(
|
||||
rule = copydeps,
|
||||
@ -348,30 +351,80 @@ if bld.env.DISTRO not in ["Windows","Mac"]:
|
||||
tgen = bld(
|
||||
rule = zip_up,
|
||||
source = " ".join( [sources,artifacts,deps,systems] ),
|
||||
target = 'systemvm.zip',
|
||||
target = 'target/oss/systemvm.zip',
|
||||
name = 'systemvm_zip',
|
||||
after = 'copydeps getsystemjars runant',
|
||||
after = 'getsystemjars runant',
|
||||
)
|
||||
bld.process_after(tgen)
|
||||
bld.install_files("${AGENTLIBDIR}/vms", "target/oss/systemvm.zip")
|
||||
|
||||
if buildpremium:
|
||||
tgen = bld(
|
||||
rule = zip_up,
|
||||
source = " ".join( [premiumsources,premiumartifacts,thirdparties] ),
|
||||
target = 'systemvm-premium.zip',
|
||||
target = 'target/premium/systemvm.zip',
|
||||
name = 'systemvm-premium_zip',
|
||||
after = 'runant',
|
||||
)
|
||||
bld.process_after(tgen)
|
||||
|
||||
if bld.env.DISTRO not in [ "Windows", "Mac"]:
|
||||
bld.install_files("${AGENTLIBDIR}/vms", "systemvm.zip")
|
||||
|
||||
if buildpremium:
|
||||
bld.install_files("${AGENTLIBDIR}/vms", "systemvm-premium.zip")
|
||||
#no need to install the premium one, we have ISOs below
|
||||
#bld.install_files("${AGENTLIBDIR}/vms", "systemvm-premium.zip")
|
||||
|
||||
# ================== End systemvm patch creation ====================
|
||||
|
||||
|
||||
# ================== systemvm ISO creation ====================
|
||||
|
||||
if bld.env.DISTRO not in ["Windows","Mac"]: # mkisofs only on windows
|
||||
|
||||
def iso_up(task):
|
||||
tgt = task.outputs[0].bldpath(task.env)
|
||||
if _exists(tgt): _unlink(tgt)
|
||||
inps = []
|
||||
for inp in task.inputs:
|
||||
if inp.id&3==Node.BUILD:
|
||||
src = inp.bldpath(task.env)
|
||||
srcname = src
|
||||
srcname = "/".join(srcname.split("/")[1:]) # chop off default/
|
||||
else:
|
||||
src = inp.srcpath(task.env)
|
||||
srcname = src
|
||||
srcname = "/".join(srcname.split("/")[1:]) # chop off ../
|
||||
# post-process the paths
|
||||
inps.append(src)
|
||||
return Utils.exec_command(
|
||||
[
|
||||
#"echo",
|
||||
"mkisofs",
|
||||
"-quiet",
|
||||
"-r",
|
||||
"-o",tgt,
|
||||
] + inps)
|
||||
|
||||
tgen = bld(
|
||||
rule = iso_up,
|
||||
source = "xenserver-patch.tgz target/oss/systemvm.zip",
|
||||
target = 'target/oss/systemvm.iso',
|
||||
name = 'systemvm_iso',
|
||||
after = 'systemvm_zip xenserver-patch_tgz',
|
||||
)
|
||||
bld.process_after(tgen)
|
||||
bld.install_as("${AGENTLIBDIR}/vms/systemvm.iso", "target/oss/systemvm.iso")
|
||||
|
||||
if buildpremium:
|
||||
tgen = bld(
|
||||
rule = iso_up,
|
||||
source = "xenserver-patch.tgz target/premium/systemvm.zip",
|
||||
target = 'target/premium/systemvm.iso',
|
||||
name = 'systemvm-premium_iso',
|
||||
after = 'systemvm-premium_zip xenserver-patch_tgz',
|
||||
)
|
||||
bld.process_after(tgen)
|
||||
bld.install_as("${AGENTLIBDIR}/vms/systemvm-premium.iso", "target/premium/systemvm.iso")
|
||||
|
||||
# ================== End systemvm ISO creation ====================
|
||||
|
||||
|
||||
# =================== Empty directory / symlink creation on install target ====================
|
||||
|
||||
# 7. make log and cache dirs (this actually runs first)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user