mirror of https://github.com/apache/cloudstack.git
Merge 30aab35ed6 into 9bbd32a8ef
This commit is contained in:
commit
fbe89bf3a4
|
|
@ -73,5 +73,7 @@
|
|||
<bean id="volumeDaoImpl" class="com.cloud.storage.dao.VolumeDaoImpl" />
|
||||
<bean id="reservationDao" class="org.apache.cloudstack.reservation.dao.ReservationDaoImpl" />
|
||||
<bean id="backupOfferingDaoImpl" class="org.apache.cloudstack.backup.dao.BackupOfferingDaoImpl" />
|
||||
<bean id="vpcOfferingDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingDaoImpl" />
|
||||
<bean id="vpcOfferingDetailsDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingDetailsDaoImpl"/>
|
||||
<bean id="backupOfferingDetailsDaoImpl" class="org.apache.cloudstack.backup.dao.BackupOfferingDetailsDaoImpl" />
|
||||
</beans>
|
||||
|
|
|
|||
|
|
@ -236,13 +236,11 @@
|
|||
<bean id="volumeStatsDaoImpl" class="com.cloud.storage.dao.VolumeStatsDaoImpl" />
|
||||
<bean id="vpcDaoImpl" class="com.cloud.network.vpc.dao.VpcDaoImpl" />
|
||||
<bean id="vpcGatewayDaoImpl" class="com.cloud.network.vpc.dao.VpcGatewayDaoImpl" />
|
||||
<bean id="vpcOfferingDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingDaoImpl" />
|
||||
<bean id="vpcOfferingJoinDaoImpl" class="com.cloud.api.query.dao.VpcOfferingJoinDaoImpl" />
|
||||
<bean id="vpcOfferingServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingServiceMapDaoImpl" />
|
||||
<bean id="vpcServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcServiceMapDaoImpl" />
|
||||
<bean id="vpnUserDaoImpl" class="com.cloud.network.dao.VpnUserDaoImpl" />
|
||||
<bean id="applicationLbRuleDaoImpl" class="org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDaoImpl" />
|
||||
<bean id="vpcOfferingDetailsDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingDetailsDaoImpl"/>
|
||||
<bean id="networkDetailsDaoImpl" class="com.cloud.network.dao.NetworkDetailsDaoImpl" />
|
||||
<bean id="tungstenGuestNetworkIpAddressDaoImpl" class="com.cloud.network.dao.TungstenGuestNetworkIpAddressDaoImpl"/>
|
||||
<bean id="tungstenSecurityGroupRuleDaoImpl" class="com.cloud.network.security.dao.TungstenSecurityGroupRuleDaoImpl"/>
|
||||
|
|
|
|||
|
|
@ -28,11 +28,12 @@ import java.util.stream.Collectors;
|
|||
import com.cloud.dc.ClusterDetailsDao;
|
||||
import com.cloud.dc.ClusterDetailsVO;
|
||||
import com.cloud.host.HostTagVO;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.vpc.VpcOfferingVO;
|
||||
import com.cloud.network.vpc.VpcVO;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.storage.StoragePoolTagVO;
|
||||
import org.apache.cloudstack.acl.RoleVO;
|
||||
import org.apache.cloudstack.acl.dao.RoleDao;
|
||||
|
|
@ -66,6 +67,7 @@ import com.cloud.domain.dao.DomainDao;
|
|||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostTagsDao;
|
||||
import com.cloud.network.vpc.dao.VpcOfferingDao;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.server.ResourceTag;
|
||||
|
|
@ -191,6 +193,9 @@ public class PresetVariableHelper {
|
|||
@Inject
|
||||
ClusterDetailsDao clusterDetailsDao;
|
||||
|
||||
@Inject
|
||||
VpcOfferingDao vpcOfferingDao;
|
||||
|
||||
protected boolean backupSnapshotAfterTakingSnapshot = SnapshotInfo.BackupSnapshotAfterTakingSnapshot.value();
|
||||
|
||||
private List<Integer> runningAndAllocatedVmUsageTypes = Arrays.asList(UsageTypes.RUNNING_VM, UsageTypes.ALLOCATED_VM);
|
||||
|
|
@ -778,6 +783,19 @@ public class PresetVariableHelper {
|
|||
value.setId(network.getUuid());
|
||||
value.setName(network.getName());
|
||||
value.setState(usageRecord.getState());
|
||||
|
||||
value.setNetworkOffering(getPresetVariableValueNetworkOffering(network.getNetworkOfferingId()));
|
||||
}
|
||||
|
||||
protected GenericPresetVariable getPresetVariableValueNetworkOffering(Long networkOfferingId) {
|
||||
NetworkOfferingVO networkOfferingVo = networkOfferingDao.findByIdIncludingRemoved(networkOfferingId);
|
||||
validateIfObjectIsNull(networkOfferingVo, networkOfferingId, "network offering");
|
||||
|
||||
GenericPresetVariable networkOffering = new GenericPresetVariable();
|
||||
networkOffering.setId(networkOfferingVo.getUuid());
|
||||
networkOffering.setName(networkOfferingVo.getName());
|
||||
|
||||
return networkOffering;
|
||||
}
|
||||
|
||||
protected void loadPresetVariableValueForVpc(UsageVO usageRecord, Value value) {
|
||||
|
|
@ -793,6 +811,18 @@ public class PresetVariableHelper {
|
|||
|
||||
value.setId(vpc.getUuid());
|
||||
value.setName(vpc.getName());
|
||||
value.setVpcOffering(getPresetVariableValueVpcOffering(vpc.getVpcOfferingId()));
|
||||
}
|
||||
|
||||
protected GenericPresetVariable getPresetVariableValueVpcOffering(long vpcOfferingId) {
|
||||
VpcOfferingVO vpcOfferingVo = vpcOfferingDao.findByIdIncludingRemoved(vpcOfferingId);
|
||||
validateIfObjectIsNull(vpcOfferingVo, vpcOfferingId, "vpc offering");
|
||||
|
||||
GenericPresetVariable vpcOffering = new GenericPresetVariable();
|
||||
vpcOffering.setId(vpcOfferingVo.getUuid());
|
||||
vpcOffering.setName(vpcOfferingVo.getName());
|
||||
|
||||
return vpcOffering;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -96,6 +96,12 @@ public class Value extends GenericPresetVariable {
|
|||
|
||||
private String state;
|
||||
|
||||
@PresetVariableDefinition(description = "Network offering of the network.", supportedTypes = {QuotaTypes.NETWORK})
|
||||
private GenericPresetVariable networkOffering;
|
||||
|
||||
@PresetVariableDefinition(description = "VPC offering of the VPC.", supportedTypes = {QuotaTypes.VPC})
|
||||
private GenericPresetVariable vpcOffering;
|
||||
|
||||
public Host getHost() {
|
||||
return host;
|
||||
}
|
||||
|
|
@ -255,4 +261,22 @@ public class Value extends GenericPresetVariable {
|
|||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public GenericPresetVariable getNetworkOffering() {
|
||||
return networkOffering;
|
||||
}
|
||||
|
||||
public void setNetworkOffering(GenericPresetVariable networkOffering) {
|
||||
this.networkOffering = networkOffering;
|
||||
fieldNamesToIncludeInToString.add("networkOffering");
|
||||
}
|
||||
|
||||
public GenericPresetVariable getVpcOffering() {
|
||||
return vpcOffering;
|
||||
}
|
||||
|
||||
public void setVpcOffering(GenericPresetVariable vpcOffering) {
|
||||
this.vpcOffering = vpcOffering;
|
||||
fieldNamesToIncludeInToString.add("vpcOffering");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ import com.cloud.dc.ClusterDetailsDao;
|
|||
import com.cloud.dc.ClusterDetailsVO;
|
||||
import com.cloud.host.HostTagVO;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.network.vpc.VpcOfferingVO;
|
||||
import com.cloud.network.vpc.dao.VpcOfferingDao;
|
||||
import com.cloud.storage.StoragePoolTagVO;
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.acl.RoleVO;
|
||||
|
|
@ -188,6 +190,9 @@ public class PresetVariableHelperTest {
|
|||
@Mock
|
||||
BackupOfferingDao backupOfferingDaoMock;
|
||||
|
||||
@Mock
|
||||
VpcOfferingDao vpcOfferingDao;
|
||||
|
||||
List<Integer> runningAndAllocatedVmUsageTypes = Arrays.asList(UsageTypes.RUNNING_VM, UsageTypes.ALLOCATED_VM);
|
||||
List<Integer> templateAndIsoUsageTypes = Arrays.asList(UsageTypes.TEMPLATE, UsageTypes.ISO);
|
||||
|
||||
|
|
@ -1289,4 +1294,36 @@ public class PresetVariableHelperTest {
|
|||
Mockito.when(imageStoreDaoMock.findById(1L)).thenReturn(store);
|
||||
Assert.assertNotNull(presetVariableHelperSpy.getSnapshotImageStoreRef(1L, 1L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPresetVariableValueNetworkOfferingTestSetValuesAndReturnObject() {
|
||||
NetworkOfferingVO networkOfferingVoMock = Mockito.mock(NetworkOfferingVO.class);
|
||||
Mockito.doReturn(networkOfferingVoMock).when(networkOfferingDaoMock).findByIdIncludingRemoved(Mockito.anyLong());
|
||||
mockMethodValidateIfObjectIsNull();
|
||||
|
||||
GenericPresetVariable expected = getGenericPresetVariableForTests();
|
||||
Mockito.doReturn(expected.getId()).when(networkOfferingVoMock).getUuid();
|
||||
Mockito.doReturn(expected.getName()).when(networkOfferingVoMock).getName();
|
||||
|
||||
GenericPresetVariable result = presetVariableHelperSpy.getPresetVariableValueNetworkOffering(1L);
|
||||
|
||||
assertPresetVariableIdAndName(expected, result);
|
||||
validateFieldNamesToIncludeInToString(Arrays.asList("id", "name"), result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPresetVariableValueVpcOfferingTestSetValuesAndReturnObject() {
|
||||
VpcOfferingVO vpcOfferingVoMock = Mockito.mock(VpcOfferingVO.class);
|
||||
Mockito.doReturn(vpcOfferingVoMock).when(vpcOfferingDao).findByIdIncludingRemoved(Mockito.anyLong());
|
||||
mockMethodValidateIfObjectIsNull();
|
||||
|
||||
GenericPresetVariable expected = getGenericPresetVariableForTests();
|
||||
Mockito.doReturn(expected.getId()).when(vpcOfferingVoMock).getUuid();
|
||||
Mockito.doReturn(expected.getName()).when(vpcOfferingVoMock).getName();
|
||||
|
||||
GenericPresetVariable result = presetVariableHelperSpy.getPresetVariableValueVpcOffering(1L);
|
||||
|
||||
assertPresetVariableIdAndName(expected, result);
|
||||
validateFieldNamesToIncludeInToString(Arrays.asList("id", "name"), result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue