mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix style for LibvirtComputingResource variable names and its dependencies (#7991)
* Fix style for LibvirtComputingResource variable names and its dependencies * More variable name fixes --------- Co-authored-by: Marcus Sorensen <mls@apple.com>
This commit is contained in:
parent
f069c69807
commit
28c4be1cf2
@ -83,16 +83,16 @@ import com.google.gson.Gson;
|
||||
public class ConsoleProxyResource extends ServerResourceBase implements ServerResource {
|
||||
static final Logger s_logger = Logger.getLogger(ConsoleProxyResource.class);
|
||||
|
||||
private final Properties _properties = new Properties();
|
||||
private Thread _consoleProxyMain = null;
|
||||
private final Properties properties = new Properties();
|
||||
private Thread consoleProxyMain = null;
|
||||
|
||||
long _proxyVmId;
|
||||
int _proxyPort;
|
||||
long proxyVmId;
|
||||
int proxyPort;
|
||||
|
||||
String _localgw;
|
||||
String _eth1ip;
|
||||
String _eth1mask;
|
||||
String _pubIp;
|
||||
String localGateway;
|
||||
String eth1Ip;
|
||||
String eth1Mask;
|
||||
String publicIp;
|
||||
|
||||
@Override
|
||||
public Answer executeRequest(final Command cmd) {
|
||||
@ -203,10 +203,10 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
|
||||
public synchronized StartupCommand[] initialize() {
|
||||
final StartupProxyCommand cmd = new StartupProxyCommand();
|
||||
fillNetworkInformation(cmd);
|
||||
cmd.setProxyPort(_proxyPort);
|
||||
cmd.setProxyVmId(_proxyVmId);
|
||||
if (_pubIp != null)
|
||||
cmd.setPublicIpAddress(_pubIp);
|
||||
cmd.setProxyPort(proxyPort);
|
||||
cmd.setProxyVmId(proxyVmId);
|
||||
if (publicIp != null)
|
||||
cmd.setPublicIpAddress(publicIp);
|
||||
return new StartupCommand[] {cmd};
|
||||
}
|
||||
|
||||
@ -221,10 +221,10 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_localgw = (String)params.get("localgw");
|
||||
_eth1mask = (String)params.get("eth1mask");
|
||||
_eth1ip = (String)params.get("eth1ip");
|
||||
if (_eth1ip != null) {
|
||||
localGateway = (String)params.get("localgw");
|
||||
eth1Mask = (String)params.get("eth1mask");
|
||||
eth1Ip = (String)params.get("eth1ip");
|
||||
if (eth1Ip != null) {
|
||||
params.put("private.network.device", "eth1");
|
||||
} else {
|
||||
s_logger.info("eth1ip parameter has not been configured, assuming that we are not inside a system vm");
|
||||
@ -240,40 +240,40 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
|
||||
super.configure(name, params);
|
||||
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
_properties.put(entry.getKey(), entry.getValue());
|
||||
properties.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
String value = (String)params.get("premium");
|
||||
if (value != null && value.equals("premium"))
|
||||
_proxyPort = 443;
|
||||
proxyPort = 443;
|
||||
else {
|
||||
value = (String)params.get("consoleproxy.httpListenPort");
|
||||
_proxyPort = NumbersUtil.parseInt(value, 80);
|
||||
proxyPort = NumbersUtil.parseInt(value, 80);
|
||||
}
|
||||
|
||||
value = (String)params.get("proxy_vm");
|
||||
_proxyVmId = NumbersUtil.parseLong(value, 0);
|
||||
proxyVmId = NumbersUtil.parseLong(value, 0);
|
||||
|
||||
if (_localgw != null) {
|
||||
if (localGateway != null) {
|
||||
String mgmtHosts = (String)params.get("host");
|
||||
if (_eth1ip != null) {
|
||||
if (eth1Ip != null) {
|
||||
for (final String mgmtHost : mgmtHosts.split(",")) {
|
||||
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, mgmtHost);
|
||||
addRouteToInternalIpOrCidr(localGateway, eth1Ip, eth1Mask, mgmtHost);
|
||||
}
|
||||
String internalDns1 = (String) params.get("internaldns1");
|
||||
if (internalDns1 == null) {
|
||||
s_logger.warn("No DNS entry found during configuration of ConsoleProxy");
|
||||
} else {
|
||||
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, internalDns1);
|
||||
addRouteToInternalIpOrCidr(localGateway, eth1Ip, eth1Mask, internalDns1);
|
||||
}
|
||||
String internalDns2 = (String) params.get("internaldns2");
|
||||
if (internalDns2 != null) {
|
||||
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, internalDns2);
|
||||
addRouteToInternalIpOrCidr(localGateway, eth1Ip, eth1Mask, internalDns2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_pubIp = (String)params.get("public.ip");
|
||||
publicIp = (String)params.get("public.ip");
|
||||
|
||||
value = (String)params.get("disable_rp_filter");
|
||||
if (value != null && value.equalsIgnoreCase("true")) {
|
||||
@ -281,7 +281,7 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
|
||||
}
|
||||
|
||||
if (s_logger.isInfoEnabled())
|
||||
s_logger.info("Receive proxyVmId in ConsoleProxyResource configuration as " + _proxyVmId);
|
||||
s_logger.info("Receive proxyVmId in ConsoleProxyResource configuration as " + proxyVmId);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -301,7 +301,7 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
|
||||
if (eth1ip != null && eth1mask != null) {
|
||||
inSameSubnet = NetUtils.sameSubnet(eth1ip, destIpOrCidr, eth1mask);
|
||||
} else {
|
||||
s_logger.warn("addRouteToInternalIp: unable to determine same subnet: _eth1ip=" + eth1ip + ", dest ip=" + destIpOrCidr + ", _eth1mask=" + eth1mask);
|
||||
s_logger.warn("addRouteToInternalIp: unable to determine same subnet: eth1ip=" + eth1ip + ", dest ip=" + destIpOrCidr + ", eth1mask=" + eth1mask);
|
||||
}
|
||||
} else {
|
||||
inSameSubnet = NetUtils.isNetworkAWithinNetworkB(destIpOrCidr, NetUtils.ipAndNetMaskToCidr(eth1ip, eth1mask));
|
||||
@ -327,15 +327,15 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
return name;
|
||||
}
|
||||
|
||||
private void launchConsoleProxy(final byte[] ksBits, final String ksPassword, final String encryptorPassword, final Boolean isSourceIpCheckEnabled) {
|
||||
final Object resource = this;
|
||||
s_logger.info("Building class loader for com.cloud.consoleproxy.ConsoleProxy");
|
||||
if (_consoleProxyMain == null) {
|
||||
if (consoleProxyMain == null) {
|
||||
s_logger.info("Running com.cloud.consoleproxy.ConsoleProxy with encryptor password=" + encryptorPassword);
|
||||
_consoleProxyMain = new Thread(new ManagedContextRunnable() {
|
||||
consoleProxyMain = new Thread(new ManagedContextRunnable() {
|
||||
@Override
|
||||
protected void runInContext() {
|
||||
try {
|
||||
@ -343,7 +343,7 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
|
||||
try {
|
||||
s_logger.info("Invoke startWithContext()");
|
||||
Method method = consoleProxyClazz.getMethod("startWithContext", Properties.class, Object.class, byte[].class, String.class, String.class, Boolean.class);
|
||||
method.invoke(null, _properties, resource, ksBits, ksPassword, encryptorPassword, isSourceIpCheckEnabled);
|
||||
method.invoke(null, properties, resource, ksBits, ksPassword, encryptorPassword, isSourceIpCheckEnabled);
|
||||
} catch (SecurityException e) {
|
||||
s_logger.error("Unable to launch console proxy due to SecurityException", e);
|
||||
System.exit(ExitStatus.Error.value());
|
||||
@ -366,8 +366,8 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
|
||||
}
|
||||
}
|
||||
}, "Console-Proxy-Main");
|
||||
_consoleProxyMain.setDaemon(true);
|
||||
_consoleProxyMain.start();
|
||||
consoleProxyMain.setDaemon(true);
|
||||
consoleProxyMain.start();
|
||||
} else {
|
||||
s_logger.info("com.cloud.consoleproxy.ConsoleProxy is already running");
|
||||
|
||||
@ -430,27 +430,27 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
|
||||
}
|
||||
|
||||
public void reportLoadInfo(String gsonLoadInfo) {
|
||||
ConsoleProxyLoadReportCommand cmd = new ConsoleProxyLoadReportCommand(_proxyVmId, gsonLoadInfo);
|
||||
ConsoleProxyLoadReportCommand cmd = new ConsoleProxyLoadReportCommand(proxyVmId, gsonLoadInfo);
|
||||
try {
|
||||
getAgentControl().postRequest(cmd);
|
||||
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Report proxy load info, proxy : " + _proxyVmId + ", load: " + gsonLoadInfo);
|
||||
s_logger.debug("Report proxy load info, proxy : " + proxyVmId + ", load: " + gsonLoadInfo);
|
||||
} catch (AgentControlChannelException e) {
|
||||
s_logger.error("Unable to send out load info due to " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureRoute(String address) {
|
||||
if (_localgw != null) {
|
||||
if (localGateway != null) {
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Ensure route for " + address + " via " + _localgw);
|
||||
s_logger.debug("Ensure route for " + address + " via " + localGateway);
|
||||
|
||||
// this method won't be called in high frequency, serialize access
|
||||
// to script execution
|
||||
synchronized (this) {
|
||||
try {
|
||||
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, address);
|
||||
addRouteToInternalIpOrCidr(localGateway, eth1Ip, eth1Mask, address);
|
||||
} catch (Throwable e) {
|
||||
s_logger.warn("Unexpected exception while adding internal route to " + address, e);
|
||||
}
|
||||
|
||||
@ -46,18 +46,18 @@ import com.cloud.utils.script.Script;
|
||||
|
||||
public abstract class ServerResourceBase implements ServerResource {
|
||||
private static final Logger s_logger = Logger.getLogger(ServerResourceBase.class);
|
||||
protected String _name;
|
||||
private ArrayList<String> _warnings = new ArrayList<String>();
|
||||
private ArrayList<String> _errors = new ArrayList<String>();
|
||||
protected NetworkInterface _publicNic;
|
||||
protected NetworkInterface _privateNic;
|
||||
protected NetworkInterface _storageNic;
|
||||
protected NetworkInterface _storageNic2;
|
||||
protected IAgentControl _agentControl;
|
||||
protected String name;
|
||||
private ArrayList<String> warnings = new ArrayList<String>();
|
||||
private ArrayList<String> errors = new ArrayList<String>();
|
||||
protected NetworkInterface publicNic;
|
||||
protected NetworkInterface privateNic;
|
||||
protected NetworkInterface storageNic;
|
||||
protected NetworkInterface storageNic2;
|
||||
protected IAgentControl agentControl;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
return name;
|
||||
}
|
||||
|
||||
protected String findScript(String script) {
|
||||
@ -68,15 +68,15 @@ public abstract class ServerResourceBase implements ServerResource {
|
||||
|
||||
@Override
|
||||
public boolean configure(final String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
this.name = name;
|
||||
|
||||
defineResourceNetworkInterfaces(params);
|
||||
|
||||
if (_privateNic == null) {
|
||||
if (privateNic == null) {
|
||||
tryToAutoDiscoverResourcePrivateNetworkInterface();
|
||||
}
|
||||
|
||||
String infos[] = NetUtils.getNetworkParams(_privateNic);
|
||||
String infos[] = NetUtils.getNetworkParams(privateNic);
|
||||
if (infos == null) {
|
||||
s_logger.warn("Incorrect details for private Nic during initialization of ServerResourceBase");
|
||||
return false;
|
||||
@ -97,10 +97,10 @@ public abstract class ServerResourceBase implements ServerResource {
|
||||
String storageNic = (String) params.get("storage.network.device");
|
||||
String storageNic2 = (String) params.get("storage.network.device.2");
|
||||
|
||||
_privateNic = NetUtils.getNetworkInterface(privateNic);
|
||||
_publicNic = NetUtils.getNetworkInterface(publicNic);
|
||||
_storageNic = NetUtils.getNetworkInterface(storageNic);
|
||||
_storageNic2 = NetUtils.getNetworkInterface(storageNic2);
|
||||
this.privateNic = NetUtils.getNetworkInterface(privateNic);
|
||||
this.publicNic = NetUtils.getNetworkInterface(publicNic);
|
||||
this.storageNic = NetUtils.getNetworkInterface(storageNic);
|
||||
this.storageNic2 = NetUtils.getNetworkInterface(storageNic2);
|
||||
}
|
||||
|
||||
protected void tryToAutoDiscoverResourcePrivateNetworkInterface() throws ConfigurationException {
|
||||
@ -121,7 +121,7 @@ public abstract class ServerResourceBase implements ServerResource {
|
||||
for (NetworkInterface nic : nics) {
|
||||
if (isValidNicToUseAsPrivateNic(nic)) {
|
||||
s_logger.info(String.format("Using NIC [%s] as private NIC.", nic));
|
||||
_privateNic = nic;
|
||||
privateNic = nic;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -152,8 +152,8 @@ public abstract class ServerResourceBase implements ServerResource {
|
||||
|
||||
protected void fillNetworkInformation(final StartupCommand cmd) {
|
||||
String[] info = null;
|
||||
if (_privateNic != null) {
|
||||
info = NetUtils.getNetworkParams(_privateNic);
|
||||
if (privateNic != null) {
|
||||
info = NetUtils.getNetworkParams(privateNic);
|
||||
if (info != null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Parameters for private nic: " + info[0] + " - " + info[1] + "-" + info[2]);
|
||||
@ -164,11 +164,11 @@ public abstract class ServerResourceBase implements ServerResource {
|
||||
}
|
||||
}
|
||||
|
||||
if (_storageNic != null) {
|
||||
if (storageNic != null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Storage has its now nic: " + _storageNic.getName());
|
||||
s_logger.debug("Storage has its now nic: " + storageNic.getName());
|
||||
}
|
||||
info = NetUtils.getNetworkParams(_storageNic);
|
||||
info = NetUtils.getNetworkParams(storageNic);
|
||||
}
|
||||
|
||||
// NOTE: In case you're wondering, this is not here by mistake.
|
||||
@ -181,8 +181,8 @@ public abstract class ServerResourceBase implements ServerResource {
|
||||
cmd.setStorageNetmask(info[2]);
|
||||
}
|
||||
|
||||
if (_publicNic != null) {
|
||||
info = NetUtils.getNetworkParams(_publicNic);
|
||||
if (publicNic != null) {
|
||||
info = NetUtils.getNetworkParams(publicNic);
|
||||
if (info != null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Parameters for public nic: " + info[0] + " - " + info[1] + "-" + info[2]);
|
||||
@ -193,8 +193,8 @@ public abstract class ServerResourceBase implements ServerResource {
|
||||
}
|
||||
}
|
||||
|
||||
if (_storageNic2 != null) {
|
||||
info = NetUtils.getNetworkParams(_storageNic2);
|
||||
if (storageNic2 != null) {
|
||||
info = NetUtils.getNetworkParams(storageNic2);
|
||||
if (info != null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Parameters for storage nic 2: " + info[0] + " - " + info[1] + "-" + info[2]);
|
||||
@ -212,18 +212,18 @@ public abstract class ServerResourceBase implements ServerResource {
|
||||
|
||||
@Override
|
||||
public IAgentControl getAgentControl() {
|
||||
return _agentControl;
|
||||
return agentControl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAgentControl(IAgentControl agentControl) {
|
||||
_agentControl = agentControl;
|
||||
this.agentControl = agentControl;
|
||||
}
|
||||
|
||||
protected void recordWarning(final String msg, final Throwable th) {
|
||||
final String str = getLogStr(msg, th);
|
||||
synchronized (_warnings) {
|
||||
_warnings.add(str);
|
||||
synchronized (warnings) {
|
||||
warnings.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,25 +232,25 @@ public abstract class ServerResourceBase implements ServerResource {
|
||||
}
|
||||
|
||||
protected List<String> getWarnings() {
|
||||
synchronized (_warnings) {
|
||||
final List<String> results = new LinkedList<String>(_warnings);
|
||||
_warnings.clear();
|
||||
synchronized (warnings) {
|
||||
final List<String> results = new LinkedList<String>(warnings);
|
||||
warnings.clear();
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
protected List<String> getErrors() {
|
||||
synchronized (_errors) {
|
||||
final List<String> result = new LinkedList<String>(_errors);
|
||||
_errors.clear();
|
||||
synchronized (errors) {
|
||||
final List<String> result = new LinkedList<String>(errors);
|
||||
errors.clear();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
protected void recordError(final String msg, final Throwable th) {
|
||||
final String str = getLogStr(msg, th);
|
||||
synchronized (_errors) {
|
||||
_errors.add(str);
|
||||
synchronized (errors) {
|
||||
errors.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -170,7 +170,7 @@ public class ServerResourceBaseTest {
|
||||
|
||||
serverResourceBaseSpy.tryToAutoDiscoverResourcePrivateNetworkInterface();
|
||||
|
||||
Assert.assertEquals(networkInterfaceMock2, serverResourceBaseSpy._privateNic);
|
||||
Assert.assertEquals(networkInterfaceMock2, serverResourceBaseSpy.privateNic);
|
||||
Mockito.verify(serverResourceBaseSpy, Mockito.times(2)).isValidNicToUseAsPrivateNic(Mockito.any());
|
||||
}
|
||||
}
|
||||
@ -229,9 +229,9 @@ public class ServerResourceBaseTest {
|
||||
Assert.assertEquals(expectedResults[i], keys.get(i));
|
||||
}
|
||||
|
||||
Assert.assertEquals(networkInterfaceMock1, serverResourceBaseSpy._privateNic);
|
||||
Assert.assertEquals(networkInterfaceMock2, serverResourceBaseSpy._publicNic);
|
||||
Assert.assertEquals(networkInterfaceMock3, serverResourceBaseSpy._storageNic);
|
||||
Assert.assertEquals(networkInterfaceMock4, serverResourceBaseSpy._storageNic2);
|
||||
Assert.assertEquals(networkInterfaceMock1, serverResourceBaseSpy.privateNic);
|
||||
Assert.assertEquals(networkInterfaceMock2, serverResourceBaseSpy.publicNic);
|
||||
Assert.assertEquals(networkInterfaceMock3, serverResourceBaseSpy.storageNic);
|
||||
Assert.assertEquals(networkInterfaceMock4, serverResourceBaseSpy.storageNic2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,34 +166,34 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
private static final Logger s_logger = Logger.getLogger(HypervDirectConnectResource.class.getName());
|
||||
|
||||
private static final Gson s_gson = GsonHelper.getGson();
|
||||
private String _zoneId;
|
||||
private String _podId;
|
||||
private String _clusterId;
|
||||
private String _guid;
|
||||
private String _agentIp;
|
||||
private final int _port = DEFAULT_AGENT_PORT;
|
||||
protected final long _opsTimeout = 900000; // 15 minutes time out to time
|
||||
private String zoneId;
|
||||
private String podId;
|
||||
private String clusterId;
|
||||
private String guid;
|
||||
private String agentIp;
|
||||
private final int port = DEFAULT_AGENT_PORT;
|
||||
protected final long opsTimeout = 900000; // 15 minutes time out to time
|
||||
|
||||
protected final int _retry = 24;
|
||||
protected final int _sleep = 10000;
|
||||
protected final int retry = 24;
|
||||
protected final int sleep = 10000;
|
||||
protected static final int DEFAULT_DOMR_SSHPORT = 3922;
|
||||
private String _clusterGuid;
|
||||
private String clusterGuid;
|
||||
|
||||
// Used by initialize to assert object configured before
|
||||
// initialize called.
|
||||
private boolean _configureCalled = false;
|
||||
private boolean configureCalled = false;
|
||||
|
||||
private String _username;
|
||||
private String _password;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
private static HypervManager s_hypervMgr;
|
||||
@Inject
|
||||
HypervManager _hypervMgr;
|
||||
protected VirtualRoutingResource _vrResource;
|
||||
HypervManager hypervManager;
|
||||
protected VirtualRoutingResource vrResource;
|
||||
|
||||
@PostConstruct
|
||||
void init() {
|
||||
s_hypervMgr = _hypervMgr;
|
||||
s_hypervMgr = hypervManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -204,7 +204,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
@Override
|
||||
public final StartupCommand[] initialize() {
|
||||
// assert
|
||||
if (!_configureCalled) {
|
||||
if (!configureCalled) {
|
||||
final String errMsg = this.getClass().getName() + " requires configure() be called before" + " initialize()";
|
||||
s_logger.error(errMsg);
|
||||
}
|
||||
@ -215,16 +215,16 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
|
||||
// Identity within the data centre is decided by CloudStack kernel,
|
||||
// and passed via ServerResource.configure()
|
||||
defaultStartRoutCmd.setDataCenter(_zoneId);
|
||||
defaultStartRoutCmd.setPod(_podId);
|
||||
defaultStartRoutCmd.setCluster(_clusterId);
|
||||
defaultStartRoutCmd.setGuid(_guid);
|
||||
defaultStartRoutCmd.setName(_name);
|
||||
defaultStartRoutCmd.setPrivateIpAddress(_agentIp);
|
||||
defaultStartRoutCmd.setStorageIpAddress(_agentIp);
|
||||
defaultStartRoutCmd.setPool(_clusterGuid);
|
||||
defaultStartRoutCmd.setDataCenter(zoneId);
|
||||
defaultStartRoutCmd.setPod(podId);
|
||||
defaultStartRoutCmd.setCluster(clusterId);
|
||||
defaultStartRoutCmd.setGuid(guid);
|
||||
defaultStartRoutCmd.setName(name);
|
||||
defaultStartRoutCmd.setPrivateIpAddress(agentIp);
|
||||
defaultStartRoutCmd.setStorageIpAddress(agentIp);
|
||||
defaultStartRoutCmd.setPool(clusterGuid);
|
||||
|
||||
s_logger.debug("Generated StartupRoutingCommand for _agentIp \"" + _agentIp + "\"");
|
||||
s_logger.debug("Generated StartupRoutingCommand for agentIp \"" + agentIp + "\"");
|
||||
|
||||
defaultStartRoutCmd.setVersion(this.getClass().getPackage().getImplementationVersion());
|
||||
|
||||
@ -239,48 +239,48 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
|
||||
// Assert that host identity is consistent with existing values.
|
||||
if (startCmd == null) {
|
||||
final String errMsg = String.format("Host %s (IP %s)" + "did not return a StartupRoutingCommand", _name, _agentIp);
|
||||
final String errMsg = String.format("Host %s (IP %s)" + "did not return a StartupRoutingCommand", name, agentIp);
|
||||
s_logger.error(errMsg);
|
||||
// TODO: valid to return null, or should we throw?
|
||||
return null;
|
||||
}
|
||||
if (!startCmd.getDataCenter().equals(defaultStartRoutCmd.getDataCenter())) {
|
||||
final String errMsg =
|
||||
String.format("Host %s (IP %s) changed zone/data center. Was " + defaultStartRoutCmd.getDataCenter() + " NOW its " + startCmd.getDataCenter(), _name,
|
||||
_agentIp);
|
||||
String.format("Host %s (IP %s) changed zone/data center. Was " + defaultStartRoutCmd.getDataCenter() + " NOW its " + startCmd.getDataCenter(), name,
|
||||
agentIp);
|
||||
s_logger.error(errMsg);
|
||||
// TODO: valid to return null, or should we throw?
|
||||
return null;
|
||||
}
|
||||
if (!startCmd.getPod().equals(defaultStartRoutCmd.getPod())) {
|
||||
final String errMsg = String.format("Host %s (IP %s) changed pod. Was " + defaultStartRoutCmd.getPod() + " NOW its " + startCmd.getPod(), _name, _agentIp);
|
||||
final String errMsg = String.format("Host %s (IP %s) changed pod. Was " + defaultStartRoutCmd.getPod() + " NOW its " + startCmd.getPod(), name, agentIp);
|
||||
s_logger.error(errMsg);
|
||||
// TODO: valid to return null, or should we throw?
|
||||
return null;
|
||||
}
|
||||
if (!startCmd.getCluster().equals(defaultStartRoutCmd.getCluster())) {
|
||||
final String errMsg =
|
||||
String.format("Host %s (IP %s) changed cluster. Was " + defaultStartRoutCmd.getCluster() + " NOW its " + startCmd.getCluster(), _name, _agentIp);
|
||||
String.format("Host %s (IP %s) changed cluster. Was " + defaultStartRoutCmd.getCluster() + " NOW its " + startCmd.getCluster(), name, agentIp);
|
||||
s_logger.error(errMsg);
|
||||
// TODO: valid to return null, or should we throw?
|
||||
return null;
|
||||
}
|
||||
if (!startCmd.getGuid().equals(defaultStartRoutCmd.getGuid())) {
|
||||
final String errMsg = String.format("Host %s (IP %s) changed guid. Was " + defaultStartRoutCmd.getGuid() + " NOW its " + startCmd.getGuid(), _name, _agentIp);
|
||||
final String errMsg = String.format("Host %s (IP %s) changed guid. Was " + defaultStartRoutCmd.getGuid() + " NOW its " + startCmd.getGuid(), name, agentIp);
|
||||
s_logger.error(errMsg);
|
||||
// TODO: valid to return null, or should we throw?
|
||||
return null;
|
||||
}
|
||||
if (!startCmd.getPrivateIpAddress().equals(defaultStartRoutCmd.getPrivateIpAddress())) {
|
||||
final String errMsg =
|
||||
String.format("Host %s (IP %s) IP address. Was " + defaultStartRoutCmd.getPrivateIpAddress() + " NOW its " + startCmd.getPrivateIpAddress(), _name,
|
||||
_agentIp);
|
||||
String.format("Host %s (IP %s) IP address. Was " + defaultStartRoutCmd.getPrivateIpAddress() + " NOW its " + startCmd.getPrivateIpAddress(), name,
|
||||
agentIp);
|
||||
s_logger.error(errMsg);
|
||||
// TODO: valid to return null, or should we throw?
|
||||
return null;
|
||||
}
|
||||
if (!startCmd.getName().equals(defaultStartRoutCmd.getName())) {
|
||||
final String errMsg = String.format("Host %s (IP %s) name. Was " + startCmd.getName() + " NOW its " + defaultStartRoutCmd.getName(), _name, _agentIp);
|
||||
final String errMsg = String.format("Host %s (IP %s) name. Was " + startCmd.getName() + " NOW its " + defaultStartRoutCmd.getName(), name, agentIp);
|
||||
s_logger.error(errMsg);
|
||||
// TODO: valid to return null, or should we throw?
|
||||
return null;
|
||||
@ -300,14 +300,14 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
// TODO: is this assertion required?
|
||||
if (storePoolCmd == null) {
|
||||
final String frmtStr = "Host %s (IP %s) sent incorrect Command, " + "second parameter should be a " + "StartupStorageCommand";
|
||||
final String errMsg = String.format(frmtStr, _name, _agentIp);
|
||||
final String errMsg = String.format(frmtStr, name, agentIp);
|
||||
s_logger.error(errMsg);
|
||||
// TODO: valid to return null, or should we throw?
|
||||
return null;
|
||||
}
|
||||
s_logger.info("Host " + _name + " (IP " + _agentIp + ") already configured with a storeage pool, details " + s_gson.toJson(startCmds[1]));
|
||||
s_logger.info("Host " + name + " (IP " + agentIp + ") already configured with a storeage pool, details " + s_gson.toJson(startCmds[1]));
|
||||
} else {
|
||||
s_logger.info("Host " + _name + " (IP " + _agentIp + ") already configured with a storeage pool, details ");
|
||||
s_logger.info("Host " + name + " (IP " + agentIp + ") already configured with a storeage pool, details ");
|
||||
}
|
||||
return new StartupCommand[] {startCmd, storePoolCmd};
|
||||
}
|
||||
@ -317,13 +317,13 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
final PingCommand pingCmd = new PingRoutingCommand(getType(), id, getHostVmStateReport());
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Ping host " + _name + " (IP " + _agentIp + ")");
|
||||
s_logger.debug("Ping host " + name + " (IP " + agentIp + ")");
|
||||
}
|
||||
|
||||
final Answer pingAns = executeRequest(pingCmd);
|
||||
|
||||
if (pingAns == null || !pingAns.getResult()) {
|
||||
s_logger.info("Cannot ping host " + _name + " (IP " + _agentIp + "), pingAns (blank means null) is:" + pingAns);
|
||||
s_logger.info("Cannot ping host " + name + " (IP " + agentIp + "), pingAns (blank means null) is:" + pingAns);
|
||||
return null;
|
||||
}
|
||||
return pingCmd;
|
||||
@ -332,7 +332,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
public final ArrayList<Map<String, String>> requestHostVmStateReport() {
|
||||
URI agentUri = null;
|
||||
try {
|
||||
agentUri = new URI("https", null, _agentIp, _port, "/api/HypervResource/" + HOST_VM_STATE_REPORT_COMMAND, null, null);
|
||||
agentUri = new URI("https", null, agentIp, port, "/api/HypervResource/" + HOST_VM_STATE_REPORT_COMMAND, null, null);
|
||||
} catch (final URISyntaxException e) {
|
||||
final String errMsg = "Could not generate URI for Hyper-V agent";
|
||||
s_logger.error(errMsg, e);
|
||||
@ -372,7 +372,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
|
||||
for (final Map<String, String> vmMap : vmList) {
|
||||
final String name = (String)vmMap.keySet().toArray()[0];
|
||||
vmStates.put(name, new HostVmStateReportEntry(PowerState.valueOf(vmMap.get(name)), _guid));
|
||||
vmStates.put(name, new HostVmStateReportEntry(PowerState.valueOf(vmMap.get(name)), guid));
|
||||
}
|
||||
return vmStates;
|
||||
}
|
||||
@ -388,7 +388,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
try {
|
||||
final String cmdName = StartupCommand.class.getName();
|
||||
agentUri =
|
||||
new URI("https", null, _agentIp, _port,
|
||||
new URI("https", null, agentIp, port,
|
||||
"/api/HypervResource/" + cmdName, null, null);
|
||||
} catch (final URISyntaxException e) {
|
||||
// TODO add proper logging
|
||||
@ -427,7 +427,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
try {
|
||||
final String cmdName = cmd.getClass().getName();
|
||||
agentUri =
|
||||
new URI("https", null, _agentIp, _port,
|
||||
new URI("https", null, agentIp, port,
|
||||
"/api/HypervResource/" + cmdName, null, null);
|
||||
} catch (final URISyntaxException e) {
|
||||
// TODO add proper logging
|
||||
@ -436,7 +436,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
return null;
|
||||
}
|
||||
if (cmd instanceof NetworkElementCommand) {
|
||||
return _vrResource.executeRequest((NetworkElementCommand)cmd);
|
||||
return vrResource.executeRequest((NetworkElementCommand)cmd);
|
||||
}if (clazz == CheckSshCommand.class) {
|
||||
answer = execute((CheckSshCommand)cmd);
|
||||
} else if (cmd instanceof NetworkUsageCommand) {
|
||||
@ -455,7 +455,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
final VirtualMachineTO vmSpec = ((StartCommand)cmd).getVirtualMachine();
|
||||
if (vmSpec.getType() != VirtualMachine.Type.User) {
|
||||
if (s_hypervMgr != null) {
|
||||
final String secondary = s_hypervMgr.prepareSecondaryStorageStore(Long.parseLong(_zoneId));
|
||||
final String secondary = s_hypervMgr.prepareSecondaryStorageStore(Long.parseLong(zoneId));
|
||||
if (secondary != null) {
|
||||
((StartCommand)cmd).setSecondaryStorage(secondary);
|
||||
}
|
||||
@ -487,7 +487,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
try {
|
||||
final String cmdName = cmd.getClass().getName();
|
||||
agentUri =
|
||||
new URI("https", null, _agentIp, _port,
|
||||
new URI("https", null, agentIp, port,
|
||||
"/api/HypervResource/" + cmdName, null, null);
|
||||
} catch (final URISyntaxException e) {
|
||||
final String errMsg = "Could not generate URI for Hyper-V agent";
|
||||
@ -1803,7 +1803,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
try {
|
||||
final String cmdName = GetVmConfigCommand.class.getName();
|
||||
agentUri =
|
||||
new URI("https", null, _agentIp, _port,
|
||||
new URI("https", null, agentIp, port,
|
||||
"/api/HypervResource/" + cmdName, null, null);
|
||||
} catch (final URISyntaxException e) {
|
||||
final String errMsg = "Could not generate URI for Hyper-V agent";
|
||||
@ -1836,7 +1836,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
try {
|
||||
final String cmdName = GetVmConfigCommand.class.getName();
|
||||
agentUri =
|
||||
new URI("https", null, _agentIp, _port,
|
||||
new URI("https", null, agentIp, port,
|
||||
"/api/HypervResource/" + cmdName, null, null);
|
||||
} catch (final URISyntaxException e) {
|
||||
final String errMsg = "Could not generate URI for Hyper-V agent";
|
||||
@ -1865,7 +1865,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
try {
|
||||
final String cmdName = ModifyVmNicConfigCommand.class.getName();
|
||||
agentUri =
|
||||
new URI("https", null, _agentIp, _port,
|
||||
new URI("https", null, agentIp, port,
|
||||
"/api/HypervResource/" + cmdName, null, null);
|
||||
} catch (final URISyntaxException e) {
|
||||
final String errMsg = "Could not generate URI for Hyper-V agent";
|
||||
@ -1886,7 +1886,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
try {
|
||||
final String cmdName = ModifyVmNicConfigCommand.class.getName();
|
||||
agentUri =
|
||||
new URI("https", null, _agentIp, _port,
|
||||
new URI("https", null, agentIp, port,
|
||||
"/api/HypervResource/" + cmdName, null, null);
|
||||
} catch (final URISyntaxException e) {
|
||||
final String errMsg = "Could not generate URI for Hyper-V agent";
|
||||
@ -2298,22 +2298,22 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
/* todo: update, make consistent with the xen server equivalent. */
|
||||
|
||||
if (params != null) {
|
||||
_guid = (String)params.get("guid");
|
||||
_zoneId = (String)params.get("zone");
|
||||
_podId = (String)params.get("pod");
|
||||
_clusterId = (String)params.get("cluster");
|
||||
_agentIp = (String)params.get("ipaddress"); // was agentIp
|
||||
_name = name;
|
||||
guid = (String)params.get("guid");
|
||||
zoneId = (String)params.get("zone");
|
||||
podId = (String)params.get("pod");
|
||||
clusterId = (String)params.get("cluster");
|
||||
agentIp = (String)params.get("ipaddress"); // was agentIp
|
||||
this.name = name;
|
||||
|
||||
_clusterGuid = (String)params.get("cluster.guid");
|
||||
_username = (String)params.get("url");
|
||||
_password = (String)params.get("password");
|
||||
_username = (String)params.get("username");
|
||||
_configureCalled = true;
|
||||
clusterGuid = (String)params.get("cluster.guid");
|
||||
username = (String)params.get("url");
|
||||
password = (String)params.get("password");
|
||||
username = (String)params.get("username");
|
||||
configureCalled = true;
|
||||
}
|
||||
|
||||
_vrResource = new VirtualRoutingResource(this);
|
||||
if (!_vrResource.configure(name, new HashMap<String, Object>())) {
|
||||
vrResource = new VirtualRoutingResource(this);
|
||||
if (!vrResource.configure(name, new HashMap<String, Object>())) {
|
||||
throw new ConfigurationException("Unable to configure VirtualRoutingResource");
|
||||
}
|
||||
return true;
|
||||
@ -2349,11 +2349,11 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
protected String connect(final String vmName, final String ipAddress, final int port) {
|
||||
final long startTick = System.currentTimeMillis();
|
||||
|
||||
// wait until we have at least been waiting for _ops_timeout time or
|
||||
// at least have tried _retry times, this is to coordinate with system
|
||||
// wait until we have at least been waiting for ops_timeout time or
|
||||
// at least have tried retry times, this is to coordinate with system
|
||||
// VM patching/rebooting time that may need
|
||||
int retry = _retry;
|
||||
while (System.currentTimeMillis() - startTick <= _opsTimeout || --retry > 0) {
|
||||
int retry = this.retry;
|
||||
while (System.currentTimeMillis() - startTick <= opsTimeout || --retry > 0) {
|
||||
s_logger.info("Trying to connect to " + ipAddress);
|
||||
try (SocketChannel sch = SocketChannel.open();) {
|
||||
sch.configureBlocking(true);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -269,7 +269,7 @@ public class LibvirtComputingResourceTest {
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
libvirtComputingResourceSpy._qemuSocketsPath = new File("/var/run/qemu");
|
||||
libvirtComputingResourceSpy.qemuSocketsPath = new File("/var/run/qemu");
|
||||
libvirtComputingResourceSpy.parser = parserMock;
|
||||
LibvirtComputingResource.s_logger = loggerMock;
|
||||
}
|
||||
@ -466,8 +466,8 @@ public class LibvirtComputingResourceTest {
|
||||
@Test
|
||||
public void testConfigureGuestAndSystemVMToUseKVM() {
|
||||
VirtualMachineTO to = createDefaultVM(false);
|
||||
libvirtComputingResourceSpy._hypervisorLibvirtVersion = 100;
|
||||
libvirtComputingResourceSpy._hypervisorQemuVersion = 10;
|
||||
libvirtComputingResourceSpy.hypervisorLibvirtVersion = 100;
|
||||
libvirtComputingResourceSpy.hypervisorQemuVersion = 10;
|
||||
LibvirtVMDef vm = new LibvirtVMDef();
|
||||
|
||||
GuestDef guestFromSpec = libvirtComputingResourceSpy.createGuestFromSpec(to, vm, to.getUuid(), null);
|
||||
@ -478,7 +478,7 @@ public class LibvirtComputingResourceTest {
|
||||
@Test
|
||||
public void testConfigureGuestAndUserVMToUseLXC() {
|
||||
VirtualMachineTO to = createDefaultVM(false);
|
||||
libvirtComputingResourceSpy._hypervisorType = HypervisorType.LXC;
|
||||
libvirtComputingResourceSpy.hypervisorType = HypervisorType.LXC;
|
||||
LibvirtVMDef vm = new LibvirtVMDef();
|
||||
|
||||
GuestDef guestFromSpec = libvirtComputingResourceSpy.createGuestFromSpec(to, vm, to.getUuid(), null);
|
||||
@ -545,7 +545,7 @@ public class LibvirtComputingResourceTest {
|
||||
@Test
|
||||
public void testCreateClockDefKvmclock() {
|
||||
VirtualMachineTO to = createDefaultVM(false);
|
||||
libvirtComputingResourceSpy._hypervisorLibvirtVersion = 9020;
|
||||
libvirtComputingResourceSpy.hypervisorLibvirtVersion = 9020;
|
||||
|
||||
ClockDef clockDef = libvirtComputingResourceSpy.createClockDef(to);
|
||||
Document domainDoc = parse(clockDef.toString());
|
||||
@ -652,8 +652,8 @@ public class LibvirtComputingResourceTest {
|
||||
@Test
|
||||
public void testCreateVideoDef() {
|
||||
VirtualMachineTO to = createDefaultVM(false);
|
||||
libvirtComputingResourceSpy._videoRam = 200;
|
||||
libvirtComputingResourceSpy._videoHw = "vGPU";
|
||||
libvirtComputingResourceSpy.videoRam = 200;
|
||||
libvirtComputingResourceSpy.videoHw = "vGPU";
|
||||
|
||||
VideoDef videoDef = libvirtComputingResourceSpy.createVideoDef(to);
|
||||
Document domainDoc = parse(videoDef.toString());
|
||||
@ -5665,7 +5665,7 @@ public class LibvirtComputingResourceTest {
|
||||
VirtualMachineTO vmTo = Mockito.mock(VirtualMachineTO.class);
|
||||
Mockito.when(vmTo.getType()).thenReturn(Type.User);
|
||||
LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource();
|
||||
libvirtComputingResource._noMemBalloon = true;
|
||||
libvirtComputingResource.noMemBalloon = true;
|
||||
long maxMemory = 2048;
|
||||
|
||||
long currentMemory = libvirtComputingResource.getCurrentMemAccordingToMemBallooning(vmTo, maxMemory);
|
||||
@ -5676,7 +5676,7 @@ public class LibvirtComputingResourceTest {
|
||||
@Test
|
||||
public void validateGetCurrentMemAccordingToMemBallooningWithtMemBalooning(){
|
||||
LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource();
|
||||
libvirtComputingResource._noMemBalloon = false;
|
||||
libvirtComputingResource.noMemBalloon = false;
|
||||
|
||||
long maxMemory = 2048;
|
||||
long minMemory = ByteScaleUtils.mebibytesToBytes(64);
|
||||
@ -5893,8 +5893,8 @@ public class LibvirtComputingResourceTest {
|
||||
Assert.assertEquals("cloudbr15", keys.get(0));
|
||||
Assert.assertEquals("cloudbr28", keys.get(1));
|
||||
|
||||
Assert.assertEquals("cloudbr15", libvirtComputingResourceSpy._privBridgeName);
|
||||
Assert.assertEquals("cloudbr28", libvirtComputingResourceSpy._publicBridgeName);
|
||||
Assert.assertEquals("cloudbr15", libvirtComputingResourceSpy.privBridgeName);
|
||||
Assert.assertEquals("cloudbr28", libvirtComputingResourceSpy.publicBridgeName);
|
||||
|
||||
Assert.assertEquals(networkInterfaceMock1, libvirtComputingResourceSpy.getPrivateNic());
|
||||
Assert.assertEquals(networkInterfaceMock2, libvirtComputingResourceSpy.getPublicNic());
|
||||
|
||||
@ -121,11 +121,11 @@ public class LibvirtVifDriverTest {
|
||||
// map to the default vif driver for the bridge type
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
|
||||
res._bridgeType = BridgeType.NATIVE;
|
||||
res.bridgeType = BridgeType.NATIVE;
|
||||
configure(params);
|
||||
checkAllSame(bridgeVifDriver);
|
||||
|
||||
res._bridgeType = BridgeType.OPENVSWITCH;
|
||||
res.bridgeType = BridgeType.OPENVSWITCH;
|
||||
configure(params);
|
||||
checkAllSame(ovsVifDriver);
|
||||
}
|
||||
@ -141,11 +141,11 @@ public class LibvirtVifDriverTest {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
|
||||
// Switch res' bridge type for test purposes
|
||||
res._bridgeType = BridgeType.NATIVE;
|
||||
res.bridgeType = BridgeType.NATIVE;
|
||||
configure(params);
|
||||
checkAllSame(bridgeVifDriver);
|
||||
|
||||
res._bridgeType = BridgeType.OPENVSWITCH;
|
||||
res.bridgeType = BridgeType.OPENVSWITCH;
|
||||
configure(params);
|
||||
checkAllSame(ovsVifDriver);
|
||||
|
||||
@ -167,11 +167,11 @@ public class LibvirtVifDriverTest {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
|
||||
// Switch res' bridge type for test purposes
|
||||
res._bridgeType = BridgeType.NATIVE;
|
||||
res.bridgeType = BridgeType.NATIVE;
|
||||
configure(params);
|
||||
checkAllSame(ovsVifDriver);
|
||||
|
||||
res._bridgeType = BridgeType.OPENVSWITCH;
|
||||
res.bridgeType = BridgeType.OPENVSWITCH;
|
||||
configure(params);
|
||||
checkAllSame(bridgeVifDriver);
|
||||
|
||||
@ -186,7 +186,7 @@ public class LibvirtVifDriverTest {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put(LibVirtVifDriver + "." + "Public", FakeVifDriverClassName);
|
||||
params.put(LibVirtVifDriver + "." + "Guest", LibvirtComputingResource.DEFAULT_OVS_VIF_DRIVER_CLASS_NAME);
|
||||
res._bridgeType = BridgeType.NATIVE;
|
||||
res.bridgeType = BridgeType.NATIVE;
|
||||
configure(params);
|
||||
|
||||
// Initially, set all traffic types to use default
|
||||
@ -204,7 +204,7 @@ public class LibvirtVifDriverTest {
|
||||
public void testBadTrafficType() throws ConfigurationException {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put(LibVirtVifDriver + "." + "NonExistentTrafficType", FakeVifDriverClassName);
|
||||
res._bridgeType = BridgeType.NATIVE;
|
||||
res.bridgeType = BridgeType.NATIVE;
|
||||
configure(params);
|
||||
|
||||
// Set all traffic types to use default, because bad traffic type should be ignored
|
||||
@ -219,7 +219,7 @@ public class LibvirtVifDriverTest {
|
||||
public void testEmptyTrafficType() throws ConfigurationException {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put(LibVirtVifDriver + ".", FakeVifDriverClassName);
|
||||
res._bridgeType = BridgeType.NATIVE;
|
||||
res.bridgeType = BridgeType.NATIVE;
|
||||
configure(params);
|
||||
|
||||
// Set all traffic types to use default, because bad traffic type should be ignored
|
||||
@ -234,7 +234,7 @@ public class LibvirtVifDriverTest {
|
||||
public void testBadVifDriverClassName() throws ConfigurationException {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put(LibVirtVifDriver + "." + "Public", NonExistentVifDriverClassName);
|
||||
res._bridgeType = BridgeType.NATIVE;
|
||||
res.bridgeType = BridgeType.NATIVE;
|
||||
configure(params);
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ public class LibvirtNetworkElementCommandWrapperTest {
|
||||
+ "</domain>\n";
|
||||
|
||||
private LibvirtComputingResource res;
|
||||
private final Domain _domain = mock(Domain.class);
|
||||
private final Domain domain = mock(Domain.class);
|
||||
|
||||
final String memInfo = "MemTotal: 5830236 kB\n" +
|
||||
"MemFree: 156752 kB\n" +
|
||||
@ -225,10 +225,10 @@ public class LibvirtNetworkElementCommandWrapperTest {
|
||||
// Use a spy because we only want to override getVifDriverClass
|
||||
LibvirtComputingResource resReal = new LibvirtComputingResource() {
|
||||
{
|
||||
_linkLocalBridgeName = "cloud0";
|
||||
_guestBridgeName = "guestbr";
|
||||
_publicBridgeName = "publicbr";
|
||||
_privBridgeName = "mgmtbr";
|
||||
linkLocalBridgeName = "cloud0";
|
||||
guestBridgeName = "guestbr";
|
||||
publicBridgeName = "publicbr";
|
||||
privBridgeName = "mgmtbr";
|
||||
}
|
||||
};
|
||||
|
||||
@ -237,8 +237,8 @@ public class LibvirtNetworkElementCommandWrapperTest {
|
||||
Connect conn = mock(Connect.class);
|
||||
LibvirtUtilitiesHelper helper = mock(LibvirtUtilitiesHelper.class);
|
||||
|
||||
when(_domain.getXMLDesc(0)).thenReturn(fullfile);
|
||||
when(conn.domainLookupByName(nullable(String.class))).thenReturn(_domain);
|
||||
when(domain.getXMLDesc(0)).thenReturn(fullfile);
|
||||
when(conn.domainLookupByName(nullable(String.class))).thenReturn(domain);
|
||||
when(helper.getConnectionByVmName(nullable(String.class))).thenReturn(conn);
|
||||
|
||||
doReturn(helper).when(res).getLibvirtUtilitiesHelper();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user