use of com.cloud.agent.api.to.NicTO in project cloudstack by apache.
the class VmwareResource method sortNicsByDeviceId.
private static NicTO[] sortNicsByDeviceId(NicTO[] nics) {
List<NicTO> listForSort = new ArrayList<NicTO>();
for (NicTO nic : nics) {
listForSort.add(nic);
}
Collections.sort(listForSort, new Comparator<NicTO>() {
@Override
public int compare(NicTO arg0, NicTO arg1) {
if (arg0.getDeviceId() < arg1.getDeviceId()) {
return -1;
} else if (arg0.getDeviceId() == arg1.getDeviceId()) {
return 0;
}
return 1;
}
});
return listForSort.toArray(new NicTO[0]);
}
use of com.cloud.agent.api.to.NicTO in project cloudstack by apache.
the class HypervDirectConnectResource method execute.
private PlugNicAnswer execute(final PlugNicCommand cmd) {
if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource PlugNicCommand " + s_gson.toJson(cmd));
}
try {
final String vmName = cmd.getVmName();
final NicTO nic = cmd.getNic();
final URI broadcastUri = nic.getBroadcastUri();
if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
throw new InternalErrorException("Unable to assign a public IP to a VIF on network " + nic.getBroadcastUri());
}
final String vlanId = BroadcastDomainType.getValue(broadcastUri);
int publicNicInfo = -1;
publicNicInfo = getVmFreeNicIndex(vmName);
if (publicNicInfo > 0) {
modifyNicVlan(vmName, vlanId, publicNicInfo, true, cmd.getNic().getName());
return new PlugNicAnswer(cmd, true, "success");
}
final String msg = " Plug Nic failed for the vm as it has reached max limit of NICs to be added";
s_logger.warn(msg);
return new PlugNicAnswer(cmd, false, msg);
} catch (final Exception e) {
s_logger.error("Unexpected exception: ", e);
return new PlugNicAnswer(cmd, false, "Unable to execute PlugNicCommand due to " + e.toString());
}
}
use of com.cloud.agent.api.to.NicTO in project cloudstack by apache.
the class HypervGuru method sortNicsByDeviceId.
private NicTO[] sortNicsByDeviceId(NicTO[] nics) {
List<NicTO> listForSort = new ArrayList<NicTO>();
for (NicTO nic : nics) {
listForSort.add(nic);
}
Collections.sort(listForSort, new Comparator<NicTO>() {
@Override
public int compare(NicTO arg0, NicTO arg1) {
if (arg0.getDeviceId() < arg1.getDeviceId()) {
return -1;
} else if (arg0.getDeviceId() == arg1.getDeviceId()) {
return 0;
}
return 1;
}
});
return listForSort.toArray(new NicTO[0]);
}
use of com.cloud.agent.api.to.NicTO in project cloudstack by apache.
the class Ovm3VmSupportTest method PlugNicBreakTest.
@Test
public void PlugNicBreakTest() throws ConfigurationException, URISyntaxException {
hypervisor = support.prepare(configTest.getParams());
NicTO nic = prepNic(xen.getVmNicMac(), 240, TrafficType.Guest);
PlugNicCommand plug = new PlugNicCommand(nic, xen.getVmName(), VirtualMachine.Type.User);
Answer ra = hypervisor.executeRequest(plug);
results.basicBooleanTest(ra.getResult(), false);
}
use of com.cloud.agent.api.to.NicTO in project cloudstack by apache.
the class Ovm3VmSupportTest method unPlugNicBreakTest.
@Test
public void unPlugNicBreakTest() throws ConfigurationException, URISyntaxException {
hypervisor = support.prepare(configTest.getParams());
NicTO nic = prepNic(xen.getVmNicMac(), 240, TrafficType.Guest);
UnPlugNicCommand plug = new UnPlugNicCommand(nic, xen.getVmName());
Answer ra = hypervisor.executeRequest(plug);
results.basicBooleanTest(ra.getResult(), false);
}
Aggregations