@@ -1531,8 +1531,6 @@ public Pair<NetworkGuru, NetworkVO> implementNetwork(final long networkId, final
15311531 if (isNetworkImplemented (network )) {
15321532 logger .debug ("Network {} is already implemented" , network );
15331533 implemented .set (guru , network );
1534- UsageEventUtils .publishUsageEvent (EventTypes .EVENT_NETWORK_UPDATE , network .getAccountId (), network .getDataCenterId (), network .getId (),
1535- network .getName (), network .getNetworkOfferingId (), null , network .getState ().name (), Network .class .getName (), network .getUuid (), true );
15361534 return implemented ;
15371535 }
15381536
@@ -1588,9 +1586,8 @@ public Pair<NetworkGuru, NetworkVO> implementNetwork(final long networkId, final
15881586
15891587 network .setRestartRequired (false );
15901588 _networksDao .update (network .getId (), network );
1589+ UsageEventUtils .publishNetworkUpdate (network );
15911590 implemented .set (guru , network );
1592- UsageEventUtils .publishUsageEvent (EventTypes .EVENT_NETWORK_CREATE , network .getAccountId (), network .getDataCenterId (), network .getId (),
1593- network .getName (), network .getNetworkOfferingId (), null , null , null , network .getState ().name (), network .getUuid ());
15941591 return implemented ;
15951592 } catch (final NoTransitionException e ) {
15961593 logger .error (e .getMessage ());
@@ -3089,6 +3086,7 @@ public Network doInTransaction(final TransactionStatus status) {
30893086 if (updateResourceCount ) {
30903087 _resourceLimitMgr .incrementResourceCount (owner .getId (), ResourceType .network , isDisplayNetworkEnabled );
30913088 }
3089+ UsageEventUtils .publishNetworkCreation (network );
30923090
30933091 return network ;
30943092 }
@@ -3170,13 +3168,14 @@ public boolean shutdownNetwork(final long networkId, final ReservationContext co
31703168 }
31713169 logger .debug ("Lock is acquired for network {} as a part of network shutdown" , network );
31723170
3173- if (network .getState () == Network .State .Allocated ) {
3174- logger .debug ("Network is already shutdown: {}" , network );
3171+ final Network .State initialState = network .getState ();
3172+ if (initialState == Network .State .Allocated ) {
3173+ logger .debug (String .format ("Network [%s] is in Allocated state, no need to shutdown." , network ));
31753174 return true ;
31763175 }
31773176
3178- if (network . getState () != Network .State .Implemented && network . getState () != Network .State .Shutdown ) {
3179- logger .debug ("Network is not implemented: {}" , network );
3177+ if (initialState != Network .State .Implemented && initialState != Network .State .Shutdown ) {
3178+ logger .debug ("Network is not implemented: " + network );
31803179 return false ;
31813180 }
31823181
@@ -3220,6 +3219,9 @@ public Boolean doInTransaction(final TransactionStatus status) {
32203219 }
32213220 _networksDao .update (networkFinal .getId (), networkFinal );
32223221 _networksDao .clearCheckForGc (networkId );
3222+ if (initialState == Network .State .Implemented ) {
3223+ UsageEventUtils .publishNetworkUpdate (networkFinal );
3224+ }
32233225 result = true ;
32243226 } else {
32253227 try {
@@ -3471,8 +3473,7 @@ public List<VlanVO> doInTransaction(TransactionStatus status) {
34713473 final Pair <Class <?>, Long > networkMsg = new Pair <Class <?>, Long >(Network .class , networkFinal .getId ());
34723474 _messageBus .publish (_name , EntityManager .MESSAGE_REMOVE_ENTITY_EVENT , PublishScope .LOCAL , networkMsg );
34733475 }
3474- UsageEventUtils .publishUsageEvent (EventTypes .EVENT_NETWORK_DELETE , network .getAccountId (), network .getDataCenterId (), network .getId (),
3475- network .getName (), network .getNetworkOfferingId (), null , null , null , Network .class .getName (), network .getUuid ());
3476+ UsageEventUtils .publishNetworkDeletion (network );
34763477 return true ;
34773478 } catch (final CloudRuntimeException e ) {
34783479 logger .error ("Failed to delete network" , e );
0 commit comments