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 @Override
public boolean executeInSequence() { public boolean executeInSequence() {
return false; return true;
} }
public String getSecUrl() { public String getSecUrl() {

View File

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

View File

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

View File

@ -22,7 +22,7 @@ package com.cloud.storage.template;
* *
*/ */
public final class TemplateConstants { 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_TMPLT_FIRST_LEVEL_DIR = "tmpl/";
public static final String DEFAULT_SYSTEM_VM_TEMPLATE_PATH = "template/tmpl/1/"; 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); _sslCopy = Boolean.parseBoolean(useSsl);
} }
configureFolders(name, params);
String inSystemVM = (String)params.get("secondary.storage.vm"); String inSystemVM = (String)params.get("secondary.storage.vm");
if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) { if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) {
s_logger.info("UploadManager: starting additional services since we are inside system vm"); s_logger.info("UploadManager: starting additional services since we are inside system vm");
@ -526,34 +525,6 @@ public class UploadManagerImpl implements UploadManager {
} }
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 @Override
public String getName() { public String getName() {
return _name; return _name;

View File

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

View File

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