mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Keep removing
This commit is contained in:
parent
56e5fbdee2
commit
f922c6fc03
@ -53,10 +53,7 @@ import com.cloud.utils.ProcessUtil;
|
|||||||
import com.cloud.utils.PropertiesUtil;
|
import com.cloud.utils.PropertiesUtil;
|
||||||
import com.cloud.utils.backoff.BackoffAlgorithm;
|
import com.cloud.utils.backoff.BackoffAlgorithm;
|
||||||
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
|
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
|
||||||
import com.cloud.utils.component.Adapters;
|
|
||||||
import com.cloud.utils.component.LegacyComponentLocator;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.utils.net.MacAddress;
|
|
||||||
import com.cloud.utils.script.Script;
|
import com.cloud.utils.script.Script;
|
||||||
|
|
||||||
public class AgentShell implements IAgentShell {
|
public class AgentShell implements IAgentShell {
|
||||||
@ -146,6 +143,7 @@ public class AgentShell implements IAgentShell {
|
|||||||
return _guid;
|
return _guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Map<String, Object> getCmdLineProperties() {
|
public Map<String, Object> getCmdLineProperties() {
|
||||||
return _cmdLineProperties;
|
return _cmdLineProperties;
|
||||||
}
|
}
|
||||||
@ -378,8 +376,6 @@ public class AgentShell implements IAgentShell {
|
|||||||
|
|
||||||
public void init(String[] args) throws ConfigurationException {
|
public void init(String[] args) throws ConfigurationException {
|
||||||
|
|
||||||
final LegacyComponentLocator locator = LegacyComponentLocator.getLocator("agent");
|
|
||||||
|
|
||||||
final Class<?> c = this.getClass();
|
final Class<?> c = this.getClass();
|
||||||
_version = c.getPackage().getImplementationVersion();
|
_version = c.getPackage().getImplementationVersion();
|
||||||
if (_version == null) {
|
if (_version == null) {
|
||||||
@ -396,12 +392,9 @@ public class AgentShell implements IAgentShell {
|
|||||||
s_logger.debug("Found property: " + property);
|
s_logger.debug("Found property: " + property);
|
||||||
}
|
}
|
||||||
|
|
||||||
_storage = locator.getManager(StorageComponent.class);
|
s_logger.info("Defaulting to using properties file for storage");
|
||||||
if (_storage == null) {
|
_storage = new PropertiesStorage();
|
||||||
s_logger.info("Defaulting to using properties file for storage");
|
_storage.configure("Storage", new HashMap<String, Object>());
|
||||||
_storage = new PropertiesStorage();
|
|
||||||
_storage.configure("Storage", new HashMap<String, Object>());
|
|
||||||
}
|
|
||||||
|
|
||||||
// merge with properties from command line to let resource access
|
// merge with properties from command line to let resource access
|
||||||
// command line parameters
|
// command line parameters
|
||||||
@ -410,22 +403,9 @@ public class AgentShell implements IAgentShell {
|
|||||||
_properties.put(cmdLineProp.getKey(), cmdLineProp.getValue());
|
_properties.put(cmdLineProp.getKey(), cmdLineProp.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
final Adapters adapters = locator.getAdapters(BackoffAlgorithm.class);
|
s_logger.info("Defaulting to the constant time backoff algorithm");
|
||||||
final Enumeration en = adapters.enumeration();
|
_backoff = new ConstantTimeBackoff();
|
||||||
while (en.hasMoreElements()) {
|
_backoff.configure("ConstantTimeBackoff", new HashMap<String, Object>());
|
||||||
_backoff = (BackoffAlgorithm) en.nextElement();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (en.hasMoreElements()) {
|
|
||||||
s_logger.info("More than one backoff algorithm specified. Using the first one ");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_backoff == null) {
|
|
||||||
s_logger.info("Defaulting to the constant time backoff algorithm");
|
|
||||||
_backoff = new ConstantTimeBackoff();
|
|
||||||
_backoff.configure("ConstantTimeBackoff",
|
|
||||||
new HashMap<String, Object>());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchAgent() throws ConfigurationException {
|
private void launchAgent() throws ConfigurationException {
|
||||||
@ -469,6 +449,7 @@ public class AgentShell implements IAgentShell {
|
|||||||
openPortWithIptables(port);
|
openPortWithIptables(port);
|
||||||
|
|
||||||
_consoleProxyMain = new Thread(new Runnable() {
|
_consoleProxyMain = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
|
Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
|
||||||
@ -522,7 +503,7 @@ public class AgentShell implements IAgentShell {
|
|||||||
} catch (final SecurityException e) {
|
} catch (final SecurityException e) {
|
||||||
throw new ConfigurationException(
|
throw new ConfigurationException(
|
||||||
"Security excetion when loading resource: " + name
|
"Security excetion when loading resource: " + name
|
||||||
+ " due to: " + e.toString());
|
+ " due to: " + e.toString());
|
||||||
} catch (final NoSuchMethodException e) {
|
} catch (final NoSuchMethodException e) {
|
||||||
throw new ConfigurationException(
|
throw new ConfigurationException(
|
||||||
"Method not found excetion when loading resource: "
|
"Method not found excetion when loading resource: "
|
||||||
@ -534,7 +515,7 @@ public class AgentShell implements IAgentShell {
|
|||||||
} catch (final InstantiationException e) {
|
} catch (final InstantiationException e) {
|
||||||
throw new ConfigurationException(
|
throw new ConfigurationException(
|
||||||
"Instantiation excetion when loading resource: " + name
|
"Instantiation excetion when loading resource: " + name
|
||||||
+ " due to: " + e.toString());
|
+ " due to: " + e.toString());
|
||||||
} catch (final IllegalAccessException e) {
|
} catch (final IllegalAccessException e) {
|
||||||
throw new ConfigurationException(
|
throw new ConfigurationException(
|
||||||
"Illegal access exception when loading resource: "
|
"Illegal access exception when loading resource: "
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -41,19 +40,15 @@ import com.cloud.agent.dao.impl.PropertiesStorage;
|
|||||||
import com.cloud.agent.transport.Request;
|
import com.cloud.agent.transport.Request;
|
||||||
import com.cloud.resource.ServerResource;
|
import com.cloud.resource.ServerResource;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.ProcessUtil;
|
|
||||||
import com.cloud.utils.PropertiesUtil;
|
import com.cloud.utils.PropertiesUtil;
|
||||||
import com.cloud.utils.backoff.BackoffAlgorithm;
|
import com.cloud.utils.backoff.BackoffAlgorithm;
|
||||||
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
|
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
|
||||||
import com.cloud.utils.component.Adapters;
|
|
||||||
import com.cloud.utils.component.LegacyComponentLocator;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.utils.net.MacAddress;
|
import com.cloud.utils.net.MacAddress;
|
||||||
import com.cloud.utils.nio.HandlerFactory;
|
import com.cloud.utils.nio.HandlerFactory;
|
||||||
import com.cloud.utils.nio.Link;
|
import com.cloud.utils.nio.Link;
|
||||||
import com.cloud.utils.nio.NioServer;
|
import com.cloud.utils.nio.NioServer;
|
||||||
import com.cloud.utils.nio.Task;
|
import com.cloud.utils.nio.Task;
|
||||||
import com.cloud.utils.nio.Task.Type;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of agent shell to run the agents on System Center Virtual Machine manager
|
* Implementation of agent shell to run the agents on System Center Virtual Machine manager
|
||||||
@ -61,7 +56,7 @@ import com.cloud.utils.nio.Task.Type;
|
|||||||
|
|
||||||
public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
||||||
|
|
||||||
private static final Logger s_logger = Logger.getLogger(VmmAgentShell.class.getName());
|
private static final Logger s_logger = Logger.getLogger(VmmAgentShell.class.getName());
|
||||||
private final Properties _properties = new Properties();
|
private final Properties _properties = new Properties();
|
||||||
private final Map<String, Object> _cmdLineProperties = new HashMap<String, Object>();
|
private final Map<String, Object> _cmdLineProperties = new HashMap<String, Object>();
|
||||||
private StorageComponent _storage;
|
private StorageComponent _storage;
|
||||||
@ -76,12 +71,12 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||||||
private int _proxyPort;
|
private int _proxyPort;
|
||||||
private int _workers;
|
private int _workers;
|
||||||
private String _guid;
|
private String _guid;
|
||||||
static private NioServer _connection;
|
static private NioServer _connection;
|
||||||
static private int _listenerPort=9000;
|
static private int _listenerPort=9000;
|
||||||
private int _nextAgentId = 1;
|
private int _nextAgentId = 1;
|
||||||
private volatile boolean _exit = false;
|
private volatile boolean _exit = false;
|
||||||
private int _pingRetries;
|
private int _pingRetries;
|
||||||
private Thread _consoleProxyMain = null;
|
private final Thread _consoleProxyMain = null;
|
||||||
private final List<Agent> _agents = new ArrayList<Agent>();
|
private final List<Agent> _agents = new ArrayList<Agent>();
|
||||||
|
|
||||||
public VmmAgentShell() {
|
public VmmAgentShell() {
|
||||||
@ -89,99 +84,99 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Properties getProperties() {
|
public Properties getProperties() {
|
||||||
return _properties;
|
return _properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackoffAlgorithm getBackoffAlgorithm() {
|
public BackoffAlgorithm getBackoffAlgorithm() {
|
||||||
return _backoff;
|
return _backoff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPingRetries() {
|
public int getPingRetries() {
|
||||||
return _pingRetries;
|
return _pingRetries;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getZone() {
|
public String getZone() {
|
||||||
return _zone;
|
return _zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPod() {
|
public String getPod() {
|
||||||
return _pod;
|
return _pod;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return _host;
|
return _host;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrivateIp() {
|
public String getPrivateIp() {
|
||||||
return _privateIp;
|
return _privateIp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
return _port;
|
return _port;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getProxyPort() {
|
public int getProxyPort() {
|
||||||
return _proxyPort;
|
return _proxyPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWorkers() {
|
public int getWorkers() {
|
||||||
return _workers;
|
return _workers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGuid() {
|
public String getGuid() {
|
||||||
return _guid;
|
return _guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upgradeAgent(String url) {
|
public void upgradeAgent(String url) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return _version;
|
return _version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getCmdLineProperties() {
|
public Map<String, Object> getCmdLineProperties() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return _cmdLineProperties;
|
return _cmdLineProperties;
|
||||||
}
|
|
||||||
|
|
||||||
public String getProperty(String prefix, String name) {
|
|
||||||
if(prefix != null)
|
|
||||||
return _properties.getProperty(prefix + "." + name);
|
|
||||||
|
|
||||||
return _properties.getProperty(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String getProperty(String prefix, String name) {
|
||||||
public String getPersistentProperty(String prefix, String name) {
|
if(prefix != null)
|
||||||
if(prefix != null)
|
return _properties.getProperty(prefix + "." + name);
|
||||||
return _storage.get(prefix + "." + name);
|
|
||||||
return _storage.get(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
return _properties.getProperty(name);
|
||||||
public void setPersistentProperty(String prefix, String name, String value) {
|
}
|
||||||
if(prefix != null)
|
|
||||||
_storage.persist(prefix + "." + name, value);
|
|
||||||
else
|
|
||||||
_storage.persist(name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadProperties() throws ConfigurationException {
|
@Override
|
||||||
|
public String getPersistentProperty(String prefix, String name) {
|
||||||
|
if(prefix != null)
|
||||||
|
return _storage.get(prefix + "." + name);
|
||||||
|
return _storage.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPersistentProperty(String prefix, String name, String value) {
|
||||||
|
if(prefix != null)
|
||||||
|
_storage.persist(prefix + "." + name, value);
|
||||||
|
else
|
||||||
|
_storage.persist(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadProperties() throws ConfigurationException {
|
||||||
final File file = PropertiesUtil.findConfigFile("agent.properties");
|
final File file = PropertiesUtil.findConfigFile("agent.properties");
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
throw new ConfigurationException("Unable to find agent.properties.");
|
throw new ConfigurationException("Unable to find agent.properties.");
|
||||||
@ -222,14 +217,14 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||||||
} else if (tokens[0].equalsIgnoreCase("host")) {
|
} else if (tokens[0].equalsIgnoreCase("host")) {
|
||||||
host = tokens[1];
|
host = tokens[1];
|
||||||
} else if(tokens[0].equalsIgnoreCase("zone")) {
|
} else if(tokens[0].equalsIgnoreCase("zone")) {
|
||||||
zone = tokens[1];
|
zone = tokens[1];
|
||||||
} else if(tokens[0].equalsIgnoreCase("pod")) {
|
} else if(tokens[0].equalsIgnoreCase("pod")) {
|
||||||
pod = tokens[1];
|
pod = tokens[1];
|
||||||
} else if(tokens[0].equalsIgnoreCase("guid")) {
|
} else if(tokens[0].equalsIgnoreCase("guid")) {
|
||||||
guid = tokens[1];
|
guid = tokens[1];
|
||||||
} else if(tokens[0].equalsIgnoreCase("eth1ip")) {
|
} else if(tokens[0].equalsIgnoreCase("eth1ip")) {
|
||||||
_privateIp = tokens[1];
|
_privateIp = tokens[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port == null) {
|
if (port == null) {
|
||||||
@ -256,19 +251,19 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||||||
_host = host;
|
_host = host;
|
||||||
|
|
||||||
if(zone != null)
|
if(zone != null)
|
||||||
_zone = zone;
|
_zone = zone;
|
||||||
else
|
else
|
||||||
_zone = getProperty(null, "zone");
|
_zone = getProperty(null, "zone");
|
||||||
if (_zone == null || (_zone.startsWith("@") && _zone.endsWith("@"))) {
|
if (_zone == null || (_zone.startsWith("@") && _zone.endsWith("@"))) {
|
||||||
_zone = "default";
|
_zone = "default";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pod != null)
|
if(pod != null)
|
||||||
_pod = pod;
|
_pod = pod;
|
||||||
else
|
else
|
||||||
_pod = getProperty(null, "pod");
|
_pod = getProperty(null, "pod");
|
||||||
if (_pod == null || (_pod.startsWith("@") && _pod.endsWith("@"))) {
|
if (_pod == null || (_pod.startsWith("@") && _pod.endsWith("@"))) {
|
||||||
_pod = "default";
|
_pod = "default";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_host == null || (_host.startsWith("@") && _host.endsWith("@"))) {
|
if (_host == null || (_host.startsWith("@") && _host.endsWith("@"))) {
|
||||||
@ -282,14 +277,14 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||||||
boolean developer = Boolean.parseBoolean(value);
|
boolean developer = Boolean.parseBoolean(value);
|
||||||
|
|
||||||
if(guid != null)
|
if(guid != null)
|
||||||
_guid = guid;
|
_guid = guid;
|
||||||
else
|
else
|
||||||
_guid = getProperty(null, "guid");
|
_guid = getProperty(null, "guid");
|
||||||
if (_guid == null) {
|
if (_guid == null) {
|
||||||
if (!developer) {
|
if (!developer) {
|
||||||
throw new ConfigurationException("Unable to find the guid");
|
throw new ConfigurationException("Unable to find the guid");
|
||||||
}
|
}
|
||||||
_guid = MacAddress.getMacAddress().toString(":");
|
_guid = MacAddress.getMacAddress().toString(":");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -308,8 +303,8 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||||||
String resourceClassNames = getProperty(null, "resource");
|
String resourceClassNames = getProperty(null, "resource");
|
||||||
s_logger.trace("resource=" + resourceClassNames);
|
s_logger.trace("resource=" + resourceClassNames);
|
||||||
if(resourceClassNames != null) {
|
if(resourceClassNames != null) {
|
||||||
launchAgentFromClassInfo(resourceClassNames);
|
launchAgentFromClassInfo(resourceClassNames);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
launchAgentFromTypeInfo();
|
launchAgentFromTypeInfo();
|
||||||
@ -317,8 +312,6 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||||||
|
|
||||||
private void init(String[] args) throws ConfigurationException{
|
private void init(String[] args) throws ConfigurationException{
|
||||||
|
|
||||||
final LegacyComponentLocator locator = LegacyComponentLocator.getLocator("agent");
|
|
||||||
|
|
||||||
final Class<?> c = this.getClass();
|
final Class<?> c = this.getClass();
|
||||||
_version = c.getPackage().getImplementationVersion();
|
_version = c.getPackage().getImplementationVersion();
|
||||||
if (_version == null) {
|
if (_version == null) {
|
||||||
@ -328,38 +321,23 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||||||
|
|
||||||
parseCommand(args);
|
parseCommand(args);
|
||||||
|
|
||||||
_storage = locator.getManager(StorageComponent.class);
|
s_logger.info("Defaulting to using properties file for storage");
|
||||||
if (_storage == null) {
|
_storage = new PropertiesStorage();
|
||||||
s_logger.info("Defaulting to using properties file for storage");
|
_storage.configure("Storage", new HashMap<String, Object>());
|
||||||
_storage = new PropertiesStorage();
|
|
||||||
_storage.configure("Storage", new HashMap<String, Object>());
|
|
||||||
}
|
|
||||||
|
|
||||||
// merge with properties from command line to let resource access command line parameters
|
// merge with properties from command line to let resource access command line parameters
|
||||||
for(Map.Entry<String, Object> cmdLineProp : getCmdLineProperties().entrySet()) {
|
for(Map.Entry<String, Object> cmdLineProp : getCmdLineProperties().entrySet()) {
|
||||||
_properties.put(cmdLineProp.getKey(), cmdLineProp.getValue());
|
_properties.put(cmdLineProp.getKey(), cmdLineProp.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
final Adapters adapters = locator.getAdapters(BackoffAlgorithm.class);
|
s_logger.info("Defaulting to the constant time backoff algorithm");
|
||||||
final Enumeration en = adapters.enumeration();
|
_backoff = new ConstantTimeBackoff();
|
||||||
while (en.hasMoreElements()) {
|
_backoff.configure("ConstantTimeBackoff", new HashMap<String, Object>());
|
||||||
_backoff = (BackoffAlgorithm)en.nextElement();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (en.hasMoreElements()) {
|
|
||||||
s_logger.info("More than one backoff algorithm specified. Using the first one ");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_backoff == null) {
|
|
||||||
s_logger.info("Defaulting to the constant time backoff algorithm");
|
|
||||||
_backoff = new ConstantTimeBackoff();
|
|
||||||
_backoff.configure("ConstantTimeBackoff", new HashMap<String, Object>());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchAgentFromClassInfo(String resourceClassNames) throws ConfigurationException {
|
private void launchAgentFromClassInfo(String resourceClassNames) throws ConfigurationException {
|
||||||
String[] names = resourceClassNames.split("\\|");
|
String[] names = resourceClassNames.split("\\|");
|
||||||
for(String name: names) {
|
for(String name: names) {
|
||||||
Class<?> impl;
|
Class<?> impl;
|
||||||
try {
|
try {
|
||||||
impl = Class.forName(name);
|
impl = Class.forName(name);
|
||||||
@ -368,40 +346,40 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||||||
ServerResource resource = (ServerResource)constructor.newInstance();
|
ServerResource resource = (ServerResource)constructor.newInstance();
|
||||||
launchAgent(getNextAgentId(), resource);
|
launchAgent(getNextAgentId(), resource);
|
||||||
} catch (final ClassNotFoundException e) {
|
} catch (final ClassNotFoundException e) {
|
||||||
throw new ConfigurationException("Resource class not found: " + name);
|
throw new ConfigurationException("Resource class not found: " + name);
|
||||||
} catch (final SecurityException e) {
|
} catch (final SecurityException e) {
|
||||||
throw new ConfigurationException("Security excetion when loading resource: " + name);
|
throw new ConfigurationException("Security excetion when loading resource: " + name);
|
||||||
} catch (final NoSuchMethodException e) {
|
} catch (final NoSuchMethodException e) {
|
||||||
throw new ConfigurationException("Method not found excetion when loading resource: " + name);
|
throw new ConfigurationException("Method not found excetion when loading resource: " + name);
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
throw new ConfigurationException("Illegal argument excetion when loading resource: " + name);
|
throw new ConfigurationException("Illegal argument excetion when loading resource: " + name);
|
||||||
} catch (final InstantiationException e) {
|
} catch (final InstantiationException e) {
|
||||||
throw new ConfigurationException("Instantiation excetion when loading resource: " + name);
|
throw new ConfigurationException("Instantiation excetion when loading resource: " + name);
|
||||||
} catch (final IllegalAccessException e) {
|
} catch (final IllegalAccessException e) {
|
||||||
throw new ConfigurationException("Illegal access exception when loading resource: " + name);
|
throw new ConfigurationException("Illegal access exception when loading resource: " + name);
|
||||||
} catch (final InvocationTargetException e) {
|
} catch (final InvocationTargetException e) {
|
||||||
throw new ConfigurationException("Invocation target exception when loading resource: " + name);
|
throw new ConfigurationException("Invocation target exception when loading resource: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchAgent(int localAgentId, ServerResource resource) throws ConfigurationException {
|
private void launchAgent(int localAgentId, ServerResource resource) throws ConfigurationException {
|
||||||
// we don't track agent after it is launched for now
|
// we don't track agent after it is launched for now
|
||||||
Agent agent = new Agent(this, localAgentId, resource);
|
Agent agent = new Agent(this, localAgentId, resource);
|
||||||
_agents.add(agent);
|
_agents.add(agent);
|
||||||
agent.start();
|
agent.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized int getNextAgentId() {
|
public synchronized int getNextAgentId() {
|
||||||
return _nextAgentId++;
|
return _nextAgentId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run(String[] args) {
|
private void run(String[] args) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
System.setProperty("java.net.preferIPv4Stack","true");
|
System.setProperty("java.net.preferIPv4Stack","true");
|
||||||
loadProperties();
|
loadProperties();
|
||||||
init(args);
|
init(args);
|
||||||
|
|
||||||
String instance = getProperty(null, "instance");
|
String instance = getProperty(null, "instance");
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
@ -413,22 +391,22 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||||||
// TODO need to do this check. For Agentshell running on windows needs different approach
|
// TODO need to do this check. For Agentshell running on windows needs different approach
|
||||||
//final String run = "agent." + instance + "pid";
|
//final String run = "agent." + instance + "pid";
|
||||||
//s_logger.debug("Checking to see if " + run + "exists.");
|
//s_logger.debug("Checking to see if " + run + "exists.");
|
||||||
//ProcessUtil.pidCheck(run);
|
//ProcessUtil.pidCheck(run);
|
||||||
|
|
||||||
|
|
||||||
// TODO: For Hyper-V agent.properties need to be revamped to support multiple agents
|
// TODO: For Hyper-V agent.properties need to be revamped to support multiple agents
|
||||||
// corresponding to multiple clusters but running on a SCVMM host
|
// corresponding to multiple clusters but running on a SCVMM host
|
||||||
|
|
||||||
// read the persistent storage and launch the agents
|
// read the persistent storage and launch the agents
|
||||||
//launchAgent();
|
//launchAgent();
|
||||||
|
|
||||||
// FIXME get rid of this approach of agent listening for boot strap commands from the management server
|
// FIXME get rid of this approach of agent listening for boot strap commands from the management server
|
||||||
|
|
||||||
// now listen for bootstrap request from the management server and launch agents
|
// now listen for bootstrap request from the management server and launch agents
|
||||||
_connection = new NioServer("VmmAgentShell", _listenerPort, 1, this);
|
_connection = new NioServer("VmmAgentShell", _listenerPort, 1, this);
|
||||||
_connection.start();
|
_connection.start();
|
||||||
s_logger.info("SCVMM agent is listening on port " +_listenerPort + " for bootstrap command from management server");
|
s_logger.info("SCVMM agent is listening on port " +_listenerPort + " for bootstrap command from management server");
|
||||||
while(_connection.isRunning());
|
while(_connection.isRunning());
|
||||||
} catch(final ConfigurationException e) {
|
} catch(final ConfigurationException e) {
|
||||||
s_logger.error("Unable to start agent: " + e.getMessage());
|
s_logger.error("Unable to start agent: " + e.getMessage());
|
||||||
System.out.println("Unable to start agent: " + e.getMessage());
|
System.out.println("Unable to start agent: " + e.getMessage());
|
||||||
@ -438,81 +416,81 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||||||
System.out.println("Unable to start agent: " + e.getMessage());
|
System.out.println("Unable to start agent: " + e.getMessage());
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task create(com.cloud.utils.nio.Task.Type type, Link link,
|
public Task create(com.cloud.utils.nio.Task.Type type, Link link,
|
||||||
byte[] data) {
|
byte[] data) {
|
||||||
return new AgentBootStrapHandler(type, link, data);
|
return new AgentBootStrapHandler(type, link, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
_exit = true;
|
_exit = true;
|
||||||
if(_consoleProxyMain != null) {
|
if(_consoleProxyMain != null) {
|
||||||
_consoleProxyMain.interrupt();
|
_consoleProxyMain.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
VmmAgentShell shell = new VmmAgentShell();
|
VmmAgentShell shell = new VmmAgentShell();
|
||||||
Runtime.getRuntime().addShutdownHook(new ShutdownThread(shell));
|
Runtime.getRuntime().addShutdownHook(new ShutdownThread(shell));
|
||||||
shell.run(args);
|
shell.run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// class to handle the bootstrap command from the management server
|
// class to handle the bootstrap command from the management server
|
||||||
private class AgentBootStrapHandler extends Task {
|
private class AgentBootStrapHandler extends Task {
|
||||||
|
|
||||||
public AgentBootStrapHandler(Task.Type type, Link link, byte[] data) {
|
public AgentBootStrapHandler(Task.Type type, Link link, byte[] data) {
|
||||||
super(type, link, data);
|
super(type, link, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doTask(Task task) throws Exception {
|
protected void doTask(Task task) throws Exception {
|
||||||
final Type type = task.getType();
|
final Type type = task.getType();
|
||||||
s_logger.info("recieved task of type "+ type.toString() +" to handle in BootStrapTakHandler");
|
s_logger.info("recieved task of type "+ type.toString() +" to handle in BootStrapTakHandler");
|
||||||
if (type == Task.Type.DATA)
|
if (type == Task.Type.DATA)
|
||||||
{
|
{
|
||||||
final byte[] data = task.getData();
|
final byte[] data = task.getData();
|
||||||
final Request request = Request.parse(data);
|
final Request request = Request.parse(data);
|
||||||
final Command cmd = request.getCommand();
|
final Command cmd = request.getCommand();
|
||||||
|
|
||||||
if (cmd instanceof StartupVMMAgentCommand) {
|
if (cmd instanceof StartupVMMAgentCommand) {
|
||||||
|
|
||||||
StartupVMMAgentCommand vmmCmd = (StartupVMMAgentCommand) cmd;
|
StartupVMMAgentCommand vmmCmd = (StartupVMMAgentCommand) cmd;
|
||||||
|
|
||||||
_zone = Long.toString(vmmCmd.getDataCenter());
|
_zone = Long.toString(vmmCmd.getDataCenter());
|
||||||
_cmdLineProperties.put("zone", _zone);
|
_cmdLineProperties.put("zone", _zone);
|
||||||
|
|
||||||
_pod = Long.toString(vmmCmd.getPod());
|
_pod = Long.toString(vmmCmd.getPod());
|
||||||
_cmdLineProperties.put("pod", _pod);
|
_cmdLineProperties.put("pod", _pod);
|
||||||
|
|
||||||
_cluster = vmmCmd.getClusterName();
|
_cluster = vmmCmd.getClusterName();
|
||||||
_cmdLineProperties.put("cluster", _cluster);
|
_cmdLineProperties.put("cluster", _cluster);
|
||||||
|
|
||||||
_guid = vmmCmd.getGuid();
|
_guid = vmmCmd.getGuid();
|
||||||
_cmdLineProperties.put("guid", _guid);
|
_cmdLineProperties.put("guid", _guid);
|
||||||
|
|
||||||
_host = vmmCmd.getManagementServerIP();
|
_host = vmmCmd.getManagementServerIP();
|
||||||
_port = NumbersUtil.parseInt(vmmCmd.getport(), 8250);
|
_port = NumbersUtil.parseInt(vmmCmd.getport(), 8250);
|
||||||
|
|
||||||
s_logger.info("Recieved boot strap command from management server with parameters " +
|
s_logger.info("Recieved boot strap command from management server with parameters " +
|
||||||
" Zone:"+ _zone + " "+
|
" Zone:"+ _zone + " "+
|
||||||
" Cluster:"+ _cluster + " "+
|
" Cluster:"+ _cluster + " "+
|
||||||
" pod:"+_pod + " "+
|
" pod:"+_pod + " "+
|
||||||
" host:"+ _host +" "+
|
" host:"+ _host +" "+
|
||||||
" port:"+_port);
|
" port:"+_port);
|
||||||
|
|
||||||
launchAgentFromClassInfo("com.cloud.hypervisor.hyperv.resource.HypervResource");
|
launchAgentFromClassInfo("com.cloud.hypervisor.hyperv.resource.HypervResource");
|
||||||
|
|
||||||
// TODO: persist the info in agent.properties for agent restarts
|
// TODO: persist the info in agent.properties for agent restarts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ShutdownThread extends Thread {
|
private static class ShutdownThread extends Thread {
|
||||||
VmmAgentShell _shell;
|
VmmAgentShell _shell;
|
||||||
public ShutdownThread(VmmAgentShell shell) {
|
public ShutdownThread(VmmAgentShell shell) {
|
||||||
this._shell = shell;
|
this._shell = shell;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,76 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.agent.configuration;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.cloud.utils.component.Adapter;
|
|
||||||
import com.cloud.utils.component.ComponentLibraryBase;
|
|
||||||
import com.cloud.utils.component.LegacyComponentLocator.ComponentInfo;
|
|
||||||
import com.cloud.utils.component.Manager;
|
|
||||||
import com.cloud.utils.component.PluggableService;
|
|
||||||
import com.cloud.utils.db.GenericDao;
|
|
||||||
|
|
||||||
public class AgentComponentLibraryBase extends ComponentLibraryBase {
|
|
||||||
@Override
|
|
||||||
public Map<String, ComponentInfo<GenericDao<?, ?>>> getDaos() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, ComponentInfo<Manager>> getManagers() {
|
|
||||||
if (_managers.size() == 0) {
|
|
||||||
populateManagers();
|
|
||||||
}
|
|
||||||
return _managers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, List<ComponentInfo<Adapter>>> getAdapters() {
|
|
||||||
if (_adapters.size() == 0) {
|
|
||||||
populateAdapters();
|
|
||||||
}
|
|
||||||
return _adapters;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<Class<?>, Class<?>> getFactories() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void populateManagers() {
|
|
||||||
// addManager("StackMaidManager", StackMaidManagerImpl.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void populateAdapters() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void populateServices() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, ComponentInfo<PluggableService>> getPluggableServices() {
|
|
||||||
if (_pluggableServices.size() == 0) {
|
|
||||||
populateServices();
|
|
||||||
}
|
|
||||||
return _pluggableServices;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -19,12 +19,11 @@ package com.cloud.agent;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.agent.AgentShell;
|
public class TestAgentShell extends TestCase {
|
||||||
import com.cloud.utils.testcase.Log4jEnabledTestCase;
|
|
||||||
|
|
||||||
public class TestAgentShell extends Log4jEnabledTestCase {
|
|
||||||
protected final static Logger s_logger = Logger.getLogger(TestAgentShell.class);
|
protected final static Logger s_logger = Logger.getLogger(TestAgentShell.class);
|
||||||
|
|
||||||
public void testWget() {
|
public void testWget() {
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package org.apache.cloudstack.storage.datastore;
|
package org.apache.cloudstack.storage.datastore;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreDao;
|
import org.apache.cloudstack.storage.db.ObjectInDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||||
|
|||||||
@ -25,9 +25,7 @@ import java.io.FileReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
@ -44,15 +42,14 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
@ -167,7 +164,13 @@ import com.cloud.agent.api.to.NicTO;
|
|||||||
import com.cloud.agent.api.to.StorageFilerTO;
|
import com.cloud.agent.api.to.StorageFilerTO;
|
||||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||||
import com.cloud.agent.api.to.VolumeTO;
|
import com.cloud.agent.api.to.VolumeTO;
|
||||||
|
import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource;
|
||||||
|
import com.cloud.dc.Vlan;
|
||||||
|
import com.cloud.exception.InternalErrorException;
|
||||||
|
import com.cloud.host.Host.Type;
|
||||||
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool;
|
import com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool;
|
||||||
|
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ClockDef;
|
||||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ConsoleDef;
|
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ConsoleDef;
|
||||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.CpuTuneDef;
|
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.CpuTuneDef;
|
||||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DevicesDef;
|
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DevicesDef;
|
||||||
@ -182,16 +185,10 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef;
|
|||||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.hostNicType;
|
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.hostNicType;
|
||||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SerialDef;
|
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SerialDef;
|
||||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy;
|
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy;
|
||||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ClockDef;
|
|
||||||
import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource;
|
|
||||||
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk;
|
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk;
|
||||||
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
|
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
|
||||||
import com.cloud.hypervisor.kvm.storage.KVMStoragePool;
|
import com.cloud.hypervisor.kvm.storage.KVMStoragePool;
|
||||||
import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager;
|
import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager;
|
||||||
import com.cloud.dc.Vlan;
|
|
||||||
import com.cloud.exception.InternalErrorException;
|
|
||||||
import com.cloud.host.Host.Type;
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|
||||||
import com.cloud.network.Networks.BroadcastDomainType;
|
import com.cloud.network.Networks.BroadcastDomainType;
|
||||||
import com.cloud.network.Networks.IsolationType;
|
import com.cloud.network.Networks.IsolationType;
|
||||||
import com.cloud.network.Networks.RouterPrivateIpStrategy;
|
import com.cloud.network.Networks.RouterPrivateIpStrategy;
|
||||||
@ -199,6 +196,7 @@ import com.cloud.network.Networks.TrafficType;
|
|||||||
import com.cloud.network.PhysicalNetworkSetupInfo;
|
import com.cloud.network.PhysicalNetworkSetupInfo;
|
||||||
import com.cloud.resource.ServerResource;
|
import com.cloud.resource.ServerResource;
|
||||||
import com.cloud.resource.ServerResourceBase;
|
import com.cloud.resource.ServerResourceBase;
|
||||||
|
import com.cloud.storage.JavaStorageLayer;
|
||||||
import com.cloud.storage.Storage;
|
import com.cloud.storage.Storage;
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.storage.Storage.StoragePoolType;
|
import com.cloud.storage.Storage.StoragePoolType;
|
||||||
@ -212,7 +210,6 @@ import com.cloud.storage.template.TemplateLocation;
|
|||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.PropertiesUtil;
|
import com.cloud.utils.PropertiesUtil;
|
||||||
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.utils.net.NetUtils;
|
import com.cloud.utils.net.NetUtils;
|
||||||
import com.cloud.utils.script.OutputInterpreter;
|
import com.cloud.utils.script.OutputInterpreter;
|
||||||
@ -246,7 +243,7 @@ import com.cloud.vm.VirtualMachineName;
|
|||||||
**/
|
**/
|
||||||
@Local(value = { ServerResource.class })
|
@Local(value = { ServerResource.class })
|
||||||
public class LibvirtComputingResource extends ServerResourceBase implements
|
public class LibvirtComputingResource extends ServerResourceBase implements
|
||||||
ServerResource {
|
ServerResource {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(LibvirtComputingResource.class);
|
.getLogger(LibvirtComputingResource.class);
|
||||||
|
|
||||||
@ -329,8 +326,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
private boolean _can_bridge_firewall;
|
private boolean _can_bridge_firewall;
|
||||||
protected String _localStoragePath;
|
protected String _localStoragePath;
|
||||||
protected String _localStorageUUID;
|
protected String _localStorageUUID;
|
||||||
private Map <String, String> _pifs = new HashMap<String, String>();
|
private final Map <String, String> _pifs = new HashMap<String, String>();
|
||||||
private Map<String, Map<String, String>> hostNetInfo = new HashMap<String, Map<String, String>>();
|
private final Map<String, Map<String, String>> hostNetInfo = new HashMap<String, Map<String, String>>();
|
||||||
private final Map<String, vmStats> _vmStats = new ConcurrentHashMap<String, vmStats>();
|
private final Map<String, vmStats> _vmStats = new ConcurrentHashMap<String, vmStats>();
|
||||||
|
|
||||||
protected boolean _disconnected = true;
|
protected boolean _disconnected = true;
|
||||||
@ -375,7 +372,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
tokens[3] = Integer.toString(lastbyte);
|
tokens[3] = Integer.toString(lastbyte);
|
||||||
StringBuilder end = new StringBuilder(15);
|
StringBuilder end = new StringBuilder(15);
|
||||||
end.append(tokens[0]).append(".").append(tokens[1]).append(".")
|
end.append(tokens[0]).append(".").append(tokens[1]).append(".")
|
||||||
.append(tokens[2]).append(".").append(tokens[3]);
|
.append(tokens[2]).append(".").append(tokens[3]);
|
||||||
return end.toString();
|
return end.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,16 +441,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
_storage = new JavaStorageLayer();
|
||||||
Class<?> clazz = Class
|
_storage.configure("StorageLayer", params);
|
||||||
.forName("com.cloud.storage.JavaStorageLayer");
|
|
||||||
_storage = (StorageLayer) ComponentLocator.inject(clazz);
|
|
||||||
_storage.configure("StorageLayer", params);
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
throw new ConfigurationException("Unable to find class "
|
|
||||||
+ "com.cloud.storage.JavaStorageLayer");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String domrScriptsDir = (String) params.get("domr.scripts.dir");
|
String domrScriptsDir = (String) params.get("domr.scripts.dir");
|
||||||
if (domrScriptsDir == null) {
|
if (domrScriptsDir == null) {
|
||||||
@ -685,7 +674,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
String[] isoPaths = { "/usr/lib64/cloud/agent/vms/systemvm.iso",
|
String[] isoPaths = { "/usr/lib64/cloud/agent/vms/systemvm.iso",
|
||||||
"/usr/lib/cloud/agent/vms/systemvm.iso",
|
"/usr/lib/cloud/agent/vms/systemvm.iso",
|
||||||
"/usr/lib64/cloud/common/vms/systemvm.iso",
|
"/usr/lib64/cloud/common/vms/systemvm.iso",
|
||||||
"/usr/lib/cloud/common/vms/systemvm.iso" };
|
"/usr/lib/cloud/common/vms/systemvm.iso" };
|
||||||
for (String isoPath : isoPaths) {
|
for (String isoPath : isoPaths) {
|
||||||
if (_storage.exists(isoPath)) {
|
if (_storage.exists(isoPath)) {
|
||||||
_sysvmISOPath = isoPath;
|
_sysvmISOPath = isoPath;
|
||||||
@ -750,28 +739,28 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
bridges.put("private", _privBridgeName);
|
bridges.put("private", _privBridgeName);
|
||||||
bridges.put("guest", _guestBridgeName);
|
bridges.put("guest", _guestBridgeName);
|
||||||
|
|
||||||
params.put("libvirt.host.bridges", (Object) bridges);
|
params.put("libvirt.host.bridges", bridges);
|
||||||
params.put("libvirt.host.pifs", (Object) _pifs);
|
params.put("libvirt.host.pifs", _pifs);
|
||||||
|
|
||||||
// Load the vif driver
|
// Load the vif driver
|
||||||
String vifDriverName = (String) params.get("libvirt.vif.driver");
|
String vifDriverName = (String) params.get("libvirt.vif.driver");
|
||||||
if (vifDriverName == null) {
|
if (vifDriverName == null) {
|
||||||
s_logger.info("No libvirt.vif.driver specififed. Defaults to BridgeVifDriver.");
|
s_logger.info("No libvirt.vif.driver specififed. Defaults to BridgeVifDriver.");
|
||||||
vifDriverName = "com.cloud.hypervisor.kvm.resource.BridgeVifDriver";
|
vifDriverName = "com.cloud.hypervisor.kvm.resource.BridgeVifDriver";
|
||||||
}
|
}
|
||||||
|
|
||||||
params.put("libvirt.computing.resource", (Object) this);
|
params.put("libvirt.computing.resource", this);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Class.forName(vifDriverName);
|
Class<?> clazz = Class.forName(vifDriverName);
|
||||||
_vifDriver = (VifDriver) clazz.newInstance();
|
_vifDriver = (VifDriver) clazz.newInstance();
|
||||||
_vifDriver.configure(params);
|
_vifDriver.configure(params);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new ConfigurationException("Unable to find class for libvirt.vif.driver " + e);
|
throw new ConfigurationException("Unable to find class for libvirt.vif.driver " + e);
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e);
|
throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException("Failed to initialize libvirt.vif.driver " + e);
|
throw new ConfigurationException("Failed to initialize libvirt.vif.driver " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -802,7 +791,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
String vlan = Script.runSimpleBashScript("ls /proc/net/vlan/" + pif);
|
String vlan = Script.runSimpleBashScript("ls /proc/net/vlan/" + pif);
|
||||||
|
|
||||||
if (vlan != null && !vlan.isEmpty()) {
|
if (vlan != null && !vlan.isEmpty()) {
|
||||||
pif = Script.runSimpleBashScript("grep ^Device\\: /proc/net/vlan/" + pif + " | awk {'print $2'}");
|
pif = Script.runSimpleBashScript("grep ^Device\\: /proc/net/vlan/" + pif + " | awk {'print $2'}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return pif;
|
return pif;
|
||||||
@ -1105,8 +1094,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
KVMStoragePool secondaryStoragePool = null;
|
KVMStoragePool secondaryStoragePool = null;
|
||||||
try {
|
try {
|
||||||
KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(
|
KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(
|
||||||
pool.getType(),
|
pool.getType(),
|
||||||
pool.getUuid());
|
pool.getUuid());
|
||||||
String volumeName = UUID.randomUUID().toString();
|
String volumeName = UUID.randomUUID().toString();
|
||||||
|
|
||||||
if (copyToSecondary) {
|
if (copyToSecondary) {
|
||||||
@ -1116,20 +1105,20 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
String volumeDestPath = "/volumes/" + cmd.getVolumeId()
|
String volumeDestPath = "/volumes/" + cmd.getVolumeId()
|
||||||
+ File.separator;
|
+ File.separator;
|
||||||
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(
|
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(
|
||||||
secondaryStorageUrl);
|
secondaryStorageUrl);
|
||||||
secondaryStoragePool.createFolder(volumeDestPath);
|
secondaryStoragePool.createFolder(volumeDestPath);
|
||||||
secondaryStoragePool.delete();
|
secondaryStoragePool.delete();
|
||||||
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(
|
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(
|
||||||
secondaryStorageUrl
|
secondaryStorageUrl
|
||||||
+ volumeDestPath);
|
+ volumeDestPath);
|
||||||
_storagePoolMgr.copyPhysicalDisk(volume,
|
_storagePoolMgr.copyPhysicalDisk(volume,
|
||||||
destVolumeName,secondaryStoragePool);
|
destVolumeName,secondaryStoragePool);
|
||||||
return new CopyVolumeAnswer(cmd, true, null, null, volumeName);
|
return new CopyVolumeAnswer(cmd, true, null, null, volumeName);
|
||||||
} else {
|
} else {
|
||||||
volumePath = "/volumes/" + cmd.getVolumeId() + File.separator;
|
volumePath = "/volumes/" + cmd.getVolumeId() + File.separator;
|
||||||
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(
|
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(
|
||||||
secondaryStorageUrl
|
secondaryStorageUrl
|
||||||
+ volumePath);
|
+ volumePath);
|
||||||
KVMPhysicalDisk volume = secondaryStoragePool
|
KVMPhysicalDisk volume = secondaryStoragePool
|
||||||
.getPhysicalDisk(cmd.getVolumePath() + ".qcow2");
|
.getPhysicalDisk(cmd.getVolumePath() + ".qcow2");
|
||||||
_storagePoolMgr.copyPhysicalDisk(volume, volumeName,
|
_storagePoolMgr.copyPhysicalDisk(volume, volumeName,
|
||||||
@ -1148,7 +1137,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
protected Answer execute(DeleteStoragePoolCommand cmd) {
|
protected Answer execute(DeleteStoragePoolCommand cmd) {
|
||||||
try {
|
try {
|
||||||
_storagePoolMgr.deleteStoragePool(cmd.getPool().getType(),
|
_storagePoolMgr.deleteStoragePool(cmd.getPool().getType(),
|
||||||
cmd.getPool().getUuid());
|
cmd.getPool().getUuid());
|
||||||
return new Answer(cmd);
|
return new Answer(cmd);
|
||||||
} catch (CloudRuntimeException e) {
|
} catch (CloudRuntimeException e) {
|
||||||
return new Answer(cmd, false, e.toString());
|
return new Answer(cmd, false, e.toString());
|
||||||
@ -1190,7 +1179,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
long disksize;
|
long disksize;
|
||||||
try {
|
try {
|
||||||
primaryPool = _storagePoolMgr.getStoragePool(pool.getType(),
|
primaryPool = _storagePoolMgr.getStoragePool(pool.getType(),
|
||||||
pool.getUuid());
|
pool.getUuid());
|
||||||
disksize = dskch.getSize();
|
disksize = dskch.getSize();
|
||||||
|
|
||||||
if (cmd.getTemplateUrl() != null) {
|
if (cmd.getTemplateUrl() != null) {
|
||||||
@ -1199,7 +1188,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
} else {
|
} else {
|
||||||
BaseVol = primaryPool.getPhysicalDisk(cmd.getTemplateUrl());
|
BaseVol = primaryPool.getPhysicalDisk(cmd.getTemplateUrl());
|
||||||
vol = _storagePoolMgr.createDiskFromTemplate(BaseVol, UUID
|
vol = _storagePoolMgr.createDiskFromTemplate(BaseVol, UUID
|
||||||
.randomUUID().toString(), primaryPool);
|
.randomUUID().toString(), primaryPool);
|
||||||
}
|
}
|
||||||
if (vol == null) {
|
if (vol == null) {
|
||||||
return new Answer(cmd, false,
|
return new Answer(cmd, false,
|
||||||
@ -1273,8 +1262,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
KVMStoragePool pool = _storagePoolMgr.getStoragePool(
|
KVMStoragePool pool = _storagePoolMgr.getStoragePool(
|
||||||
vol.getPoolType(),
|
vol.getPoolType(),
|
||||||
vol.getPoolUuid());
|
vol.getPoolUuid());
|
||||||
pool.deletePhysicalDisk(vol.getPath());
|
pool.deletePhysicalDisk(vol.getPath());
|
||||||
String vmName = cmd.getVmName();
|
String vmName = cmd.getVmName();
|
||||||
String poolPath = pool.getLocalPath();
|
String poolPath = pool.getLocalPath();
|
||||||
@ -1289,7 +1278,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
_storagePoolMgr.deleteVbdByPath(vol.getPoolType(),patchVbd.getAbsolutePath());
|
_storagePoolMgr.deleteVbdByPath(vol.getPoolType(),patchVbd.getAbsolutePath());
|
||||||
} catch(CloudRuntimeException e) {
|
} catch(CloudRuntimeException e) {
|
||||||
s_logger.warn("unable to destroy patch disk '" + patchVbd.getAbsolutePath() +
|
s_logger.warn("unable to destroy patch disk '" + patchVbd.getAbsolutePath() +
|
||||||
"' while removing root disk for " + vmName + " : " + e);
|
"' while removing root disk for " + vmName + " : " + e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("file '" +patchVbd.getAbsolutePath()+ "' not found");
|
s_logger.debug("file '" +patchVbd.getAbsolutePath()+ "' not found");
|
||||||
@ -1425,7 +1414,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
String dev = "eth" + nic.getDeviceId();
|
String dev = "eth" + nic.getDeviceId();
|
||||||
String netmask = NetUtils.getSubNet(routerGIP, nic.getNetmask());
|
String netmask = NetUtils.getSubNet(routerGIP, nic.getNetmask());
|
||||||
String result = _virtRouterResource.assignGuestNetwork(dev, routerIP,
|
String result = _virtRouterResource.assignGuestNetwork(dev, routerIP,
|
||||||
routerGIP, gateway, cidr, netmask, dns, domainName );
|
routerGIP, gateway, cidr, netmask, dns, domainName );
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return new SetupGuestNetworkAnswer(cmd, false, "Creating guest network failed due to " + result);
|
return new SetupGuestNetworkAnswer(cmd, false, "Creating guest network failed due to " + result);
|
||||||
@ -1461,7 +1450,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
|
|
||||||
String rule = sb.toString();
|
String rule = sb.toString();
|
||||||
String result = _virtRouterResource.assignNetworkACL(routerIp,
|
String result = _virtRouterResource.assignNetworkACL(routerIp,
|
||||||
dev, nic.getIp(), netmask, rule);
|
dev, nic.getIp(), netmask, rule);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
for (int i=0; i < results.length; i++) {
|
for (int i=0; i < results.length; i++) {
|
||||||
@ -1492,21 +1481,21 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
List<InterfaceDef> pluggedNics = getInterfaces(conn, routerName);
|
List<InterfaceDef> pluggedNics = getInterfaces(conn, routerName);
|
||||||
|
|
||||||
for (InterfaceDef pluggedNic : pluggedNics) {
|
for (InterfaceDef pluggedNic : pluggedNics) {
|
||||||
String pluggedVlanBr = pluggedNic.getBrName();
|
String pluggedVlanBr = pluggedNic.getBrName();
|
||||||
String pluggedVlanId = getVlanIdFromBridge(pluggedVlanBr);
|
String pluggedVlanId = getVlanIdFromBridge(pluggedVlanBr);
|
||||||
if (pubVlan.equalsIgnoreCase(Vlan.UNTAGGED)
|
if (pubVlan.equalsIgnoreCase(Vlan.UNTAGGED)
|
||||||
&& pluggedVlanBr.equalsIgnoreCase(_publicBridgeName)) {
|
&& pluggedVlanBr.equalsIgnoreCase(_publicBridgeName)) {
|
||||||
break;
|
break;
|
||||||
} else if (pluggedVlanBr.equalsIgnoreCase(_linkLocalBridgeName)){
|
} else if (pluggedVlanBr.equalsIgnoreCase(_linkLocalBridgeName)){
|
||||||
/*skip over, no physical bridge device exists*/
|
/*skip over, no physical bridge device exists*/
|
||||||
} else if (pluggedVlanId == null) {
|
} else if (pluggedVlanId == null) {
|
||||||
/*this should only be true in the case of link local bridge*/
|
/*this should only be true in the case of link local bridge*/
|
||||||
return new SetSourceNatAnswer(cmd, false, "unable to find the vlan id for bridge "+pluggedVlanBr+
|
return new SetSourceNatAnswer(cmd, false, "unable to find the vlan id for bridge "+pluggedVlanBr+
|
||||||
" when attempting to set up" + pubVlan + " on router " + routerName);
|
" when attempting to set up" + pubVlan + " on router " + routerName);
|
||||||
} else if (pluggedVlanId.equals(pubVlan)) {
|
} else if (pluggedVlanId.equals(pubVlan)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
devNum++;
|
devNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
String dev = "eth" + devNum;
|
String dev = "eth" + devNum;
|
||||||
@ -1544,8 +1533,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
vlanToNicNum.put("LinkLocal",devNum);
|
vlanToNicNum.put("LinkLocal",devNum);
|
||||||
}
|
}
|
||||||
else if (pluggedVlan.equalsIgnoreCase(_publicBridgeName)
|
else if (pluggedVlan.equalsIgnoreCase(_publicBridgeName)
|
||||||
|| pluggedVlan.equalsIgnoreCase(_privBridgeName)
|
|| pluggedVlan.equalsIgnoreCase(_privBridgeName)
|
||||||
|| pluggedVlan.equalsIgnoreCase(_guestBridgeName)) {
|
|| pluggedVlan.equalsIgnoreCase(_guestBridgeName)) {
|
||||||
vlanToNicNum.put(Vlan.UNTAGGED,devNum);
|
vlanToNicNum.put(Vlan.UNTAGGED,devNum);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1560,7 +1549,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
String netmask = Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask()));
|
String netmask = Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask()));
|
||||||
String subnet = NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask());
|
String subnet = NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask());
|
||||||
_virtRouterResource.assignVpcIpToRouter(routerIP, ip.isAdd(), ip.getPublicIp(),
|
_virtRouterResource.assignVpcIpToRouter(routerIP, ip.isAdd(), ip.getPublicIp(),
|
||||||
nicName, ip.getVlanGateway(), netmask, subnet);
|
nicName, ip.getVlanGateway(), netmask, subnet);
|
||||||
results[i++] = ip.getPublicIp() + " - success";
|
results[i++] = ip.getPublicIp() + " - success";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1587,14 +1576,14 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
if (nic.getBrName().equalsIgnoreCase(_linkLocalBridgeName)) {
|
if (nic.getBrName().equalsIgnoreCase(_linkLocalBridgeName)) {
|
||||||
vlanAllocatedToVM.put("LinkLocal", nicPos);
|
vlanAllocatedToVM.put("LinkLocal", nicPos);
|
||||||
} else {
|
} else {
|
||||||
if (nic.getBrName().equalsIgnoreCase(_publicBridgeName)
|
if (nic.getBrName().equalsIgnoreCase(_publicBridgeName)
|
||||||
|| nic.getBrName().equalsIgnoreCase(_privBridgeName)
|
|| nic.getBrName().equalsIgnoreCase(_privBridgeName)
|
||||||
|| nic.getBrName().equalsIgnoreCase(_guestBridgeName)) {
|
|| nic.getBrName().equalsIgnoreCase(_guestBridgeName)) {
|
||||||
vlanAllocatedToVM.put(Vlan.UNTAGGED, nicPos);
|
vlanAllocatedToVM.put(Vlan.UNTAGGED, nicPos);
|
||||||
} else {
|
} else {
|
||||||
String vlanId = getVlanIdFromBridge(nic.getBrName());
|
String vlanId = getVlanIdFromBridge(nic.getBrName());
|
||||||
vlanAllocatedToVM.put(vlanId, nicPos);
|
vlanAllocatedToVM.put(vlanId, nicPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nicPos++;
|
nicPos++;
|
||||||
}
|
}
|
||||||
@ -1649,13 +1638,13 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(
|
KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(
|
||||||
cmd.getPool().getType(),
|
cmd.getPool().getType(),
|
||||||
cmd.getPool().getUuid());
|
cmd.getPool().getUuid());
|
||||||
|
|
||||||
if (primaryPool.getType() == StoragePoolType.RBD) {
|
if (primaryPool.getType() == StoragePoolType.RBD) {
|
||||||
s_logger.debug("Snapshots are not supported on RBD volumes");
|
s_logger.debug("Snapshots are not supported on RBD volumes");
|
||||||
return new ManageSnapshotAnswer(cmd, false,
|
return new ManageSnapshotAnswer(cmd, false,
|
||||||
"Snapshots are not supported on RBD volumes");
|
"Snapshots are not supported on RBD volumes");
|
||||||
}
|
}
|
||||||
|
|
||||||
KVMPhysicalDisk disk = primaryPool.getPhysicalDisk(cmd
|
KVMPhysicalDisk disk = primaryPool.getPhysicalDisk(cmd
|
||||||
@ -1728,7 +1717,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
Connect conn = LibvirtConnection.getConnection();
|
Connect conn = LibvirtConnection.getConnection();
|
||||||
|
|
||||||
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(
|
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(
|
||||||
secondaryStoragePoolUrl);
|
secondaryStoragePoolUrl);
|
||||||
|
|
||||||
String ssPmountPath = secondaryStoragePool.getLocalPath();
|
String ssPmountPath = secondaryStoragePool.getLocalPath();
|
||||||
snapshotRelPath = File.separator + "snapshots" + File.separator
|
snapshotRelPath = File.separator + "snapshots" + File.separator
|
||||||
@ -1739,8 +1728,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
+ File.separator + dcId + File.separator + accountId
|
+ File.separator + dcId + File.separator + accountId
|
||||||
+ File.separator + volumeId;
|
+ File.separator + volumeId;
|
||||||
KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(
|
KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(
|
||||||
cmd.getPool().getType(),
|
cmd.getPool().getType(),
|
||||||
cmd.getPrimaryStoragePoolNameLabel());
|
cmd.getPrimaryStoragePoolNameLabel());
|
||||||
KVMPhysicalDisk snapshotDisk = primaryPool.getPhysicalDisk(cmd
|
KVMPhysicalDisk snapshotDisk = primaryPool.getPhysicalDisk(cmd
|
||||||
.getVolumePath());
|
.getVolumePath());
|
||||||
Script command = new Script(_manageSnapshotPath, _cmdsTimeout,
|
Script command = new Script(_manageSnapshotPath, _cmdsTimeout,
|
||||||
@ -1768,8 +1757,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
KVMStoragePool primaryStorage = _storagePoolMgr.getStoragePool(
|
KVMStoragePool primaryStorage = _storagePoolMgr.getStoragePool(
|
||||||
cmd.getPool().getType(),
|
cmd.getPool().getType(),
|
||||||
cmd.getPool().getUuid());
|
cmd.getPool().getUuid());
|
||||||
if (state == DomainInfo.DomainState.VIR_DOMAIN_RUNNING
|
if (state == DomainInfo.DomainState.VIR_DOMAIN_RUNNING
|
||||||
&& !primaryStorage.isExternalSnapshot()) {
|
&& !primaryStorage.isExternalSnapshot()) {
|
||||||
String vmUuid = vm.getUUIDString();
|
String vmUuid = vm.getUUIDString();
|
||||||
@ -1853,7 +1842,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
KVMStoragePool secondaryStoragePool = null;
|
KVMStoragePool secondaryStoragePool = null;
|
||||||
try {
|
try {
|
||||||
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(cmd
|
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(cmd
|
||||||
.getSecondaryStorageUrl());
|
.getSecondaryStorageUrl());
|
||||||
|
|
||||||
String ssPmountPath = secondaryStoragePool.getLocalPath();
|
String ssPmountPath = secondaryStoragePool.getLocalPath();
|
||||||
String snapshotDestPath = ssPmountPath + File.separator
|
String snapshotDestPath = ssPmountPath + File.separator
|
||||||
@ -1884,15 +1873,15 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
int index = snapshotPath.lastIndexOf("/");
|
int index = snapshotPath.lastIndexOf("/");
|
||||||
snapshotPath = snapshotPath.substring(0, index);
|
snapshotPath = snapshotPath.substring(0, index);
|
||||||
KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(
|
KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(
|
||||||
cmd.getSecondaryStorageUrl()
|
cmd.getSecondaryStorageUrl()
|
||||||
+ snapshotPath);
|
+ snapshotPath);
|
||||||
KVMPhysicalDisk snapshot = secondaryPool.getPhysicalDisk(cmd
|
KVMPhysicalDisk snapshot = secondaryPool.getPhysicalDisk(cmd
|
||||||
.getSnapshotName());
|
.getSnapshotName());
|
||||||
|
|
||||||
String primaryUuid = cmd.getPrimaryStoragePoolNameLabel();
|
String primaryUuid = cmd.getPrimaryStoragePoolNameLabel();
|
||||||
KVMStoragePool primaryPool = _storagePoolMgr
|
KVMStoragePool primaryPool = _storagePoolMgr
|
||||||
.getStoragePool(cmd.getPool().getType(),
|
.getStoragePool(cmd.getPool().getType(),
|
||||||
primaryUuid);
|
primaryUuid);
|
||||||
String volUuid = UUID.randomUUID().toString();
|
String volUuid = UUID.randomUUID().toString();
|
||||||
KVMPhysicalDisk disk = _storagePoolMgr.copyPhysicalDisk(snapshot,
|
KVMPhysicalDisk disk = _storagePoolMgr.copyPhysicalDisk(snapshot,
|
||||||
volUuid, primaryPool);
|
volUuid, primaryPool);
|
||||||
@ -1928,7 +1917,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
.getSnapshotName());
|
.getSnapshotName());
|
||||||
|
|
||||||
secondaryPool = _storagePoolMgr.getStoragePoolByURI(
|
secondaryPool = _storagePoolMgr.getStoragePoolByURI(
|
||||||
cmd.getSecondaryStorageUrl());
|
cmd.getSecondaryStorageUrl());
|
||||||
|
|
||||||
String templatePath = secondaryPool.getLocalPath() + File.separator
|
String templatePath = secondaryPool.getLocalPath() + File.separator
|
||||||
+ templateInstallFolder;
|
+ templateInstallFolder;
|
||||||
@ -1978,8 +1967,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
|
protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
|
||||||
try {
|
try {
|
||||||
KVMStoragePool sp = _storagePoolMgr.getStoragePool(
|
KVMStoragePool sp = _storagePoolMgr.getStoragePool(
|
||||||
cmd.getPooltype(),
|
cmd.getPooltype(),
|
||||||
cmd.getStorageId());
|
cmd.getStorageId());
|
||||||
return new GetStorageStatsAnswer(cmd, sp.getCapacity(),
|
return new GetStorageStatsAnswer(cmd, sp.getCapacity(),
|
||||||
sp.getUsed());
|
sp.getUsed());
|
||||||
} catch (CloudRuntimeException e) {
|
} catch (CloudRuntimeException e) {
|
||||||
@ -1999,11 +1988,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
String templateInstallFolder = "/template/tmpl/" + templateFolder;
|
String templateInstallFolder = "/template/tmpl/" + templateFolder;
|
||||||
|
|
||||||
secondaryStorage = _storagePoolMgr.getStoragePoolByURI(
|
secondaryStorage = _storagePoolMgr.getStoragePoolByURI(
|
||||||
secondaryStorageURL);
|
secondaryStorageURL);
|
||||||
|
|
||||||
KVMStoragePool primary = _storagePoolMgr.getStoragePool(
|
KVMStoragePool primary = _storagePoolMgr.getStoragePool(
|
||||||
cmd.getPool().getType(),
|
cmd.getPool().getType(),
|
||||||
cmd.getPrimaryStoragePoolNameLabel());
|
cmd.getPrimaryStoragePoolNameLabel());
|
||||||
KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath());
|
KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath());
|
||||||
String tmpltPath = secondaryStorage.getLocalPath() + File.separator
|
String tmpltPath = secondaryStorage.getLocalPath() + File.separator
|
||||||
+ templateInstallFolder;
|
+ templateInstallFolder;
|
||||||
@ -2024,12 +2013,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
} else {
|
} else {
|
||||||
s_logger.debug("Converting RBD disk " + disk.getPath() + " into template " + cmd.getUniqueName());
|
s_logger.debug("Converting RBD disk " + disk.getPath() + " into template " + cmd.getUniqueName());
|
||||||
Script.runSimpleBashScript("qemu-img convert"
|
Script.runSimpleBashScript("qemu-img convert"
|
||||||
+ " -f raw -O qcow2 "
|
+ " -f raw -O qcow2 "
|
||||||
+ KVMPhysicalDisk.RBDStringBuilder(primary.getSourceHost(),
|
+ KVMPhysicalDisk.RBDStringBuilder(primary.getSourceHost(),
|
||||||
primary.getSourcePort(),
|
primary.getSourcePort(),
|
||||||
primary.getAuthUserName(),
|
primary.getAuthUserName(),
|
||||||
primary.getAuthSecret(),
|
primary.getAuthSecret(),
|
||||||
disk.getPath())
|
disk.getPath())
|
||||||
+ " " + tmpltPath + "/" + cmd.getUniqueName() + ".qcow2");
|
+ " " + tmpltPath + "/" + cmd.getUniqueName() + ".qcow2");
|
||||||
File templateProp = new File(tmpltPath + "/template.properties");
|
File templateProp = new File(tmpltPath + "/template.properties");
|
||||||
if (!templateProp.exists()) {
|
if (!templateProp.exists()) {
|
||||||
@ -2126,8 +2115,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
|
|
||||||
/* Copy volume to primary storage */
|
/* Copy volume to primary storage */
|
||||||
KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(
|
KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(
|
||||||
cmd.getPool().getType(),
|
cmd.getPool().getType(),
|
||||||
cmd.getPoolUuid());
|
cmd.getPoolUuid());
|
||||||
|
|
||||||
KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(
|
KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(
|
||||||
tmplVol, UUID.randomUUID().toString(), primaryPool);
|
tmplVol, UUID.randomUUID().toString(), primaryPool);
|
||||||
@ -2233,7 +2222,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
|
|
||||||
final StringBuffer sb = new StringBuffer();
|
final StringBuffer sb = new StringBuffer();
|
||||||
sb.append("http://").append(proxyManagementIp).append(":" + cmdPort)
|
sb.append("http://").append(proxyManagementIp).append(":" + cmdPort)
|
||||||
.append("/cmd/getstatus");
|
.append("/cmd/getstatus");
|
||||||
|
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
try {
|
try {
|
||||||
@ -2291,8 +2280,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
try {
|
try {
|
||||||
Connect conn = LibvirtConnection.getConnection();
|
Connect conn = LibvirtConnection.getConnection();
|
||||||
KVMStoragePool primary = _storagePoolMgr.getStoragePool(
|
KVMStoragePool primary = _storagePoolMgr.getStoragePool(
|
||||||
cmd.getPooltype(),
|
cmd.getPooltype(),
|
||||||
cmd.getPoolUuid());
|
cmd.getPoolUuid());
|
||||||
KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath());
|
KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath());
|
||||||
attachOrDetachDisk(conn, cmd.getAttach(), cmd.getVmName(), disk,
|
attachOrDetachDisk(conn, cmd.getAttach(), cmd.getVmName(), disk,
|
||||||
cmd.getDeviceId().intValue());
|
cmd.getDeviceId().intValue());
|
||||||
@ -2364,10 +2353,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
private Answer execute(PingTestCommand cmd) {
|
private Answer execute(PingTestCommand cmd) {
|
||||||
String result = null;
|
String result = null;
|
||||||
final String computingHostIp = cmd.getComputingHostIp(); // TODO, split
|
final String computingHostIp = cmd.getComputingHostIp(); // TODO, split
|
||||||
// the
|
// the
|
||||||
// command
|
// command
|
||||||
// into 2
|
// into 2
|
||||||
// types
|
// types
|
||||||
|
|
||||||
if (computingHostIp != null) {
|
if (computingHostIp != null) {
|
||||||
result = doPingTest(computingHostIp);
|
result = doPingTest(computingHostIp);
|
||||||
@ -2507,7 +2496,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
final Script cpuScript = new Script("/bin/bash", s_logger);
|
final Script cpuScript = new Script("/bin/bash", s_logger);
|
||||||
cpuScript.add("-c");
|
cpuScript.add("-c");
|
||||||
cpuScript
|
cpuScript
|
||||||
.add("idle=$(top -b -n 1|grep Cpu\\(s\\):|cut -d% -f4|cut -d, -f2);echo $idle");
|
.add("idle=$(top -b -n 1|grep Cpu\\(s\\):|cut -d% -f4|cut -d, -f2);echo $idle");
|
||||||
|
|
||||||
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
|
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
|
||||||
String result = cpuScript.execute(parser);
|
String result = cpuScript.execute(parser);
|
||||||
@ -2521,7 +2510,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
final Script memScript = new Script("/bin/bash", s_logger);
|
final Script memScript = new Script("/bin/bash", s_logger);
|
||||||
memScript.add("-c");
|
memScript.add("-c");
|
||||||
memScript
|
memScript
|
||||||
.add("freeMem=$(free|grep cache:|awk '{print $4}');echo $freeMem");
|
.add("freeMem=$(free|grep cache:|awk '{print $4}');echo $freeMem");
|
||||||
final OutputInterpreter.OneLineParser Memparser = new OutputInterpreter.OneLineParser();
|
final OutputInterpreter.OneLineParser Memparser = new OutputInterpreter.OneLineParser();
|
||||||
result = memScript.execute(Memparser);
|
result = memScript.execute(Memparser);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
@ -2903,7 +2892,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
for (NicTO nic : nics) {
|
for (NicTO nic : nics) {
|
||||||
if (nic.getIsolationUri() != null
|
if (nic.getIsolationUri() != null
|
||||||
&& nic.getIsolationUri().getScheme()
|
&& nic.getIsolationUri().getScheme()
|
||||||
.equalsIgnoreCase(IsolationType.Ec2.toString())) {
|
.equalsIgnoreCase(IsolationType.Ec2.toString())) {
|
||||||
if (vmSpec.getType() != VirtualMachine.Type.User) {
|
if (vmSpec.getType() != VirtualMachine.Type.User) {
|
||||||
default_network_rules_for_systemvm(conn, vmName);
|
default_network_rules_for_systemvm(conn, vmName);
|
||||||
break;
|
break;
|
||||||
@ -2940,7 +2929,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
String path = isoPath.substring(0, index);
|
String path = isoPath.substring(0, index);
|
||||||
String name = isoPath.substring(index + 1);
|
String name = isoPath.substring(index + 1);
|
||||||
KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(
|
KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(
|
||||||
path);
|
path);
|
||||||
KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name);
|
KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name);
|
||||||
return isoVol.getPath();
|
return isoVol.getPath();
|
||||||
} else {
|
} else {
|
||||||
@ -2968,12 +2957,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
String volDir = volPath.substring(0, index);
|
String volDir = volPath.substring(0, index);
|
||||||
String volName = volPath.substring(index + 1);
|
String volName = volPath.substring(index + 1);
|
||||||
KVMStoragePool secondaryStorage = _storagePoolMgr.
|
KVMStoragePool secondaryStorage = _storagePoolMgr.
|
||||||
getStoragePoolByURI(volDir);
|
getStoragePoolByURI(volDir);
|
||||||
physicalDisk = secondaryStorage.getPhysicalDisk(volName);
|
physicalDisk = secondaryStorage.getPhysicalDisk(volName);
|
||||||
} else if (volume.getType() != Volume.Type.ISO) {
|
} else if (volume.getType() != Volume.Type.ISO) {
|
||||||
pool = _storagePoolMgr.getStoragePool(
|
pool = _storagePoolMgr.getStoragePool(
|
||||||
volume.getPoolType(),
|
volume.getPoolType(),
|
||||||
volume.getPoolUuid());
|
volume.getPoolUuid());
|
||||||
physicalDisk = pool.getPhysicalDisk(volume.getPath());
|
physicalDisk = pool.getPhysicalDisk(volume.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2999,23 +2988,23 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
For RBD pools we use the secret mechanism in libvirt.
|
For RBD pools we use the secret mechanism in libvirt.
|
||||||
We store the secret under the UUID of the pool, that's why
|
We store the secret under the UUID of the pool, that's why
|
||||||
we pass the pool's UUID as the authSecret
|
we pass the pool's UUID as the authSecret
|
||||||
*/
|
*/
|
||||||
disk.defNetworkBasedDisk(physicalDisk.getPath().replace("rbd:", ""), pool.getSourceHost(), pool.getSourcePort(),
|
disk.defNetworkBasedDisk(physicalDisk.getPath().replace("rbd:", ""), pool.getSourceHost(), pool.getSourcePort(),
|
||||||
pool.getAuthUserName(), pool.getUuid(),
|
pool.getAuthUserName(), pool.getUuid(),
|
||||||
devId, diskBusType, diskProtocol.RBD);
|
devId, diskBusType, diskProtocol.RBD);
|
||||||
} else if (pool.getType() == StoragePoolType.CLVM) {
|
} else if (pool.getType() == StoragePoolType.CLVM) {
|
||||||
disk.defBlockBasedDisk(physicalDisk.getPath(), devId,
|
disk.defBlockBasedDisk(physicalDisk.getPath(), devId,
|
||||||
diskBusType);
|
diskBusType);
|
||||||
} else {
|
} else {
|
||||||
if (volume.getType() == Volume.Type.DATADISK) {
|
if (volume.getType() == Volume.Type.DATADISK) {
|
||||||
disk.defFileBasedDisk(physicalDisk.getPath(), devId,
|
disk.defFileBasedDisk(physicalDisk.getPath(), devId,
|
||||||
DiskDef.diskBus.VIRTIO,
|
DiskDef.diskBus.VIRTIO,
|
||||||
DiskDef.diskFmtType.QCOW2);
|
DiskDef.diskFmtType.QCOW2);
|
||||||
} else {
|
} else {
|
||||||
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusType, DiskDef.diskFmtType.QCOW2);
|
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusType, DiskDef.diskFmtType.QCOW2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3052,8 +3041,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
VolumeTO rootVol = getVolume(vmSpec, Volume.Type.ROOT);
|
VolumeTO rootVol = getVolume(vmSpec, Volume.Type.ROOT);
|
||||||
String patchName = vmName + "-patchdisk";
|
String patchName = vmName + "-patchdisk";
|
||||||
KVMStoragePool pool = _storagePoolMgr.getStoragePool(
|
KVMStoragePool pool = _storagePoolMgr.getStoragePool(
|
||||||
rootVol.getPoolType(),
|
rootVol.getPoolType(),
|
||||||
rootVol.getPoolUuid());
|
rootVol.getPoolUuid());
|
||||||
String patchDiskPath = pool.getLocalPath() + "/" + patchName;
|
String patchDiskPath = pool.getLocalPath() + "/" + patchName;
|
||||||
|
|
||||||
List<KVMPhysicalDisk> phyDisks = pool.listPhysicalDisks();
|
List<KVMPhysicalDisk> phyDisks = pool.listPhysicalDisks();
|
||||||
@ -3069,7 +3058,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
if (!foundDisk) {
|
if (!foundDisk) {
|
||||||
s_logger.debug("generating new patch disk for " + vmName + " since none was found");
|
s_logger.debug("generating new patch disk for " + vmName + " since none was found");
|
||||||
KVMPhysicalDisk disk = pool.createPhysicalDisk(patchName, KVMPhysicalDisk.PhysicalDiskFormat.RAW,
|
KVMPhysicalDisk disk = pool.createPhysicalDisk(patchName, KVMPhysicalDisk.PhysicalDiskFormat.RAW,
|
||||||
10L * 1024 * 1024);
|
10L * 1024 * 1024);
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("found existing patch disk at " + patchDiskPath + " using it for " + vmName);
|
s_logger.debug("found existing patch disk at " + patchDiskPath + " using it for " + vmName);
|
||||||
}
|
}
|
||||||
@ -3091,7 +3080,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
patchDisk.defBlockBasedDisk(patchDiskPath, 1, rootDisk.getBusType());
|
patchDisk.defBlockBasedDisk(patchDiskPath, 1, rootDisk.getBusType());
|
||||||
} else {
|
} else {
|
||||||
patchDisk.defFileBasedDisk(patchDiskPath, 1, rootDisk.getBusType(),
|
patchDisk.defFileBasedDisk(patchDiskPath, 1, rootDisk.getBusType(),
|
||||||
DiskDef.diskFmtType.RAW);
|
DiskDef.diskFmtType.RAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
disks.add(patchDisk);
|
disks.add(patchDisk);
|
||||||
@ -3162,14 +3151,14 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
|
|
||||||
protected synchronized String attachOrDetachISO(Connect conn,
|
protected synchronized String attachOrDetachISO(Connect conn,
|
||||||
String vmName, String isoPath, boolean isAttach)
|
String vmName, String isoPath, boolean isAttach)
|
||||||
throws LibvirtException, URISyntaxException, InternalErrorException {
|
throws LibvirtException, URISyntaxException, InternalErrorException {
|
||||||
String isoXml = null;
|
String isoXml = null;
|
||||||
if (isoPath != null && isAttach) {
|
if (isoPath != null && isAttach) {
|
||||||
int index = isoPath.lastIndexOf("/");
|
int index = isoPath.lastIndexOf("/");
|
||||||
String path = isoPath.substring(0, index);
|
String path = isoPath.substring(0, index);
|
||||||
String name = isoPath.substring(index + 1);
|
String name = isoPath.substring(index + 1);
|
||||||
KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(
|
KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(
|
||||||
path);
|
path);
|
||||||
KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name);
|
KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name);
|
||||||
isoPath = isoVol.getPath();
|
isoPath = isoVol.getPath();
|
||||||
|
|
||||||
@ -3691,9 +3680,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
info.add(ram);
|
info.add(ram);
|
||||||
info.add(cap);
|
info.add(cap);
|
||||||
long dom0ram = Math.min(ram / 10, 768 * 1024 * 1024L);// save a maximum
|
long dom0ram = Math.min(ram / 10, 768 * 1024 * 1024L);// save a maximum
|
||||||
// of 10% of
|
// of 10% of
|
||||||
// system ram or
|
// system ram or
|
||||||
// 768M
|
// 768M
|
||||||
dom0ram = Math.max(dom0ram, _dom0MinMem);
|
dom0ram = Math.max(dom0ram, _dom0MinMem);
|
||||||
info.add(dom0ram);
|
info.add(dom0ram);
|
||||||
s_logger.debug("cpus=" + cpus + ", speed=" + speed + ", ram=" + ram
|
s_logger.debug("cpus=" + cpus + ", speed=" + speed + ", ram=" + ram
|
||||||
@ -4162,7 +4151,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
NodeInfo node = conn.nodeInfo();
|
NodeInfo node = conn.nodeInfo();
|
||||||
utilization = utilization / node.cpus;
|
utilization = utilization / node.cpus;
|
||||||
if(utilization > 0){
|
if(utilization > 0){
|
||||||
stats.setCPUUtilization(utilization * 100);
|
stats.setCPUUtilization(utilization * 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -84,6 +84,10 @@ public class ApiDispatcher {
|
|||||||
|
|
||||||
private static ApiDispatcher s_instance;
|
private static ApiDispatcher s_instance;
|
||||||
|
|
||||||
|
public static ApiDispatcher getInstance() {
|
||||||
|
return s_instance;
|
||||||
|
}
|
||||||
|
|
||||||
protected ApiDispatcher() {
|
protected ApiDispatcher() {
|
||||||
super();
|
super();
|
||||||
Map<String, String> configs = _configDao.getConfiguration();
|
Map<String, String> configs = _configDao.getConfiguration();
|
||||||
|
|||||||
@ -19,26 +19,28 @@ package com.cloud.api.commands;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.APICommand;
|
||||||
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
|
import org.apache.cloudstack.api.BaseListCmd;
|
||||||
|
import org.apache.cloudstack.api.Parameter;
|
||||||
import org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd;
|
import org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd;
|
||||||
|
import org.apache.cloudstack.api.response.ListResponse;
|
||||||
|
import org.apache.cloudstack.api.response.TrafficMonitorResponse;
|
||||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.BaseListCmd;
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.response.ListResponse;
|
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.network.NetworkUsageManager;
|
import com.cloud.network.NetworkUsageManager;
|
||||||
import com.cloud.server.ManagementService;
|
|
||||||
import org.apache.cloudstack.api.response.TrafficMonitorResponse;
|
|
||||||
|
|
||||||
|
|
||||||
@APICommand(name = "listTrafficMonitors", description="List traffic monitor Hosts.", responseObject = TrafficMonitorResponse.class)
|
@APICommand(name = "listTrafficMonitors", description="List traffic monitor Hosts.", responseObject = TrafficMonitorResponse.class)
|
||||||
public class ListTrafficMonitorsCmd extends BaseListCmd {
|
public class ListTrafficMonitorsCmd extends BaseListCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName());
|
||||||
private static final String s_name = "listtrafficmonitorsresponse";
|
private static final String s_name = "listtrafficmonitorsresponse";
|
||||||
|
|
||||||
|
@Inject NetworkUsageManager networkUsageMgr;
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
//////////////// API parameters /////////////////////
|
//////////////// API parameters /////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
@ -66,17 +68,15 @@ public class ListTrafficMonitorsCmd extends BaseListCmd {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(){
|
public void execute(){
|
||||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
List<? extends Host> trafficMonitors = networkUsageMgr.listTrafficMonitors(this);
|
||||||
NetworkUsageManager networkUsageMgr = locator.getManager(NetworkUsageManager.class);
|
|
||||||
List<? extends Host> trafficMonitors = networkUsageMgr.listTrafficMonitors(this);
|
|
||||||
|
|
||||||
ListResponse<TrafficMonitorResponse> listResponse = new ListResponse<TrafficMonitorResponse>();
|
ListResponse<TrafficMonitorResponse> listResponse = new ListResponse<TrafficMonitorResponse>();
|
||||||
List<TrafficMonitorResponse> responses = new ArrayList<TrafficMonitorResponse>();
|
List<TrafficMonitorResponse> responses = new ArrayList<TrafficMonitorResponse>();
|
||||||
for (Host trafficMonitor : trafficMonitors) {
|
for (Host trafficMonitor : trafficMonitors) {
|
||||||
TrafficMonitorResponse response = networkUsageMgr.getApiResponse(trafficMonitor);
|
TrafficMonitorResponse response = networkUsageMgr.getApiResponse(trafficMonitor);
|
||||||
response.setObjectName("trafficmonitor");
|
response.setObjectName("trafficmonitor");
|
||||||
response.setResponseName(getCommandName());
|
response.setResponseName(getCommandName());
|
||||||
responses.add(response);
|
responses.add(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
listResponse.setResponses(responses);
|
listResponse.setResponses(responses);
|
||||||
|
|||||||
@ -42,10 +42,13 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
|
import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
|
||||||
|
import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
@ -53,9 +56,6 @@ import com.cloud.agent.api.DeleteTemplateFromS3Command;
|
|||||||
import com.cloud.agent.api.DownloadTemplateFromS3ToSecondaryStorageCommand;
|
import com.cloud.agent.api.DownloadTemplateFromS3ToSecondaryStorageCommand;
|
||||||
import com.cloud.agent.api.UploadTemplateToS3FromSecondaryStorageCommand;
|
import com.cloud.agent.api.UploadTemplateToS3FromSecondaryStorageCommand;
|
||||||
import com.cloud.agent.api.to.S3TO;
|
import com.cloud.agent.api.to.S3TO;
|
||||||
import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
@ -77,7 +77,6 @@ import com.cloud.storage.dao.VMTemplateS3Dao;
|
|||||||
import com.cloud.storage.dao.VMTemplateZoneDao;
|
import com.cloud.storage.dao.VMTemplateZoneDao;
|
||||||
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
||||||
import com.cloud.utils.S3Utils.ClientOptions;
|
import com.cloud.utils.S3Utils.ClientOptions;
|
||||||
|
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
@ -288,32 +287,32 @@ public class S3ManagerImpl implements S3Manager {
|
|||||||
executeWithNoWaitLock(determineLockId(accountId, templateId),
|
executeWithNoWaitLock(determineLockId(accountId, templateId),
|
||||||
new Callable<Void>() {
|
new Callable<Void>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
|
|
||||||
final Answer answer = agentManager.sendToSSVM(null,
|
final Answer answer = agentManager.sendToSSVM(null,
|
||||||
new DeleteTemplateFromS3Command(s3,
|
new DeleteTemplateFromS3Command(s3,
|
||||||
accountId, templateId));
|
accountId, templateId));
|
||||||
if (answer == null || !answer.getResult()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
final String errorMessage = format(
|
final String errorMessage = format(
|
||||||
"Delete Template Failed: Unable to delete template id %1$s from S3 due to following error: %2$s",
|
"Delete Template Failed: Unable to delete template id %1$s from S3 due to following error: %2$s",
|
||||||
templateId,
|
templateId,
|
||||||
((answer == null) ? "answer is null"
|
((answer == null) ? "answer is null"
|
||||||
: answer.getDetails()));
|
: answer.getDetails()));
|
||||||
LOGGER.error(errorMessage);
|
LOGGER.error(errorMessage);
|
||||||
throw new CloudRuntimeException(errorMessage);
|
throw new CloudRuntimeException(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
vmTemplateS3Dao.remove(vmTemplateS3VO.getId());
|
vmTemplateS3Dao.remove(vmTemplateS3VO.getId());
|
||||||
LOGGER.debug(format(
|
LOGGER.debug(format(
|
||||||
"Deleted template %1$s from S3.",
|
"Deleted template %1$s from S3.",
|
||||||
templateId));
|
templateId));
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
@ -384,38 +383,38 @@ public class S3ManagerImpl implements S3Manager {
|
|||||||
executeWithNoWaitLock(determineLockId(accountId, templateId),
|
executeWithNoWaitLock(determineLockId(accountId, templateId),
|
||||||
new Callable<Void>() {
|
new Callable<Void>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
|
|
||||||
final Answer answer = agentManager.sendToSSVM(
|
final Answer answer = agentManager.sendToSSVM(
|
||||||
dataCenterId, cmd);
|
dataCenterId, cmd);
|
||||||
|
|
||||||
if (answer == null || !answer.getResult()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
final String errMsg = String
|
final String errMsg = String
|
||||||
.format("Failed to download template from S3 to secondary storage due to %1$s",
|
.format("Failed to download template from S3 to secondary storage due to %1$s",
|
||||||
(answer == null ? "answer is null"
|
(answer == null ? "answer is null"
|
||||||
: answer.getDetails()));
|
: answer.getDetails()));
|
||||||
LOGGER.error(errMsg);
|
LOGGER.error(errMsg);
|
||||||
throw new CloudRuntimeException(errMsg);
|
throw new CloudRuntimeException(errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String installPath = join(
|
final String installPath = join(
|
||||||
asList("template", "tmpl", accountId,
|
asList("template", "tmpl", accountId,
|
||||||
templateId), File.separator);
|
templateId), File.separator);
|
||||||
final VMTemplateHostVO tmpltHost = new VMTemplateHostVO(
|
final VMTemplateHostVO tmpltHost = new VMTemplateHostVO(
|
||||||
secondaryStorageHost.getId(), templateId,
|
secondaryStorageHost.getId(), templateId,
|
||||||
now(), 100, Status.DOWNLOADED, null, null,
|
now(), 100, Status.DOWNLOADED, null, null,
|
||||||
null, installPath, template.getUrl());
|
null, installPath, template.getUrl());
|
||||||
tmpltHost.setSize(templateS3VO.getSize());
|
tmpltHost.setSize(templateS3VO.getSize());
|
||||||
tmpltHost.setPhysicalSize(templateS3VO
|
tmpltHost.setPhysicalSize(templateS3VO
|
||||||
.getPhysicalSize());
|
.getPhysicalSize());
|
||||||
vmTemplateHostDao.persist(tmpltHost);
|
vmTemplateHostDao.persist(tmpltHost);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
final String errMsg = "Failed to download template from S3 to secondary storage due to "
|
final String errMsg = "Failed to download template from S3 to secondary storage due to "
|
||||||
@ -608,50 +607,50 @@ public class S3ManagerImpl implements S3Manager {
|
|||||||
executeWithNoWaitLock(determineLockId(accountId, templateId),
|
executeWithNoWaitLock(determineLockId(accountId, templateId),
|
||||||
new Callable<Void>() {
|
new Callable<Void>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
|
|
||||||
final UploadTemplateToS3FromSecondaryStorageCommand cmd = new UploadTemplateToS3FromSecondaryStorageCommand(
|
final UploadTemplateToS3FromSecondaryStorageCommand cmd = new UploadTemplateToS3FromSecondaryStorageCommand(
|
||||||
s3, secondaryHost.getStorageUrl(),
|
s3, secondaryHost.getStorageUrl(),
|
||||||
dataCenterId, accountId, templateId);
|
dataCenterId, accountId, templateId);
|
||||||
|
|
||||||
final Answer answer = agentManager.sendToSSVM(
|
final Answer answer = agentManager.sendToSSVM(
|
||||||
dataCenterId, cmd);
|
dataCenterId, cmd);
|
||||||
if (answer == null || !answer.getResult()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
|
|
||||||
final String reason = answer != null ? answer
|
final String reason = answer != null ? answer
|
||||||
.getDetails()
|
.getDetails()
|
||||||
: "S3 template sync failed due to an unspecified error.";
|
: "S3 template sync failed due to an unspecified error.";
|
||||||
throw new CloudRuntimeException(
|
throw new CloudRuntimeException(
|
||||||
format("Failed to upload template id %1$s to S3 from secondary storage due to %2$s.",
|
format("Failed to upload template id %1$s to S3 from secondary storage due to %2$s.",
|
||||||
templateId, reason));
|
templateId, reason));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug(format(
|
LOGGER.debug(format(
|
||||||
"Creating VMTemplateS3VO instance using template id %1s.",
|
"Creating VMTemplateS3VO instance using template id %1s.",
|
||||||
templateId));
|
templateId));
|
||||||
}
|
}
|
||||||
|
|
||||||
final VMTemplateS3VO vmTemplateS3VO = new VMTemplateS3VO(
|
final VMTemplateS3VO vmTemplateS3VO = new VMTemplateS3VO(
|
||||||
s3.getId(), templateId, now(),
|
s3.getId(), templateId, now(),
|
||||||
templateHostRef.getSize(), templateHostRef
|
templateHostRef.getSize(), templateHostRef
|
||||||
.getPhysicalSize());
|
.getPhysicalSize());
|
||||||
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug(format("Persisting %1$s",
|
LOGGER.debug(format("Persisting %1$s",
|
||||||
vmTemplateS3VO));
|
vmTemplateS3VO));
|
||||||
}
|
}
|
||||||
|
|
||||||
vmTemplateS3Dao.persist(vmTemplateS3VO);
|
vmTemplateS3Dao.persist(vmTemplateS3VO);
|
||||||
propagateTemplateToAllZones(vmTemplateS3VO);
|
propagateTemplateToAllZones(vmTemplateS3VO);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
|||||||
@ -38,8 +38,7 @@ public class UsageServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
final ComponentLocator _locator = ComponentLocator.getLocator(UsageServer.Name, "usage-components.xml", "log4j-cloud_usage");
|
UsageManager mgr = new UsageManager();
|
||||||
UsageManager mgr = _locator.getManager(UsageManager.class);
|
|
||||||
if (mgr != null) {
|
if (mgr != null) {
|
||||||
if (s_logger.isInfoEnabled()) {
|
if (s_logger.isInfoEnabled()) {
|
||||||
s_logger.info("UsageServer ready...");
|
s_logger.info("UsageServer ready...");
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import org.junit.Assert;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.cloud.utils.component.ComponentContext;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +76,7 @@ public class TransactionTest {
|
|||||||
* that the same db connection is reused rather than acquiring a new one each time in typical transaction model.
|
* that the same db connection is reused rather than acquiring a new one each time in typical transaction model.
|
||||||
*/
|
*/
|
||||||
public void testUserManagedConnection() {
|
public void testUserManagedConnection() {
|
||||||
DbTestDao testDao = ComponentLocator.inject(DbTestDao.class);
|
DbTestDao testDao = ComponentContext.inject(DbTestDao.class);
|
||||||
Transaction txn = Transaction.open("SingleConnectionThread");
|
Transaction txn = Transaction.open("SingleConnectionThread");
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
try {
|
try {
|
||||||
@ -115,7 +115,7 @@ public class TransactionTest {
|
|||||||
* This test is simulating ClusterHeartBeat process, where the same transaction and db connection is reused.
|
* This test is simulating ClusterHeartBeat process, where the same transaction and db connection is reused.
|
||||||
*/
|
*/
|
||||||
public void testTransactionReuse() {
|
public void testTransactionReuse() {
|
||||||
DbTestDao testDao = ComponentLocator.inject(DbTestDao.class);
|
DbTestDao testDao = ComponentContext.inject(DbTestDao.class);
|
||||||
// acquire a db connection and keep it
|
// acquire a db connection and keep it
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import junit.framework.TestCase;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.utils.component.ComponentContext;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public class CglibThrowableRendererTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testException() {
|
public void testException() {
|
||||||
Test test = ComponentLocator.inject(Test.class);
|
Test test = ComponentContext.inject(Test.class);
|
||||||
try {
|
try {
|
||||||
test.exception();
|
test.exception();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user