use of com.cloud.agent.api.SetupPersistentNetworkAnswer in project cloudstack by apache.
the class LibvirtSetupPersistentNetworkCommandWrapper method execute.
@Override
public Answer execute(SetupPersistentNetworkCommand command, LibvirtComputingResource serverResource) {
NicTO nic = command.getNic();
VifDriver driver = serverResource.getVifDriver(nic.getType());
try {
driver.plug(nic, null, "", null);
} catch (InternalErrorException | LibvirtException e) {
return new SetupPersistentNetworkAnswer(command, false, e.getLocalizedMessage());
}
return new SetupPersistentNetworkAnswer(command, true, "Successfully setup persistent network");
}
use of com.cloud.agent.api.SetupPersistentNetworkAnswer in project cloudstack by apache.
the class CitrixSetupPersistentNetworkCommandWrapper method execute.
@Override
public Answer execute(SetupPersistentNetworkCommand command, CitrixResourceBase citrixResourceBase) {
final Connection conn = citrixResourceBase.getConnection();
final XsHost host = citrixResourceBase.getHost();
try {
Network network = citrixResourceBase.getNetwork(conn, command.getNic());
if (network == null) {
return new SetupPersistentNetworkAnswer(command, false, "Failed to setup network on host: " + host.getIp());
}
return new SetupPersistentNetworkAnswer(command, true, "Successfully setup network on host: " + host.getIp());
} catch (final Exception e) {
final String msg = " Failed to setup network on host: " + host.getIp() + " due to: " + e.toString();
s_logger.error(msg, e);
return new SetupPersistentNetworkAnswer(command, false, msg);
}
}
use of com.cloud.agent.api.SetupPersistentNetworkAnswer in project cloudstack by apache.
the class NetworkOrchestrator method setupPersistentNetwork.
private void setupPersistentNetwork(NetworkVO network, NetworkOfferingVO offering, Long dcId) throws AgentUnavailableException, OperationTimedoutException {
List<ClusterVO> clusterVOs = clusterDao.listClustersByDcId(dcId);
List<HostVO> hosts = resourceManager.listAllUpAndEnabledHostsInOneZoneByType(Host.Type.Routing, dcId);
Map<Long, List<Long>> clusterToHostsMap = new HashMap<>();
for (HostVO host : hosts) {
try {
Pair<Boolean, NicTO> networkCfgStateAndDetails = isNtwConfiguredInCluster(host, clusterToHostsMap, network, offering);
if (networkCfgStateAndDetails.first()) {
continue;
}
NicTO to = networkCfgStateAndDetails.second();
SetupPersistentNetworkCommand cmd = new SetupPersistentNetworkCommand(to);
final SetupPersistentNetworkAnswer answer = (SetupPersistentNetworkAnswer) _agentMgr.send(host.getId(), cmd);
if (answer == null) {
s_logger.warn("Unable to get an answer to the SetupPersistentNetworkCommand from agent:" + host.getId());
clusterToHostsMap.get(host.getClusterId()).remove(host.getId());
continue;
}
if (!answer.getResult()) {
s_logger.warn("Unable to setup agent " + host.getId() + " due to " + answer.getDetails());
clusterToHostsMap.get(host.getClusterId()).remove(host.getId());
}
} catch (Exception e) {
s_logger.warn("Failed to connect to host: " + host.getName());
}
}
if (clusterToHostsMap.keySet().size() != clusterVOs.size()) {
s_logger.warn("Hosts on all clusters may not have been configured with network devices.");
}
}
use of com.cloud.agent.api.SetupPersistentNetworkAnswer in project cloudstack by apache.
the class VmwareResource method execute.
private Answer execute(SetupPersistentNetworkCommand cmd) {
VmwareHypervisorHost host = getHyperHost(getServiceContext());
String hostname = null;
VmwareContext context = getServiceContext();
HostMO hostMO = new HostMO(context, host.getMor());
try {
prepareNetworkFromNicInfo(hostMO, cmd.getNic(), false, null);
hostname = host.getHyperHostName();
} catch (Exception e) {
return new SetupPersistentNetworkAnswer(cmd, false, "failed to setup port-group due to: " + e.getLocalizedMessage());
}
return new SetupPersistentNetworkAnswer(cmd, true, hostname);
}
Aggregations