Template size,

1. the size in template_pool_ref now is physical size.
2. template in storage pool is implemented as snapshot, fix x3  issue
3. fix x4 issue
This commit is contained in:
anthony 2010-09-01 20:12:01 -07:00
parent 49f2616fd9
commit 4289dd79ec
6 changed files with 21 additions and 260 deletions

View File

@ -2078,6 +2078,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
/* Does the template exist in primary storage pool? If yes, no copy */
VDI vmtmpltvdi = null;
VDI snapshotvdi = null;
Set<VDI> vdis = VDI.getByNameLabel(conn, "Template " + cmd.getName());
@ -2110,19 +2111,21 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
return new DownloadAnswer(null, 0, msg, com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR, "", "", 0);
}
vmtmpltvdi = cloudVDIcopy(tmpltvdi, poolsr);
vmtmpltvdi.setNameLabel(conn, "Template " + cmd.getName());
snapshotvdi = vmtmpltvdi.snapshot(conn, new HashMap<String, String>());
vmtmpltvdi.destroy(conn);
snapshotvdi.setNameLabel(conn, "Template " + cmd.getName());
// vmtmpltvdi.setNameDescription(conn, cmd.getDescription());
uuid = vmtmpltvdi.getUuid(conn);
uuid = snapshotvdi.getUuid(conn);
vmtmpltvdi = snapshotvdi;
} else
uuid = vmtmpltvdi.getUuid(conn);
// Determine the size of the template
long createdSize = vmtmpltvdi.getVirtualSize(conn);
long phySize = vmtmpltvdi.getPhysicalUtilisation(conn);
DownloadAnswer answer = new DownloadAnswer(null, 100, cmd, com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED, uuid, uuid);
answer.setTemplateSize(createdSize);
answer.setTemplateSize(phySize);
return answer;

View File

