cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [05/31] Changed SearchCriteria2 to GenericQueryBuilder to reflect the same placement
Date Mon, 30 Sep 2013 21:52:04 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmDiscoverer.java b/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmDiscoverer.java
index d8b8310..eba7ae5 100755
--- a/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmDiscoverer.java
+++ b/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmDiscoverer.java
@@ -31,9 +31,9 @@ import javax.naming.ConfigurationException;
 import org.apache.log4j.Logger;
 import org.apache.xmlrpc.XmlRpcException;
 
-import com.cloud.configuration.Config;
 import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.StartupRoutingCommand;
+import com.cloud.configuration.Config;
 import com.cloud.dc.ClusterVO;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.exception.DiscoveryException;
@@ -48,244 +48,214 @@ import com.cloud.resource.ResourceManager;
 import com.cloud.resource.ResourceStateAdapter;
 import com.cloud.resource.ServerResource;
 import com.cloud.resource.UnableDeleteHostException;
+import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.GenericQueryBuilder;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.ssh.SSHCmdHelper;
 
 @Local(value = Discoverer.class)
-public class OvmDiscoverer extends DiscovererBase implements Discoverer,
-		ResourceStateAdapter {
-	private static final Logger s_logger = Logger
-			.getLogger(OvmDiscoverer.class);
-	protected String _publicNetworkDevice;
-	protected String _privateNetworkDevice;
-	protected String _guestNetworkDevice;
-
-	@Inject
-	ClusterDao _clusterDao;
-	@Inject
-	ResourceManager _resourceMgr;
-
-	@Override
-	public boolean configure(String name, Map<String, Object> params)
-			throws ConfigurationException {
-		super.configure(name, params);
-		_publicNetworkDevice = _params.get(Config.OvmPublicNetwork.key());
-		_privateNetworkDevice = _params.get(Config.OvmPrivateNetwork.key());
-		_guestNetworkDevice = _params.get(Config.OvmGuestNetwork.key());
-		_resourceMgr.registerResourceStateAdapter(this.getClass()
-				.getSimpleName(), this);
-		return true;
-	}
-
-	protected OvmDiscoverer() {
-	}
-
-	@Override
-	public boolean stop() {
-		_resourceMgr.unregisterResourceStateAdapter(this.getClass()
-				.getSimpleName());
-		return super.stop();
-	}
-
-	private boolean checkIfExisted(String guid) {
-		GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-		sc.addAnd(sc.getEntity().getGuid(), SearchCriteria.Op.EQ, guid);
-		sc.addAnd(sc.getEntity().getHypervisorType(), SearchCriteria.Op.EQ,
-				HypervisorType.Ovm);
-		List<HostVO> hosts = sc.list();
-		return !hosts.isEmpty();
-	}
-
-	@Override
-	public Map<? extends ServerResource, Map<String, String>> find(long dcId,
-			Long podId, Long clusterId, URI url, String username,
-			String password, List<String> hostTags) throws DiscoveryException {
-		Connection conn = null;
-
-		if (!url.getScheme().equals("http")) {
-			String msg = "urlString is not http so we're not taking care of the discovery for this: "
-					+ url;
-			s_logger.debug(msg);
-			return null;
-		}
-		if (clusterId == null) {
-			String msg = "must specify cluster Id when add host";
-			s_logger.debug(msg);
-			throw new CloudRuntimeException(msg);
-		}
-
-		if (podId == null) {
-			String msg = "must specify pod Id when add host";
-			s_logger.debug(msg);
-			throw new CloudRuntimeException(msg);
-		}
-
-		ClusterVO cluster = _clusterDao.findById(clusterId);
-		if (cluster == null
-				|| (cluster.getHypervisorType() != HypervisorType.Ovm)) {
-			if (s_logger.isInfoEnabled())
-				s_logger.info("invalid cluster id or cluster is not for Ovm hypervisors");
-			return null;
-		}
-
-		String agentUsername = _params.get("agentusername");
-		if (agentUsername == null) {
-			throw new CloudRuntimeException("Agent user name must be specified");
-		}
-
-		String agentPassword = _params.get("agentpassword");
-		if (agentPassword == null) {
-			throw new CloudRuntimeException("Agent password must be specified");
-		}
-
-		try {
-			String hostname = url.getHost();
-			InetAddress ia = InetAddress.getByName(hostname);
-			String hostIp = ia.getHostAddress();
-			String guid = UUID.nameUUIDFromBytes(hostIp.getBytes()).toString();
-
-			if (checkIfExisted(guid)) {
-				throw new CloudRuntimeException("The host " + hostIp
-						+ " has been added before");
-			}
-
-			s_logger.debug("Ovm discover is going to disover host having guid "
-					+ guid);
-
-			ClusterVO clu = _clusterDao.findById(clusterId);
-			if (clu.getGuid() == null) {
-				clu.setGuid(UUID.randomUUID().toString());
-				_clusterDao.update(clusterId, clu);
-			}
-
-			com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(
-					hostIp, 22);
-			sshConnection.connect(null, 60000, 60000);
-			sshConnection = SSHCmdHelper.acquireAuthorizedConnection(hostIp,
-					username, password);
-			if (sshConnection == null) {
-				throw new DiscoveryException(
-						String.format(
-								"Cannot connect to ovm host(IP=%1$s, username=%2$s, password=%3$s, discover failed",
-								hostIp, username, password));
-			}
-
-			if (!SSHCmdHelper.sshExecuteCmd(sshConnection,
-					"[ -f '/etc/ovs-agent/agent.ini' ]")) {
-				throw new DiscoveryException(
-						"Can not find /etc/ovs-agent/agent.ini " + hostIp);
-			}
-
-			Map<String, String> details = new HashMap<String, String>();
-			OvmResourceBase ovmResource = new OvmResourceBase();
-			details.put("ip", hostIp);
-			details.put("username", username);
-			details.put("password", password);
-			details.put("zone", Long.toString(dcId));
-			details.put("guid", guid);
-			details.put("pod", Long.toString(podId));
-			details.put("cluster", Long.toString(clusterId));
-			details.put("agentusername", agentUsername);
-			details.put("agentpassword", agentPassword);
-			if (_publicNetworkDevice != null) {
-				details.put("public.network.device", _publicNetworkDevice);
-			}
-			if (_privateNetworkDevice != null) {
-				details.put("private.network.device", _privateNetworkDevice);
-			}
-			if (_guestNetworkDevice != null) {
-				details.put("guest.network.device", _guestNetworkDevice);
-			}
-
-			Map<String, Object> params = new HashMap<String, Object>();
-			params.putAll(details);
-			ovmResource.configure("Ovm Server", params);
-			ovmResource.start();
-
-			conn = new Connection(hostIp, "oracle", agentPassword);
-			/* After resource start, we are able to execute our agent api */
-			OvmHost.Details d = OvmHost.getDetails(conn);
-			details.put("agentVersion", d.agentVersion);
-			details.put(HostInfo.HOST_OS_KERNEL_VERSION, d.dom0KernelVersion);
-			details.put(HostInfo.HYPERVISOR_VERSION, d.hypervisorVersion);
-
-			Map<OvmResourceBase, Map<String, String>> resources = new HashMap<OvmResourceBase, Map<String, String>>();
-			resources.put(ovmResource, details);
-			return resources;
-		} catch (XmlRpcException e) {
-			s_logger.debug("XmlRpc exception, Unable to discover OVM: " + url,
-					e);
-			return null;
-		} catch (UnknownHostException e) {
-			s_logger.debug(
-					"Host name resolve failed exception, Unable to discover OVM: "
-							+ url, e);
-			return null;
-		} catch (ConfigurationException e) {
-			s_logger.debug(
-					"Configure resource failed, Unable to discover OVM: " + url,
-					e);
-			return null;
-		} catch (Exception e) {
-			s_logger.debug("Unable to discover OVM: " + url, e);
-			return null;
-		}
-	}
-
-	@Override
-	public void postDiscovery(List<HostVO> hosts, long msId)
-			throws DiscoveryException {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public boolean matchHypervisor(String hypervisor) {
-		return HypervisorType.Ovm.toString().equalsIgnoreCase(hypervisor);
-	}
-
-	@Override
-	public HypervisorType getHypervisorType() {
-		return HypervisorType.Ovm;
-	}
-
-	@Override
-	public HostVO createHostVOForConnectedAgent(HostVO host,
-			StartupCommand[] cmd) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public HostVO createHostVOForDirectConnectAgent(HostVO host,
-			StartupCommand[] startup, ServerResource resource,
-			Map<String, String> details, List<String> hostTags) {
-		StartupCommand firstCmd = startup[0];
-		if (!(firstCmd instanceof StartupRoutingCommand)) {
-			return null;
-		}
-
-		StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
-		if (ssCmd.getHypervisorType() != HypervisorType.Ovm) {
-			return null;
-		}
-
-		return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Ovm,
-				details, hostTags);
-	}
-
-	@Override
-	public DeleteHostAnswer deleteHost(HostVO host, boolean isForced,
-			boolean isForceDeleteStorage) throws UnableDeleteHostException {
-		if (host.getType() != com.cloud.host.Host.Type.Routing
-				|| host.getHypervisorType() != HypervisorType.Ovm) {
-			return null;
-		}
-
-		_resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
-		return new DeleteHostAnswer(true);
-	}
+public class OvmDiscoverer extends DiscovererBase implements Discoverer, ResourceStateAdapter {
+    private static final Logger s_logger = Logger.getLogger(OvmDiscoverer.class);
+    protected String _publicNetworkDevice;
+    protected String _privateNetworkDevice;
+    protected String _guestNetworkDevice;
+
+    @Inject
+    ClusterDao _clusterDao;
+    @Inject
+    ResourceManager _resourceMgr;
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+        _publicNetworkDevice = _params.get(Config.OvmPublicNetwork.key());
+        _privateNetworkDevice = _params.get(Config.OvmPrivateNetwork.key());
+        _guestNetworkDevice = _params.get(Config.OvmGuestNetwork.key());
+        _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
+        return true;
+    }
+
+    protected OvmDiscoverer() {
+    }
+
+    @Override
+    public boolean stop() {
+        _resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
+        return super.stop();
+    }
+
+    private boolean checkIfExisted(String guid) {
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getGuid(), SearchCriteria.Op.EQ, guid);
+        sc.and(sc.entity().getHypervisorType(), SearchCriteria.Op.EQ, HypervisorType.Ovm);
+        List<HostVO> hosts = sc.list();
+        return !hosts.isEmpty();
+    }
+
+    @Override
+    public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags)
+        throws DiscoveryException {
+        Connection conn = null;
+
+        if (!url.getScheme().equals("http")) {
+            String msg = "urlString is not http so we're not taking care of the discovery for this: " + url;
+            s_logger.debug(msg);
+            return null;
+        }
+        if (clusterId == null) {
+            String msg = "must specify cluster Id when add host";
+            s_logger.debug(msg);
+            throw new CloudRuntimeException(msg);
+        }
+
+        if (podId == null) {
+            String msg = "must specify pod Id when add host";
+            s_logger.debug(msg);
+            throw new CloudRuntimeException(msg);
+        }
+
+        ClusterVO cluster = _clusterDao.findById(clusterId);
+        if (cluster == null || (cluster.getHypervisorType() != HypervisorType.Ovm)) {
+            if (s_logger.isInfoEnabled())
+                s_logger.info("invalid cluster id or cluster is not for Ovm hypervisors");
+            return null;
+        }
+
+        String agentUsername = _params.get("agentusername");
+        if (agentUsername == null) {
+            throw new CloudRuntimeException("Agent user name must be specified");
+        }
+
+        String agentPassword = _params.get("agentpassword");
+        if (agentPassword == null) {
+            throw new CloudRuntimeException("Agent password must be specified");
+        }
+
+        try {
+            String hostname = url.getHost();
+            InetAddress ia = InetAddress.getByName(hostname);
+            String hostIp = ia.getHostAddress();
+            String guid = UUID.nameUUIDFromBytes(hostIp.getBytes()).toString();
+
+            if (checkIfExisted(guid)) {
+                throw new CloudRuntimeException("The host " + hostIp + " has been added before");
+            }
+
+            s_logger.debug("Ovm discover is going to disover host having guid " + guid);
+
+            ClusterVO clu = _clusterDao.findById(clusterId);
+            if (clu.getGuid() == null) {
+                clu.setGuid(UUID.randomUUID().toString());
+                _clusterDao.update(clusterId, clu);
+            }
+
+            com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(hostIp, 22);
+            sshConnection.connect(null, 60000, 60000);
+            sshConnection = SSHCmdHelper.acquireAuthorizedConnection(hostIp, username, password);
+            if (sshConnection == null) {
+                throw new DiscoveryException(String.format("Cannot connect to ovm host(IP=%1$s, username=%2$s, password=%3$s, discover failed", hostIp, username, password));
+            }
+
+            if (!SSHCmdHelper.sshExecuteCmd(sshConnection, "[ -f '/etc/ovs-agent/agent.ini' ]")) {
+                throw new DiscoveryException("Can not find /etc/ovs-agent/agent.ini " + hostIp);
+            }
+
+            Map<String, String> details = new HashMap<String, String>();
+            OvmResourceBase ovmResource = new OvmResourceBase();
+            details.put("ip", hostIp);
+            details.put("username", username);
+            details.put("password", password);
+            details.put("zone", Long.toString(dcId));
+            details.put("guid", guid);
+            details.put("pod", Long.toString(podId));
+            details.put("cluster", Long.toString(clusterId));
+            details.put("agentusername", agentUsername);
+            details.put("agentpassword", agentPassword);
+            if (_publicNetworkDevice != null) {
+                details.put("public.network.device", _publicNetworkDevice);
+            }
+            if (_privateNetworkDevice != null) {
+                details.put("private.network.device", _privateNetworkDevice);
+            }
+            if (_guestNetworkDevice != null) {
+                details.put("guest.network.device", _guestNetworkDevice);
+            }
+
+            Map<String, Object> params = new HashMap<String, Object>();
+            params.putAll(details);
+            ovmResource.configure("Ovm Server", params);
+            ovmResource.start();
+
+            conn = new Connection(hostIp, "oracle", agentPassword);
+            /* After resource start, we are able to execute our agent api */
+            OvmHost.Details d = OvmHost.getDetails(conn);
+            details.put("agentVersion", d.agentVersion);
+            details.put(HostInfo.HOST_OS_KERNEL_VERSION, d.dom0KernelVersion);
+            details.put(HostInfo.HYPERVISOR_VERSION, d.hypervisorVersion);
+
+            Map<OvmResourceBase, Map<String, String>> resources = new HashMap<OvmResourceBase, Map<String, String>>();
+            resources.put(ovmResource, details);
+            return resources;
+        } catch (XmlRpcException e) {
+            s_logger.debug("XmlRpc exception, Unable to discover OVM: " + url, e);
+            return null;
+        } catch (UnknownHostException e) {
+            s_logger.debug("Host name resolve failed exception, Unable to discover OVM: " + url, e);
+            return null;
+        } catch (ConfigurationException e) {
+            s_logger.debug("Configure resource failed, Unable to discover OVM: " + url, e);
+            return null;
+        } catch (Exception e) {
+            s_logger.debug("Unable to discover OVM: " + url, e);
+            return null;
+        }
+    }
+
+    @Override
+    public void postDiscovery(List<HostVO> hosts, long msId) throws DiscoveryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public boolean matchHypervisor(String hypervisor) {
+        return HypervisorType.Ovm.toString().equalsIgnoreCase(hypervisor);
+    }
+
+    @Override
+    public HypervisorType getHypervisorType() {
+        return HypervisorType.Ovm;
+    }
+
+    @Override
+    public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map<String, String> details, List<String> hostTags) {
+        StartupCommand firstCmd = startup[0];
+        if (!(firstCmd instanceof StartupRoutingCommand)) {
+            return null;
+        }
+
+        StartupRoutingCommand ssCmd = ((StartupRoutingCommand)firstCmd);
+        if (ssCmd.getHypervisorType() != HypervisorType.Ovm) {
+            return null;
+        }
+
+        return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Ovm, details, hostTags);
+    }
+
+    @Override
+    public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException {
+        if (host.getType() != com.cloud.host.Host.Type.Routing || host.getHypervisorType() != HypervisorType.Ovm) {
+            return null;
+        }
+
+        _resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
+        return new DeleteHostAnswer(true);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java
index bc22ba6..dec4a79 100755
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java
@@ -133,7 +133,7 @@ public class UcsManagerImpl implements UcsManager {
 
     	private void syncBlades(UcsManagerVO mgr) {
     		GenericQueryBuilder<UcsBladeVO, UcsBladeVO> q = GenericQueryBuilder.create(UcsBladeVO.class);
-    		q.addAnd(q.getEntity().getUcsManagerId(), Op.EQ, mgr.getId());
+    		q.and(q.entity().getUcsManagerId(), Op.EQ, mgr.getId());
     		List<UcsBladeVO> pblades = q.list();
     		if (pblades.isEmpty()) {
     			return;
@@ -211,7 +211,7 @@ public class UcsManagerImpl implements UcsManager {
     @DB
     public UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd) {
         GenericQueryBuilder<UcsManagerVO, UcsManagerVO> q = GenericQueryBuilder.create(UcsManagerVO.class);
-        q.addAnd(q.getEntity().getUrl(), Op.EQ, cmd.getUrl());
+        q.and(q.entity().getUrl(), Op.EQ, cmd.getUrl());
         UcsManagerVO mgrvo = q.find();
         if (mgrvo != null) {
             throw new IllegalArgumentException(String.format("duplicate UCS manager. url[%s] is used by another UCS manager already", cmd.getUrl()));
@@ -343,8 +343,8 @@ public class UcsManagerImpl implements UcsManager {
     @Override
     public UcsBladeResponse associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd) {
         GenericQueryBuilder<UcsBladeVO, UcsBladeVO> q = GenericQueryBuilder.create(UcsBladeVO.class);
-        q.addAnd(q.getEntity().getUcsManagerId(), Op.EQ, cmd.getUcsManagerId());
-        q.addAnd(q.getEntity().getId(), Op.EQ, cmd.getBladeId());
+        q.and(q.entity().getUcsManagerId(), Op.EQ, cmd.getUcsManagerId());
+        q.and(q.entity().getId(), Op.EQ, cmd.getBladeId());
         UcsBladeVO bvo = q.find();
         if (bvo == null) {
             throw new IllegalArgumentException(String.format("cannot find UCS blade[id:%s, ucs manager id:%s]", cmd.getBladeId(), cmd.getUcsManagerId()));
@@ -425,7 +425,7 @@ public class UcsManagerImpl implements UcsManager {
     	}
     	
         GenericQueryBuilder<UcsManagerVO, UcsManagerVO> serv = GenericQueryBuilder.create(UcsManagerVO.class);
-        serv.addAnd(serv.getEntity().getZoneId(), Op.EQ, cmd.getZoneId());
+        serv.and(serv.entity().getZoneId(), Op.EQ, cmd.getZoneId());
         List<UcsManagerVO> vos = serv.list();
 
         for (UcsManagerVO vo : vos) {
@@ -455,7 +455,7 @@ public class UcsManagerImpl implements UcsManager {
     @Override
     public ListResponse<UcsBladeResponse> listUcsBlades(ListUcsBladeCmd cmd) {
         GenericQueryBuilder<UcsBladeVO, UcsBladeVO> serv = GenericQueryBuilder.create(UcsBladeVO.class);
-        serv.addAnd(serv.getEntity().getUcsManagerId(), Op.EQ, cmd.getUcsManagerId());
+        serv.and(serv.entity().getUcsManagerId(), Op.EQ, cmd.getUcsManagerId());
         List<UcsBladeVO> vos = serv.list();
         
         List<UcsBladeResponse> rsps = new ArrayList<UcsBladeResponse>(vos.size());
@@ -510,7 +510,7 @@ public class UcsManagerImpl implements UcsManager {
 	@Override
 	public void deleteUcsManager(Long id) {
         GenericQueryBuilder<UcsBladeVO, UcsBladeVO> serv = GenericQueryBuilder.create(UcsBladeVO.class);
-        serv.addAnd(serv.getEntity().getUcsManagerId(), Op.EQ, id);
+        serv.and(serv.entity().getUcsManagerId(), Op.EQ, id);
         List<UcsBladeVO> vos = serv.list();
         for (UcsBladeVO vo : vos) {
         	bladeDao.remove(vo.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
index 202b340..bb357ca 100755
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
@@ -127,7 +127,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
             _clusterDao.update(cluster.getId(), cluster);
         } catch (EntityExistsException e) {
             GenericQueryBuilder<ClusterVO, ClusterVO> sc = GenericQueryBuilder.create(ClusterVO.class);
-            sc.addAnd(sc.getEntity().getGuid(), Op.EQ, guid);
+            sc.and(sc.entity().getGuid(), Op.EQ, guid);
             List<ClusterVO> clusters = sc.list();
             ClusterVO clu = clusters.get(0);
             List<HostVO> clusterHosts = _resourceMgr.listAllHostsInCluster(clu.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
index ecd6006..6b719eb 100644
--- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
+++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
@@ -85,7 +85,7 @@ import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.addr.PublicIp;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.IPAddressVO;
@@ -506,7 +506,7 @@ public class ElasticLoadBalancerManagerImpl extends ManagerBase implements Elast
                 if (provider == null) {
                     throw new CloudRuntimeException("Cannot find service provider " + typeString + " in physical network " + physicalNetworkId);
                 }
-                VirtualRouterProvider vrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(), VirtualRouterProviderType.ElasticLoadBalancerVm);
+                VirtualRouterProvider vrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(), Type.ElasticLoadBalancerVm);
                 if (vrProvider == null) {
                     throw new CloudRuntimeException("Cannot find virtual router provider " + typeString + " as service provider " + provider.getId());
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
index 35b4d52..7080ca3 100644
--- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
+++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
@@ -53,7 +53,7 @@ import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PublicIpAddress;
 import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.dao.NetworkServiceMapDao;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
 import com.cloud.network.dao.VirtualRouterProviderDao;
@@ -73,9 +73,8 @@ import com.cloud.user.AccountManager;
 import com.cloud.user.User;
 import com.cloud.utils.component.AdapterBase;
 import com.cloud.utils.db.EntityManager;
+import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.GenericQueryBuilder;
-import com.cloud.utils.db.GenericQueryBuilder;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.net.Ip;
 import com.cloud.vm.DomainRouterVO;
@@ -270,7 +269,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     @Override
     public boolean isReady(PhysicalNetworkServiceProvider provider) {
         VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(),
-                VirtualRouterProviderType.InternalLbVm);
+                Type.InternalLbVm);
         if (element == null) {
             return false;
         }
@@ -282,7 +281,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context)
             throws ConcurrentOperationException, ResourceUnavailableException {
         VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(),
-                VirtualRouterProviderType.InternalLbVm);
+                Type.InternalLbVm);
         if (element == null) {
             return true;
         }
@@ -467,7 +466,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     @Override
     public VirtualRouterProvider configureInternalLoadBalancerElement(long id, boolean enable) {
         VirtualRouterProviderVO element = _vrProviderDao.findById(id);
-        if (element == null || element.getType() != VirtualRouterProviderType.InternalLbVm) {
+        if (element == null || element.getType() != Type.InternalLbVm) {
             throw new InvalidParameterValueException("Can't find " + getName() + " element with network service provider id " + id +
                     " to be used as a provider for " + getName());
         }
@@ -480,7 +479,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
 
     @Override
     public VirtualRouterProvider addInternalLoadBalancerElement(long ntwkSvcProviderId) {
-        VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(ntwkSvcProviderId, VirtualRouterProviderType.InternalLbVm);
+        VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(ntwkSvcProviderId, Type.InternalLbVm);
         if (element != null) {
             s_logger.debug("There is already an " + getName() + " with service provider id " + ntwkSvcProviderId);
             return null;
@@ -491,7 +490,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
             throw new InvalidParameterValueException("Invalid network service provider is specified");
         }
         
-        element = new VirtualRouterProviderVO(ntwkSvcProviderId, VirtualRouterProviderType.InternalLbVm);
+        element = new VirtualRouterProviderVO(ntwkSvcProviderId, Type.InternalLbVm);
         element = _vrProviderDao.persist(element);
         return element;
     }
@@ -500,7 +499,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     @Override
     public VirtualRouterProvider getInternalLoadBalancerElement(long id) {
         VirtualRouterProvider provider = _vrProviderDao.findById(id);
-        if (provider == null || provider.getType() != VirtualRouterProviderType.InternalLbVm) {
+        if (provider == null || provider.getType() != Type.InternalLbVm) {
             throw new InvalidParameterValueException("Unable to find " + getName() + " by id");
         }
         return provider;
@@ -509,19 +508,19 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     @Override
     public List<? extends VirtualRouterProvider> searchForInternalLoadBalancerElements(Long id, Long ntwkSvsProviderId, Boolean enabled) {
 
-        GenericQueryBuilder<VirtualRouterProviderVO, VirtualRouterProviderVO> sc = GenericQueryBuilder.create(VirtualRouterProviderVO.class);
+        QueryBuilder<VirtualRouterProviderVO> sc = QueryBuilder.create(VirtualRouterProviderVO.class);
         if (id != null) {
-            sc.addAnd(sc.getEntity().getId(), Op.EQ, id);
+            sc.and(sc.entity().getId(), Op.EQ, id);
         }
         if (ntwkSvsProviderId != null) {
-            sc.addAnd(sc.getEntity().getNspId(), Op.EQ, ntwkSvsProviderId);
+            sc.and(sc.entity().getNspId(), Op.EQ, ntwkSvsProviderId);
         }
         if (enabled != null) {
-            sc.addAnd(sc.getEntity().isEnabled(), Op.EQ, enabled);
+            sc.and(sc.entity().isEnabled(), Op.EQ, enabled);
         }
         
         //return only Internal LB elements
-        sc.addAnd(sc.getEntity().getType(), Op.EQ, VirtualRouterProvider.VirtualRouterProviderType.InternalLbVm);
+        sc.and(sc.entity().getType(), Op.EQ, VirtualRouterProvider.Type.InternalLbVm);
         
         return sc.list();
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
index 587ae99..5da6e02 100644
--- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
+++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
@@ -69,7 +69,7 @@ import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
 import com.cloud.network.dao.VirtualRouterProviderDao;
@@ -310,7 +310,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements In
 
         VirtualRouterProvider lbProvider = _vrProviderDao.findById(internalLbVm.getElementId());
         if (lbProvider == null) {
-            throw new CloudRuntimeException("Cannot find related element " + VirtualRouterProviderType.InternalLbVm + " of vm: " + internalLbVm.getHostName());
+            throw new CloudRuntimeException("Cannot find related element " + Type.InternalLbVm + " of vm: " + internalLbVm.getHostName());
         }
         
         Provider provider = Network.Provider.getProvider(lbProvider.getType().toString());
@@ -629,7 +629,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements In
     }
 
     protected long getInternalLbProviderId(Network guestNetwork) {
-        VirtualRouterProviderType type = VirtualRouterProviderType.InternalLbVm;
+        Type type = Type.InternalLbVm;
         long physicalNetworkId = _ntwkModel.getPhysicalNetworkId(guestNetwork);
         
         PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementServiceTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementServiceTest.java b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementServiceTest.java
index bdc50ca..7a47af9 100644
--- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementServiceTest.java
+++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementServiceTest.java
@@ -33,7 +33,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
 import com.cloud.network.dao.VirtualRouterProviderDao;
@@ -65,15 +65,15 @@ public class InternalLbElementServiceTest {
     public void setUp() {
         
         ComponentContext.initComponentsLifeCycle();
-        VirtualRouterProviderVO validElement = new VirtualRouterProviderVO(1, VirtualRouterProviderType.InternalLbVm);
-        VirtualRouterProviderVO invalidElement = new VirtualRouterProviderVO(1, VirtualRouterProviderType.VirtualRouter);
+        VirtualRouterProviderVO validElement = new VirtualRouterProviderVO(1, Type.InternalLbVm);
+        VirtualRouterProviderVO invalidElement = new VirtualRouterProviderVO(1, Type.VirtualRouter);
         
         Mockito.when(_vrProviderDao.findById(validElId)).thenReturn(validElement);
         Mockito.when(_vrProviderDao.findById(invalidElId)).thenReturn(invalidElement);
         
         Mockito.when(_vrProviderDao.persist(validElement)).thenReturn(validElement);
         
-        Mockito.when(_vrProviderDao.findByNspIdAndType(validProviderId, VirtualRouterProviderType.InternalLbVm)).thenReturn(validElement);
+        Mockito.when(_vrProviderDao.findByNspIdAndType(validProviderId, Type.InternalLbVm)).thenReturn(validElement);
         
         PhysicalNetworkServiceProviderVO validProvider = new PhysicalNetworkServiceProviderVO(1, "InternalLoadBalancerElement");
         PhysicalNetworkServiceProviderVO invalidProvider = new PhysicalNetworkServiceProviderVO(1, "Invalid name!");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementTest.java b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementTest.java
index 7af6796..f170fee 100644
--- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementTest.java
+++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementTest.java
@@ -47,7 +47,7 @@ import com.cloud.dc.DataCenterVO;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.addr.PublicIp;
 import com.cloud.network.dao.NetworkVO;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
@@ -91,18 +91,18 @@ public class InternalLbElementTest {
     public void setUp() {
         
         ComponentContext.initComponentsLifeCycle();
-        VirtualRouterProviderVO validElement = new VirtualRouterProviderVO(1, VirtualRouterProviderType.InternalLbVm);
+        VirtualRouterProviderVO validElement = new VirtualRouterProviderVO(1, Type.InternalLbVm);
         validElement.setEnabled(true);
-        VirtualRouterProviderVO invalidElement = new VirtualRouterProviderVO(1, VirtualRouterProviderType.VirtualRouter);
-        VirtualRouterProviderVO notEnabledElement = new VirtualRouterProviderVO(1, VirtualRouterProviderType.InternalLbVm);
+        VirtualRouterProviderVO invalidElement = new VirtualRouterProviderVO(1, Type.VirtualRouter);
+        VirtualRouterProviderVO notEnabledElement = new VirtualRouterProviderVO(1, Type.InternalLbVm);
  
-        Mockito.when(_vrProviderDao.findByNspIdAndType(validElId, VirtualRouterProviderType.InternalLbVm)).thenReturn(validElement);
-        Mockito.when(_vrProviderDao.findByNspIdAndType(invalidElId, VirtualRouterProviderType.InternalLbVm)).thenReturn(invalidElement);
-        Mockito.when(_vrProviderDao.findByNspIdAndType(notEnabledElId, VirtualRouterProviderType.InternalLbVm)).thenReturn(notEnabledElement);
+        Mockito.when(_vrProviderDao.findByNspIdAndType(validElId, Type.InternalLbVm)).thenReturn(validElement);
+        Mockito.when(_vrProviderDao.findByNspIdAndType(invalidElId, Type.InternalLbVm)).thenReturn(invalidElement);
+        Mockito.when(_vrProviderDao.findByNspIdAndType(notEnabledElId, Type.InternalLbVm)).thenReturn(notEnabledElement);
 
         Mockito.when(_vrProviderDao.persist(validElement)).thenReturn(validElement);
         
-        Mockito.when(_vrProviderDao.findByNspIdAndType(validProviderId, VirtualRouterProviderType.InternalLbVm)).thenReturn(validElement);
+        Mockito.when(_vrProviderDao.findByNspIdAndType(validProviderId, Type.InternalLbVm)).thenReturn(validElement);
         
         PhysicalNetworkServiceProviderVO validProvider = new PhysicalNetworkServiceProviderVO(1, "InternalLoadBalancerElement");
         PhysicalNetworkServiceProviderVO invalidProvider = new PhysicalNetworkServiceProviderVO(1, "Invalid name!");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 1ba55bf..f4ca112 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -2681,8 +2681,8 @@ public class ApiResponseHelper implements ResponseGenerator {
     @Override
     public VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result) {
         //generate only response of the VR/VPCVR provider type
-        if (!(result.getType() == VirtualRouterProvider.VirtualRouterProviderType.VirtualRouter
-                || result.getType() == VirtualRouterProvider.VirtualRouterProviderType.VPCVirtualRouter)) {
+        if (!(result.getType() == VirtualRouterProvider.Type.VirtualRouter
+                || result.getType() == VirtualRouterProvider.Type.VPCVirtualRouter)) {
             return null;
         }
         VirtualRouterProviderResponse response = new VirtualRouterProviderResponse();
@@ -3734,7 +3734,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public InternalLoadBalancerElementResponse createInternalLbElementResponse(VirtualRouterProvider result) {
-        if (result.getType() != VirtualRouterProvider.VirtualRouterProviderType.InternalLbVm) {
+        if (result.getType() != VirtualRouterProvider.Type.InternalLbVm) {
             return null;
         }
         InternalLoadBalancerElementResponse response = new InternalLoadBalancerElementResponse();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index 8ad553a..b6b9bb5 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -1694,8 +1694,8 @@ VirtualMachineGuru, SystemVmLoadScanHandler<Long>, ResourceStateAdapter {
 
     protected HostVO findConsoleProxyHostByName(String name) {
         GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.ConsoleProxy);
-        sc.addAnd(sc.getEntity().getName(), Op.EQ, name);
+        sc.and(sc.entity().getType(), Op.EQ, Host.Type.ConsoleProxy);
+        sc.and(sc.entity().getName(), Op.EQ, name);
         return sc.find();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/server/src/com/cloud/ha/AbstractInvestigatorImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/AbstractInvestigatorImpl.java b/server/src/com/cloud/ha/AbstractInvestigatorImpl.java
index c64d2ec..e551386 100755
--- a/server/src/com/cloud/ha/AbstractInvestigatorImpl.java
+++ b/server/src/com/cloud/ha/AbstractInvestigatorImpl.java
@@ -21,7 +21,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
@@ -38,16 +37,15 @@ import com.cloud.host.Status;
 import com.cloud.host.dao.HostDao;
 import com.cloud.resource.ResourceManager;
 import com.cloud.utils.component.AdapterBase;
-import com.cloud.utils.db.GenericQueryBuilder;
+import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.GenericQueryBuilder;
 
 public abstract class AbstractInvestigatorImpl extends AdapterBase implements Investigator {
     private static final Logger s_logger = Logger.getLogger(AbstractInvestigatorImpl.class);
 
-    @Inject private HostDao _hostDao = null;
-    @Inject private AgentManager _agentMgr = null;
-    @Inject private ResourceManager _resourceMgr = null;
+    @Inject private final HostDao _hostDao = null;
+    @Inject private final AgentManager _agentMgr = null;
+    @Inject private final ResourceManager _resourceMgr = null;
 
 
     @Override
@@ -68,10 +66,10 @@ public abstract class AbstractInvestigatorImpl extends AdapterBase implements In
     
     // Host.status is up and Host.type is routing
     protected List<Long> findHostByPod(long podId, Long excludeHostId) {
-    	GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getType(), Op.EQ, Type.Routing);
-        sc.addAnd(sc.getEntity().getPodId(), Op.EQ, podId);
-        sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getType(), Op.EQ, Type.Routing);
+        sc.and(sc.entity().getPodId(), Op.EQ, podId);
+        sc.and(sc.entity().getStatus(), Op.EQ, Status.Up);
         List<HostVO> hosts = sc.list();
         
         List<Long> hostIds = new ArrayList<Long>(hosts.size());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 4dbf486..598b31c 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -97,7 +97,7 @@ import com.cloud.network.Network.Service;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.PhysicalNetwork.BroadcastDomainRange;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.addr.PublicIp;
 import com.cloud.network.dao.AccountGuestVlanMapDao;
 import com.cloud.network.dao.AccountGuestVlanMapVO;
@@ -3685,7 +3685,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
         }
 
         VirtualRouterElement element = (VirtualRouterElement)networkElement;
-        element.addElement(nsp.getId(), VirtualRouterProviderType.VirtualRouter);
+        element.addElement(nsp.getId(), Type.VirtualRouter);
 
         return nsp;
     }
@@ -3701,7 +3701,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
         }
 
         VpcVirtualRouterElement element = (VpcVirtualRouterElement)networkElement;
-        element.addElement(nsp.getId(), VirtualRouterProviderType.VPCVirtualRouter);
+        element.addElement(nsp.getId(), Type.VPCVirtualRouter);
 
         return nsp;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/server/src/com/cloud/network/StorageNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/StorageNetworkManagerImpl.java b/server/src/com/cloud/network/StorageNetworkManagerImpl.java
index 5d6fd62..2c6414e 100755
--- a/server/src/com/cloud/network/StorageNetworkManagerImpl.java
+++ b/server/src/com/cloud/network/StorageNetworkManagerImpl.java
@@ -340,7 +340,7 @@ public class StorageNetworkManagerImpl extends ManagerBase implements StorageNet
     @Override
     public boolean isStorageIpRangeAvailable(long zoneId) {
         GenericQueryBuilder<StorageNetworkIpRangeVO, StorageNetworkIpRangeVO> sc = GenericQueryBuilder.create(StorageNetworkIpRangeVO.class);
-        sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, zoneId);
+        sc.and(sc.entity().getDataCenterId(), Op.EQ, zoneId);
         List<StorageNetworkIpRangeVO> entries = sc.list();
         return entries.size() > 0;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/server/src/com/cloud/network/element/VirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java
index 00d52bf..0cd3bcf 100755
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -25,13 +25,15 @@ import java.util.Set;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import org.apache.log4j.Logger;
+
+import com.google.gson.Gson;
+
 import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElementCmd;
 import org.apache.cloudstack.api.command.admin.router.CreateVirtualRouterElementCmd;
 import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.agent.api.to.LoadBalancerTO;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.dc.DataCenter;
@@ -55,7 +57,7 @@ import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PublicIpAddress;
 import com.cloud.network.RemoteAccessVpn;
 import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.VpnUser;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.LoadBalancerDao;
@@ -77,12 +79,10 @@ import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.user.AccountManager;
-import com.cloud.uservm.UserVm;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.GenericQueryBuilder;
-import com.cloud.utils.db.GenericQueryBuilder;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.NicProfile;
@@ -91,19 +91,16 @@ import com.cloud.vm.UserVmManager;
 import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachine.State;
-import com.cloud.vm.VirtualMachine.Type;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.UserVmDao;
 
-import com.google.gson.Gson;
-
-@Local(value = {NetworkElement.class, FirewallServiceProvider.class, 
-		        DhcpServiceProvider.class, UserDataServiceProvider.class, 
+@Local(value = {NetworkElement.class, FirewallServiceProvider.class,
+		        DhcpServiceProvider.class, UserDataServiceProvider.class,
 		        StaticNatServiceProvider.class, LoadBalancingServiceProvider.class,
 		        PortForwardingServiceProvider.class, IpDeployer.class,
 		        RemoteAccessVPNServiceProvider.class, NetworkMigrationResponder.class} )
-public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider, 
+public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider,
     UserDataServiceProvider, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider,
         LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer,
         NetworkMigrationResponder {
@@ -166,7 +163,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
             }
         } else {
             if (!_networkMgr.isProviderSupportServiceInNetwork(network.getId(), service, getProvider())) {
-                s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName() 
+                s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName()
                         + " in the network " + network);
                 return false;
             }
@@ -187,19 +184,19 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1);
         params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
 
-        List<DomainRouterVO> routers = _routerMgr.deployVirtualRouterInGuestNetwork(network, dest, 
-                _accountMgr.getAccount(network.getAccountId()), params, 
+        List<DomainRouterVO> routers = _routerMgr.deployVirtualRouterInGuestNetwork(network, dest,
+                _accountMgr.getAccount(network.getAccountId()), params,
                 offering.getRedundantRouter());
         if ((routers == null) || (routers.size() == 0)) {
             throw new ResourceUnavailableException("Can't find at least one running router!",
                     DataCenter.class, network.getDataCenterId());
         }
         
-        return true;       
+        return true;
     }
 
     @Override
-    public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, 
+    public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm,
             DeployDestination dest, ReservationContext context)
             throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
         if (vm.getType() != VirtualMachine.Type.User || vm.getHypervisorType() == HypervisorType.BareMetal) {
@@ -219,15 +216,15 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         }
 
         @SuppressWarnings("unchecked")
-        VirtualMachineProfile uservm = (VirtualMachineProfile) vm;
-        List<DomainRouterVO> routers = _routerMgr.deployVirtualRouterInGuestNetwork(network, dest, 
+        VirtualMachineProfile uservm = vm;
+        List<DomainRouterVO> routers = _routerMgr.deployVirtualRouterInGuestNetwork(network, dest,
                 _accountMgr.getAccount(network.getAccountId()),
                 uservm.getParameters(), offering.getRedundantRouter());
         if ((routers == null) || (routers.size() == 0)) {
             throw new ResourceUnavailableException("Can't find at least one running router!",
                     DataCenter.class, network.getDataCenterId());
         }
-        return true;      
+        return true;
     }
 
     @Override
@@ -306,11 +303,11 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
                         expire = value;
                 }
                 if ((expire != null) && !containsOnlyNumbers(expire, timeEndChar)) {
-                    throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + 
+                    throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() +
                             " Cause: expire is not in timeformat: " + expire);
                 }
                 if ((tablesize != null) && !containsOnlyNumbers(tablesize, "kmg")) {
-                    throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + 
+                    throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() +
                             " Cause: tablesize is not in size format: " + tablesize);
 
                 }
@@ -337,11 +334,11 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
                 }
 
                 if ((length != null) && (!containsOnlyNumbers(length, null))) {
-                    throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + 
+                    throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() +
                             " Cause: length is not a number: " + length);
                 }
                 if ((holdTime != null) && (!containsOnlyNumbers(holdTime, timeEndChar) && !containsOnlyNumbers(holdTime, null))) {
-                    throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + 
+                    throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() +
                             " Cause: holdtime is not in timeformat: " + holdTime);
                 }
             }
@@ -400,7 +397,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
             }
             return _routerMgr.applyVpnUsers(network, users, routers);
         } else {
-            s_logger.debug("Element " + this.getName() + " doesn't handle applyVpnUsers command");
+            s_logger.debug("Element " + getName() + " doesn't handle applyVpnUsers command");
             return null;
         }
     }
@@ -416,7 +413,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
             }
             return _routerMgr.startRemoteAccessVpn(network, vpn, routers);
         } else {
-            s_logger.debug("Element " + this.getName() + " doesn't handle createVpn command");
+            s_logger.debug("Element " + getName() + " doesn't handle createVpn command");
             return false;
         }
     }
@@ -432,13 +429,13 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
             }
             return _routerMgr.deleteRemoteAccessVpn(network, vpn, routers);
         } else {
-            s_logger.debug("Element " + this.getName() + " doesn't handle removeVpn command");
+            s_logger.debug("Element " + getName() + " doesn't handle removeVpn command");
             return false;
         }
     }
 
     @Override
-    public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> services) 
+    public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> services)
             throws ResourceUnavailableException {
         boolean canHandle = true;
         for (Service service : services) {
@@ -636,7 +633,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     }
 
     @Override
-    public boolean shutdown(Network network, ReservationContext context, boolean cleanup) 
+    public boolean shutdown(Network network, ReservationContext context, boolean cleanup)
             throws ConcurrentOperationException, ResourceUnavailableException {
         List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
         if (routers == null || routers.isEmpty()) {
@@ -672,7 +669,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     }
 
     @Override
-    public boolean savePassword(Network network, NicProfile nic, VirtualMachineProfile vm) 
+    public boolean savePassword(Network network, NicProfile nic, VirtualMachineProfile vm)
             throws ResourceUnavailableException {
         if (!canHandle(network, null)) {
             return false;
@@ -684,7 +681,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         }
 
         @SuppressWarnings("unchecked")
-        VirtualMachineProfile uservm = (VirtualMachineProfile) vm;
+        VirtualMachineProfile uservm = vm;
 
         return _routerMgr.savePasswordToRouter(network, nic, uservm, routers);
     }
@@ -702,7 +699,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         }
 
         @SuppressWarnings("unchecked")
-        VirtualMachineProfile uservm = (VirtualMachineProfile) vm;
+        VirtualMachineProfile uservm = vm;
 
         return _routerMgr.saveSSHPublicKeyToRouter(network, nic, uservm, routers, SSHPublicKey);
     }
@@ -720,7 +717,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         }
 
         @SuppressWarnings("unchecked")
-        VirtualMachineProfile uservm = (VirtualMachineProfile) vm;
+        VirtualMachineProfile uservm = vm;
 
         return _routerMgr.saveUserDataToRouter(network, nic, uservm, routers);
     }
@@ -737,7 +734,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     @Override
     public VirtualRouterProvider configure(ConfigureVirtualRouterElementCmd cmd) {
         VirtualRouterProviderVO element = _vrProviderDao.findById(cmd.getId());
-        if (element == null || !(element.getType() == VirtualRouterProviderType.VirtualRouter || element.getType() == VirtualRouterProviderType.VPCVirtualRouter)) {
+        if (element == null || !(element.getType() == Type.VirtualRouter || element.getType() == Type.VPCVirtualRouter)) {
             s_logger.debug("Can't find Virtual Router element with network service provider id " + cmd.getId());
             return null;
         }
@@ -749,10 +746,10 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     }
 
     @Override
-    public VirtualRouterProvider addElement(Long nspId, VirtualRouterProviderType providerType) {
-        if (!(providerType == VirtualRouterProviderType.VirtualRouter || providerType == VirtualRouterProviderType.VPCVirtualRouter)) {
-            throw new InvalidParameterValueException("Element " + this.getName() + " supports only providerTypes: " + 
-        VirtualRouterProviderType.VirtualRouter.toString() + " and " + VirtualRouterProviderType.VPCVirtualRouter);
+    public VirtualRouterProvider addElement(Long nspId, Type providerType) {
+        if (!(providerType == Type.VirtualRouter || providerType == Type.VPCVirtualRouter)) {
+            throw new InvalidParameterValueException("Element " + getName() + " supports only providerTypes: " +
+        Type.VirtualRouter.toString() + " and " + Type.VPCVirtualRouter);
         }
         VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(nspId, providerType);
         if (element != null) {
@@ -786,7 +783,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
 
     @Override
     public boolean isReady(PhysicalNetworkServiceProvider provider) {
-        VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), 
+        VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(),
                 getVirtualRouterProvider());
         if (element == null) {
             return false;
@@ -795,10 +792,10 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     }
 
     @Override
-    public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) 
+    public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context)
             throws ConcurrentOperationException,
             ResourceUnavailableException {
-        VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), 
+        VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(),
                 getVirtualRouterProvider());
         if (element == null) {
             return true;
@@ -821,14 +818,14 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     }
 
     public Long getIdByNspId(Long nspId) {
-        VirtualRouterProviderVO vr = _vrProviderDao.findByNspIdAndType(nspId, VirtualRouterProviderType.VirtualRouter);
+        VirtualRouterProviderVO vr = _vrProviderDao.findByNspIdAndType(nspId, Type.VirtualRouter);
         return vr.getId();
     }
 
     @Override
     public VirtualRouterProvider getCreatedElement(long id) {
         VirtualRouterProvider provider = _vrProviderDao.findById(id);
-        if (!(provider.getType() == VirtualRouterProviderType.VirtualRouter || provider.getType() == VirtualRouterProviderType.VPCVirtualRouter)) {
+        if (!(provider.getType() == Type.VirtualRouter || provider.getType() == Type.VPCVirtualRouter)) {
             throw new InvalidParameterValueException("Unable to find provider by id");
         }
         return provider;
@@ -849,7 +846,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
                 return false;
             }
             @SuppressWarnings("unchecked")
-            VirtualMachineProfile uservm = (VirtualMachineProfile) vm;
+            VirtualMachineProfile uservm = vm;
 
             List<DomainRouterVO> routers = getRouters(network, dest);
 
@@ -880,7 +877,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     }
 
     @Override
-    public boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile vm, 
+    public boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile vm,
             DeployDestination dest, ReservationContext context)
             throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
         if (canHandle(network, Service.Dhcp)) {
@@ -889,7 +886,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
             }
 
             @SuppressWarnings("unchecked")
-            VirtualMachineProfile uservm = (VirtualMachineProfile) vm;
+            VirtualMachineProfile uservm = vm;
 
             List<DomainRouterVO> routers = getRouters(network, dest);
 
@@ -917,7 +914,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
             }
 
             @SuppressWarnings("unchecked")
-            VirtualMachineProfile uservm = (VirtualMachineProfile) vm;
+            VirtualMachineProfile uservm = vm;
 
             List<DomainRouterVO> routers = getRouters(network, dest);
 
@@ -935,7 +932,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         if (_networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, getProvider())) {
             publicNetwork = true;
         }
