fix template permission

This commit is contained in:
edison 2010-09-01 15:40:19 -07:00
parent 84fa801360
commit d550ab6245
2 changed files with 9 additions and 16 deletions

View File

@ -1428,10 +1428,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
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;
File f = new File(templatePath);
if (!f.exists()) {
f.mkdirs();
}
_storage.mkdirs(templatePath);
String tmplPath = templateInstallFolder + File.separator + tmplFileName;
Script command = new Script(_createTmplPath, _timeout, s_logger);
command.add("-t", templatePath);
@ -1487,10 +1485,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
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 tmpltPath = _mountPoint + File.separator + secondaryStorage.getUUIDString() + templateInstallFolder;
File mpfile = new File(tmpltPath);
if (!mpfile.exists()) {
mpfile.mkdirs();
}
_storage.mkdirs(tmpltPath);
Script command = new Script(_createTmplPath, _timeout, s_logger);
command.add("-f", cmd.getSnapshotPath());
@ -1589,10 +1584,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
if (sp == null) {
try {
File tpFile = new File(targetPath);
if (!tpFile.exists()) {
tpFile.mkdir();
}
_storage.mkdir(targetPath);
LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(poolType.NFS, uuid, uuid,
sourceHost, sourcePath, targetPath);
s_logger.debug(spd.toString());
@ -1702,10 +1694,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
String targetPath = _mountPoint + File.separator + pool.getUuid();
LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(poolType.NFS, pool.getUuid(), pool.getUuid(),
pool.getHostAddress(), pool.getPath(), targetPath);
File tpFile = new File(targetPath);
if (!tpFile.exists()) {
tpFile.mkdirs();
}
_storage.mkdir(targetPath);
StoragePool sp = null;
try {
s_logger.debug(spd.toString());

View File

@ -78,6 +78,7 @@ create_from_file() {
then
rm -f $tmpltimg
fi
chmod +r /$tmpltfs/$tmpltname
}
create_from_snapshot() {
@ -92,6 +93,8 @@ create_from_snapshot() {
printf "Failed to create template /$tmplfs/$tmpltname from snapshot $snapshotName on disk $tmpltImg "
exit 2
fi
chmod +r /$tmpltfs/$tmpltname
}
tflag=
@ -165,6 +168,7 @@ else
fi
touch /$tmpltfs/template.properties
chmod +r /$tmpltfs/template.properties
echo -n "" > /$tmpltfs/template.properties
today=$(date '+%m_%d_%Y')