use of org.apache.cloudstack.network.opendaylight.dao.OpenDaylightControllerVO in project cloudstack by apache.
the class OpendaylightGuestNetworkGuru method shutdown.
@Override
public void shutdown(NetworkProfile profile, NetworkOffering offering) {
NetworkVO networkObject = networkDao.findById(profile.getId());
if (networkObject.getBroadcastDomainType() != BroadcastDomainType.OpenDaylight || networkObject.getBroadcastUri() == null) {
s_logger.warn("BroadcastUri is empty or incorrect for guestnetwork " + networkObject.getDisplayText());
return;
}
List<OpenDaylightControllerVO> devices = openDaylightControllerMappingDao.listByPhysicalNetwork(networkObject.getPhysicalNetworkId());
if (devices.isEmpty()) {
s_logger.error("No Controller on physical network " + networkObject.getPhysicalNetworkId());
return;
}
OpenDaylightControllerVO controller = devices.get(0);
DestroyNetworkCommand cmd = new DestroyNetworkCommand(BroadcastDomainType.getValue(networkObject.getBroadcastUri()));
DestroyNetworkAnswer answer = (DestroyNetworkAnswer) agentManager.easySend(controller.getHostId(), cmd);
if (answer == null || !answer.getResult()) {
s_logger.error("DestroyNetworkCommand failed");
}
super.shutdown(profile, offering);
}
use of org.apache.cloudstack.network.opendaylight.dao.OpenDaylightControllerVO in project cloudstack by apache.
the class OpendaylightGuestNetworkGuru method design.
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
PhysicalNetworkVO physnet = physicalNetworkDao.findById(plan.getPhysicalNetworkId());
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
if (!canHandle(offering, dc.getNetworkType(), physnet)) {
s_logger.debug("Refusing to design this network");
return null;
}
List<OpenDaylightControllerVO> devices = openDaylightControllerMappingDao.listByPhysicalNetwork(physnet.getId());
if (devices.isEmpty()) {
s_logger.error("No Controller on physical network " + physnet.getName());
return null;
}
s_logger.debug("Controller " + devices.get(0).getUuid() + " found on physical network " + physnet.getId());
s_logger.debug("Physical isolation type is ODL, asking GuestNetworkGuru to design this network");
NetworkVO networkObject = (NetworkVO) super.design(offering, plan, userSpecified, owner);
if (networkObject == null) {
return null;
}
// Override the broadcast domain type
networkObject.setBroadcastDomainType(BroadcastDomainType.OpenDaylight);
return networkObject;
}
use of org.apache.cloudstack.network.opendaylight.dao.OpenDaylightControllerVO in project cloudstack by apache.
the class ListOpenDaylightControllersCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
List<OpenDaylightControllerVO> controllers = resourceManager.listControllers(this);
List<OpenDaylightControllerResponse> controllerList = new ArrayList<OpenDaylightControllerResponse>();
for (OpenDaylightControllerVO controller : controllers) {
OpenDaylightControllerResponse responseObject = resourceManager.createResponseFromVO(controller);
controllerList.add(responseObject);
}
ListResponse<OpenDaylightControllerResponse> responseList = new ListResponse<OpenDaylightControllerResponse>();
responseList.setResponseName(getCommandName());
responseList.setResponses(controllerList);
setResponseObject(responseList);
}
use of org.apache.cloudstack.network.opendaylight.dao.OpenDaylightControllerVO in project cloudstack by apache.
the class OpenDaylightControllerResourceManagerImpl method addController.
@Override
public OpenDaylightControllerVO addController(AddOpenDaylightControllerCmd cmd) {
ServerResource odlController = new OpenDaylightControllerResource();
final String deviceName = NetworkDevice.OpenDaylightController.getName();
NetworkDevice networkDevice = NetworkDevice.getNetworkDevice(deviceName);
if (networkDevice == null) {
throw new CloudRuntimeException("No network device found for name " + deviceName);
}
final Long physicalNetworkId = cmd.getPhysicalNetworkId();
PhysicalNetworkVO physicalNetwork = physicalNetworkDao.findById(physicalNetworkId);
if (physicalNetwork == null) {
throw new InvalidParameterValueException("Could not find phyical network with ID: " + physicalNetworkId);
}
long zoneId = physicalNetwork.getDataCenterId();
final PhysicalNetworkServiceProviderVO ntwkSvcProvider = physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(), networkDevice.getNetworkServiceProvder());
if (ntwkSvcProvider == null) {
throw new CloudRuntimeException("Network Service Provider: " + networkDevice.getNetworkServiceProvder() + " is not enabled in the physical network: " + physicalNetworkId + "to add this device");
} else if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown) {
throw new CloudRuntimeException("Network Service Provider: " + ntwkSvcProvider.getProviderName() + " is in shutdown state in the physical network: " + physicalNetworkId + "to add this device");
}
final Map<String, String> hostParams = new HashMap<String, String>();
hostParams.put("guid", UUID.randomUUID().toString());
hostParams.put("zoneId", String.valueOf(physicalNetwork.getDataCenterId()));
hostParams.put("physicalNetworkId", String.valueOf(physicalNetwork.getId()));
hostParams.put("name", "ODL Controller - " + hostParams.get("guid"));
hostParams.put("url", cmd.getUrl());
hostParams.put("username", cmd.getUsername());
hostParams.put("password", cmd.getPassword());
Map<String, Object> hostdetails = new HashMap<String, Object>();
hostdetails.putAll(hostParams);
try {
odlController.configure(hostParams.get("name"), hostdetails);
final Host host = resourceManager.addHost(zoneId, odlController, Host.Type.L2Networking, hostParams);
if (host != null) {
return Transaction.execute(new TransactionCallback<OpenDaylightControllerVO>() {
@Override
public OpenDaylightControllerVO doInTransaction(TransactionStatus status) {
OpenDaylightControllerVO controller = new OpenDaylightControllerVO(host.getId(), physicalNetworkId, ntwkSvcProvider.getProviderName(), hostParams.get("name"));
openDaylightControllerMappingDao.persist(controller);
return controller;
}
});
} else {
throw new CloudRuntimeException("Failed to create host object for ODL Controller");
}
} catch (ConfigurationException e) {
throw new CloudRuntimeException("Failed to add ODL Controller as a resource", e);
}
}
Aggregations