-        boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic 
+        boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic
                 || _networkMgr.isSecurityGroupSupportedInNetwork(network)) &&
                 network.getTrafficType() == TrafficType.Guest;
 
@@ -969,19 +966,19 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         Long nspId = cmd.getNspId();
         Boolean enabled = cmd.getEnabled();
 
-        GenericQueryBuilder<VirtualRouterProviderVO, VirtualRouterProviderVO> sc = GenericQueryBuilder.create(VirtualRouterProviderVO.class);
+        QueryBuilder<VirtualRouterProviderVO> sc = QueryBuilder.create(VirtualRouterProviderVO.class);
         if (id != null) {
-            sc.addAnd(sc.getEntity().getId(), Op.EQ, id);
+            sc.and(sc.entity().getId(), Op.EQ, id);
         }
         if (nspId != null) {
-            sc.addAnd(sc.getEntity().getNspId(), Op.EQ, nspId);
+            sc.and(sc.entity().getNspId(), Op.EQ, nspId);
         }
         if (enabled != null) {
-            sc.addAnd(sc.getEntity().isEnabled(), Op.EQ, enabled);
+            sc.and(sc.entity().isEnabled(), Op.EQ, enabled);
         }
         
         //return only VR and VPC VR
-        sc.addAnd(sc.getEntity().getType(), Op.IN, VirtualRouterProvider.VirtualRouterProviderType.VPCVirtualRouter, VirtualRouterProvider.VirtualRouterProviderType.VirtualRouter);
+        sc.and(sc.entity().getType(), Op.IN, VirtualRouterProvider.Type.VPCVirtualRouter, VirtualRouterProvider.Type.VirtualRouter);
         
         return sc.list();
     }
