From 8a7e525aa9c76c1e55e8e5319616928c35806d3b 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 1d9f4698414..ea3272c8c0c 100644 --- a/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java +++ b/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java @@ -171,10 +171,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 b38f3e4635d..925e8d2babe 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(); @@ -951,6 +951,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 { @@ -1010,6 +1011,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) { @@ -1164,6 +1166,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(); @@ -1182,6 +1185,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();