use of com.cloud.common.virtualnetwork.VirtualRoutingResource in project cosmic by MissionCriticalCloud.
the class CitrixResourceBase method configure.
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
this._name = name;
try {
this._dcId = Long.parseLong((String) params.get("zone"));
} catch (final NumberFormatException e) {
throw new ConfigurationException("Unable to get the zone " + params.get("zone"));
}
this._host.setUuid((String) params.get("guid"));
this._name = this._host.getUuid();
this._host.setIp((String) params.get("ipaddress"));
this._username = (String) params.get("username");
this._password.add((String) params.get("password"));
this._pod = (String) params.get("pod");
this._cluster = (String) params.get("cluster");
this._privateNetworkName = (String) params.get("private.network.device");
this._publicNetworkName = (String) params.get("public.network.device");
this._guestNetworkName = (String) params.get("guest.network.device");
this._instance = (String) params.get("instance.name");
this._linkLocalPrivateNetworkName = (String) params.get("private.linkLocal.device");
if (this._linkLocalPrivateNetworkName == null) {
this._linkLocalPrivateNetworkName = "cloud_link_local_network";
}
this._storageNetworkName1 = (String) params.get("storage.network.device1");
this._storageNetworkName2 = (String) params.get("storage.network.device2");
this._heartbeatTimeout = NumbersUtil.parseInt((String) params.get("xenserver.heartbeat.timeout"), 120);
this._heartbeatInterval = NumbersUtil.parseInt((String) params.get("xenserver.heartbeat.interval"), 60);
String value = (String) params.get("wait");
this._wait = NumbersUtil.parseInt(value, 600);
value = (String) params.get("migratewait");
this._migratewait = NumbersUtil.parseInt(value, 3600);
this._maxNics = NumbersUtil.parseInt((String) params.get("xenserver.nics.max"), 7);
if (this._pod == null) {
throw new ConfigurationException("Unable to get the pod");
}
if (this._host.getIp() == null) {
throw new ConfigurationException("Unable to get the host address");
}
if (this._username == null) {
throw new ConfigurationException("Unable to get the username");
}
if (this._password.peek() == null) {
throw new ConfigurationException("Unable to get the password");
}
if (this._host.getUuid() == null) {
throw new ConfigurationException("Unable to get the uuid");
}
CheckXenHostInfo();
this.storageHandler = buildStorageHandler();
this._vrResource = new VirtualRoutingResource(this);
if (!this._vrResource.configure(params)) {
throw new ConfigurationException("Unable to configure VirtualRoutingResource");
}
return true;
}
use of com.cloud.common.virtualnetwork.VirtualRoutingResource in project cosmic by MissionCriticalCloud.
the class LibvirtCheckSshCommandWrapper method execute.
@Override
public Answer execute(final CheckSshCommand command, final LibvirtComputingResource libvirtComputingResource) {
final String vmName = command.getName();
final String privateIp = command.getIp();
final int cmdPort = command.getPort();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Ping command port, " + privateIp + ":" + cmdPort);
}
final VirtualRoutingResource virtRouterResource = libvirtComputingResource.getVirtRouterResource();
if (!virtRouterResource.connect(privateIp, cmdPort)) {
return new CheckSshAnswer(command, "Can not ping System vm " + vmName + " because of a connection failure");
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Ping command port succeeded for vm " + vmName);
}
return new CheckSshAnswer(command);
}
use of com.cloud.common.virtualnetwork.VirtualRoutingResource in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testStartCommandIsolationEc2.
@Test
public void testStartCommandIsolationEc2() {
final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
final Host host = Mockito.mock(Host.class);
final boolean executeInSequence = false;
final StartCommand command = new StartCommand(vmSpec, host, executeInSequence);
final KvmStoragePoolManager storagePoolMgr = Mockito.mock(KvmStoragePoolManager.class);
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
final Connect conn = Mockito.mock(Connect.class);
final LibvirtVmDef vmDef = Mockito.mock(LibvirtVmDef.class);
final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class);
final NicTO nic = Mockito.mock(NicTO.class);
final NicTO[] nics = new NicTO[] { nic };
final int[] vms = new int[0];
final String vmName = "Test";
final String controlIp = "127.0.0.1";
when(this.libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr);
when(vmSpec.getNics()).thenReturn(nics);
when(vmSpec.getType()).thenReturn(VirtualMachineType.DomainRouter);
when(vmSpec.getName()).thenReturn(vmName);
when(this.libvirtComputingResource.createVmFromSpec(vmSpec)).thenReturn(vmDef);
when(this.libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
try {
when(libvirtUtilitiesHelper.getConnectionByType(vmDef.getHvsType())).thenReturn(conn);
when(conn.listDomains()).thenReturn(vms);
doNothing().when(this.libvirtComputingResource).createVbd(conn, vmSpec, vmName, vmDef);
} catch (final LibvirtException e) {
fail(e.getMessage());
} catch (final InternalErrorException e) {
fail(e.getMessage());
} catch (final URISyntaxException e) {
fail(e.getMessage());
}
when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)).thenReturn(true);
try {
doNothing().when(this.libvirtComputingResource).createVifs(vmSpec, vmDef);
when(this.libvirtComputingResource.startVm(conn, vmName, vmDef.toString())).thenReturn("SUCCESS");
when(nic.getIsolationUri()).thenReturn(new URI("ec2://test"));
when(vmSpec.getBootArgs()).thenReturn("ls -lart");
when(this.libvirtComputingResource.passCmdLine(vmName, vmSpec.getBootArgs())).thenReturn(true);
when(nic.getIp()).thenReturn(controlIp);
when(nic.getType()).thenReturn(TrafficType.Control);
when(this.libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource);
when(virtRouterResource.connect(controlIp, 30, 5000)).thenReturn(true);
} catch (final InternalErrorException e) {
fail(e.getMessage());
} catch (final LibvirtException e) {
fail(e.getMessage());
} catch (final URISyntaxException e) {
fail(e.getMessage());
}
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertTrue(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getStoragePoolMgr();
verify(this.libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper();
try {
verify(libvirtUtilitiesHelper, times(1)).getConnectionByType(vmDef.getHvsType());
} catch (final LibvirtException e) {
fail(e.getMessage());
}
}
use of com.cloud.common.virtualnetwork.VirtualRoutingResource in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testRebootRouterCommand.
@Test
public void testRebootRouterCommand() {
final VirtualRoutingResource routingResource = Mockito.mock(VirtualRoutingResource.class);
final Connect conn = Mockito.mock(Connect.class);
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
final String vmName = "Test";
final RebootRouterCommand command = new RebootRouterCommand(vmName, "127.0.0.1");
when(this.libvirtComputingResource.getVirtRouterResource()).thenReturn(routingResource);
when(this.libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
try {
when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn);
} catch (final LibvirtException e) {
fail(e.getMessage());
}
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertFalse(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getVirtRouterResource();
verify(this.libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper();
try {
verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName);
} catch (final LibvirtException e) {
fail(e.getMessage());
}
}
use of com.cloud.common.virtualnetwork.VirtualRoutingResource in project cosmic by MissionCriticalCloud.
the class LibvirtRebootRouterCommandWrapper method execute.
@Override
public Answer execute(final RebootRouterCommand command, final LibvirtComputingResource libvirtComputingResource) {
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
final RebootCommand rebootCommand = new RebootCommand(command.getVmName(), true);
final Answer answer = wrapper.execute(rebootCommand, libvirtComputingResource);
final VirtualRoutingResource virtualRouterResource = libvirtComputingResource.getVirtRouterResource();
if (virtualRouterResource.connect(command.getPrivateIpAddress())) {
libvirtComputingResource.networkUsage(command.getPrivateIpAddress(), "create", null);
return answer;
} else {
return new Answer(command, false, "Failed to connect to virtual router " + command.getVmName());
}
}
Aggregations