@@ -989,7 +986,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     @Override
     public boolean verifyServicesCombination(Set<Service> services) {
         if (!services.contains(Service.SourceNat)) {
-            if (services.contains(Service.StaticNat) || services.contains(Service.Firewall) || services.contains(Service.Lb) || 
+            if (services.contains(Service.StaticNat) || services.contains(Service.Firewall) || services.contains(Service.Lb) ||
                     services.contains(Service.PortForwarding) || services.contains(Service.Vpn)) {
                 String servicesList = "[";
                 for (Service service : services) {
@@ -1008,8 +1005,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         return this;
     }
 
-    protected VirtualRouterProviderType getVirtualRouterProvider() {
-        return VirtualRouterProviderType.VirtualRouter;
+    protected VirtualRouterProvider.Type getVirtualRouterProvider() {
+        return VirtualRouterProvider.Type.VirtualRouter;
     }
 
 	@Override
@@ -1019,13 +1016,13 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
 		return null;
 	}
 	private boolean canHandleLbRules(List<LoadBalancingRule> rules) {
-	    Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
+	    Map<Capability, String> lbCaps = getCapabilities().get(Service.Lb);
 	    if (!lbCaps.isEmpty()) {
 	        String schemeCaps = lbCaps.get(Capability.LbSchemes);
 	        if (schemeCaps != null) {
 	            for (LoadBalancingRule rule : rules) {
 	                if (!schemeCaps.contains(rule.getScheme().toString())) {
-	                    s_logger.debug("Scheme " + rules.get(0).getScheme() + " is not supported by the provider " + this.getName());
+	                    s_logger.debug("Scheme " + rules.get(0).getScheme() + " is not supported by the provider " + getName());
 	                    return false;
 	                }
 	            }
@@ -1041,11 +1038,11 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
 		if (nic.getBroadcastType() != Networks.BroadcastDomainType.Pvlan) {
 			return true;
 		}
-		if (vm.getType() == Type.DomainRouter) {
+        if (vm.getType() == VirtualMachine.Type.DomainRouter) {
 			assert vm instanceof DomainRouterVO;
 			DomainRouterVO router = (DomainRouterVO)vm.getVirtualMachine();
 			_routerMgr.setupDhcpForPvlan(false, router, router.getHostId(), nic);
-		} else if (vm.getType() == Type.User){
+        } else if (vm.getType() == VirtualMachine.Type.User) {
 			assert vm instanceof UserVmVO;
 			UserVmVO userVm = (UserVmVO)vm.getVirtualMachine();
 			_userVmMgr.setupVmForPvlan(false, userVm.getHostId(), nic);
@@ -1060,11 +1057,11 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
 		if (nic.getBroadcastType() != Networks.BroadcastDomainType.Pvlan) {
 			return;
 		}
-		if (vm.getType() == Type.DomainRouter) {
+        if (vm.getType() == VirtualMachine.Type.DomainRouter) {
 			assert vm instanceof DomainRouterVO;
 			DomainRouterVO router = (DomainRouterVO)vm.getVirtualMachine();
 			_routerMgr.setupDhcpForPvlan(true, router, router.getHostId(), nic);
-		} else if (vm.getType() == Type.User){
+        } else if (vm.getType() == VirtualMachine.Type.User) {
 			assert vm instanceof UserVmVO;
 			UserVmVO userVm = (UserVmVO)vm.getVirtualMachine();
 			_userVmMgr.setupVmForPvlan(true, userVm.getHostId(), nic);
@@ -1078,11 +1075,11 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
 		if (nic.getBroadcastType() != Networks.BroadcastDomainType.Pvlan) {
 			return;
 		}
-		if (vm.getType() == Type.DomainRouter) {
+        if (vm.getType() == VirtualMachine.Type.DomainRouter) {
 			assert vm instanceof DomainRouterVO;
 			DomainRouterVO router = (DomainRouterVO)vm.getVirtualMachine();
 			_routerMgr.setupDhcpForPvlan(true, router, router.getHostId(), nic);
-		} else if (vm.getType() == Type.User){
+        } else if (vm.getType() == VirtualMachine.Type.User) {
 			assert vm instanceof UserVmVO;
 			UserVmVO userVm = (UserVmVO)vm.getVirtualMachine();
 			_userVmMgr.setupVmForPvlan(true, userVm.getHostId(), nic);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
index c512dda..b8a8246 100644
--- a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
@@ -41,7 +41,7 @@ import com.cloud.network.NetworkModel;
 import com.cloud.network.PublicIpAddress;
 import com.cloud.network.Site2SiteVpnConnection;
 import com.cloud.network.Site2SiteVpnGateway;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.Site2SiteVpnGatewayDao;
@@ -63,7 +63,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine.Type;
+import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 
 @Local(value = {NetworkElement.class, FirewallServiceProvider.class,
@@ -210,7 +210,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
             return false;
         }
 
-        if (vm.getType() == Type.User) {
+        if (vm.getType() == VirtualMachine.Type.User) {
             Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1);
             params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
             List<DomainRouterVO> routers = _vpcRouterMgr.deployVirtualRouterInVpc(vpc, dest,
@@ -434,8 +434,8 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
     }
 
     @Override
-    protected VirtualRouterProviderType getVirtualRouterProvider() {
-        return VirtualRouterProviderType.VPCVirtualRouter;
+    protected Type getVirtualRouterProvider() {
+        return Type.VPCVirtualRouter;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 7c026a4..043c376 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -155,7 +155,7 @@ import com.cloud.network.Site2SiteVpnConnection;
 import com.cloud.network.SshKeysDistriMonitor;
 import com.cloud.network.VirtualNetworkApplianceService;
 import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.VpnUser;
 import com.cloud.network.VpnUserVO;
 import com.cloud.network.addr.PublicIp;
@@ -202,7 +202,7 @@ import com.cloud.server.ConfigurationServer;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.VMTemplateVO;
-import com.cloud.storage.Volume.Type;
+import com.cloud.storage.Volume;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.GuestOSDao;
 import com.cloud.storage.dao.VMTemplateDao;
@@ -1506,7 +1506,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
             }
 
             // Check if providers are supported in the physical networks
-            VirtualRouterProviderType type = VirtualRouterProviderType.VirtualRouter;
+            Type type = Type.VirtualRouter;
                 Long physicalNetworkId = _networkModel.getPhysicalNetworkId(guestNetwork);
             PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());
             if (provider == null) {
@@ -1930,7 +1930,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
         avoids[1] = new ExcludeList();
         avoids[1].addCluster(_hostDao.findById(routerToBeAvoid.getHostId()).getClusterId());
         avoids[2] = new ExcludeList();
-        List<VolumeVO> volumes = _volumeDao.findByInstanceAndType(routerToBeAvoid.getId(), Type.ROOT);
+        List<VolumeVO> volumes = _volumeDao.findByInstanceAndType(routerToBeAvoid.getId(), Volume.Type.ROOT);
         if (volumes != null && volumes.size() != 0) {
             avoids[2].addPool(volumes.get(0).getPoolId());
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index ea2d7c4..12d90ef 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -72,7 +72,7 @@ import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PublicIpAddress;
 import com.cloud.network.Site2SiteVpnConnection;
 import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.VpcVirtualNetworkApplianceService;
 import com.cloud.network.addr.PublicIp;
 import com.cloud.network.dao.FirewallRulesDao;
@@ -203,13 +203,13 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
            
             for (PhysicalNetwork pNtwk : pNtwks) {
                 PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(pNtwk.getId(),
-                        VirtualRouterProviderType.VPCVirtualRouter.toString());
+                        Type.VPCVirtualRouter.toString());
                 if (provider == null) {
                     throw new CloudRuntimeException("Cannot find service provider " +
-                            VirtualRouterProviderType.VPCVirtualRouter.toString() + " in physical network " + pNtwk.getId());
+                            Type.VPCVirtualRouter.toString() + " in physical network " + pNtwk.getId());
                 }
                 vpcVrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(),
-                        VirtualRouterProviderType.VPCVirtualRouter);
+                        Type.VPCVirtualRouter);
                 if (vpcVrProvider != null) {
                     break;
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 27f0600..7a9343c 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -140,12 +140,11 @@ import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericSearchBuilder;
 import com.cloud.utils.db.GlobalLock;
+import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.SearchCriteria.Func;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.GenericQueryBuilder;
-import com.cloud.utils.db.GenericQueryBuilder;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.fsm.NoTransitionException;
@@ -2256,27 +2255,27 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
     @Override
     public List<HostVO> findDirectlyConnectedHosts() {
         /* The resource column is not null for direct connected resource */
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getResource(), Op.NNULL);
-        sc.addAnd(sc.getEntity().getResourceState(), Op.NIN, ResourceState.Disabled);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getResource(), Op.NNULL);
+        sc.and(sc.entity().getResourceState(), Op.NIN, ResourceState.Disabled);
         return sc.list();
     }
 
     @Override
     public List<HostVO> listAllUpAndEnabledHosts(Type type, Long clusterId, Long podId, long dcId) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
         if (type != null) {
-            sc.addAnd(sc.getEntity().getType(), Op.EQ, type);
+            sc.and(sc.entity().getType(), Op.EQ,type);
         }
         if (clusterId != null) {
-            sc.addAnd(sc.getEntity().getClusterId(), Op.EQ, clusterId);
+            sc.and(sc.entity().getClusterId(), Op.EQ,clusterId);
         }
         if (podId != null) {
-            sc.addAnd(sc.getEntity().getPodId(), Op.EQ, podId);
+            sc.and(sc.entity().getPodId(), Op.EQ,podId);
         }
-        sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
-        sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
-        sc.addAnd(sc.getEntity().getResourceState(), Op.EQ, ResourceState.Enabled);
+        sc.and(sc.entity().getDataCenterId(), Op.EQ,dcId);
+        sc.and(sc.entity().getStatus(), Op.EQ,Status.Up);
+        sc.and(sc.entity().getResourceState(), Op.EQ,ResourceState.Enabled);
         return sc.list();
     }
 
@@ -2288,60 +2287,60 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
     @Override
     public List<HostVO> findHostByGuid(long dcId, String guid) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
-        sc.addAnd(sc.getEntity().getGuid(), Op.EQ, guid);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getDataCenterId(), Op.EQ,dcId);
+        sc.and(sc.entity().getGuid(), Op.EQ,guid);
         return sc.list();
     }
 
     @Override
     public List<HostVO> listAllHostsInCluster(long clusterId) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getClusterId(), Op.EQ, clusterId);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getClusterId(), Op.EQ,clusterId);
         return sc.list();
     }
 
     @Override
     public List<HostVO> listHostsInClusterByStatus(long clusterId, Status status) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getClusterId(), Op.EQ, clusterId);
-        sc.addAnd(sc.getEntity().getStatus(), Op.EQ, status);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getClusterId(), Op.EQ,clusterId);
+        sc.and(sc.entity().getStatus(), Op.EQ,status);
         return sc.list();
     }
 
     @Override
     public List<HostVO> listAllUpAndEnabledHostsInOneZoneByType(Type type, long dcId) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getType(), Op.EQ, type);
-        sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
-        sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
-        sc.addAnd(sc.getEntity().getResourceState(), Op.EQ, ResourceState.Enabled);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getType(), Op.EQ,type);
+        sc.and(sc.entity().getDataCenterId(), Op.EQ,dcId);
+        sc.and(sc.entity().getStatus(), Op.EQ,Status.Up);
+        sc.and(sc.entity().getResourceState(), Op.EQ,ResourceState.Enabled);
         return sc.list();
     }
 
     @Override
     public List<HostVO> listAllNotInMaintenanceHostsInOneZone(Type type, Long dcId) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
         if (dcId != null) {
-            sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
+            sc.and(sc.entity().getDataCenterId(), Op.EQ,dcId);
         }
-        sc.addAnd(sc.getEntity().getType(), Op.EQ, type);
-        sc.addAnd(sc.getEntity().getResourceState(), Op.NIN, ResourceState.Maintenance, ResourceState.ErrorInMaintenance, ResourceState.PrepareForMaintenance, ResourceState.Error);
+        sc.and(sc.entity().getType(), Op.EQ,type);
+        sc.and(sc.entity().getResourceState(), Op.NIN, ResourceState.Maintenance, ResourceState.ErrorInMaintenance, ResourceState.PrepareForMaintenance, ResourceState.Error);
         return sc.list();
     }
 
     @Override
     public List<HostVO> listAllHostsInOneZoneByType(Type type, long dcId) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getType(), Op.EQ, type);
