Search in sources :

Example 1 with State

use of com.cloud.network.Network.State in project cloudstack by apache.

the class NetworkStateListener method postStateTransitionEvent.

@Override
public boolean postStateTransitionEvent(StateMachine2.Transition<State, Event> transition, Network vo, boolean status, Object opaque) {
    State oldState = transition.getCurrentState();
    State newState = transition.getToState();
    Event event = transition.getEvent();
    pubishOnEventBus(event.name(), "postStateTransitionEvent", vo, oldState, newState);
    return true;
}
Also used : State(com.cloud.network.Network.State) Event(com.cloud.network.Network.Event)

Example 2 with State

use of com.cloud.network.Network.State in project cloudstack by apache.

the class DirectNetworkGuru method design.

@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
    DataCenter dc = _dcDao.findById(plan.getDataCenterId());
    if (!canHandle(offering, dc)) {
        return null;
    }
    State state = State.Allocated;
    if (dc.getNetworkType() == NetworkType.Basic) {
        state = State.Setup;
    }
    NetworkVO config = new NetworkVO(offering.getTrafficType(), Mode.Dhcp, BroadcastDomainType.Vlan, offering.getId(), state, plan.getDataCenterId(), plan.getPhysicalNetworkId(), offering.getRedundantRouter());
    if (userSpecified != null) {
        if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) || (userSpecified.getCidr() != null && userSpecified.getGateway() == null)) {
            throw new InvalidParameterValueException("cidr and gateway must be specified together.");
        }
        if ((userSpecified.getIp6Cidr() == null && userSpecified.getIp6Gateway() != null) || (userSpecified.getIp6Cidr() != null && userSpecified.getIp6Gateway() == null)) {
            throw new InvalidParameterValueException("cidrv6 and gatewayv6 must be specified together.");
        }
        if (userSpecified.getCidr() != null) {
            config.setCidr(userSpecified.getCidr());
            config.setGateway(userSpecified.getGateway());
        }
        if (userSpecified.getIp6Cidr() != null) {
            config.setIp6Cidr(userSpecified.getIp6Cidr());
            config.setIp6Gateway(userSpecified.getIp6Gateway());
        }
        if (userSpecified.getBroadcastUri() != null) {
            config.setBroadcastUri(userSpecified.getBroadcastUri());
            config.setState(State.Setup);
        }
        if (userSpecified.getBroadcastDomainType() != null) {
            config.setBroadcastDomainType(userSpecified.getBroadcastDomainType());
        }
    }
    boolean isSecurityGroupEnabled = _networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup);
    if (isSecurityGroupEnabled) {
        if (userSpecified.getIp6Cidr() != null) {
            throw new InvalidParameterValueException("Didn't support security group with IPv6");
        }
        config.setName("SecurityGroupEnabledNetwork");
        config.setDisplayText("SecurityGroupEnabledNetwork");
    }
    return config;
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) DataCenter(com.cloud.dc.DataCenter) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) State(com.cloud.network.Network.State)

Aggregations

State (com.cloud.network.Network.State)2 DataCenter (com.cloud.dc.DataCenter)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 Event (com.cloud.network.Network.Event)1 NetworkVO (com.cloud.network.dao.NetworkVO)1