You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/24 01:57:37 UTC

[5/50] [abbrv] Merge branch 'master' into test-merge-api

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/api/ApiDispatcher.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiDispatcher.java
index 6fcfb79,9fd0b2e..e9a7571
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@@ -607,64 -418,51 +609,74 @@@ public class ApiDispatcher 
                  }
                  break;
              case FLOAT:
-                 field.set(cmdObj, Float.valueOf(paramObj.toString()));
+                 // Assuming that the parameters have been checked for required before now,
+                 // we ignore blank or null values and defer to the command to set a default
+                 // value for optional parameters ...
+                 if (paramObj != null && isNotBlank(paramObj.toString())) {
+                     field.set(cmdObj, Float.valueOf(paramObj.toString()));
+                 }
                  break;
              case INTEGER:
-                 field.set(cmdObj, Integer.valueOf(paramObj.toString()));
+                 // Assuming that the parameters have been checked for required before now,
+                 // we ignore blank or null values and defer to the command to set a default
+                 // value for optional parameters ...
+                 if (paramObj != null && isNotBlank(paramObj.toString())) {
+                     field.set(cmdObj, Integer.valueOf(paramObj.toString()));
+                 }
                  break;
 -            case LIST:
 -                List listParam = new ArrayList();
 -                StringTokenizer st = new StringTokenizer(paramObj.toString(), ",");
 -                while (st.hasMoreTokens()) {
 -                    String token = st.nextToken();
 -                    CommandType listType = annotation.collectionType();
 -                    switch (listType) {
 -                    case INTEGER:
 -                        listParam.add(Integer.valueOf(token));
 -                        break;
 -                    case LONG: {
 -                        Long val = null;
 -                        if (identityMapper != null)
 -                            val = s_instance._identityDao.getIdentityId(identityMapper, token);
 -                        else
 -                            val = Long.valueOf(token);
 -
 -                        listParam.add(val);
 -                    }
 -                        break;
 -                    case SHORT:
 -                        listParam.add(Short.valueOf(token));
 -                    case STRING:
 -                        listParam.add(token);
 -                        break;
 +                case LIST:
 +                    List listParam = new ArrayList();
 +                    StringTokenizer st = new StringTokenizer(paramObj.toString(), ",");
 +                    while (st.hasMoreTokens()) {
 +                        String token = st.nextToken();
 +                        CommandType listType = annotation.collectionType();
 +                        switch (listType) {
 +                            case INTEGER:
 +                                listParam.add(Integer.valueOf(token));
 +                                break;
 +                            case UUID:
 +                                if (token.isEmpty())
 +                                    break;
 +                                Long internalId = translateUuidToInternalId(token, annotation);
 +                                // If id is null, entity with the uuid was not found, throw exception
 +                                if (internalId == null) {
 +                                    throw new InvalidParameterValueException("No entity with " + field.getName() + "(uuid)="
 +                                            + paramObj.toString() + " was found in the database.");
 +                                }
 +                                listParam.add(internalId);
 +                                break;
 +                            case LONG: {
 +                                Long val = null;
 +                                if (identityMapper != null)
 +                                    val = s_instance._identityDao.getIdentityId(identityMapper, token);
 +                                else
 +                                    val = Long.valueOf(token);
 +
 +                                listParam.add(val);
 +                            }
 +                            break;
 +                            case SHORT:
 +                                listParam.add(Short.valueOf(token));
 +                            case STRING:
 +                                listParam.add(token);
 +                                break;
 +                        }
                      }
 +                    field.set(cmdObj, listParam);
 +                    break;
 +            case UUID:
 +                if (paramObj.toString().isEmpty())
 +                    break;
 +                Long internalId = translateUuidToInternalId(paramObj.toString(), annotation);
 +                // If id is null, entity with the uuid was not found, throw exception
 +                if (internalId == null) {
 +                    throw new InvalidParameterValueException("No entity with " + field.getName() + "(uuid)="
 +                            + paramObj.toString() + " was found in the database.");
                  }
 -                field.set(cmdObj, listParam);
 +                field.set(cmdObj, internalId);
                  break;
              case LONG:
 +                // APITODO: Remove identityMapper, simply convert the over the wire param to Long
                  if (identityMapper != null)
                      field.set(cmdObj, s_instance._identityDao.getIdentityId(identityMapper, paramObj.toString()));
                  else

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiResponseHelper.java
index 5cb0f48,a574710..b2bfee8
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@@ -36,99 -36,85 +39,99 @@@ import org.apache.log4j.Logger
  
  import com.cloud.acl.ControlledEntity;
  import com.cloud.acl.ControlledEntity.ACLType;
 -import com.cloud.api.ApiConstants.HostDetails;
 -import com.cloud.api.ApiConstants.VMDetails;
 -import com.cloud.api.commands.QueryAsyncJobResultCmd;
 -import com.cloud.api.response.AccountResponse;
 +import org.apache.cloudstack.api.ApiConstants.HostDetails;
 +import org.apache.cloudstack.api.ApiConstants.VMDetails;
 +import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
 +import org.apache.cloudstack.api.response.AccountResponse;
 +
 +import com.cloud.api.query.ViewResponseHelper;
 +import com.cloud.api.query.vo.ControlledViewEntity;
 +import com.cloud.api.query.vo.DomainRouterJoinVO;
 +import com.cloud.api.query.vo.EventJoinVO;
 +import com.cloud.api.query.vo.HostJoinVO;
 +import com.cloud.api.query.vo.InstanceGroupJoinVO;
 +import com.cloud.api.query.vo.ProjectAccountJoinVO;
 +import com.cloud.api.query.vo.ProjectInvitationJoinVO;
 +import com.cloud.api.query.vo.ProjectJoinVO;
 +import com.cloud.api.query.vo.ResourceTagJoinVO;
 +import com.cloud.api.query.vo.SecurityGroupJoinVO;
 +import com.cloud.api.query.vo.UserAccountJoinVO;
 +import com.cloud.api.query.vo.UserVmJoinVO;
  import com.cloud.api.response.ApiResponseSerializer;
 -import com.cloud.api.response.AsyncJobResponse;
 -import com.cloud.api.response.AutoScalePolicyResponse;
 -import com.cloud.api.response.AutoScaleVmGroupResponse;
 -import com.cloud.api.response.AutoScaleVmProfileResponse;
 -import com.cloud.api.response.CapabilityResponse;
 -import com.cloud.api.response.CapacityResponse;
 -import com.cloud.api.response.ClusterResponse;
 -import com.cloud.api.response.ConditionResponse;
 -import com.cloud.api.response.ConfigurationResponse;
 -import com.cloud.api.response.ControlledEntityResponse;
 -import com.cloud.api.response.CounterResponse;
 -import com.cloud.api.response.CreateCmdResponse;
 -import com.cloud.api.response.DiskOfferingResponse;
 -import com.cloud.api.response.DomainResponse;
 -import com.cloud.api.response.DomainRouterResponse;
 -import com.cloud.api.response.EventResponse;
 -import com.cloud.api.response.ExtractResponse;
 -import com.cloud.api.response.FirewallResponse;
 -import com.cloud.api.response.FirewallRuleResponse;
 -import com.cloud.api.response.HostResponse;
 -import com.cloud.api.response.HypervisorCapabilitiesResponse;
 -import com.cloud.api.response.IPAddressResponse;
 -import com.cloud.api.response.InstanceGroupResponse;
 -import com.cloud.api.response.IpForwardingRuleResponse;
 -import com.cloud.api.response.LBStickinessPolicyResponse;
 -import com.cloud.api.response.LBStickinessResponse;
 -import com.cloud.api.response.LDAPConfigResponse;
 -import com.cloud.api.response.ListResponse;
 -import com.cloud.api.response.LoadBalancerResponse;
 -import com.cloud.api.response.NetworkACLResponse;
 -import com.cloud.api.response.NetworkOfferingResponse;
 -import com.cloud.api.response.NetworkResponse;
 -import com.cloud.api.response.NicResponse;
 -import com.cloud.api.response.PhysicalNetworkResponse;
 -import com.cloud.api.response.PodResponse;
 -import com.cloud.api.response.PrivateGatewayResponse;
 -import com.cloud.api.response.ProjectAccountResponse;
 -import com.cloud.api.response.ProjectInvitationResponse;
 -import com.cloud.api.response.ProjectResponse;
 -import com.cloud.api.response.ProviderResponse;
 -import com.cloud.api.response.RemoteAccessVpnResponse;
 -import com.cloud.api.response.ResourceCountResponse;
 -import com.cloud.api.response.ResourceLimitResponse;
 -import com.cloud.api.response.ResourceTagResponse;
 +import org.apache.cloudstack.api.response.AsyncJobResponse;
 +import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
 +import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
 +import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
 +import org.apache.cloudstack.api.response.CapabilityResponse;
 +import org.apache.cloudstack.api.response.CapacityResponse;
 +import org.apache.cloudstack.api.response.ClusterResponse;
 +import org.apache.cloudstack.api.response.ConditionResponse;
 +import org.apache.cloudstack.api.response.ConfigurationResponse;
 +import org.apache.cloudstack.api.response.ControlledEntityResponse;
 +import org.apache.cloudstack.api.response.CounterResponse;
 +import org.apache.cloudstack.api.response.CreateCmdResponse;
 +import org.apache.cloudstack.api.response.DiskOfferingResponse;
 +import org.apache.cloudstack.api.response.DomainResponse;
 +import org.apache.cloudstack.api.response.DomainRouterResponse;
 +import org.apache.cloudstack.api.response.EventResponse;
 +import org.apache.cloudstack.api.response.ExtractResponse;
 +import org.apache.cloudstack.api.response.FirewallResponse;
 +import org.apache.cloudstack.api.response.FirewallRuleResponse;
 +import org.apache.cloudstack.api.response.GuestOSResponse;
 +import org.apache.cloudstack.api.response.HostResponse;
 +import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
 +import org.apache.cloudstack.api.response.ControlledViewEntityResponse;
 +import org.apache.cloudstack.api.response.IPAddressResponse;
 +import org.apache.cloudstack.api.response.InstanceGroupResponse;
 +import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
 +import org.apache.cloudstack.api.response.LBStickinessPolicyResponse;
 +import org.apache.cloudstack.api.response.LBStickinessResponse;
 +import org.apache.cloudstack.api.response.LDAPConfigResponse;
 +import org.apache.cloudstack.api.response.LoadBalancerResponse;
 +import org.apache.cloudstack.api.response.NetworkACLResponse;
 +import org.apache.cloudstack.api.response.NetworkOfferingResponse;
 +import org.apache.cloudstack.api.response.NetworkResponse;
 +import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 +import org.apache.cloudstack.api.response.PodResponse;
 +import org.apache.cloudstack.api.response.PrivateGatewayResponse;
 +import org.apache.cloudstack.api.response.ProjectAccountResponse;
 +import org.apache.cloudstack.api.response.ProjectInvitationResponse;
 +import org.apache.cloudstack.api.response.ProjectResponse;
 +import org.apache.cloudstack.api.response.ProviderResponse;
 +import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
 +import org.apache.cloudstack.api.response.ResourceCountResponse;
 +import org.apache.cloudstack.api.response.ResourceLimitResponse;
 +import org.apache.cloudstack.api.response.ResourceTagResponse;
 +import org.apache.cloudstack.api.response.SecurityGroupResponse;
 +import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
 +import org.apache.cloudstack.api.response.ServiceOfferingResponse;
 +import org.apache.cloudstack.api.response.ServiceResponse;
 +import org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse;
 +import org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse;
 +import org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse;
 +import org.apache.cloudstack.api.response.SnapshotPolicyResponse;
 +import org.apache.cloudstack.api.response.SnapshotResponse;
 +import org.apache.cloudstack.api.response.SnapshotScheduleResponse;
 +import org.apache.cloudstack.api.response.StaticRouteResponse;
 +import org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse;
 +import org.apache.cloudstack.api.response.StoragePoolResponse;
 +import org.apache.cloudstack.api.response.SwiftResponse;
 +import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
 +import org.apache.cloudstack.api.response.SystemVmResponse;
 +import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
 +import org.apache.cloudstack.api.response.TemplateResponse;
 +import org.apache.cloudstack.api.response.TrafficTypeResponse;
 +import org.apache.cloudstack.api.response.UserResponse;
 +import org.apache.cloudstack.api.response.UserVmResponse;
 +import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
 +import org.apache.cloudstack.api.response.VlanIpRangeResponse;
 +import org.apache.cloudstack.api.response.VolumeResponse;
 +import org.apache.cloudstack.api.response.VpcOfferingResponse;
 +import org.apache.cloudstack.api.response.VpcResponse;
 +import org.apache.cloudstack.api.response.VpnUsersResponse;
 +import org.apache.cloudstack.api.response.ZoneResponse;
- import org.bouncycastle.util.IPAddress;
 +
+ import com.cloud.api.response.S3Response;
 -import com.cloud.api.response.SecurityGroupResponse;
 -import com.cloud.api.response.SecurityGroupResultObject;
 -import com.cloud.api.response.SecurityGroupRuleResponse;
 -import com.cloud.api.response.SecurityGroupRuleResultObject;
 -import com.cloud.api.response.ServiceOfferingResponse;
 -import com.cloud.api.response.ServiceResponse;
 -import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
 -import com.cloud.api.response.Site2SiteVpnConnectionResponse;
 -import com.cloud.api.response.Site2SiteVpnGatewayResponse;
 -import com.cloud.api.response.SnapshotPolicyResponse;
 -import com.cloud.api.response.SnapshotResponse;
 -import com.cloud.api.response.StaticRouteResponse;
 -import com.cloud.api.response.StorageNetworkIpRangeResponse;
 -import com.cloud.api.response.StoragePoolResponse;
 -import com.cloud.api.response.SwiftResponse;
 -import com.cloud.api.response.SystemVmInstanceResponse;
 -import com.cloud.api.response.SystemVmResponse;
 -import com.cloud.api.response.TemplatePermissionsResponse;
 -import com.cloud.api.response.TemplateResponse;
 -import com.cloud.api.response.TrafficTypeResponse;
 -import com.cloud.api.response.UserResponse;
 -import com.cloud.api.response.UserVmResponse;
 -import com.cloud.api.response.VirtualRouterProviderResponse;
 -import com.cloud.api.response.VlanIpRangeResponse;
 -import com.cloud.api.response.VolumeResponse;
 -import com.cloud.api.response.VpcOfferingResponse;
 -import com.cloud.api.response.VpcResponse;
 -import com.cloud.api.response.VpnUsersResponse;
 -import com.cloud.api.response.ZoneResponse;
  import com.cloud.async.AsyncJob;
  import com.cloud.capacity.Capacity;
  import com.cloud.capacity.CapacityVO;
@@@ -1805,6 -2237,65 +1835,65 @@@ public class ApiResponseHelper implemen
          }
      }
  