-        sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getType(), Op.EQ,type);
+        sc.and(sc.entity().getDataCenterId(), Op.EQ,dcId);
         return sc.list();
     }
 
     @Override
     public List<HostVO> listAllHostsInAllZonesByType(Type type) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getType(), Op.EQ, type);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getType(), Op.EQ,type);
         return sc.list();
     }
 
@@ -2370,15 +2369,15 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
     @Override
     public HostVO findHostByGuid(String guid) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getGuid(), Op.EQ, guid);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getGuid(), Op.EQ,guid);
         return sc.find();
     }
 
     @Override
     public HostVO findHostByName(String name) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getName(), Op.EQ, name);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getName(), Op.EQ,name);
         return sc.find();
     }
 
@@ -2449,11 +2448,11 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
     @Override
     public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType type, long dcId) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getHypervisorType(), Op.EQ, type);
-        sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
-        sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
-        sc.addAnd(sc.getEntity().getResourceState(), Op.EQ, ResourceState.Enabled);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getHypervisorType(), Op.EQ,type);
+        sc.and(sc.entity().getDataCenterId(), Op.EQ,dcId);
+        sc.and(sc.entity().getStatus(), Op.EQ,Status.Up);
+        sc.and(sc.entity().getResourceState(), Op.EQ,ResourceState.Enabled);
         return sc.list();
     }
 


Mime
View raw message