fixed template download

This commit is contained in:
anthony 2011-05-17 14:00:50 -07:00
parent c0ffcfc46d
commit 384f30101e
7 changed files with 11 additions and 40 deletions

View File

@ -29,7 +29,7 @@ public class ListTemplateCommand extends StorageCommand {
@Override
public boolean executeInSequence() {
return false;
return true;
}
public String getSecUrl() {

View File

@ -108,7 +108,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
private String _localgw;
private String _eth1mask;
private String _eth1ip;
final private String _parent = "/mnt/SecStorage/";
@Override
public void disconnected() {
}
@ -361,8 +361,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
return new Answer(cmd, true, null);
}
public String getRootDir(String secUrl) {
synchronized public String getRootDir(String secUrl) {
try {
URI uri = new URI(secUrl);
String nfsHost = uri.getHost();
@ -371,7 +370,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
String nfsHostIp = nfsHostAddr.getHostAddress();
String nfsPath = nfsHostIp + ":" + uri.getPath();
String dir = UUID.nameUUIDFromBytes(nfsPath.getBytes()).toString();
String root = "/mnt/SecStorage/" + dir;
String root = _parent + "/" + dir;
mount(root, nfsPath);
return root;
} catch (Exception e) {
@ -465,6 +464,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
throw new ConfigurationException("Unable to find class " + value);
}
}
_storage.mkdirs(_parent);
_configSslScr = Script.findScript(getDefaultScriptsDir(), "config_ssl.sh");
if (_configSslScr != null) {
s_logger.info("config_ssl.sh found in " + _configSslScr);
@ -538,8 +538,8 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
_params.put(StorageLayer.InstanceConfigKey, _storage);
_dlMgr = new DownloadManagerImpl();
_dlMgr.configure("DownloadManager", _params);
_upldMgr = new UploadManagerImpl();
_upldMgr.configure("UploadManager", params);
//_upldMgr = new UploadManagerImpl();
//_upldMgr.configure("UploadManager", params);
} catch (ConfigurationException e) {
s_logger.warn("Caught problem while configuring DownloadManager", e);
return false;

View File

@ -608,7 +608,7 @@ public class DownloadManagerImpl implements DownloadManager {
ZfsPathParser zpp = new ZfsPathParser(rootdir);
script.execute(zpp);
result.addAll(zpp.getPaths());
s_logger.info("found " + zpp.getPaths().size() + " templates");
s_logger.info("found " + zpp.getPaths().size() + " templates" + zpp.getPaths());
return result;
}

View File

@ -22,7 +22,7 @@ package com.cloud.storage.template;
*
*/
public final class TemplateConstants {
public static final String DEFAULT_TMPLT_ROOT_DIR = "template/";
public static final String DEFAULT_TMPLT_ROOT_DIR = "template";
public static final String DEFAULT_TMPLT_FIRST_LEVEL_DIR = "tmpl/";
public static final String DEFAULT_SYSTEM_VM_TEMPLATE_PATH = "template/tmpl/1/";

View File

@ -470,7 +470,6 @@ public class UploadManagerImpl implements UploadManager {
_sslCopy = Boolean.parseBoolean(useSsl);
}
configureFolders(name, params);
String inSystemVM = (String)params.get("secondary.storage.vm");
if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) {
s_logger.info("UploadManager: starting additional services since we are inside system vm");
@ -524,34 +523,6 @@ public class UploadManagerImpl implements UploadManager {
return;
}
}
protected void configureFolders(String name, Map<String, Object> params) throws ConfigurationException {
parentDir = (String) params.get("template.parent");
if (parentDir == null) {
throw new ConfigurationException("Unable to find the parent root for the templates");
}
String value = (String) params.get("public.templates.root.dir");
if (value == null) {
value = TemplateConstants.DEFAULT_TMPLT_ROOT_DIR;
}
if (value.startsWith(File.separator)) {
publicTemplateRepo = value;
} else {
publicTemplateRepo = parentDir + File.separator + value;
}
if (!publicTemplateRepo.endsWith(File.separator)) {
publicTemplateRepo += File.separator;
}
publicTemplateRepo += TemplateConstants.DEFAULT_TMPLT_FIRST_LEVEL_DIR;
if (!_storage.mkdirs(publicTemplateRepo)) {
throw new ConfigurationException("Unable to create public templates directory");
}
}
@Override

View File

@ -55,7 +55,7 @@ fi
for i in $(find /$rootdir -name template.properties );
do
d=$(dirname $i)
filename=$(grep "filename" $i | awk -F"=" '{print $NF}')
filename=$(grep "^filename" $i | awk -F"=" '{print $NF}')
# size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}')
# if [ -n "$filename" ] && [ -n "$size" ]
# then

View File

@ -280,7 +280,7 @@ public class DownloadListener implements Listener {
@Override
public void processConnect(HostVO agent, StartupCommand cmd) throws ConnectionException {
if (cmd instanceof StartupRoutingCommand) {
downloadMonitor.handleSysTemplateDownload(agent);
//downloadMonitor.handleSysTemplateDownload(agent);
} else if ( cmd instanceof StartupStorageCommand) {
StartupStorageCommand storage = (StartupStorageCommand)cmd;
if( storage.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE ||