use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class HypervDirectConnectResource method prepareNetworkElementCommand.
private ExecutionResult prepareNetworkElementCommand(final SetNetworkACLCommand cmd) {
final NicTO nic = cmd.getNic();
final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
try {
final URI broadcastUri = nic.getBroadcastUri();
final String vlanId = BroadcastDomainType.getValue(broadcastUri);
final int ethDeviceNum = getVmNics(routerName, vlanId);
if (ethDeviceNum > 0) {
nic.setDeviceId(ethDeviceNum);
} else {
return new ExecutionResult(false, "Prepare SetNetworkACL failed due to unable to find the nic");
}
} catch (final Exception e) {
final String msg = "Prepare SetNetworkACL failed due to " + e.toString();
s_logger.error(msg, e);
return new ExecutionResult(false, msg);
}
return new ExecutionResult(true, null);
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class HypervDirectConnectResource method prepareNetworkElementCommand.
protected ExecutionResult prepareNetworkElementCommand(final SetupGuestNetworkCommand cmd) {
final NicTO nic = cmd.getNic();
final String domrName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
try {
final URI broadcastUri = nic.getBroadcastUri();
final String vlanId = BroadcastDomainType.getValue(broadcastUri);
final int ethDeviceNum = getVmNics(domrName, vlanId);
if (ethDeviceNum > 0) {
nic.setDeviceId(ethDeviceNum);
} else {
return new ExecutionResult(false, "Prepare SetupGuestNetwork failed due to unable to find the nic");
}
} catch (final Exception e) {
final String msg = "Prepare SetupGuestNetwork failed due to " + e.toString();
s_logger.warn(msg, e);
return new ExecutionResult(false, msg);
}
return new ExecutionResult(true, null);
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class HypervDirectConnectResource method prepareNetworkElementCommand.
private ExecutionResult prepareNetworkElementCommand(final IpAssocVpcCommand cmd) {
final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
try {
final IpAddressTO[] ips = cmd.getIpAddresses();
for (final IpAddressTO ip : ips) {
final URI broadcastUri = BroadcastDomainType.fromString(ip.getBroadcastUri());
if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
throw new InternalErrorException("Invalid Broadcast URI " + ip.getBroadcastUri());
}
final String vlanId = BroadcastDomainType.getValue(broadcastUri);
int publicNicInfo = -1;
publicNicInfo = getVmNics(routerName, vlanId);
if (publicNicInfo < 0) {
if (ip.isAdd()) {
throw new InternalErrorException("Failed to find DomR VIF to associate/disassociate IP with.");
} else {
s_logger.debug("VIF to deassociate IP with does not exist, return success");
continue;
}
}
ip.setNicDevId(publicNicInfo);
}
} catch (final Exception e) {
s_logger.error("Prepare Ip Assoc failure on applying one ip due to exception: ", e);
return new ExecutionResult(false, e.toString());
}
return new ExecutionResult(true, null);
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class CitrixResourceBase method prepareNetworkElementCommand.
/**
* @param cmd
* @return
*/
private ExecutionResult prepareNetworkElementCommand(final SetupGuestNetworkCommand cmd) {
final Connection conn = getConnection();
final NicTO nic = cmd.getNic();
final String domrName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
try {
final Set<VM> vms = VM.getByNameLabel(conn, domrName);
if (vms == null || vms.isEmpty()) {
return new ExecutionResult(false, "Can not find VM " + domrName);
}
final VM vm = vms.iterator().next();
final String mac = nic.getMac();
VIF domrVif = null;
for (final VIF vif : vm.getVIFs(conn)) {
final String lmac = vif.getMAC(conn);
if (lmac.equals(mac)) {
domrVif = vif;
// Do not break it! We have 2 routers.
// break;
}
}
if (domrVif == null) {
return new ExecutionResult(false, "Can not find vif with mac " + mac + " for VM " + domrName);
}
nic.setDeviceId(Integer.parseInt(domrVif.getDevice(conn)));
} catch (final Exception e) {
final String msg = "Creating guest network failed due to " + e.toString();
s_logger.warn(msg, e);
return new ExecutionResult(false, msg);
}
return new ExecutionResult(true, null);
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class VirtualRoutingResourceTest method prepareNetworkElementCommand.
private ExecutionResult prepareNetworkElementCommand(final SetSourceNatCommand cmd) {
final IpAddressTO ip = cmd.getIpAddress();
ip.setNicDevId(1);
return new ExecutionResult(true, null);
}
Aggregations