+     private List<? extends TemplateResponse> createS3IsoResponses(final VirtualMachineTemplate iso) {
+ 
+         final VMTemplateS3VO s3Iso = ApiDBUtils.findTemplateS3Ref(iso.getId());
+ 
+         if (s3Iso == null) {
+             return emptyList();
+         }
+ 
+         final TemplateResponse templateResponse = new TemplateResponse();
+ 
 -        templateResponse.setId(iso.getId());
++        templateResponse.setId(iso.getUuid());
+         templateResponse.setName(iso.getName());
+         templateResponse.setDisplayText(iso.getDisplayText());
+         templateResponse.setPublic(iso.isPublicTemplate());
+         templateResponse.setExtractable(iso.isExtractable());
+         templateResponse.setCreated(s3Iso.getCreated());
+         templateResponse.setReady(true);
+         templateResponse.setBootable(iso.isBootable());
+         templateResponse.setFeatured(iso.isFeatured());
+         templateResponse.setCrossZones(iso.isCrossZones());
+         templateResponse.setChecksum(iso.getChecksum());
+         templateResponse.setDetails(iso.getDetails());
+ 
+         final GuestOS os = ApiDBUtils.findGuestOSById(iso.getGuestOSId());
+ 
+         if (os != null) {
 -            templateResponse.setOsTypeId(os.getId());
++            templateResponse.setOsTypeId(os.getUuid());
+             templateResponse.setOsTypeName(os.getDisplayName());
+         } else {
 -            templateResponse.setOsTypeId(-1L);
++            templateResponse.setOsTypeId("");
+             templateResponse.setOsTypeName("");
+         }
+ 
+         final Account account = ApiDBUtils.findAccountByIdIncludingRemoved(iso.getAccountId());
+         populateAccount(templateResponse, account.getId());
+         populateDomain(templateResponse, account.getDomainId());
+ 
+         boolean isAdmin = false;
+         if ((account == null) || BaseCmd.isAdmin(account.getType())) {
+             isAdmin = true;
+         }
+ 
+         // If the user is an admin, add the template download status
+         if (isAdmin || account.getId() == iso.getAccountId()) {
+             // add download status
+             templateResponse.setStatus("Successfully Installed");
+         }
+ 
+         final Long isoSize = s3Iso.getSize();
+         if (isoSize > 0) {
+             templateResponse.setSize(isoSize);
+         }
+ 
+         templateResponse.setObjectName("iso");
+ 
+         return singletonList(templateResponse);
+ 
+     }
+ 
      private List<TemplateResponse> createSwiftIsoResponses(VirtualMachineTemplate iso) {
          long isoId = iso.getId();
          List<TemplateResponse> isoResponses = new ArrayList<TemplateResponse>();
@@@ -2516,19 -3081,14 +2605,19 @@@
          }
  
          DataCenter zone = ApiDBUtils.findZoneById(network.getDataCenterId());
 -        response.setZoneId(network.getDataCenterId());
 -        response.setZoneName(zone.getName());
 -        response.setPhysicalNetworkId(network.getPhysicalNetworkId());
 +        if (zone != null) {
 +            response.setZoneId(zone.getUuid());
 +            response.setZoneName(zone.getName());
 +        }
 +        if (network.getPhysicalNetworkId() != null) {
 +            PhysicalNetworkVO pnet = ApiDBUtils.findPhysicalNetworkById(network.getPhysicalNetworkId());
 +            response.setPhysicalNetworkId(pnet.getUuid());
 +        }
  
          // populate network offering information
