2424import javax .inject .Inject ;
2525import javax .naming .ConfigurationException ;
2626
27- import com .cloud .network .vpc .VpcOfferingVO ;
28- import com .cloud .offerings .NetworkOfferingVO ;
29- import com .cloud .storage .SnapshotPolicyVO ;
30- import com .cloud .user .dao .AccountDao ;
31- import com .cloud .utils .exception .CloudRuntimeException ;
3227import org .apache .cloudstack .api .Identity ;
3328import org .apache .cloudstack .api .InternalIdentity ;
3429import org .apache .cloudstack .context .CallContext ;
5651import com .cloud .network .dao .Site2SiteVpnGatewayVO ;
5752import com .cloud .network .rules .FirewallRuleVO ;
5853import com .cloud .network .rules .PortForwardingRuleVO ;
59- import com .cloud .network .security .SecurityGroupVO ;
6054import com .cloud .network .security .SecurityGroupRuleVO ;
55+ import com .cloud .network .security .SecurityGroupVO ;
6156import com .cloud .network .vpc .NetworkACLItemVO ;
6257import com .cloud .network .vpc .NetworkACLVO ;
6358import com .cloud .network .vpc .StaticRouteVO ;
59+ import com .cloud .network .vpc .VpcOfferingVO ;
6460import com .cloud .network .vpc .VpcVO ;
61+ import com .cloud .offerings .NetworkOfferingVO ;
6562import com .cloud .projects .ProjectVO ;
6663import com .cloud .server .ResourceTag ;
6764import com .cloud .server .ResourceTag .ResourceObjectType ;
6865import com .cloud .server .TaggedResourceService ;
6966import com .cloud .service .ServiceOfferingVO ;
7067import com .cloud .storage .DiskOfferingVO ;
68+ import com .cloud .storage .SnapshotPolicyVO ;
7169import com .cloud .storage .SnapshotVO ;
7270import com .cloud .storage .VMTemplateVO ;
7371import com .cloud .storage .VolumeVO ;
7775import com .cloud .user .DomainManager ;
7876import com .cloud .user .OwnedBy ;
7977import com .cloud .user .UserVO ;
78+ import com .cloud .user .dao .AccountDao ;
8079import com .cloud .utils .Pair ;
8180import com .cloud .utils .component .ManagerBase ;
8281import com .cloud .utils .db .DB ;
8685import com .cloud .utils .db .Transaction ;
8786import com .cloud .utils .db .TransactionCallbackNoReturn ;
8887import com .cloud .utils .db .TransactionStatus ;
88+ import com .cloud .utils .exception .CloudRuntimeException ;
8989import com .cloud .vm .NicVO ;
9090import com .cloud .vm .UserVmVO ;
9191import com .cloud .vm .snapshot .VMSnapshotVO ;
@@ -146,7 +146,6 @@ public class TaggedResourceManagerImpl extends ManagerBase implements TaggedReso
146146 @ Inject
147147 AccountDao _accountDao ;
148148
149-
150149 @ Override
151150 public boolean configure (String name , Map <String , Object > params ) throws ConfigurationException {
152151 return true ;
@@ -195,6 +194,20 @@ private Pair<Long, Long> getAccountDomain(long resourceId, ResourceObjectType re
195194 domainId = ((SecurityGroupVO )SecurityGroup ).getDomainId ();
196195 }
197196
197+ // if the resource type is network acl, get the accountId and domainId from VPC following: NetworkACLItem -> NetworkACL -> VPC
198+ if (resourceType == ResourceObjectType .NetworkACL ) {
199+ NetworkACLItemVO aclItem = (NetworkACLItemVO )entity ;
200+ Object networkACL = _entityMgr .findById (s_typeMap .get (ResourceObjectType .NetworkACLList ), aclItem .getAclId ());
201+ Long vpcId = ((NetworkACLVO )networkACL ).getVpcId ();
202+
203+ if (vpcId != null && vpcId != 0 ) {
204+ Object vpc = _entityMgr .findById (s_typeMap .get (ResourceObjectType .Vpc ), vpcId );
205+
206+ accountId = ((VpcVO )vpc ).getAccountId ();
207+ domainId = ((VpcVO )vpc ).getDomainId ();
208+ }
209+ }
210+
198211 if (entity instanceof OwnedBy ) {
199212 accountId = ((OwnedBy )entity ).getAccountId ();
200213 }
@@ -207,8 +220,7 @@ private Pair<Long, Long> getAccountDomain(long resourceId, ResourceObjectType re
207220 accountId = Account .ACCOUNT_ID_SYSTEM ;
208221 }
209222
210- if ((domainId == null ) || ((accountId != null ) && (domainId .longValue () == -1 )))
211- {
223+ if ((domainId == null ) || ((accountId != null ) && (domainId .longValue () == -1 ))) {
212224 domainId = _accountDao .getDomainIdForGivenAccountId (accountId );
213225 }
214226 return new Pair <Long , Long >(accountId , domainId );
@@ -238,7 +250,7 @@ public List<ResourceTag> createTags(final List<String> resourceIds, final Resour
238250 public void doInTransactionWithoutResult (TransactionStatus status ) {
239251 for (String key : tags .keySet ()) {
240252 for (String resourceId : resourceIds ) {
241- if (!resourceType .resourceTagsSupport ()) {
253+ if (!resourceType .resourceTagsSupport ()) {
242254 throw new InvalidParameterValueException ("The resource type " + resourceType + " doesn't support resource tags" );
243255 }
244256
@@ -249,9 +261,8 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
249261 Long domainId = accountDomainPair .second ();
250262 Long accountId = accountDomainPair .first ();
251263
252- if ((domainId != null ) && (domainId == -1 ))
253- {
254- throw new CloudRuntimeException ("Invalid DomainId : -1" );
264+ if ((domainId != null ) && (domainId == -1 )) {
265+ throw new CloudRuntimeException ("Invalid DomainId : -1" );
255266 }
256267 if (accountId != null ) {
257268 _accountMgr .checkAccess (caller , null , false , _accountMgr .getAccount (accountId ));
@@ -290,10 +301,10 @@ public String getUuid(String resourceId, ResourceObjectType resourceType) {
290301 Object entity = _entityMgr .findById (clazz , resourceId );
291302 if (entity != null && entity instanceof Identity ) {
292303 return ((Identity )entity ).getUuid ();
293- }
304+ }
294305
295- return resourceId ;
296- }
306+ return resourceId ;
307+ }
297308
298309 @ Override
299310 @ DB
0 commit comments