@ -1,232 +0,0 @@
#/bin/bash
# $Id: prepsystemvm.sh 10800 2010-07-16 13:48:39Z edison $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/vm/hypervisor/xenserver/prepsystemvm.sh $
#set -x
mntpath() {
local vmname=$1
echo "/mnt/$vmname"
}
mount_local() {
local vmname=$1
local disk=$2
local path=$(mntpath $vmname)
mkdir -p ${path}
mount $disk ${path}
return $?
}
umount_local() {
local vmname=$1
local path=$(mntpath $vmname)
umount $path
local ret=$?
rm -rf $path
return $ret
}
patch_scripts() {
local vmname=$1
local patchfile=$2
local path=$(mntpath $vmname)
local oldmd5=
local md5file=${path}/md5sum
[ -f ${md5file} ] && oldmd5=$(cat ${md5file})
local newmd5=$(md5sum $patchfile | awk '{print $1}')
if [ "$oldmd5" != "$newmd5" ]
then
tar xzf $patchfile -C ${path}
echo ${newmd5} > ${md5file}
fi
return 0
}
#
# To use existing console proxy .zip-based package file
#
patch_console_proxy() {
local vmname=$1
local patchfile=$2
local path=$(mntpath $vmname)
local oldmd5=
local md5file=${path}/usr/local/cloud/systemvm/md5sum
[ -f ${md5file} ] && oldmd5=$(cat ${md5file})
local newmd5=$(md5sum $patchfile | awk '{print $1}')
if [ "$oldmd5" != "$newmd5" ]
then
echo "All" | unzip $patchfile -d ${path}/usr/local/cloud/systemvm >/dev/null 2>&1
chmod 555 ${path}/usr/local/cloud/systemvm/run.sh
find ${path}/usr/local/cloud/systemvm/ -name \*.sh | xargs chmod 555
echo ${newmd5} > ${md5file}
fi
return 0
}
consoleproxy_svcs() {
local vmname=$1
local path=$(mntpath $vmname)
chroot ${path} /sbin/chkconfig cloud on
chroot ${path} /sbin/chkconfig postinit on
chroot ${path} /sbin/chkconfig domr_webserver off
chroot ${path} /sbin/chkconfig haproxy off ;
chroot ${path} /sbin/chkconfig dnsmasq off
chroot ${path} /sbin/chkconfig sshd on
chroot ${path} /sbin/chkconfig httpd off
chroot ${path} /sbin/chkconfig nfs off
chroot ${path} /sbin/chkconfig nfslock off
chroot ${path} /sbin/chkconfig rpcbind off
chroot ${path} /sbin/chkconfig rpcidmap off
cp ${path}/etc/sysconfig/iptables-consoleproxy ${path}/etc/sysconfig/iptables
}
secstorage_svcs() {
local vmname=$1
local path=$(mntpath $vmname)
chroot ${path} /sbin/chkconfig cloud on
chroot ${path} /sbin/chkconfig postinit on
chroot ${path} /sbin/chkconfig domr_webserver off
chroot ${path} /sbin/chkconfig haproxy off ;
chroot ${path} /sbin/chkconfig dnsmasq off
chroot ${path} /sbin/chkconfig sshd on
chroot ${path} /sbin/chkconfig httpd off
cp ${path}/etc/sysconfig/iptables-secstorage ${path}/etc/sysconfig/iptables
mkdir -p ${path}/var/log/cloud
}
routing_svcs() {
local vmname=$1
local path=$(mntpath $vmname)
chroot ${path} /sbin/chkconfig cloud off
chroot ${path} /sbin/chkconfig domr_webserver on ;
chroot ${path} /sbin/chkconfig haproxy on ;
chroot ${path} /sbin/chkconfig dnsmasq on
chroot ${path} /sbin/chkconfig sshd on
chroot ${path} /sbin/chkconfig nfs off
chroot ${path} /sbin/chkconfig nfslock off
chroot ${path} /sbin/chkconfig rpcbind off
chroot ${path} /sbin/chkconfig rpcidmap off
cp ${path}/etc/sysconfig/iptables-domr ${path}/etc/sysconfig/iptables
}
lflag=
dflag=
while getopts 't:l:d:' OPTION
do
case $OPTION in
l) lflag=1
vmname="$OPTARG"
;;
t) tflag=1
vmtype="$OPTARG"
;;
d) dflag=1
rootdisk="$OPTARG"
;;
*) ;;
esac
done
if [ "$lflag$tflag$dflag" != "111" ]
then
printf "Error: Not enough parameter\n" >&2
exit 1
fi
mount_local $vmname $rootdisk
if [ $? -gt 0 ]
then
printf "Failed to mount disk $rootdisk for $vmname\n" >&2
exit 1
fi
if [ -f $(dirname $0)/patch.tgz ]
then
patch_scripts $vmname $(dirname $0)/patch.tgz
if [ $? -gt 0 ]
then
printf "Failed to apply patch patch.zip to $vmname\n" >&2
umount_local $vmname
exit 4
fi
fi
cpfile=$(dirname $0)/systemvm-premium.zip
if [ "$vmtype" == "consoleproxy" ] || [ "$vmtype" == "secstorage" ] && [ -f $cpfile ]
then
patch_console_proxy $vmname $cpfile
if [ $? -gt 0 ]
then
printf "Failed to apply patch $patch $cpfile to $vmname\n" >&2
umount_local $vmname
exit 5
fi
fi
# domr is 64 bit, need to copy 32bit chkconfig to domr
# this is workaroud, will use 32 bit domr
dompath=$(mntpath $vmname)
cp /sbin/chkconfig $dompath/sbin
# copy public key to system vm
cp $(dirname $0)/id_rsa.pub $dompath/root/.ssh/authorized_keys
#empty known hosts
echo "" > $dompath/root/.ssh/known_hosts
if [ "$vmtype" == "router" ]
then
routing_svcs $vmname
if [ $? -gt 0 ]
then
printf "Failed to execute routing_svcs\n" >&2
umount_local $vmname
exit 6
fi
fi
if [ "$vmtype" == "consoleproxy" ]
then
consoleproxy_svcs $vmname
if [ $? -gt 0 ]
then
printf "Failed to execute consoleproxy_svcs\n" >&2
umount_local $vmname
exit 7
fi
fi
if [ "$vmtype" == "secstorage" ]
then
secstorage_svcs $vmname
if [ $? -gt 0 ]
then
printf "Failed to execute secstorage_svcs\n" >&2
umount_local $vmname
exit 8
fi
fi
umount_local $vmname
exit $?

