Search in sources :

Example 11 with PhysicalNetwork

use of com.cloud.network.PhysicalNetwork in project cloudstack by apache.

the class BigSwitchBcfElement method createBigSwitchBcfDeviceResponse.

@Override
public BigSwitchBcfDeviceResponse createBigSwitchBcfDeviceResponse(BigSwitchBcfDeviceVO bigswitchBcfDeviceVO) {
    HostVO bigswitchBcfHost = _hostDao.findById(bigswitchBcfDeviceVO.getHostId());
    _hostDao.loadDetails(bigswitchBcfHost);
    BigSwitchBcfDeviceResponse response = new BigSwitchBcfDeviceResponse();
    response.setDeviceName(bigswitchBcfDeviceVO.getDeviceName());
    PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(bigswitchBcfDeviceVO.getPhysicalNetworkId());
    if (pnw != null) {
        response.setPhysicalNetworkId(pnw.getUuid());
    }
    response.setId(bigswitchBcfDeviceVO.getUuid());
    response.setProviderName(bigswitchBcfDeviceVO.getProviderName());
    response.setHostName(bigswitchBcfHost.getDetail("hostname"));
    response.setObjectName("bigswitchbcfdevice");
    return response;
}
Also used : PhysicalNetwork(com.cloud.network.PhysicalNetwork) BigSwitchBcfDeviceResponse(com.cloud.api.response.BigSwitchBcfDeviceResponse) HostVO(com.cloud.host.HostVO)

Example 12 with PhysicalNetwork

use of com.cloud.network.PhysicalNetwork in project cloudstack by apache.

the class NiciraNvpElement method createNiciraNvpDeviceResponse.

@Override
public NiciraNvpDeviceResponse createNiciraNvpDeviceResponse(NiciraNvpDeviceVO niciraNvpDeviceVO) {
    HostVO niciraNvpHost = hostDao.findById(niciraNvpDeviceVO.getHostId());
    hostDao.loadDetails(niciraNvpHost);
    NiciraNvpDeviceResponse response = new NiciraNvpDeviceResponse();
    response.setDeviceName(niciraNvpDeviceVO.getDeviceName());
    PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(niciraNvpDeviceVO.getPhysicalNetworkId());
    if (pnw != null) {
        response.setPhysicalNetworkId(pnw.getUuid());
    }
    response.setId(niciraNvpDeviceVO.getUuid());
    response.setProviderName(niciraNvpDeviceVO.getProviderName());
    response.setHostName(niciraNvpHost.getDetail("ip"));
    response.setTransportZoneUuid(niciraNvpHost.getDetail("transportzoneuuid"));
    response.setL3GatewayServiceUuid(niciraNvpHost.getDetail("l3gatewayserviceuuid"));
    response.setL2GatewayServiceUuid(niciraNvpHost.getDetail("l2gatewayserviceuuid"));
    response.setObjectName("niciranvpdevice");
    return response;
}
Also used : PhysicalNetwork(com.cloud.network.PhysicalNetwork) NiciraNvpDeviceResponse(com.cloud.api.response.NiciraNvpDeviceResponse) HostVO(com.cloud.host.HostVO)

Example 13 with PhysicalNetwork

use of com.cloud.network.PhysicalNetwork in project CloudStack-archive by CloudStack-extras.

the class CreatePhysicalNetworkCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
    UserContext.current().setEventDetails("Physical Network Id: " + getEntityId());
    PhysicalNetwork result = _networkService.getCreatedPhysicalNetwork(getEntityId());
    if (result != null) {
        PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create physical network");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) PhysicalNetworkResponse(com.cloud.api.response.PhysicalNetworkResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork)

Example 14 with PhysicalNetwork

use of com.cloud.network.PhysicalNetwork in project cloudstack by apache.

the class ListPhysicalNetworksCmd method execute.

@Override
public void execute() {
    Pair<List<? extends PhysicalNetwork>, Integer> result = _networkService.searchPhysicalNetworks(getId(), getZoneId(), this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(), getNetworkName());
    if (result != null) {
        ListResponse<PhysicalNetworkResponse> response = new ListResponse<PhysicalNetworkResponse>();
        List<PhysicalNetworkResponse> networkResponses = new ArrayList<PhysicalNetworkResponse>();
        for (PhysicalNetwork network : result.first()) {
            PhysicalNetworkResponse networkResponse = _responseGenerator.createPhysicalNetworkResponse(network);
            networkResponses.add(networkResponse);
        }
        response.setResponses(networkResponses, result.second());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to search for physical networks");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) PhysicalNetworkResponse(org.apache.cloudstack.api.response.PhysicalNetworkResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 15 with PhysicalNetwork

use of com.cloud.network.PhysicalNetwork in project cloudstack by apache.

the class UpdatePhysicalNetworkCmd method execute.

@Override
public void execute() {
    PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(), getNetworkSpeed(), getTags(), getVlan(), getState());
    if (result != null) {
        PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    }
}
Also used : PhysicalNetworkResponse(org.apache.cloudstack.api.response.PhysicalNetworkResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork)

Aggregations

PhysicalNetwork (com.cloud.network.PhysicalNetwork)34 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)9 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)8 ArrayList (java.util.ArrayList)8 HostVO (com.cloud.host.HostVO)7 Network (com.cloud.network.Network)7 Host (com.cloud.host.Host)6 DB (com.cloud.utils.db.DB)6 DataCenterVO (com.cloud.dc.DataCenterVO)5 TransactionStatus (com.cloud.utils.db.TransactionStatus)5 DataCenter (com.cloud.dc.DataCenter)4 ActionEvent (com.cloud.event.ActionEvent)4 NetworkVO (com.cloud.network.dao.NetworkVO)4 Account (com.cloud.user.Account)4 List (java.util.List)4 ConfigurationException (javax.naming.ConfigurationException)4 ServerApiException (com.cloud.api.ServerApiException)3 PhysicalNetworkResponse (com.cloud.api.response.PhysicalNetworkResponse)3 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)3 NetworkOffering (com.cloud.offering.NetworkOffering)3