--        NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
++        NetworkOffering networkOffering = (NetworkOffering) ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
          if (networkOffering != null) {
 -            response.setNetworkOfferingId(networkOffering.getId());
 +            response.setNetworkOfferingId(networkOffering.getUuid());
              response.setNetworkOfferingName(networkOffering.getName());
              response.setNetworkOfferingDisplayText(networkOffering.getDisplayText());
              response.setIsSystem(networkOffering.isSystemOnly());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiServer.java
index 9e549ef,f42025c..1551e44
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@@ -118,9 -107,10 +118,11 @@@ import com.cloud.user.UserContext
  import com.cloud.user.UserVO;
  import com.cloud.utils.IdentityProxy;
  import com.cloud.utils.Pair;
 +import com.cloud.utils.component.Adapters;
+ import com.cloud.utils.PropertiesUtil;
+ import com.cloud.utils.StringUtils;
  import com.cloud.utils.component.ComponentLocator;
 -import com.cloud.utils.component.PluggableService;
 +import com.cloud.utils.component.Inject;
  import com.cloud.utils.concurrency.NamedThreadFactory;
  import com.cloud.utils.db.SearchCriteria;
  import com.cloud.utils.db.Transaction;
@@@ -220,35 -314,39 +222,35 @@@ public class ApiServer implements HttpR
              InetAddress remoteAddr = ((SocketHttpServerConnection) connObj).getRemoteAddress();
              sb.append(remoteAddr.toString() + " -- ");
          }
-         sb.append(request.getRequestLine());
+         sb.append(StringUtils.cleanString(request.getRequestLine().toString()));
  
          try {
 -            String uri = request.getRequestLine().getUri();
 -            int requestParamsStartIndex = uri.indexOf('?');
 -            if (requestParamsStartIndex >= 0) {
 -                uri = uri.substring(requestParamsStartIndex + 1);
 -            }
 -
 -            String[] paramArray = uri.split("&");
 -            if (paramArray.length < 1) {
 -                s_logger.info("no parameters received for request: " + uri + ", aborting...");
 -                return;
 +            List<NameValuePair> paramList = null;
 +            try {
 +                paramList = URLEncodedUtils.parse(new URI(request.getRequestLine().getUri()), "UTF-8");
 +            } catch (URISyntaxException e) {
 +                s_logger.error("Error parsing url request", e);
              }
  
 +            // Use Multimap as the parameter map should be in the form (name=String, value=String[])
 +            // So parameter values are stored in a list for the same name key
 +            // APITODO: Use Guava's (import com.google.common.collect.Multimap;)
 +            // (Immutable)Multimap<String, String> paramMultiMap = HashMultimap.create();
 +            // Map<String, Collection<String>> parameterMap = paramMultiMap.asMap();
              Map parameterMap = new HashMap<String, String[]>();
 -
 -            String responseType = BaseCmd.RESPONSE_TYPE_XML;
 -            for (String paramEntry : paramArray) {
 -                String[] paramValue = paramEntry.split("=");
 -                if (paramValue.length != 2) {
 -                    s_logger.info("malformed parameter: " + paramEntry + ", skipping");
 +            String responseType = BaseCmd.RESPONSE_TYPE_JSON;
 +            for (NameValuePair param : paramList) {
 +                if (param.getName().equalsIgnoreCase("response")) {
 +                    responseType = param.getValue();
                      continue;
                  }
 -                if ("response".equalsIgnoreCase(paramValue[0])) {
 -                    responseType = paramValue[1];
 -                } else {
 -                    // according to the servlet spec, the parameter map should be in the form (name=String,
 -                    // value=String[]), so
 -                    // parameter values will be stored in an array
 -                    parameterMap.put(/* name */paramValue[0], /* value */new String[] { paramValue[1] });
 -                }
 +                parameterMap.put(param.getName(), new String[] { param.getValue() });
              }
 +
 +            // Check responseType, if not among valid types, fallback to JSON
 +            if (!(responseType.equals(BaseCmd.RESPONSE_TYPE_JSON) || responseType.equals(BaseCmd.RESPONSE_TYPE_XML)))
 +                responseType = BaseCmd.RESPONSE_TYPE_JSON;
 +
              try {
                  // always trust commands from API port, user context will always be UID_SYSTEM/ACCOUNT_ID_SYSTEM
                  UserContext.registerContext(_systemUser.getId(), _systemAccount, null, true);
@@@ -513,22 -587,19 +515,13 @@@
              return;
          }
          auditTrailSb.append(" " + HttpServletResponse.SC_OK + " ");
-         auditTrailSb.append(result);
-         /*
-          * if (command.equals("queryAsyncJobResult")){ //For this command we need to also log job status and job
-          * resultcode for
-          * (Pair<String,Object> pair : resultValues){ String key = pair.first(); if (key.equals("jobstatus")){
-          * auditTrailSb.append(" "); auditTrailSb.append(key); auditTrailSb.append("=");
-          * auditTrailSb.append(pair.second());
-          * }else if (key.equals("jobresultcode")){ auditTrailSb.append(" "); auditTrailSb.append(key);
-          * auditTrailSb.append("=");
-          * auditTrailSb.append(pair.second()); } } }else { for (Pair<String,Object> pair : resultValues){ if
-          * (pair.first().equals("jobid")){ // Its an async job so report the jobid auditTrailSb.append(" ");
-          * auditTrailSb.append(pair.first()); auditTrailSb.append("="); auditTrailSb.append(pair.second()); } } }
-          */
+         if (command.equals("createSSHKeyPair")){
+             auditTrailSb.append("This result was not logged because it contains sensitive data.");
+         } else {
+             auditTrailSb.append(StringUtils.cleanString(result));
+         }
      }
 -    
 -    private static boolean isCommandAvailable(String commandName) {
 -        boolean isCommandAvailable = false;
 -        isCommandAvailable = s_allCommands.contains(commandName);
 -        return isCommandAvailable;
 -    }
  
- 
      public boolean verifyRequest(Map<String, Object[]> requestParameters, Long userId) throws ServerApiException {
          try {
              String apiKey = null;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/api/commands/AddTrafficMonitorCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/api/doc/ApiXmlDocWriter.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/configuration/DefaultComponentLibrary.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/NetworkManagerImpl.java
index 347cb2f,3f8b085..493109a
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@@ -16,65 -16,24 +16,58 @@@
  // under the License.
  package com.cloud.network;
  
 +import java.net.URI;
 +import java.security.InvalidParameterException;
 +import java.sql.PreparedStatement;
 +import java.sql.ResultSet;
 +import java.sql.SQLException;
 +import java.util.ArrayList;
 +import java.util.Arrays;
 +import java.util.Comparator;
 +import java.util.Date;
 +import java.util.HashMap;
 +import java.util.HashSet;
 +import java.util.Iterator;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Random;
 +import java.util.Set;
 +import java.util.TreeSet;
 +import java.util.concurrent.Executors;
 +import java.util.concurrent.ScheduledExecutorService;
 +import java.util.concurrent.TimeUnit;
 +
 +import javax.ejb.Local;
 +import javax.naming.ConfigurationException;
 +
++import com.cloud.utils.db.*;
 +import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
 +import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
 +import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
 +import org.apache.log4j.Logger;
 +
  import com.cloud.acl.ControlledEntity.ACLType;
  import com.cloud.acl.SecurityChecker.AccessType;
  import com.cloud.agent.AgentManager;
  import com.cloud.agent.Listener;
- import com.cloud.agent.api.AgentControlAnswer;
- import com.cloud.agent.api.AgentControlCommand;
- import com.cloud.agent.api.Answer;
- import com.cloud.agent.api.CheckNetworkAnswer;
- import com.cloud.agent.api.CheckNetworkCommand;
- import com.cloud.agent.api.Command;
- import com.cloud.agent.api.StartupCommand;
- import com.cloud.agent.api.StartupRoutingCommand;
+ import com.cloud.agent.api.*;
  import com.cloud.agent.api.to.NicTO;
  import com.cloud.alert.AlertManager;
 -import com.cloud.api.commands.CreateNetworkCmd;
 -import com.cloud.api.commands.ListNetworksCmd;
 -import com.cloud.api.commands.ListTrafficTypeImplementorsCmd;
 -import com.cloud.api.commands.RestartNetworkCmd;
 +import com.cloud.api.ApiDBUtils;
 +
 +import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
  import com.cloud.configuration.Config;
  import com.cloud.configuration.ConfigurationManager;
  import com.cloud.configuration.Resource.ResourceType;
  import com.cloud.configuration.dao.ConfigurationDao;
- import com.cloud.dc.AccountVlanMapVO;
- import com.cloud.dc.DataCenter;
+ import com.cloud.dc.*;
  import com.cloud.dc.DataCenter.NetworkType;
 +import com.cloud.dc.DataCenterVO;
 +import com.cloud.dc.Pod;
 +import com.cloud.dc.PodVlanMapVO;
 +import com.cloud.dc.Vlan;
  import com.cloud.dc.Vlan.VlanType;
 +import com.cloud.dc.VlanVO;
  import com.cloud.dc.dao.AccountVlanMapDao;
  import com.cloud.dc.dao.DataCenterDao;
  import com.cloud.dc.dao.PodVlanMapDao;
@@@ -149,16 -74,8 +108,15 @@@ import com.cloud.network.lb.LoadBalanci
  import com.cloud.network.lb.LoadBalancingRule.LbDestination;
  import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
  import com.cloud.network.lb.LoadBalancingRulesManager;
- import com.cloud.network.rules.FirewallManager;
- import com.cloud.network.rules.FirewallRule;
+ import com.cloud.network.rules.*;
  import com.cloud.network.rules.FirewallRule.Purpose;
 +import com.cloud.network.rules.FirewallRuleVO;
 +import com.cloud.network.rules.PortForwardingRule;
 +import com.cloud.network.rules.PortForwardingRuleVO;
 +import com.cloud.network.rules.RulesManager;
 +import com.cloud.network.rules.StaticNat;
 +import com.cloud.network.rules.StaticNatRule;
 +import com.cloud.network.rules.StaticNatRuleImpl;
  import com.cloud.network.rules.dao.PortForwardingRulesDao;
  import com.cloud.network.vpc.NetworkACLManager;
  import com.cloud.network.vpc.PrivateIpVO;
@@@ -193,14 -104,9 +145,8 @@@ import com.cloud.utils.component.Adapte
  import com.cloud.utils.component.Inject;
  import com.cloud.utils.component.Manager;
  import com.cloud.utils.concurrency.NamedThreadFactory;
- import com.cloud.utils.db.DB;
- import com.cloud.utils.db.Filter;
- import com.cloud.utils.db.JoinBuilder;
 -import com.cloud.utils.db.*;
  import com.cloud.utils.db.JoinBuilder.JoinType;
- import com.cloud.utils.db.SearchBuilder;
- import com.cloud.utils.db.SearchCriteria;
  import com.cloud.utils.db.SearchCriteria.Op;
- import com.cloud.utils.db.Transaction;
  import com.cloud.utils.exception.CloudRuntimeException;
  import com.cloud.utils.net.Ip;
  import com.cloud.utils.net.NetUtils;
@@@ -1015,24 -924,56 +974,56 @@@ public class NetworkManagerImpl impleme
  
      @Override
      @ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "allocating Ip", create = true)
+     public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId)
+             throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
+ 
+         if (networkId != null) {
+             Network network = _networksDao.findById(networkId);
+             if (network == null) {
+                 throw new InvalidParameterValueException("Invalid network id is given");
+             }
+             if (network.getGuestType() == Network.GuestType.Shared) {
+                 DataCenter zone = _configMgr.getZone(zoneId);
+                 if (zone == null) {
+                     throw new InvalidParameterValueException("Invalid zone Id is given");
+                 }
+ 
+                 // if shared network in the advanced zone, then check the caller against the network for 'AccessType.UseNetwork'
+                 if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) && zone.getNetworkType() == NetworkType.Advanced) {
+                     Account caller = UserContext.current().getCaller();
+                     long callerUserId = UserContext.current().getCallerUserId();
+                     _accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network);
+                     if (s_logger.isDebugEnabled()) {
+                         s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId());
+                     }
+                     return allocateIp(ipOwner, false, caller, zone);
+                 } else {
+                     throw new InvalidParameterValueException("Associate IP address can only be called on the shared networks in the advanced zone" +
+                             " with Firewall/Source Nat/Static Nat/Port Forwarding/Load balancing services enabled");
+                 }
+             }
+         }
+ 
+         return allocateIP(ipOwner, false,  zoneId);
+     }
  
 -    public IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) 
 +    public IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId)
              throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
          Account caller = UserContext.current().getCaller();
          long callerUserId = UserContext.current().getCallerUserId();
          // check permissions
          _accountMgr.checkAccess(caller, null, false, ipOwner);
 -        
 +
          DataCenter zone = _configMgr.getZone(zoneId);