View File

@ -617,6 +617,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
templateHostSC.addAnd("hostId", SearchCriteria.Op.EQ, secStorageHost.getId());
_vmTemplateHostDao.remove(templateHostSC);
/*Disconnected agent needs special handling here*/
secStorageHost.setGuid(null);
txn.commit();
return true;
}catch (Throwable t) {

View File

@ -635,6 +635,9 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
}
if (!found) {
event.setDescription("failed to create Domain Router : " + name);
event.setLevel(EventVO.LEVEL_ERROR);
_eventDao.persist(event);
throw new ExecutionException("Unable to create DomainRouter");
}
_routerDao.updateIf(router, Event.OperationSucceeded, null);

View File

@ -892,7 +892,7 @@ public class StorageManagerImpl implements StorageManager {
if (dataVol != null) {
StoragePoolVO pool = _storagePoolDao.findById(rootCreated.getPoolId());
dataCreated = createVolume(dataVol, vm, template, dc, pod, pool.getClusterId(), offering, diskOffering, avoids,size);
dataCreated = createVolume(dataVol, vm, null, dc, pod, pool.getClusterId(), offering, diskOffering, avoids,size);
if (dataCreated == null) {
throw new CloudRuntimeException("Unable to create " + dataVol);
}

View File

@ -147,7 +147,7 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
if (!poolIsCorrectType(dskCh, pool, vm, offering)) {
return false;
}
// check the used size against the total size, skip this host if it's greater than the configured
// capacity check "storage.capacity.threshold"
if (sc != null) {
@ -179,35 +179,20 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
for (VMTemplateStoragePoolVO templatePoolVO : templatePoolVOs) {
VMTemplateVO templateInPool = _templateDao.findById(templatePoolVO.getTemplateId());
int templateSizeMultiplier = 2;
if ((template != null) && !tmpinstalled && (templateInPool.getId() == template.getId())) {
tmpinstalled = true;
templateSizeMultiplier = 3;
}
s_logger.debug("For template: " + templateInPool.getName() + ", using template size multiplier: " + templateSizeMultiplier);
long templateSize = templatePoolVO.getTemplateSize();
totalAllocatedSize += templateSizeMultiplier * (templateSize + _extraBytesPerVolume);
totalAllocatedSize += templateSize + _extraBytesPerVolume;
}
if ((template != null) && !tmpinstalled) {
// If the template that was passed into this allocator is not installed in the storage pool,
// add 3 * (template size on secondary storage) to the running total
HostVO secondaryStorageHost = _storageMgr.getSecondaryStorageHost(pool.getDataCenterId());
if (secondaryStorageHost == null) {
return false;
} else {
VMTemplateHostVO templateHostVO = _templateHostDao.findByHostTemplate(secondaryStorageHost.getId(), template.getId());
if (templateHostVO == null) {
return false;
} else {
s_logger.debug("For template: " + template.getName() + ", using template size multiplier: " + 3);
long templateSize = templateHostVO.getSize();
totalAllocatedSize += 3 * (templateSize + _extraBytesPerVolume);
}
}
if (template != null && !tmpinstalled ) {
// If the template that was passed into this allocator is not installed in the storage pool
// should add template size
// dskCh.getSize() should be template virtualsize
totalAllocatedSize += dskCh.getSize() + _extraBytesPerVolume;
}
long askingSize = dskCh.getSize();