From 154794d94cfa42e3a5a02d2de0ff773920f0120e Mon Sep 17 00:00:00 2001 From: alena Date: Tue, 22 Feb 2011 11:22:11 -0800 Subject: [PATCH] bug 7434: When direct.attach.untagged.vlan.enabled is set to "true", return only service offerings with Direct network support. status 7434: resolved fixed --- .../cloud/server/ManagementServerImpl.java | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index e5cff01ff58..e3747ae7ea3 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -3818,21 +3818,28 @@ public class ManagementServerImpl implements ManagementServer { } //if account doesn't have direct ip addresses and there are no direct Zone wide vlans, return virtual service offerings only + //If untagged network is enabled, return only direct service offerings List accountDirectVlans = new ArrayList(); List zoneDirectVlans = new ArrayList(); - if (accountId != null && zoneId != null) { - accountDirectVlans = _vlanDao.listVlansForAccountByType(null, ((Long)accountId).longValue(), VlanType.DirectAttached); - zoneDirectVlans = listZoneWideVlansByType(VlanType.DirectAttached, (Long)zoneId); - if (accountDirectVlans.isEmpty() && zoneDirectVlans.isEmpty()) { - sc.addAnd("guestIpType", SearchCriteria.Op.EQ, GuestIpType.Virtualized); - } - } else if (zoneId != null) { - zoneDirectVlans = listZoneWideVlansByType(VlanType.DirectAttached, (Long)zoneId); - if (zoneDirectVlans.isEmpty()) { - sc.addAnd("guestIpType", SearchCriteria.Op.EQ, GuestIpType.Virtualized); - } - } + boolean isDirectUntaggedNetworkEnabled = new Boolean(_configDao.getValue("direct.attach.untagged.vlan.enabled")); + + if (isDirectUntaggedNetworkEnabled) { + sc.addAnd("guestIpType", SearchCriteria.Op.EQ, GuestIpType.DirectSingle); + } else { + if (accountId != null && zoneId != null) { + accountDirectVlans = _vlanDao.listVlansForAccountByType(null, ((Long)accountId).longValue(), VlanType.DirectAttached); + zoneDirectVlans = listZoneWideVlansByType(VlanType.DirectAttached, (Long)zoneId); + if (accountDirectVlans.isEmpty() && zoneDirectVlans.isEmpty()) { + sc.addAnd("guestIpType", SearchCriteria.Op.EQ, GuestIpType.Virtualized); + } + } else if (zoneId != null) { + zoneDirectVlans = listZoneWideVlansByType(VlanType.DirectAttached, (Long)zoneId); + if (zoneDirectVlans.isEmpty()) { + sc.addAnd("guestIpType", SearchCriteria.Op.EQ, GuestIpType.Virtualized); + } + } + } return _offeringsDao.search(sc, searchFilter); }