From 1140f081df15c8efbb04d1ed8d2277cc835e342d Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Tue, 26 Jun 2012 14:07:25 -0700 Subject: [PATCH] VPC: fixed getEntityOwnerId() in AssociateIpAddress command to return vpc owner if vpcId is passed in. Added action events for create/delete privateGateway/staticRoutes --- api/src/com/cloud/api/commands/AssociateIPAddrCmd.java | 7 ++++++- server/src/com/cloud/network/vpc/VpcManagerImpl.java | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java b/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java index 7b8e41dea62..75044cc8215 100644 --- a/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java +++ b/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java @@ -175,10 +175,15 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { if (accountName != null && domainId != null) { Account account = _accountService.finalizeOwner(caller, accountName, domainId, projectId); return account.getId(); - } else { + } else if (getNetworkId() != null){ Network network = _networkService.getNetwork(getNetworkId()); return network.getAccountId(); + } else if (vpcId != null) { + Vpc vpc = _vpcService.getVpc(getVpcId()); + return vpc.getAccountId(); } + + throw new InvalidParameterValueException("Failed to determine ip owner"); } @Override diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java index 0eeb47afd61..210fcb7f66f 100644 --- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java @@ -175,7 +175,7 @@ public class VpcManagerImpl implements VpcManager, Manager{ } @Override - @ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_CREATE, eventDescription = "creating vpc offering") + @ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_CREATE, eventDescription = "creating vpc offering", create=true) public VpcOffering createVpcOffering(String name, String displayText, List supportedServices) { Map> svcProviderMap = new HashMap>(); Set defaultProviders = new HashSet(); @@ -428,7 +428,7 @@ public class VpcManagerImpl implements VpcManager, Manager{ } @Override - @ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc") + @ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc", create=true) public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain) { Account caller = UserContext.current().getCaller(); @@ -952,6 +952,7 @@ public class VpcManagerImpl implements VpcManager, Manager{ @Override @DB + @ActionEvent(eventType = EventTypes.EVENT_PRIVATE_GATEWAY_CREATE, eventDescription = "creating vpc private gateway", create=true) public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String vlan, String ipAddress, String gateway, String netmask, long gatewayOwnerId) throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException { @@ -1011,6 +1012,7 @@ public class VpcManagerImpl implements VpcManager, Manager{ } @Override + @ActionEvent(eventType = EventTypes.EVENT_PRIVATE_GATEWAY_DELETE, eventDescription = "deleting private gateway") public boolean deleteVpcPrivateGateway(Long gatewayId) throws ConcurrentOperationException, ResourceUnavailableException { VpcGatewayVO gatewayVO = _vpcGatewayDao.findById(gatewayId); if (gatewayVO == null || gatewayVO.getType() != VpcGateway.Type.Private) { @@ -1165,6 +1167,7 @@ public class VpcManagerImpl implements VpcManager, Manager{ } @Override + @ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_DELETE, eventDescription = "deleting static route") public boolean revokeStaticRoute(long routeId) throws ResourceUnavailableException { Account caller = UserContext.current().getCaller(); @@ -1183,6 +1186,7 @@ public class VpcManagerImpl implements VpcManager, Manager{ @Override @DB + @ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_CREATE, eventDescription = "creating static route", create=true) public StaticRoute createStaticRoute(long gatewayId, String cidr) throws NetworkRuleConflictException { Account caller = UserContext.current().getCaller();