@@ -258,8 +258,8 @@ List<HostRuleTO> mergeMultiHostRuleTO(Collection<HostRuleTO>... htos) {
258
258
}
259
259
260
260
private List <HostRuleTO > calculateByL3NetworkAndSecurityGroup () {
261
- String sql = "select ref.vmNicUuid from VmNicSecurityGroupRefVO ref, SecurityGroupL3NetworkRefVO l3ref, VmNicVO nic, UsedIpVO ip, SecurityGroupVO sg" +
262
- " where l3ref.securityGroupUuid = ref.securityGroupUuid and nic.uuid = ip.vmNicUuid and ip. l3NetworkUuid = l3ref.l3NetworkUuid" +
261
+ String sql = "select ref.vmNicUuid from VmNicSecurityGroupRefVO ref, SecurityGroupL3NetworkRefVO l3ref, VmNicVO nic, SecurityGroupVO sg" +
262
+ " where l3ref.securityGroupUuid = ref.securityGroupUuid and nic.l3NetworkUuid = l3ref.l3NetworkUuid" +
263
263
" and ref.securityGroupUuid in (:sgUuids) and l3ref.l3NetworkUuid in (:l3Uuids)" +
264
264
" and ref.securityGroupUuid = sg.uuid and sg.state in (:sgStates)" ;
265
265
TypedQuery <String > q = dbf .getEntityManager ().createQuery (sql , String .class );
@@ -798,28 +798,28 @@ private List<VmNicVO> getCandidateVmNic(String sgId, String accountUuid) {
798
798
if (nicUuidsToInclude == null ) {
799
799
// accessed by an admin
800
800
if (nicUuidsToExclued .isEmpty ()) {
801
- sql = "select nic from VmNicVO nic, VmInstanceVO vm, SecurityGroupVO sg, SecurityGroupL3NetworkRefVO ref, UsedIpVO ip " +
802
- "where nic.vmInstanceUuid = vm.uuid and nic.uuid = ip.vmNicUuid and ip. l3NetworkUuid = ref.l3NetworkUuid and ref.securityGroupUuid = sg.uuid " +
801
+ sql = "select nic from VmNicVO nic, VmInstanceVO vm, SecurityGroupVO sg, SecurityGroupL3NetworkRefVO ref " +
802
+ "where nic.vmInstanceUuid = vm.uuid and nic.l3NetworkUuid = ref.l3NetworkUuid and ref.securityGroupUuid = sg.uuid " +
803
803
" and sg.uuid = :sgUuid and vm.type = :vmType and vm.state in (:vmStates) group by nic.uuid" ;
804
804
q = dbf .getEntityManager ().createQuery (sql , VmNicVO .class );
805
805
} else {
806
- sql = "select nic from VmNicVO nic, VmInstanceVO vm, SecurityGroupVO sg, SecurityGroupL3NetworkRefVO ref, UsedIpVO ip " +
807
- " where nic.vmInstanceUuid = vm.uuid and nic.uuid = ip.vmNicUuid and ip. l3NetworkUuid = ref.l3NetworkUuid and ref.securityGroupUuid = sg.uuid " +
806
+ sql = "select nic from VmNicVO nic, VmInstanceVO vm, SecurityGroupVO sg, SecurityGroupL3NetworkRefVO ref" +
807
+ " where nic.vmInstanceUuid = vm.uuid and nic.l3NetworkUuid = ref.l3NetworkUuid and ref.securityGroupUuid = sg.uuid " +
808
808
" and sg.uuid = :sgUuid and vm.type = :vmType and vm.state in (:vmStates) and nic.uuid not in (:nicUuids) group by nic.uuid" ;
809
809
q = dbf .getEntityManager ().createQuery (sql , VmNicVO .class );
810
810
q .setParameter ("nicUuids" , nicUuidsToExclued );
811
811
}
812
812
} else {
813
813
// accessed by a normal account
814
814
if (nicUuidsToExclued .isEmpty ()) {
815
- sql = "select nic from VmNicVO nic, VmInstanceVO vm, SecurityGroupVO sg, SecurityGroupL3NetworkRefVO ref, UsedIpVO ip " +
816
- " where nic.vmInstanceUuid = vm.uuid and nic.uuid = ip.vmNicUuid and ip. l3NetworkUuid = ref.l3NetworkUuid and ref.securityGroupUuid = sg.uuid " +
815
+ sql = "select nic from VmNicVO nic, VmInstanceVO vm, SecurityGroupVO sg, SecurityGroupL3NetworkRefVO ref" +
816
+ " where nic.vmInstanceUuid = vm.uuid and nic.l3NetworkUuid = ref.l3NetworkUuid and ref.securityGroupUuid = sg.uuid " +
817
817
" and sg.uuid = :sgUuid and vm.type = :vmType and vm.state in (:vmStates) and nic.uuid in (:iuuids) group by nic.uuid" ;
818
818
q = dbf .getEntityManager ().createQuery (sql , VmNicVO .class );
819
819
q .setParameter ("iuuids" , nicUuidsToInclude );
820
820
} else {
821
- sql = "select nic from VmNicVO nic, VmInstanceVO vm, SecurityGroupVO sg, SecurityGroupL3NetworkRefVO ref, UsedIpVO ip " +
822
- " where nic.vmInstanceUuid = vm.uuid and nic.uuid = ip.vmNicUuid and ip. l3NetworkUuid = ref.l3NetworkUuid and ref.securityGroupUuid = sg.uuid " +
821
+ sql = "select nic from VmNicVO nic, VmInstanceVO vm, SecurityGroupVO sg, SecurityGroupL3NetworkRefVO ref" +
822
+ " where nic.vmInstanceUuid = vm.uuid and nic.l3NetworkUuid = ref.l3NetworkUuid and ref.securityGroupUuid = sg.uuid " +
823
823
" and sg.uuid = :sgUuid and vm.type = :vmType and vm.state in (:vmStates) and nic.uuid not in (:nicUuids) and nic.uuid in (:iuuids) group by nic.uuid" ;
824
824
q = dbf .getEntityManager ().createQuery (sql , VmNicVO .class );
825
825
q .setParameter ("nicUuids" , nicUuidsToExclued );
@@ -842,8 +842,8 @@ private void handle(APIGetCandidateVmNicForSecurityGroupMsg msg) {
842
842
843
843
@ Transactional
844
844
private void detachSecurityGroupFromL3Network (String sgUuid , String l3Uuid ) {
845
- String sql = "select distinct ref.uuid from VmNicSecurityGroupRefVO ref, VmNicVO nic, UsedIpVO ip, SecurityGroupVO sg" +
846
- " where nic.uuid = ref.vmNicUuid and nic.uuid = ip.vmNicUuid and ip. l3NetworkUuid = :l3Uuid and ref.securityGroupUuid = :sgUuid" ;
845
+ String sql = "select distinct ref.uuid from VmNicSecurityGroupRefVO ref, VmNicVO nic, SecurityGroupVO sg" +
846
+ " where nic.uuid = ref.vmNicUuid and nic.l3NetworkUuid = :l3Uuid and ref.securityGroupUuid = :sgUuid" ;
847
847
TypedQuery <String > tq = dbf .getEntityManager ().createQuery (sql , String .class );
848
848
tq .setParameter ("l3Uuid" , l3Uuid );
849
849
tq .setParameter ("sgUuid" , sgUuid );
@@ -864,8 +864,8 @@ private void detachSecurityGroupFromL3Network(String sgUuid, String l3Uuid) {
864
864
865
865
@ Transactional (readOnly = true )
866
866
private List <String > getVmNicUuidsToRemoveForDetachSecurityGroup (String sgUuid , String l3Uuid ) {
867
- String sql = "select distinct nic.uuid from VmNicVO nic, VmNicSecurityGroupRefVO ref, UsedIpVO ip, SecurityGroupVO sg" +
868
- " where ref.vmNicUuid = nic.uuid and nic.uuid = ip.vmNicUuid and ip. l3NetworkUuid = :l3Uuid and ref.securityGroupUuid = :sgUuid" ;
867
+ String sql = "select distinct nic.uuid from VmNicVO nic, VmNicSecurityGroupRefVO ref, SecurityGroupVO sg" +
868
+ " where ref.vmNicUuid = nic.uuid and nic.l3NetworkUuid = :l3Uuid and ref.securityGroupUuid = :sgUuid" ;
869
869
TypedQuery <String > tq = dbf .getEntityManager ().createQuery (sql , String .class );
870
870
tq .setParameter ("l3Uuid" , l3Uuid );
871
871
tq .setParameter ("sgUuid" , sgUuid );
0 commit comments