diff --git a/api/src/com/cloud/api/commands/CreateVPCCmd.java b/api/src/com/cloud/api/commands/CreateVPCCmd.java index 7807a0ba2b6..11c8ad6b2d9 100644 --- a/api/src/com/cloud/api/commands/CreateVPCCmd.java +++ b/api/src/com/cloud/api/commands/CreateVPCCmd.java @@ -121,7 +121,6 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{ @Override public void execute() { - //TODO - prepare vpc here (call start() method, it should start the VR, associate source nat ip address, etc) Vpc vpc = null; try { if (_vpcService.startVpc(this.getEntityId())) { diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 70cd9871327..4dfefe06c71 100755 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -351,3 +351,9 @@ createVPCOffering=com.cloud.api.commands.CreateVPCOfferingCmd;1 updateVPCOffering=com.cloud.api.commands.UpdateVPCOfferingCmd;1 deleteVPCOffering=com.cloud.api.commands.DeleteVPCOfferingCmd;1 listVPCOfferings=com.cloud.api.commands.ListVPCOfferingsCmd;15 + +#### VPC gateway commands +createVPCGateway=com.cloud.api.commands.CreateVPCGatewayCmd;15 +listVPCGateways=com.cloud.api.commands.ListVPCGatewaysCmd;15 +deleteVPCGateway=com.cloud.api.commands.DeleteVPCGatewayCmd;15 + diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 8adcc4c1960..cba9f529eb9 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -1334,7 +1334,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks, "Offering for Isolated VPC networks with Source Nat service enabled", TrafficType.Guest, null, false, Availability.Required, null, defaultIsolatedSourceNatEnabledNetworkOfferingProviders, - true, Network.GuestType.Isolated, false, null, true, null, false); + true, Network.GuestType.Isolated, false, null, false, null, false); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java index b17cf63a8d8..1d57e28be38 100644 --- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java @@ -385,7 +385,6 @@ public class VpcManagerImpl implements VpcManager, Manager{ offering.setDisplayText(displayText); } - if (state != null) { boolean validState = false; for (VpcOffering.State st : VpcOffering.State.values()) { @@ -704,19 +703,42 @@ public class VpcManagerImpl implements VpcManager, Manager{ DeployDestination dest = new DeployDestination(dc, null, null, null); ReservationContext context = new ReservationContextImpl(null, null, callerUser, _accountMgr.getAccount(vpc.getAccountId())); + + boolean result = true; + try { + if (!startVpc(vpc, dest, context)) { + s_logger.warn("Failed to start vpc " + vpc); + result = false; + } + } catch (Exception ex) { + s_logger.warn("Failed to start vpc " + vpc + " due to ", ex); + result = false; + } finally { + //do cleanup + if (!result) { + s_logger.debug("Destroying vpc " + vpc + " that failed to start"); + if (destroyVpc(vpc)) { + s_logger.warn("Successfully destroyed vpc " + vpc + " that failed to start"); + } else { + s_logger.warn("Failed to destroy vpc " + vpc + " that failed to start"); + } + } + } + return result; + } + protected boolean startVpc(Vpc vpc, DeployDestination dest, ReservationContext context) + throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { //deploy provider if (getVpcElement().implementVpc(vpc, dest, context)) { s_logger.debug("Vpc " + vpc + " has started succesfully"); return true; } else { s_logger.warn("Vpc " + vpc + " failed to start"); - //FIXME - add cleanup logic here return false; } } - @Override public boolean shutdownVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException { UserContext ctx = UserContext.current(); @@ -778,14 +800,16 @@ public class VpcManagerImpl implements VpcManager, Manager{ //4) vpc and network should belong to the same owner if (vpc.getAccountId() != networkOwner.getId()) { - throw new InvalidParameterValueException("Vpc " + vpc + " owner is different from the network owner " + networkOwner); + throw new InvalidParameterValueException("Vpc " + vpc + " owner is different from the network owner " + + networkOwner); } //5) Only Isolated networks with Source nat service enabled can be added to vpc if (!(guestNtwkOff.getGuestType() == GuestType.Isolated && _ntwkMgr.areServicesSupportedByNetworkOffering(guestNtwkOff.getId(), Service.SourceNat))) { - throw new InvalidParameterValueException("Only networks of type " + GuestType.Isolated + " with service " + Service.SourceNat + + throw new InvalidParameterValueException("Only networks of type " + GuestType.Isolated + " with service " + + Service.SourceNat + " can be added as a part of VPC"); } @@ -842,7 +866,6 @@ public class VpcManagerImpl implements VpcManager, Manager{ } return success; - } diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 90ef87d5bad..a6689b8ccd2 100755 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -1014,7 +1014,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { "Offering for Isolated Vpc networks with Source Nat service enabled", TrafficType.Guest, false, false, null, null, true, Availability.Required, - null, Network.GuestType.Isolated, true, false); + null, Network.GuestType.Isolated, false, false); defaultNetworkOfferingForVpcNetworks.setState(NetworkOffering.State.Enabled); defaultNetworkOfferingForVpcNetworks = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworks); diff --git a/wscript b/wscript index 232691701b7..df4d195d3a9 100644 --- a/wscript +++ b/wscript @@ -3,7 +3,7 @@ # the following two variables are used by the target "waf dist" # if you change 'em here, you need to change it also in cloud.spec, add a %changelog entry there, and add an entry in debian/changelog -VERSION = '3.0.3.2012-05-25T22:13:38Z' +VERSION = '3.0.3.2012-05-29T17:33:07Z' APPNAME = 'cloud' import shutil,os