- 
-         return allocateIp(ipOwner, isSystem, caller, callerUserId, zone);
+         
+         return allocateIp(ipOwner, isSystem, caller, zone);
      }
  
      @DB
-     public IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerUserId, DataCenter zone)
+     public IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, DataCenter zone)
              throws ConcurrentOperationException, ResourceAllocationException,
              InsufficientAddressCapacityException {
 -        
 +
          VlanType vlanType = VlanType.VirtualNetwork;
          boolean assign = false;
  
@@@ -2026,9 -2001,10 +2051,10 @@@
                      // because the serializer would look up the NetworkVO class's table and retrieve the
                      // network id instead of the physical network id.
                      // So just throw this exception as is. We may need to TBD by changing the serializer.
 -                    throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + 
 +                    throw new CloudRuntimeException("Service provider " + element.getProvider().getName() +
                              " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
                  }
+ 
                  if (s_logger.isDebugEnabled()) {
                      s_logger.debug("Asking " + element.getName() + " to implemenet " + network);
                  }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/network/NetworkUsageManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/NetworkUsageManagerImpl.java
index 3207c6f,42c72ad..b30f185
--- a/server/src/com/cloud/network/NetworkUsageManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkUsageManagerImpl.java
@@@ -220,8 -229,10 +229,10 @@@ public class NetworkUsageManagerImpl im
          networkJoin.and("guestType", networkJoin.entity().getGuestType(), Op.EQ);
          AllocatedIpSearch.join("network", networkJoin, AllocatedIpSearch.entity().getSourceNetworkId(), networkJoin.entity().getId(), JoinBuilder.JoinType.INNER);
          AllocatedIpSearch.done();
 -        
 +
          _networkStatsInterval = NumbersUtil.parseInt(_configDao.getValue(Config.DirectNetworkStatsInterval.key()), 86400);
+         _TSinclZones = _configDao.getValue(Config.TrafficSentinelIncludeZones.key());
+         _TSexclZones = _configDao.getValue(Config.TrafficSentinelExcludeZones.key());
          _agentMgr.registerForHostEvents(new DirectNetworkStatsListener( _networkStatsInterval), true, false, false);
          _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
          return true;
@@@ -369,10 -380,10 +380,10 @@@
              }
  
              List<UserStatisticsVO> collectedStats = new ArrayList<UserStatisticsVO>();
 -            
 +
              //Get usage for Ips which were assigned for the entire duration
              if(fullDurationIpUsage.size() > 0){
-                 DirectNetworkUsageCommand cmd = new DirectNetworkUsageCommand(IpList, lastCollection, now);
+                 DirectNetworkUsageCommand cmd = new DirectNetworkUsageCommand(IpList, lastCollection, now, _TSinclZones, _TSexclZones);
                  DirectNetworkUsageAnswer answer = (DirectNetworkUsageAnswer) _agentMgr.easySend(host.getId(), cmd);
                  if (answer == null || !answer.getResult()) {
                      String details = (answer != null) ? answer.getDetails() : "details unavailable";

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/network/rules/RulesManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/offerings/NetworkOfferingVO.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/offerings/NetworkOfferingVO.java
index 6cb1d2a,2570b70..ca315f9
--- a/server/src/com/cloud/offerings/NetworkOfferingVO.java
+++ b/server/src/com/cloud/offerings/NetworkOfferingVO.java
@@@ -16,27 -16,19 +16,33 @@@
  // under the License.
  package com.cloud.offerings;
  
 -import com.cloud.api.Identity;
++import com.cloud.network.Networks;
++
 +import java.util.Date;
 +import java.util.UUID;
 +
 +import javax.persistence.Column;
 +import javax.persistence.Entity;
 +import javax.persistence.EnumType;
 +import javax.persistence.Enumerated;
 +import javax.persistence.GeneratedValue;
 +import javax.persistence.GenerationType;
 +import javax.persistence.Id;
 +import javax.persistence.Table;
 +
 +import org.apache.cloudstack.api.Identity;
  import com.cloud.network.Network;
  import com.cloud.network.Networks.TrafficType;
  import com.cloud.offering.NetworkOffering;
  import com.cloud.utils.db.GenericDao;
  
+ import javax.persistence.*;
+ import java.util.Date;
+ import java.util.UUID;
+ 
  @Entity
  @Table(name = "network_offerings")
 -public class NetworkOfferingVO implements NetworkOffering, Identity {
 +public class NetworkOfferingVO implements NetworkOffering {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/resource/ResourceManagerImpl.java
index cfdb8be,8d50886..db01c3d
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@@ -30,11 -30,11 +30,16 @@@ import java.util.Set
  import javax.ejb.Local;
  import javax.naming.ConfigurationException;
  
 +import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
 +import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
 +import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
 +import org.apache.cloudstack.api.command.admin.host.*;
 +import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
+ import com.cloud.api.commands.AddS3Cmd;
+ import com.cloud.api.commands.ListS3sCmd;
+ import com.cloud.storage.S3;
+ import com.cloud.storage.S3VO;
+ import com.cloud.storage.s3.S3Manager;
  import org.apache.log4j.Logger;
  
  import com.cloud.agent.AgentManager;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index 242125f,7ab464b..6a0f71d
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@@ -39,11 -39,14 +41,12 @@@ import com.cloud.agent.api.DownloadSnap
  import com.cloud.agent.api.ManageSnapshotAnswer;
  import com.cloud.agent.api.ManageSnapshotCommand;
  import com.cloud.agent.api.downloadSnapshotFromSwiftCommand;
+ import com.cloud.agent.api.to.S3TO;
  import com.cloud.agent.api.to.SwiftTO;
  import com.cloud.alert.AlertManager;
 -import com.cloud.api.commands.CreateSnapshotPolicyCmd;
 -import com.cloud.api.commands.DeleteSnapshotPoliciesCmd;
 +import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
  import com.cloud.api.commands.ListRecurringSnapshotScheduleCmd;
 -import com.cloud.api.commands.ListSnapshotPoliciesCmd;
 -import com.cloud.api.commands.ListSnapshotsCmd;
 +import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
  import com.cloud.configuration.Config;
  import com.cloud.configuration.Resource.ResourceType;
  import com.cloud.configuration.dao.ConfigurationDao;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/upgrade/dao/Upgrade40to41.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/upgrade/dao/Upgrade40to41.java
index 3ba0ed8,cfb783b..e23837d
--- a/server/src/com/cloud/upgrade/dao/Upgrade40to41.java
+++ b/server/src/com/cloud/upgrade/dao/Upgrade40to41.java
@@@ -17,12 -17,15 +17,18 @@@
  
  package com.cloud.upgrade.dao;
  
+ import com.cloud.utils.exception.CloudRuntimeException;
+ import com.cloud.utils.script.Script;
+ 
  import java.io.File;
  import java.sql.Connection;
+ import java.sql.PreparedStatement;
+ import java.sql.ResultSet;
+ import java.sql.SQLException;
  
 +import com.cloud.utils.exception.CloudRuntimeException;
 +import com.cloud.utils.script.Script;
 +
  /**
   * @author htrippaers
   *

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/vm/UserVmManagerImpl.java
index 6608987,9356048..12645fa
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@@ -16,46 -16,10 +16,34 @@@
  // under the License.
  package com.cloud.vm;
  
 +import java.util.ArrayList;
 +import java.util.Date;
 +import java.util.HashMap;
 +import java.util.HashSet;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Set;
 +import java.util.UUID;
 +import java.util.concurrent.Executors;
 +import java.util.concurrent.ScheduledExecutorService;
 +import java.util.concurrent.TimeUnit;
 +
 +import javax.ejb.Local;
 +import javax.naming.ConfigurationException;
 +
 +import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
 +import org.apache.cloudstack.api.command.user.vm.*;
 +import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
 +import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
 +import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
 +import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
 +import org.apache.commons.codec.binary.Base64;
 +import org.apache.log4j.Logger;
 +
  import com.cloud.acl.ControlledEntity.ACLType;
+ import com.cloud.acl.SecurityChecker.AccessType;
  import com.cloud.agent.AgentManager;
- import com.cloud.agent.api.Answer;
- import com.cloud.agent.api.AttachIsoCommand;
- import com.cloud.agent.api.AttachVolumeAnswer;
- import com.cloud.agent.api.AttachVolumeCommand;
- import com.cloud.agent.api.ComputeChecksumCommand;
- import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
- import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
- import com.cloud.agent.api.GetVmStatsAnswer;
- import com.cloud.agent.api.GetVmStatsCommand;
- import com.cloud.agent.api.SnapshotCommand;
- import com.cloud.agent.api.StartAnswer;
- import com.cloud.agent.api.StopAnswer;
- import com.cloud.agent.api.UpgradeSnapshotCommand;
- import com.cloud.agent.api.VmStatsEntry;
+ import com.cloud.agent.api.*;
  import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
  import com.cloud.agent.api.to.NicTO;
  import com.cloud.agent.api.to.VirtualMachineTO;
@@@ -157,39 -91,18 +126,16 @@@ import com.cloud.projects.ProjectManage
  import com.cloud.resource.ResourceManager;
  import com.cloud.resource.ResourceState;
  import com.cloud.server.Criteria;
 -import com.cloud.server.ResourceTag.TaggedResourceType;
  import com.cloud.service.ServiceOfferingVO;
  import com.cloud.service.dao.ServiceOfferingDao;
- import com.cloud.storage.DiskOfferingVO;
- import com.cloud.storage.GuestOSVO;
- import com.cloud.storage.Snapshot;
- import com.cloud.storage.SnapshotVO;
- import com.cloud.storage.Storage;
+ import com.cloud.storage.*;
  import com.cloud.storage.Storage.ImageFormat;
  import com.cloud.storage.Storage.StoragePoolType;
  import com.cloud.storage.Storage.TemplateType;
- import com.cloud.storage.StorageManager;
- import com.cloud.storage.StoragePool;
- import com.cloud.storage.StoragePoolStatus;
- import com.cloud.storage.StoragePoolVO;
- import com.cloud.storage.VMTemplateHostVO;
  import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
- import com.cloud.storage.VMTemplateVO;
- import com.cloud.storage.VMTemplateZoneVO;
- import com.cloud.storage.Volume;
  import com.cloud.storage.Volume.Type;
- import com.cloud.storage.VolumeHostVO;
- import com.cloud.storage.VolumeVO;
- import com.cloud.storage.dao.DiskOfferingDao;
- import com.cloud.storage.dao.GuestOSDao;
- import com.cloud.storage.dao.SnapshotDao;
- import com.cloud.storage.dao.StoragePoolDao;
- import com.cloud.storage.dao.VMTemplateDao;
- import com.cloud.storage.dao.VMTemplateDetailsDao;
- import com.cloud.storage.dao.VMTemplateHostDao;
- import com.cloud.storage.dao.VMTemplateZoneDao;
- import com.cloud.storage.dao.VolumeDao;
- import com.cloud.storage.dao.VolumeHostDao;
+ import com.cloud.storage.dao.*;
  import com.cloud.storage.snapshot.SnapshotManager;
 -import com.cloud.tags.ResourceTagVO;
  import com.cloud.tags.dao.ResourceTagDao;
  import com.cloud.template.VirtualMachineTemplate;
  import com.cloud.template.VirtualMachineTemplate.BootloaderType;
@@@ -2191,12 -2091,13 +2132,13 @@@ public class UserVmManagerImpl implemen
                          throw new InvalidParameterValueException("Can't create a vm with multiple networks one of" +
                          		" which is Security Group enabled");
                      }
 -                    
 +
                      isSecurityGroupEnabledNetworkUsed = true;
-                 }
+                 }            
  
-                 if (network.getTrafficType() != TrafficType.Guest || network.getGuestType() != Network.GuestType.Shared || (network.getGuestType() == Network.GuestType.Shared && !isSecurityGroupEnabled)) {
-                     throw new InvalidParameterValueException("Can specify only Direct Guest Account specific networks when deploy vm in Security Group enabled zone");
+                 if (!(network.getTrafficType() == TrafficType.Guest && network.getGuestType() == Network.GuestType.Shared)) {
+                     throw new InvalidParameterValueException("Can specify only Shared Guest networks when" +
+                     		" deploy vm in Advance Security Group enabled zone");
                  }
  
                  // Perform account permission check
@@@ -2284,10 -2179,10 +2220,10 @@@
                  } else if (virtualNetworks.size() > 1) {
                      throw new InvalidParameterValueException("More than 1 default Isolated networks are found for account " + owner + "; please specify networkIds");
                  } else {
-                     defaultNetwork = virtualNetworks.get(0);
+                     defaultNetwork = _networkDao.findById(virtualNetworks.get(0).getId());
                  }
              } else {
 -                throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled); 
 +                throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled);
              }
  
              networkList.add(defaultNetwork);
@@@ -3640,10 -3609,9 +3575,9 @@@
                              if (physicalNetwork == null) {
                                  throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId   + " and tag: " +requiredOfferings.get(0).getTags());
                              }
- 
 -                            s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" + 
 +                            s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" +
                          requiredOfferings.get(0).getId() + " as a part of deployVM process");
 -                            Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), 
 +                            Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
                                      newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null,
                                      null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null);
                              defaultNetwork = _networkDao.findById(newNetwork.getId());
@@@ -3651,10 -3619,10 +3585,10 @@@
                              throw new InvalidParameterValueException("More than 1 default Isolated networks are found " +
                                      "for account " + newAccount + "; please specify networkIds");
                          } else {
-                             defaultNetwork = virtualNetworks.get(0);
+                             defaultNetwork = _networkDao.findById(virtualNetworks.get(0).getId());
                          }
                      } else {
 -                        throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled); 
 +                        throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled);
                      }
  
                      applicableNetworks.add(defaultNetwork);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/test/com/cloud/network/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --cc server/test/com/cloud/network/MockNetworkManagerImpl.java
index bcc9ba2,76b911a..071069c
--- a/server/test/com/cloud/network/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java
@@@ -16,19 -16,11 +16,11 @@@
  // under the License.
  package com.cloud.network;
  
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- import java.util.Set;
- 
- import javax.ejb.Local;
- import javax.naming.ConfigurationException;
- 
  import com.cloud.acl.ControlledEntity.ACLType;
 -import com.cloud.api.commands.CreateNetworkCmd;
 -import com.cloud.api.commands.ListNetworksCmd;
 -import com.cloud.api.commands.ListTrafficTypeImplementorsCmd;
 -import com.cloud.api.commands.RestartNetworkCmd;
 +import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
 +import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
 +import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
 +import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
  import com.cloud.dc.DataCenter;
  import com.cloud.dc.Vlan;
  import com.cloud.dc.Vlan.VlanType;
@@@ -939,7 -927,7 +927,6 @@@ public class MockNetworkManagerImpl imp
      }
  
      /* (non-Javadoc)
--<<<<<<< HEAD
       * @see com.cloud.network.NetworkManager#getDefaultPublicTrafficLabel(long, com.cloud.hypervisor.Hypervisor.HypervisorType)
       */
      @Override
@@@ -950,9 -938,9 +937,6 @@@
  
      /* (non-Javadoc)
       * @see com.cloud.network.NetworkManager#assignSourceNatIpAddressToGuestNetwork(com.cloud.user.Account, com.cloud.network.Network)
--=======
--     * @see com.cloud.network.NetworkManager#getNicProfile(com.cloud.vm.VirtualMachine, long)
-->>>>>>> ddb9e49... VPC: unittest preparation
       */
      @Override
      public PublicIp assignSourceNatIpAddressToGuestNetwork(Account owner, Network guestNetwork) throws InsufficientAddressCapacityException, ConcurrentOperationException {
@@@ -1007,7 -995,7 +991,6 @@@
      }
  
      /* (non-Javadoc)
--<<<<<<< HEAD
       * @see com.cloud.network.NetworkManager#getSite2SiteVpnElements()
       */
      @Override
@@@ -1018,9 -1006,9 +1001,6 @@@
  
      /* (non-Javadoc)
       * @see com.cloud.network.NetworkManager#isPrivateGateway(com.cloud.vm.Nic)
--=======
--     * @see com.cloud.network.NetworkService#canUseForDeploy(com.cloud.network.Network)
-->>>>>>> ddb9e49... VPC: unittest preparation
       */
      @Override
      public boolean isPrivateGateway(Nic guestNic) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/setup/db/create-schema.sql
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/setup/db/db/schema-40to410.sql
----------------------------------------------------------------------
diff --cc setup/db/db/schema-40to410.sql
index 487f1c1,73289bc..6c58bd9
--- a/setup/db/db/schema-40to410.sql
+++ b/setup/db/db/schema-40to410.sql
@@@ -60,581 -60,3 +60,580 @@@ ALTER TABLE `cloud`.`network_offerings
  
  INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network','DEFAULT','NetworkManager','network.dhcp.nondefaultnetwork.setgateway.guestos','Windows','The guest OS\'s name start with this fields would result in DHCP server response gateway information even when the network it\'s on is not default network. Names are separated by comma.');
  
 +ALTER TABLE upload ADD uuid VARCHAR(40);
 +ALTER TABLE async_job modify job_cmd VARCHAR(255);
 +
 +-- populate uuid column with db id if uuid is null
 +UPDATE `cloud`.`account` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`alert` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`async_job` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`cluster` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`data_center` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`disk_offering` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`domain` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`event` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`external_firewall_devices` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`external_load_balancer_devices` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`external_nicira_nvp_devices` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`firewall_rules` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`guest_os` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`guest_os_category` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`host` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`host_pod_ref` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`hypervisor_capabilities` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`instance_group` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`load_balancer_stickiness_policies` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`network_external_firewall_device_map` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`network_external_lb_device_map` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`network_offerings` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`networks` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`nics` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`physical_network` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`physical_network_service_providers` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`physical_network_traffic_types` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`port_profile` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`project_invitations` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`projects` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`resource_tags` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`s2s_customer_gateway` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`s2s_vpn_connection` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`s2s_vpn_gateway` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`security_group` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`security_group_rule` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`snapshot_schedule` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`snapshots` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`static_routes` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`storage_pool` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`swift` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`upload` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`user` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`user_ip_address` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`user_vm_temp` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`virtual_router_providers` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`virtual_supervisor_module` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`vlan` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`vm_instance` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`vm_template` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`vpc` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`vpc_gateways` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`vpc_offerings` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`vpn_users` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`volumes` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`autoscale_vmgroups` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`autoscale_vmprofiles` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`autoscale_policies` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`counter` set uuid=id WHERE uuid is NULL;
 +UPDATE `cloud`.`conditions` set uuid=id WHERE uuid is NULL;
 +
 +
 +--- DB views for list api ---
 +DROP VIEW IF EXISTS `cloud`.`user_vm_view`;
 +CREATE VIEW `cloud`.`user_vm_view` AS
 +select
 +vm_instance.id id,
 +vm_instance.name name,
 +user_vm.display_name display_name,
 +user_vm.user_data user_data,
 +account.id account_id,
 +account.uuid account_uuid,
 +account.account_name account_name,
 +account.type account_type,
 +domain.id domain_id,
 +domain.uuid domain_uuid,
 +domain.name domain_name,
 +domain.path domain_path,
 +projects.id project_id,
 +projects.uuid project_uuid,
 +projects.name project_name,
 +instance_group.id instance_group_id,
 +instance_group.uuid instance_group_uuid,
 +instance_group.name instance_group_name,
 +vm_instance.uuid uuid,
 +vm_instance.last_host_id last_host_id,
 +vm_instance.vm_type type,
 +vm_instance.vnc_password vnc_password,
 +vm_instance.limit_cpu_use limit_cpu_use,
 +vm_instance.created created,
 +vm_instance.state state,
 +vm_instance.removed removed,
 +vm_instance.ha_enabled ha_enabled,
 +vm_instance.hypervisor_type hypervisor_type,
 +vm_instance.instance_name instance_name,
 +vm_instance.guest_os_id guest_os_id,
 +guest_os.uuid guest_os_uuid,
 +vm_instance.pod_id pod_id,
 +host_pod_ref.uuid pod_uuid,
 +vm_instance.private_ip_address private_ip_address,
 +vm_instance.private_mac_address private_mac_address,
 +vm_instance.vm_type vm_type,
 +data_center.id data_center_id,
 +data_center.uuid data_center_uuid,
 +data_center.name data_center_name,
 +data_center.is_security_group_enabled security_group_enabled,
 +host.id host_id,
 +host.uuid host_uuid,
 +host.name host_name,
 +vm_template.id template_id,
 +vm_template.uuid template_uuid,
 +vm_template.name template_name,
 +vm_template.display_text template_display_text,
 +vm_template.enable_password password_enabled,
 +iso.id iso_id,
 +iso.uuid iso_uuid,
 +iso.name iso_name,
 +iso.display_text iso_display_text,
 +service_offering.id service_offering_id,
 +disk_offering.uuid service_offering_uuid,
 +service_offering.cpu cpu,
 +service_offering.speed speed,
 +service_offering.ram_size ram_size,
 +disk_offering.name service_offering_name,
 +storage_pool.id pool_id,
 +storage_pool.uuid pool_uuid,
 +storage_pool.pool_type pool_type,
 +volumes.id volume_id,
 +volumes.uuid volume_uuid,
 +volumes.device_id volume_device_id,
 +volumes.volume_type volume_type,
 +security_group.id security_group_id,
 +security_group.uuid security_group_uuid,
 +security_group.name security_group_name,
 +security_group.description security_group_description,
 +nics.id nic_id,
 +nics.uuid nic_uuid,
 +nics.network_id network_id,
 +nics.ip4_address ip_address,
 +nics.default_nic is_default_nic,
 +nics.gateway gateway,
 +nics.netmask netmask,
 +nics.mac_address mac_address,
 +nics.broadcast_uri broadcast_uri,
 +nics.isolation_uri isolation_uri,
 +vpc.id vpc_id,
 +vpc.uuid vpc_uuid,
 +networks.uuid network_uuid,
 +networks.traffic_type traffic_type,
 +networks.guest_type guest_type,
 +user_ip_address.id public_ip_id,
 +user_ip_address.uuid public_ip_uuid,
 +user_ip_address.public_ip_address public_ip_address,
 +ssh_keypairs.keypair_name keypair_name,
 +resource_tags.id tag_id,
 +resource_tags.uuid tag_uuid,
 +resource_tags.key tag_key,
 +resource_tags.value tag_value,
 +resource_tags.domain_id tag_domain_id,
 +resource_tags.account_id tag_account_id,
 +resource_tags.resource_id tag_resource_id,
 +resource_tags.resource_uuid tag_resource_uuid,
 +resource_tags.resource_type tag_resource_type,
 +resource_tags.customer tag_customer,
 +async_job.id job_id,
 +async_job.uuid job_uuid,
 +async_job.job_status job_status,
 +async_job.account_id job_account_id
 +from user_vm
 +inner join vm_instance on vm_instance.id = user_vm.id and vm_instance.removed is NULL
 +inner join account on vm_instance.account_id=account.id
 +inner join domain on vm_instance.domain_id=domain.id
 +left join guest_os on vm_instance.guest_os_id = guest_os.id
 +left join host_pod_ref on vm_instance.pod_id = host_pod_ref.id
 +left join projects on projects.project_account_id = account.id
 +left join instance_group_vm_map on vm_instance.id=instance_group_vm_map.instance_id
 +left join instance_group on instance_group_vm_map.group_id=instance_group.id
 +left join data_center on vm_instance.data_center_id=data_center.id
 +left join host on vm_instance.host_id=host.id
 +left join vm_template on vm_instance.vm_template_id=vm_template.id
 +left join vm_template iso on iso.id=user_vm.iso_id
 +left join service_offering on vm_instance.service_offering_id=service_offering.id
 +left join disk_offering  on vm_instance.service_offering_id=disk_offering.id
 +left join volumes on vm_instance.id=volumes.instance_id
 +left join storage_pool on volumes.pool_id=storage_pool.id
 +left join security_group_vm_map on vm_instance.id=security_group_vm_map.instance_id
 +left join security_group on security_group_vm_map.security_group_id=security_group.id
 +left join nics on vm_instance.id=nics.instance_id
 +left join networks on nics.network_id=networks.id
 +left join vpc on networks.vpc_id = vpc.id
 +left join user_ip_address on user_ip_address.vm_id=vm_instance.id
 +left join user_vm_details on user_vm_details.vm_id=vm_instance.id and user_vm_details.name = "SSH.PublicKey"
 +left join ssh_keypairs on ssh_keypairs.public_key = user_vm_details.value
 +left join resource_tags on resource_tags.resource_id = vm_instance.id and resource_tags.resource_type = "UserVm"
 +left join async_job on async_job.instance_id = vm_instance.id and async_job.instance_type = "VirtualMachine" and async_job.job_status = 0;
 +
 +DROP VIEW IF EXISTS `cloud`.`domain_router_view`;
 +CREATE VIEW domain_router_view AS
 +select
 +vm_instance.id id,
 +vm_instance.name name,
 +account.id account_id,
 +account.uuid account_uuid,
 +account.account_name account_name,
 +account.type account_type,
 +domain.id domain_id,
 +domain.uuid domain_uuid,
 +domain.name domain_name,
 +domain.path domain_path,
 +projects.id project_id,
 +projects.uuid project_uuid,
 +projects.name project_name,
 +vm_instance.uuid uuid,
 +vm_instance.created created,
 +vm_instance.state state,
 +vm_instance.removed removed,
 +vm_instance.pod_id pod_id,
 +vm_instance.instance_name instance_name,
 +host_pod_ref.uuid pod_uuid,
 +data_center.id data_center_id,
 +data_center.uuid data_center_uuid,
 +data_center.name data_center_name,
 +data_center.dns1 dns1,
 +data_center.dns2 dns2,
 +host.id host_id,
 +host.uuid host_uuid,
 +host.name host_name,
 +vm_template.id template_id,
 +vm_template.uuid template_uuid,
 +service_offering.id service_offering_id,
 +disk_offering.uuid service_offering_uuid,
 +disk_offering.name service_offering_name,
 +nics.id nic_id,
 +nics.uuid nic_uuid,
 +nics.network_id network_id,
 +nics.ip4_address ip_address,
 +nics.default_nic is_default_nic,
 +nics.gateway gateway,
 +nics.netmask netmask,
 +nics.mac_address mac_address,
 +nics.broadcast_uri broadcast_uri,
 +nics.isolation_uri isolation_uri,
 +vpc.id vpc_id,
 +vpc.uuid vpc_uuid,
 +networks.uuid network_uuid,
 +networks.name network_name,
 +networks.network_domain network_domain,
 +networks.traffic_type traffic_type,
 +networks.guest_type guest_type,
 +async_job.id job_id,
 +async_job.uuid job_uuid,
 +async_job.job_status job_status,
 +async_job.account_id job_account_id,
 +domain_router.template_version template_version,
 +domain_router.scripts_version scripts_version,
 +domain_router.is_redundant_router is_redundant_router,
 +domain_router.redundant_state redundant_state,
 +domain_router.stop_pending stop_pending
 +from domain_router
 +inner join vm_instance on vm_instance.id = domain_router.id
 +inner join account on vm_instance.account_id=account.id
 +inner join domain on vm_instance.domain_id=domain.id
 +left join host_pod_ref on vm_instance.pod_id = host_pod_ref.id
 +left join projects on projects.project_account_id = account.id
 +left join data_center on vm_instance.data_center_id=data_center.id
 +left join host on vm_instance.host_id=host.id
 +left join vm_template on vm_instance.vm_template_id=vm_template.id
 +left join service_offering on vm_instance.service_offering_id=service_offering.id
 +left join disk_offering  on vm_instance.service_offering_id=disk_offering.id
 +left join volumes on vm_instance.id=volumes.instance_id
 +left join storage_pool on volumes.pool_id=storage_pool.id
 +left join nics on vm_instance.id=nics.instance_id
 +left join networks on nics.network_id=networks.id
 +left join vpc on networks.vpc_id = vpc.id
 +left join async_job on async_job.instance_id = vm_instance.id and async_job.instance_type = "DomainRouter" and async_job.job_status = 0;
 +
 +DROP VIEW IF EXISTS `cloud`.`security_group_view`;
 +CREATE VIEW security_group_view AS
 +select
 +security_group.id id,
 +security_group.name name,
 +security_group.description description,
 +security_group.uuid uuid,
 +account.id account_id,
 +account.uuid account_uuid,
 +account.account_name account_name,
 +account.type account_type,
 +domain.id domain_id,
 +domain.uuid domain_uuid,
 +domain.name domain_name,
 +domain.path domain_path,
 +projects.id project_id,
 +projects.uuid project_uuid,
 +projects.name project_name,
 +security_group_rule.id rule_id,
 +security_group_rule.uuid rule_uuid,
 +security_group_rule.type rule_type,
 +security_group_rule.start_port rule_start_port,
 +security_group_rule.end_port rule_end_port,
 +security_group_rule.protocol rule_protocol,
 +security_group_rule.allowed_network_id rule_allowed_network_id,
 +security_group_rule.allowed_ip_cidr rule_allowed_ip_cidr,
 +security_group_rule.create_status rule_create_status,
 +resource_tags.id tag_id,
 +resource_tags.uuid tag_uuid,
 +resource_tags.key tag_key,
 +resource_tags.value tag_value,
 +resource_tags.domain_id tag_domain_id,
 +resource_tags.account_id tag_account_id,
 +resource_tags.resource_id tag_resource_id,
 +resource_tags.resource_uuid tag_resource_uuid,
 +resource_tags.resource_type tag_resource_type,
 +resource_tags.customer tag_customer,
 +async_job.id job_id,
 +async_job.uuid job_uuid,
 +async_job.job_status job_status,
 +async_job.account_id job_account_id
 +from security_group
 +left join security_group_rule on security_group.id = security_group_rule.security_group_id
 +inner join account on security_group.account_id=account.id
 +inner join domain on security_group.domain_id=domain.id
 +left join projects on projects.project_account_id = security_group.account_id
 +left join resource_tags on resource_tags.resource_id = security_group.id and resource_tags.resource_type = "SecurityGroup"
 +left join async_job on async_job.instance_id = security_group.id and async_job.instance_type = "SecurityGroup" and async_job.job_status = 0;
 +
 +DROP VIEW IF EXISTS `cloud`.`resource_tag_view`;
 +CREATE VIEW resource_tag_view AS
 +select
 +resource_tags.id,
 +resource_tags.uuid,
 +resource_tags.key,
 +resource_tags.value,
 +resource_tags.resource_id,
 +resource_tags.resource_uuid,
 +resource_tags.resource_type,
 +resource_tags.customer,
 +account.id account_id,
 +account.uuid account_uuid,
 +account.account_name account_name,
 +account.type account_type,
 +domain.id domain_id,
 +domain.uuid domain_uuid,
 +domain.name domain_name,
 +domain.path domain_path,
 +projects.id project_id,
 +projects.uuid project_uuid,
 +projects.name project_name
 +from resource_tags
 +inner join account on resource_tags.account_id=account.id
 +inner join domain on resource_tags.domain_id=domain.id
 +left join projects on projects.project_account_id = resource_tags.account_id;
 +
 +
 +DROP VIEW IF EXISTS `cloud`.`event_view`;
 +CREATE VIEW event_view AS
 +select
 +event.id,
 +event.uuid,
 +event.type,
 +event.state,
 +event.description,
 +event.created,
 +event.level,
 +event.parameters,
 +event.start_id,
 +eve.uuid start_uuid,
 +event.user_id,
 +user.username user_name,
 +account.id account_id,
 +account.uuid account_uuid,
 +account.account_name account_name,
 +account.type account_type,
 +domain.id domain_id,
 +domain.uuid domain_uuid,
 +domain.name domain_name,
 +domain.path domain_path,
 +projects.id project_id,
 +projects.uuid project_uuid,
 +projects.name project_name
 +from event
 +inner join account on event.account_id=account.id
 +inner join domain on event.domain_id=domain.id
 +inner join user on event.user_id = user.id
 +left join projects on projects.project_account_id = event.account_id
 +left join event eve on event.start_id = eve.id;
 +
 +DROP VIEW IF EXISTS `cloud`.`instance_group_view`;
 +CREATE VIEW instance_group_view AS
 +select
 +instance_group.id,
 +instance_group.uuid,
 +instance_group.name,
 +instance_group.removed,
 +instance_group.created,
 +account.id account_id,
 +account.uuid account_uuid,
 +account.account_name account_name,
 +account.type account_type,
 +domain.id domain_id,
 +domain.uuid domain_uuid,
 +domain.name domain_name,
 +domain.path domain_path,
 +projects.id project_id,
 +projects.uuid project_uuid,
 +projects.name project_name
 +from instance_group
 +inner join account on instance_group.account_id=account.id
 +inner join domain on account.domain_id=domain.id
 +left join projects on projects.project_account_id = instance_group.account_id;
 +
 +DROP VIEW IF EXISTS `cloud`.`user_view`;
 +CREATE VIEW user_view AS
 +select
 +user.id,
 +user.uuid,
 +user.username,
 +user.password,
 +user.firstname,
 +user.lastname,
 +user.email,
 +user.state,
 +user.api_key,
 +user.secret_key,
 +user.created,
 +user.removed,
 +user.timezone,
 +user.registration_token,
 +user.is_registered,
 +user.incorrect_login_attempts,
 +account.id account_id,
 +account.uuid account_uuid,
 +account.account_name account_name,
 +account.type account_type,
 +domain.id domain_id,
 +domain.uuid domain_uuid,
 +domain.name domain_name,
 +domain.path domain_path
 +from user
 +inner join account on user.account_id = account.id
 +inner join domain on account.domain_id=domain.id;
 +
 +DROP VIEW IF EXISTS `cloud`.`project_view`;
 +CREATE VIEW project_view AS
 +select
 +projects.id,
 +projects.uuid,
 +projects.name,
 +projects.display_text,
 +projects.state,
 +projects.removed,
 +projects.created,
 +account.account_name owner,
 +pacct.account_id,
 +domain.id domain_id,
 +domain.uuid domain_uuid,
 +domain.name domain_name,
 +domain.path domain_path,
 +resource_tags.id tag_id,
 +resource_tags.uuid tag_uuid,
 +resource_tags.key tag_key,
 +resource_tags.value tag_value,
 +resource_tags.domain_id tag_domain_id,
 +resource_tags.account_id tag_account_id,
 +resource_tags.resource_id tag_resource_id,
 +resource_tags.resource_uuid tag_resource_uuid,
 +resource_tags.resource_type tag_resource_type,
 +resource_tags.customer tag_customer
 +from projects
 +inner join domain on projects.domain_id=domain.id
 +inner join project_account on projects.id = project_account.project_id and project_account.account_role = "Admin"
 +inner join account on account.id = project_account.account_id
 +left join resource_tags on resource_tags.resource_id = projects.id and resource_tags.resource_type = "Project"
 +left join project_account pacct on projects.id = pacct.project_id;
 +
 +DROP VIEW IF EXISTS `cloud`.`project_account_view`;
 +CREATE VIEW project_account_view AS
 +select
 +project_account.id,
 +account.id account_id,
 +account.uuid account_uuid,
 +account.account_name,
 +account.type account_type,
 +project_account.account_role,
 +projects.id project_id,
 +projects.uuid project_uuid,
 +projects.name project_name,
 +domain.id domain_id,
 +domain.uuid domain_uuid,
 +domain.name domain_name,
 +domain.path domain_path
 +from project_account
 +inner join account on project_account.account_id = account.id
 +inner join domain on account.domain_id=domain.id
 +inner join projects on projects.id = project_account.project_id;
 +
 +DROP VIEW IF EXISTS `cloud`.`project_invitation_view`;
 +CREATE VIEW project_invitation_view AS
 +select
 +project_invitations.id,
 +project_invitations.uuid,
 +project_invitations.email,
 +project_invitations.created,
 +project_invitations.state,
 +projects.id project_id,
 +projects.uuid project_uuid,
 +projects.name project_name,
 +account.id account_id,
 +account.uuid account_uuid,
 +account.account_name,
 +account.type account_type,
 +domain.id domain_id,
 +domain.uuid domain_uuid,
 +domain.name domain_name,
 +domain.path domain_path
 +from project_invitations
 +left join account on project_invitations.account_id = account.id
 +left join domain on project_invitations.domain_id=domain.id
 +left join projects on projects.id = project_invitations.project_id;
 +
 +DROP VIEW IF EXISTS `cloud`.`host_view`;
 +CREATE VIEW host_view AS
 +select 
 +host.id,
 +host.uuid,
 +host.name,
 +host.status,
 +host.disconnected,
 +host.type,
 +host.private_ip_address,
 +host.version,
 +host.hypervisor_type,
 +host.hypervisor_version,
 +host.capabilities,
 +host.last_ping,
 +host.created,
 +host.removed,
 +host.resource_state,
 +host.mgmt_server_id,
 +host.cpus,
 +host.speed,
 +host.ram,
 +cluster.id cluster_id,
 +cluster.uuid cluster_uuid,
 +cluster.name cluster_name,
 +cluster.cluster_type,
 +data_center.id data_center_id, 
 +data_center.uuid data_center_uuid,
 +data_center.name data_center_name, 
 +host_pod_ref.id pod_id, 
 +host_pod_ref.uuid pod_uuid,
 +host_pod_ref.name pod_name,
 +host_tags.tag,
 +guest_os_category.id guest_os_category_id,
 +guest_os_category.uuid guest_os_category_uuid,
 +guest_os_category.name guest_os_category_name,
 +mem_caps.used_capacity memory_used_capacity,
 +mem_caps.reserved_capacity memory_reserved_capacity,
 +cpu_caps.used_capacity cpu_used_capacity,
 +cpu_caps.reserved_capacity cpu_reserved_capacity,
 +async_job.id job_id,
 +async_job.uuid job_uuid,
 +async_job.job_status job_status,
 +async_job.account_id job_account_id
 +from host 
 +left join cluster on host.cluster_id = cluster.id
 +left join data_center on host.data_center_id = data_center.id
 +left join host_pod_ref on host.pod_id = host_pod_ref.id
 +left join host_details on host.id = host_details.id and host_details.name = "guest.os.category.id"
 +left join guest_os_category on guest_os_category.id = CONVERT( host_details.value, UNSIGNED )
 +left join host_tags on host_tags.host_id = host.id
 +left join op_host_capacity mem_caps on host.id = mem_caps.host_id and mem_caps.capacity_type = 0
 +left join op_host_capacity cpu_caps on host.id = cpu_caps.host_id and cpu_caps.capacity_type = 1
 +left join async_job on async_job.instance_id = host.id and async_job.instance_type = "Host" and async_job.job_status = 0;
- 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296b49c2/utils/pom.xml
----------------------------------------------------------------------