mirror of https://github.com/apache/cloudstack.git
fix network listing
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
bb213dcdcb
commit
5b71847813
|
|
@ -98,6 +98,8 @@ public interface NetworkDao extends GenericDao<NetworkVO, Long>, StateDao<State,
|
|||
|
||||
List<NetworkVO> listByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
List<NetworkVO> listByTrafficType(TrafficType trafficType);
|
||||
|
||||
void setCheckForGc(long networkId);
|
||||
|
||||
int getNetworkCountByNetworkOffId(long networkOfferingId);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import javax.annotation.PostConstruct;
|
|||
import javax.inject.Inject;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -63,6 +62,7 @@ import com.cloud.utils.db.SearchCriteria.Func;
|
|||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.SequenceFetcher;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@Component
|
||||
|
|
@ -640,6 +640,14 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long>implements Ne
|
|||
return listBy(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> listByTrafficType(final TrafficType trafficType) {
|
||||
final SearchCriteria<NetworkVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("trafficType", trafficType);
|
||||
|
||||
return listBy(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNetworkCountByNetworkOffId(final long networkOfferingId) {
|
||||
final SearchCriteria<Integer> sc = NetworksCount.create();
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ import com.cloud.exception.ResourceAllocationException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
|
|
@ -465,7 +466,7 @@ public class ServerAdapter extends ManagerBase {
|
|||
if (dataCenterVO == null) {
|
||||
throw new InvalidParameterValueException("DataCenter with ID " + uuid + " not found");
|
||||
}
|
||||
List<NetworkVO> networks = networkDao.listAll();
|
||||
List<NetworkVO> networks = networkDao.listByZoneAndTrafficType(dataCenterVO.getId(), Networks.TrafficType.Guest);
|
||||
return NetworkVOToNetworkConverter.toNetworkList(networks, (dcId) -> dataCenterVO);
|
||||
}
|
||||
|
||||
|
|
@ -509,7 +510,7 @@ public class ServerAdapter extends ManagerBase {
|
|||
}
|
||||
|
||||
public List<VnicProfile> listAllVnicProfiles() {
|
||||
final List<NetworkVO> networks = networkDao.listAll();
|
||||
final List<NetworkVO> networks = networkDao.listByTrafficType(Networks.TrafficType.Guest);
|
||||
return NetworkVOToVnicProfileConverter.toVnicProfileList(networks, this::getZoneById);
|
||||
}
|
||||
|
||||
|
|
@ -522,7 +523,7 @@ public class ServerAdapter extends ManagerBase {
|
|||
}
|
||||
|
||||
public List<Vm> listAllInstances() {
|
||||
List<UserVmJoinVO> vms = userVmJoinDao.listAll();
|
||||
List<UserVmJoinVO> vms = userVmJoinDao.listByHypervisorType(Hypervisor.HypervisorType.KVM);
|
||||
return UserVmJoinVOToVmConverter.toVmList(vms, this::getHostById, this::getDetailsByInstanceId);
|
||||
}
|
||||
|
||||
|
|
@ -996,9 +997,6 @@ public class ServerAdapter extends ManagerBase {
|
|||
throw new InvalidParameterValueException("Request disk data is empty");
|
||||
}
|
||||
String name = request.getName();
|
||||
if (StringUtils.isBlank(name) && !name.startsWith("Veeam_KvmBackupDisk_")) {
|
||||
throw new InvalidParameterValueException("Only worker VM disk creation is supported");
|
||||
}
|
||||
if (request.getStorageDomains() == null || CollectionUtils.isEmpty(request.getStorageDomains().getItems()) ||
|
||||
request.getStorageDomains().getItems().size() > 1) {
|
||||
throw new InvalidParameterValueException("Exactly one storage domain must be specified");
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package com.cloud.api.query.dao;
|
||||
|
||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
|
@ -49,4 +50,6 @@ public interface UserVmJoinDao extends GenericDao<UserVmJoinVO, Long> {
|
|||
List<UserVmJoinVO> listEligibleInstancesWithExpiredLease();
|
||||
|
||||
List<UserVmJoinVO> listLeaseInstancesExpiringInDays(int days);
|
||||
|
||||
List<UserVmJoinVO> listByHypervisorType(Hypervisor.HypervisorType hypervisorType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import java.util.stream.Collectors;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.gpu.dao.VgpuProfileDao;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
import org.apache.cloudstack.annotation.AnnotationService;
|
||||
|
|
@ -832,4 +833,14 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
|
|||
}
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmJoinVO> listByHypervisorType(Hypervisor.HypervisorType hypervisorType) {
|
||||
SearchBuilder<UserVmJoinVO> sb = createSearchBuilder();
|
||||
sb.and("hypervisorType", sb.entity().getHypervisorType(), Op.EQ);
|
||||
sb.done();
|
||||
SearchCriteria<UserVmJoinVO> sc = sb.create();
|
||||
sc.setParameters("hypervisorType", hypervisorType);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@
|
|||
// under the License.
|
||||
package com.cloud.vpc.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
|
|
@ -26,11 +31,6 @@ import com.cloud.utils.db.DB;
|
|||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@DB()
|
||||
public class MockNetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements NetworkDao {
|
||||
|
||||
|
|
@ -165,6 +165,11 @@ public class MockNetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implemen
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> listByTrafficType(final TrafficType trafficType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCheckForGc(final long networkId) {
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue