@@ -1461,8 +1461,6 @@ public Pair<NetworkGuru, NetworkVO> implementNetwork(final long networkId, final
14611461 if (isNetworkImplemented (network )) {
14621462 s_logger .debug ("Network id=" + networkId + " is already implemented" );
14631463 implemented .set (guru , network );
1464- UsageEventUtils .publishUsageEvent (EventTypes .EVENT_NETWORK_UPDATE , network .getAccountId (), network .getDataCenterId (), network .getId (),
1465- network .getName (), network .getNetworkOfferingId (), null , network .getState ().name (), Network .class .getName (), network .getUuid (), true );
14661464 return implemented ;
14671465 }
14681466
@@ -1522,9 +1520,8 @@ public Pair<NetworkGuru, NetworkVO> implementNetwork(final long networkId, final
15221520
15231521 network .setRestartRequired (false );
15241522 _networksDao .update (network .getId (), network );
1523+ UsageEventUtils .publishNetworkUpdate (network );
15251524 implemented .set (guru , network );
1526- UsageEventUtils .publishUsageEvent (EventTypes .EVENT_NETWORK_CREATE , network .getAccountId (), network .getDataCenterId (), network .getId (),
1527- network .getName (), network .getNetworkOfferingId (), null , null , null , network .getState ().name (), network .getUuid ());
15281525 return implemented ;
15291526 } catch (final NoTransitionException e ) {
15301527 s_logger .error (e .getMessage ());
@@ -3005,6 +3002,7 @@ public Network doInTransaction(final TransactionStatus status) {
30053002 if (updateResourceCount ) {
30063003 _resourceLimitMgr .incrementResourceCount (owner .getId (), ResourceType .network , isDisplayNetworkEnabled );
30073004 }
3005+ UsageEventUtils .publishNetworkCreation (network );
30083006
30093007 return network ;
30103008 }
@@ -3089,12 +3087,13 @@ public boolean shutdownNetwork(final long networkId, final ReservationContext co
30893087 s_logger .debug ("Lock is acquired for network " + network + " as a part of network shutdown" );
30903088 }
30913089
3092- if (network .getState () == Network .State .Allocated ) {
3090+ final Network .State initialState = network .getState ();
3091+ if (initialState == Network .State .Allocated ) {
30933092 s_logger .debug (String .format ("Network [%s] is in Allocated state, no need to shutdown." , network ));
30943093 return true ;
30953094 }
30963095
3097- if (network . getState () != Network .State .Implemented && network . getState () != Network .State .Shutdown ) {
3096+ if (initialState != Network .State .Implemented && initialState != Network .State .Shutdown ) {
30983097 s_logger .debug ("Network is not implemented: " + network );
30993098 return false ;
31003099 }
@@ -3141,6 +3140,9 @@ public Boolean doInTransaction(final TransactionStatus status) {
31413140 }
31423141 _networksDao .update (networkFinal .getId (), networkFinal );
31433142 _networksDao .clearCheckForGc (networkId );
3143+ if (initialState == Network .State .Implemented ) {
3144+ UsageEventUtils .publishNetworkUpdate (networkFinal );
3145+ }
31443146 result = true ;
31453147 } else {
31463148 try {
@@ -3393,8 +3395,7 @@ public List<VlanVO> doInTransaction(TransactionStatus status) {
33933395 final Pair <Class <?>, Long > networkMsg = new Pair <Class <?>, Long >(Network .class , networkFinal .getId ());
33943396 _messageBus .publish (_name , EntityManager .MESSAGE_REMOVE_ENTITY_EVENT , PublishScope .LOCAL , networkMsg );
33953397 }
3396- UsageEventUtils .publishUsageEvent (EventTypes .EVENT_NETWORK_DELETE , network .getAccountId (), network .getDataCenterId (), network .getId (),
3397- network .getName (), network .getNetworkOfferingId (), null , null , null , Network .class .getName (), network .getUuid ());
3398+ UsageEventUtils .publishNetworkDeletion (network );
33983399 return true ;
33993400 } catch (final CloudRuntimeException e ) {
34003401 s_logger .error ("Failed to delete network" , e );
0 commit comments