@@ -781,8 +781,7 @@ private void syncVMVolumes(VMInstanceVO vmInstanceVO, List<VirtualDisk> virtualD
781781 volume = createVolume (disk , vmToImport , domainId , zoneId , accountId , instanceId , poolId , templateId , backup , true );
782782 operation = "created" ;
783783 }
784- s_logger .debug (String .format ("VM [id: %s, instanceName: %s] backup restore operation %s volume [id: %s]." , instanceId , vmInstanceVO .getInstanceName (),
785- operation , volume .getUuid ()));
784+ s_logger .debug (String .format ("Sync volumes to %s in backup restore operation: %s volume [id: %s]." , vmInstanceVO , operation , volume .getUuid ()));
786785 }
787786 }
788787
@@ -879,9 +878,13 @@ private NetworkVO getGuestNetworkFromNetworkMorName(String name, long accountId,
879878 String tag = parts [parts .length - 1 ];
880879 String [] tagSplit = tag .split ("-" );
881880 tag = tagSplit [tagSplit .length - 1 ];
881+
882+ s_logger .debug (String .format ("Trying to find network with vlan: [%s]." , vlan ));
882883 NetworkVO networkVO = networkDao .findByVlan (vlan );
883884 if (networkVO == null ) {
884885 networkVO = createNetworkRecord (zoneId , tag , vlan , accountId , domainId );
886+ s_logger .debug (String .format ("Created new network record [id: %s] with details [zoneId: %s, tag: %s, vlan: %s, accountId: %s and domainId: %s]." ,
887+ networkVO .getUuid (), zoneId , tag , vlan , accountId , domainId ));
885888 }
886889 return networkVO ;
887890 }
@@ -893,6 +896,7 @@ private Map<String, NetworkVO> getNetworksMapping(String[] vmNetworkNames, long
893896 Map <String , NetworkVO > mapping = new HashMap <>();
894897 for (String networkName : vmNetworkNames ) {
895898 NetworkVO networkVO = getGuestNetworkFromNetworkMorName (networkName , accountId , zoneId , domainId );
899+ s_logger .debug (String .format ("Mapping network name [%s] to networkVO [id: %s]." , networkName , networkVO .getUuid ()));
896900 mapping .put (networkName , networkVO );
897901 }
898902 return mapping ;
@@ -927,12 +931,19 @@ private void syncVMNics(VirtualDevice[] nicDevices, DatacenterMO dcMo, Map<Strin
927931 String macAddress = pair .first ();
928932 String networkName = pair .second ();
929933 NetworkVO networkVO = networksMapping .get (networkName );
930- NicVO nicVO = nicDao .findByNetworkIdAndMacAddress (networkVO .getId (), macAddress );
934+ NicVO nicVO = nicDao .findByNetworkIdAndMacAddressIncludingRemoved (networkVO .getId (), macAddress );
931935 if (nicVO != null ) {
936+ s_logger .warn (String .format ("Find NIC in DB with networkId [%s] and MAC Address [%s], so this NIC will be removed from list of unmapped NICs of VM [id: %s, name: %s]." ,
937+ networkVO .getId (), macAddress , vm .getUuid (), vm .getInstanceName ()));
932938 allNics .remove (nicVO );
939+
940+ if (nicVO .getRemoved () != null ) {
941+ nicDao .unremove (nicVO .getId ());
942+ }
933943 }
934944 }
935945 for (final NicVO unMappedNic : allNics ) {
946+ s_logger .debug (String .format ("Removing NIC [%s] from backup restored %s." , ReflectionToStringBuilderUtils .reflectOnlySelectedFields (unMappedNic , "uuid" , "macAddress" ), vm ));
936947 vmManager .removeNicFromVm (vm , unMappedNic );
937948 }
938949 }
0 commit comments