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;
}
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;
}
Aggregations