mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Improve logs on SecondaryStorageManagerImpl and few refactors (#4955)
Co-authored-by: Daniel Augusto Veronezi Salvador <daniel@scclouds.com.br>
This commit is contained in:
		
							parent
							
								
									cb167072a1
								
							
						
					
					
						commit
						3674e80219
					
				| @ -471,4 +471,10 @@ public class DataCenterVO implements DataCenter { | |||||||
|     public PartitionType partitionType() { |     public PartitionType partitionType() { | ||||||
|         return PartitionType.Zone; |         return PartitionType.Zone; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public String toString() { | ||||||
|  |         return String.format("Zone {\"id\": \"%s\", \"name\": \"%s\", \"uuid\": \"%s\"}", id, name, uuid); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -504,14 +504,9 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi | |||||||
|         this.removed = removed; |         this.removed = removed; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     transient String toString; |  | ||||||
| 
 |  | ||||||
|     @Override |     @Override | ||||||
|     public String toString() { |     public String toString() { | ||||||
|         if (toString == null) { |         return String.format("VM instance {\"id\": \"%s\", \"name\": \"%s\", \"uuid\": \"%s\", \"type\"=\"%s\"}", id, getInstanceName(), uuid, type); | ||||||
|             toString = new StringBuilder("VM[").append(type.toString()).append("|").append(getInstanceName()).append("]").toString(); |  | ||||||
|         } |  | ||||||
|         return toString; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -30,10 +30,16 @@ import org.mockito.MockitoAnnotations; | |||||||
| import com.cloud.dc.DataCenterVO; | import com.cloud.dc.DataCenterVO; | ||||||
| import com.cloud.dc.DataCenter.NetworkType; | import com.cloud.dc.DataCenter.NetworkType; | ||||||
| import com.cloud.dc.dao.DataCenterDao; | import com.cloud.dc.dao.DataCenterDao; | ||||||
|  | import com.cloud.hypervisor.Hypervisor; | ||||||
| import com.cloud.network.Networks.TrafficType; | import com.cloud.network.Networks.TrafficType; | ||||||
| import com.cloud.network.dao.NetworkDao; | import com.cloud.network.dao.NetworkDao; | ||||||
| import com.cloud.network.dao.NetworkVO; | import com.cloud.network.dao.NetworkVO; | ||||||
| import com.cloud.utils.exception.CloudRuntimeException; | import com.cloud.utils.exception.CloudRuntimeException; | ||||||
|  | import com.cloud.vm.NicProfile; | ||||||
|  | import com.cloud.vm.VirtualMachineProfile; | ||||||
|  | import java.util.ArrayList; | ||||||
|  | import java.util.Arrays; | ||||||
|  | import java.util.List; | ||||||
| 
 | 
 | ||||||
| import static org.mockito.Mockito.mock; | import static org.mockito.Mockito.mock; | ||||||
| import static org.mockito.Mockito.any; | import static org.mockito.Mockito.any; | ||||||
| @ -189,4 +195,27 @@ public class SecondaryStorageManagerTest { | |||||||
| 
 | 
 | ||||||
|         _ssMgr.getDefaultNetworkForAdvancedZone(dc); |         _ssMgr.getDefaultNetworkForAdvancedZone(dc); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void validateVerifySshAccessOnManagementNicForSystemVm(){ | ||||||
|  |         Hypervisor.HypervisorType[] hypervisorTypesArray = Hypervisor.HypervisorType.values(); | ||||||
|  |         List<Hypervisor.HypervisorType> hypervisorTypesThatMustReturnManagementNic = new ArrayList<>(Arrays.asList(Hypervisor.HypervisorType.Hyperv)); | ||||||
|  | 
 | ||||||
|  |         for (Hypervisor.HypervisorType hypervisorType: hypervisorTypesArray) { | ||||||
|  |             VirtualMachineProfile virtualMachineProfileMock = Mockito.mock(VirtualMachineProfile.class); | ||||||
|  |             NicProfile controlNic = Mockito.mock(NicProfile.class); | ||||||
|  |             NicProfile managementNic = Mockito.mock(NicProfile.class); | ||||||
|  | 
 | ||||||
|  |             Mockito.doReturn(hypervisorType).when(virtualMachineProfileMock).getHypervisorType(); | ||||||
|  | 
 | ||||||
|  |             NicProfile expectedResult = controlNic; | ||||||
|  |             if (hypervisorTypesThatMustReturnManagementNic.contains(hypervisorType)) { | ||||||
|  |                 expectedResult = managementNic; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             NicProfile result = _ssMgr.verifySshAccessOnManagementNicForSystemVm(virtualMachineProfileMock, controlNic, managementNic); | ||||||
|  | 
 | ||||||
|  |             Assert.assertEquals(expectedResult, result); | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user