File tree Expand file tree Collapse file tree
compute/src/main/java/org/zstack/compute/vm Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929import org .zstack .header .message .MessageReply ;
3030import org .zstack .header .network .l2 .L2NetworkConstant ;
3131import org .zstack .header .network .l2 .L2NetworkDetachStruct ;
32- import org .zstack .header .network .l2 .L2NetworkVO ;
3332import org .zstack .header .network .l3 .*;
3433import org .zstack .header .vm .*;
3534import org .zstack .header .vm .cdrom .VmCdRomInventory ;
@@ -325,6 +324,7 @@ protected List<DetachNicFromVmMsg> handleDeletionForIpRange(List<VmDeletionStruc
325324 }
326325 }
327326
327+
328328 return msgs ;
329329 }
330330
@@ -529,7 +529,6 @@ public List<String> getEdgeNames() {
529529 L3NetworkVO .class .getSimpleName (),
530530 IpRangeVO .class .getSimpleName (),
531531 PrimaryStorageVO .class .getSimpleName (),
532- L2NetworkVO .class .getSimpleName (),
533532 InstanceOfferingVO .class .getSimpleName (),
534533 AccountVO .class .getSimpleName ());
535534 }
Original file line number Diff line number Diff line change @@ -98,18 +98,18 @@ public void run(MessageReply reply) {
9898 }).run (new WhileDoneCompletion (trigger ){
9999 @ Override
100100 public void done (ErrorCodeList errorCodeList ) {
101- dbf .removeByPrimaryKey (nic .getUuid (), VmNicVO .class );
102-
103101 callReleaseSdnNics (java .util .Collections .singletonList (nic ), new Completion (trigger ) {
104102 @ Override
105103 public void success () {
104+ dbf .removeByPrimaryKey (nic .getUuid (), VmNicVO .class );
106105 trigger .next ();
107106 }
108107
109108 @ Override
110109 public void fail (ErrorCode errorCode ) {
111110 logger .warn (String .format ("releaseSdnNics failed for nic[uuid:%s]: %s, continue" ,
112111 nic .getUuid (), errorCode ));
112+ dbf .removeByPrimaryKey (nic .getUuid (), VmNicVO .class );
113113 trigger .next ();
114114 }
115115 });
Original file line number Diff line number Diff line change @@ -79,12 +79,13 @@ public void run(MessageReply reply) {
7979 @ Override
8080 public void done (ErrorCodeList errorCodeList ) {
8181 List <VmNicInventory > releasedNics = new ArrayList <>();
82+ List <VmNicVO > nicsToDelete = new ArrayList <>();
8283 for (VmNicInventory nic : spec .getVmInventory ().getVmNics ()) {
8384 VmNicVO vo = dbf .findByUuid (nic .getUuid (), VmNicVO .class );
8485 if (VmInstanceConstant .USER_VM_TYPE .equals (spec .getVmInventory ().getType ())) {
8586 VmInstanceDeletionPolicy deletionPolicy = getDeletionPolicy (spec , data );
8687 if (deletionPolicy == VmInstanceDeletionPolicy .Direct ) {
87- dbf . remove (vo );
88+ nicsToDelete . add (vo );
8889 } else {
8990 vo .setUsedIpUuid (null );
9091 vo .setIp (null );
@@ -93,20 +94,22 @@ public void done(ErrorCodeList errorCodeList) {
9394 dbf .update (vo );
9495 }
9596 } else {
96- dbf . remove (vo );
97+ nicsToDelete . add (vo );
9798 }
9899 releasedNics .add (nic );
99100 }
100101
101102 callReleaseSdnNics (releasedNics , new Completion (chain ) {
102103 @ Override
103104 public void success () {
105+ nicsToDelete .forEach (dbf ::remove );
104106 chain .next ();
105107 }
106108
107109 @ Override
108110 public void fail (ErrorCode errorCode ) {
109111 logger .warn (String .format ("releaseSdnNics failed: %s, continue anyway" , errorCode ));
112+ nicsToDelete .forEach (dbf ::remove );
110113 chain .next ();
111114 }
112115 });
You can’t perform that action at this time.
0 commit comments