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 2013/01/25 04:31:42 UTC
[48/50] [abbrv] Merge branch 'master' into javelin
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiDBUtils.java
index cb6dc6f,0b08b26..a464b93
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@@ -42,10 -41,12 +44,14 @@@ import org.apache.cloudstack.api.respon
import org.apache.cloudstack.api.response.UserResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.VolumeResponse;
+ import org.apache.cloudstack.api.response.ZoneResponse;
+
+import org.springframework.stereotype.Component;
+
import com.cloud.api.query.dao.AccountJoinDao;
import com.cloud.api.query.dao.AsyncJobJoinDao;
+ import com.cloud.api.query.dao.DataCenterJoinDao;
+ import com.cloud.api.query.dao.DiskOfferingJoinDao;
import com.cloud.api.query.dao.DomainRouterJoinDao;
import com.cloud.api.query.dao.HostJoinDao;
import com.cloud.api.query.dao.InstanceGroupJoinDao;
@@@ -165,9 -171,9 +176,10 @@@ import com.cloud.network.vpc.VpcManager
import com.cloud.network.vpc.VpcOffering;
import com.cloud.network.vpc.VpcVO;
import com.cloud.network.vpc.dao.StaticRouteDao;
+import com.cloud.network.vpc.dao.VpcDao;
import com.cloud.network.vpc.dao.VpcGatewayDao;
import com.cloud.network.vpc.dao.VpcOfferingDao;
+ import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
import com.cloud.offerings.NetworkOfferingVO;
@@@ -251,290 -258,202 +263,299 @@@ import com.cloud.vm.dao.DomainRouterDao
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.UserVmDetailsDao;
import com.cloud.vm.dao.VMInstanceDao;
-import com.cloud.network.vpc.dao.VpcDao;
+@Component
public class ApiDBUtils {
private static ManagementServer _ms;
- public static AsyncJobManager _asyncMgr;
- private static SecurityGroupManager _securityGroupMgr;
- private static StorageManager _storageMgr;
- private static UserVmManager _userVmMgr;
- private static NetworkManager _networkMgr;
- private static NetworkModel _networkModel;
- private static StatsCollector _statsCollector;
-
- private static AccountDao _accountDao;
- private static AccountVlanMapDao _accountVlanMapDao;
- private static ClusterDao _clusterDao;
- private static CapacityDao _capacityDao;
- private static DiskOfferingDao _diskOfferingDao;
- private static DomainDao _domainDao;
- private static DomainRouterDao _domainRouterDao;
- private static DomainRouterJoinDao _domainRouterJoinDao;
- private static GuestOSDao _guestOSDao;
- private static GuestOSCategoryDao _guestOSCategoryDao;
- private static HostDao _hostDao;
- private static IPAddressDao _ipAddressDao;
- private static LoadBalancerDao _loadBalancerDao;
- private static SecurityGroupDao _securityGroupDao;
- private static SecurityGroupJoinDao _securityGroupJoinDao;
- private static NetworkRuleConfigDao _networkRuleConfigDao;
- private static HostPodDao _podDao;
- private static ServiceOfferingDao _serviceOfferingDao;
- private static SnapshotDao _snapshotDao;
- private static StoragePoolDao _storagePoolDao;
- private static VMTemplateDao _templateDao;
- private static VMTemplateDetailsDao _templateDetailsDao;
- private static VMTemplateHostDao _templateHostDao;
- private static VMTemplateSwiftDao _templateSwiftDao;
- private static VMTemplateS3Dao _templateS3Dao;
- private static UploadDao _uploadDao;
- private static UserDao _userDao;
- private static UserStatisticsDao _userStatsDao;
- private static UserVmDao _userVmDao;
- private static UserVmJoinDao _userVmJoinDao;
- private static VlanDao _vlanDao;
- private static VolumeDao _volumeDao;
- private static Site2SiteVpnGatewayDao _site2SiteVpnGatewayDao;
- private static Site2SiteCustomerGatewayDao _site2SiteCustomerGatewayDao;
- private static VolumeHostDao _volumeHostDao;
- private static DataCenterDao _zoneDao;
- private static NetworkOfferingDao _networkOfferingDao;
- private static NetworkDao _networkDao;
- private static PhysicalNetworkDao _physicalNetworkDao;
- private static ConfigurationService _configMgr;
- private static ConfigurationDao _configDao;
- private static ConsoleProxyDao _consoleProxyDao;
- private static FirewallRulesCidrsDao _firewallCidrsDao;
- private static VMInstanceDao _vmDao;
- private static ResourceLimitService _resourceLimitMgr;
- private static ProjectService _projectMgr;
- private static ResourceManager _resourceMgr;
- private static AccountDetailsDao _accountDetailsDao;
- private static NetworkDomainDao _networkDomainDao;
- private static HighAvailabilityManager _haMgr;
- private static VpcManager _vpcMgr;
- private static TaggedResourceService _taggedResourceService;
- private static UserVmDetailsDao _userVmDetailsDao;
- private static SSHKeyPairDao _sshKeyPairDao;
-
- private static ConditionDao _asConditionDao;
- private static AutoScalePolicyConditionMapDao _asPolicyConditionMapDao;
- private static AutoScaleVmGroupPolicyMapDao _asVmGroupPolicyMapDao;
- private static AutoScalePolicyDao _asPolicyDao;
- private static AutoScaleVmProfileDao _asVmProfileDao;
- private static AutoScaleVmGroupDao _asVmGroupDao;
- private static CounterDao _counterDao;
- private static ResourceTagJoinDao _tagJoinDao;
- private static EventJoinDao _eventJoinDao;
- private static InstanceGroupJoinDao _vmGroupJoinDao;
- private static UserAccountJoinDao _userAccountJoinDao;
- private static ProjectJoinDao _projectJoinDao;
- private static ProjectAccountJoinDao _projectAccountJoinDao;
- private static ProjectInvitationJoinDao _projectInvitationJoinDao;
- private static HostJoinDao _hostJoinDao;
- private static VolumeJoinDao _volJoinDao;
- private static StoragePoolJoinDao _poolJoinDao;
- private static AccountJoinDao _accountJoinDao;
- private static AsyncJobJoinDao _jobJoinDao;
- private static DiskOfferingJoinDao _diskOfferingJoinDao;
- private static ServiceOfferingJoinDao _srvOfferingJoinDao;
- private static DataCenterJoinDao _dcJoinDao;
-
- private static PhysicalNetworkTrafficTypeDao _physicalNetworkTrafficTypeDao;
- private static PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
- private static FirewallRulesDao _firewallRuleDao;
- private static StaticRouteDao _staticRouteDao;
- private static VpcGatewayDao _vpcGatewayDao;
- private static VpcDao _vpcDao;
- private static VpcOfferingDao _vpcOfferingDao;
- private static SnapshotPolicyDao _snapshotPolicyDao;
- private static AsyncJobDao _asyncJobDao;
-
- static {
- _ms = (ManagementServer) ComponentLocator.getComponent(ManagementServer.Name);
- ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
- _asyncMgr = locator.getManager(AsyncJobManager.class);
- _securityGroupMgr = locator.getManager(SecurityGroupManager.class);
- _storageMgr = locator.getManager(StorageManager.class);
- _userVmMgr = locator.getManager(UserVmManager.class);
- _networkMgr = locator.getManager(NetworkManager.class);
- _networkModel = locator.getManager(NetworkModel.class);
- _configMgr = locator.getManager(ConfigurationService.class);
-
- _accountDao = locator.getDao(AccountDao.class);
- _accountVlanMapDao = locator.getDao(AccountVlanMapDao.class);
- _clusterDao = locator.getDao(ClusterDao.class);
- _capacityDao = locator.getDao(CapacityDao.class);
- _diskOfferingDao = locator.getDao(DiskOfferingDao.class);
- _domainDao = locator.getDao(DomainDao.class);
- _domainRouterDao = locator.getDao(DomainRouterDao.class);
- _domainRouterJoinDao = locator.getDao(DomainRouterJoinDao.class);
- _guestOSDao = locator.getDao(GuestOSDao.class);
- _guestOSCategoryDao = locator.getDao(GuestOSCategoryDao.class);
- _hostDao = locator.getDao(HostDao.class);
- _ipAddressDao = locator.getDao(IPAddressDao.class);
- _loadBalancerDao = locator.getDao(LoadBalancerDao.class);
- _networkRuleConfigDao = locator.getDao(NetworkRuleConfigDao.class);
- _podDao = locator.getDao(HostPodDao.class);
- _serviceOfferingDao = locator.getDao(ServiceOfferingDao.class);
- _snapshotDao = locator.getDao(SnapshotDao.class);
- _storagePoolDao = locator.getDao(StoragePoolDao.class);
- _templateDao = locator.getDao(VMTemplateDao.class);
- _templateDetailsDao = locator.getDao(VMTemplateDetailsDao.class);
- _templateHostDao = locator.getDao(VMTemplateHostDao.class);
- _templateSwiftDao = locator.getDao(VMTemplateSwiftDao.class);
- _templateS3Dao = locator.getDao(VMTemplateS3Dao.class);
- _uploadDao = locator.getDao(UploadDao.class);
- _userDao = locator.getDao(UserDao.class);
- _userStatsDao = locator.getDao(UserStatisticsDao.class);
- _userVmDao = locator.getDao(UserVmDao.class);
- _userVmJoinDao = locator.getDao(UserVmJoinDao.class);
- _vlanDao = locator.getDao(VlanDao.class);
- _volumeDao = locator.getDao(VolumeDao.class);
- _site2SiteVpnGatewayDao = locator.getDao(Site2SiteVpnGatewayDao.class);
- _site2SiteCustomerGatewayDao = locator.getDao(Site2SiteCustomerGatewayDao.class);
- _volumeHostDao = locator.getDao(VolumeHostDao.class);
- _zoneDao = locator.getDao(DataCenterDao.class);
- _securityGroupDao = locator.getDao(SecurityGroupDao.class);
- _securityGroupJoinDao = locator.getDao(SecurityGroupJoinDao.class);
- _networkOfferingDao = locator.getDao(NetworkOfferingDao.class);
- _networkDao = locator.getDao(NetworkDao.class);
- _physicalNetworkDao = locator.getDao(PhysicalNetworkDao.class);
- _configDao = locator.getDao(ConfigurationDao.class);
- _consoleProxyDao = locator.getDao(ConsoleProxyDao.class);
- _firewallCidrsDao = locator.getDao(FirewallRulesCidrsDao.class);
- _vmDao = locator.getDao(VMInstanceDao.class);
- _resourceLimitMgr = locator.getManager(ResourceLimitService.class);
- _projectMgr = locator.getManager(ProjectService.class);
- _resourceMgr = locator.getManager(ResourceManager.class);
- _accountDetailsDao = locator.getDao(AccountDetailsDao.class);
- _networkDomainDao = locator.getDao(NetworkDomainDao.class);
- _haMgr = locator.getManager(HighAvailabilityManager.class);
- _vpcMgr = locator.getManager(VpcManager.class);
- _taggedResourceService = locator.getManager(TaggedResourceService.class);
- _sshKeyPairDao = locator.getDao(SSHKeyPairDao.class);
- _userVmDetailsDao = locator.getDao(UserVmDetailsDao.class);
- _asConditionDao = locator.getDao(ConditionDao.class);
- _asPolicyDao = locator.getDao(AutoScalePolicyDao.class);
- _asPolicyConditionMapDao = locator.getDao(AutoScalePolicyConditionMapDao.class);
- _counterDao = locator.getDao(CounterDao.class);
- _asVmGroupPolicyMapDao = locator.getDao(AutoScaleVmGroupPolicyMapDao.class);
- _tagJoinDao = locator.getDao(ResourceTagJoinDao.class);
- _vmGroupJoinDao = locator.getDao(InstanceGroupJoinDao.class);
- _eventJoinDao = locator.getDao(EventJoinDao.class);
- _userAccountJoinDao = locator.getDao(UserAccountJoinDao.class);
- _projectJoinDao = locator.getDao(ProjectJoinDao.class);
- _projectAccountJoinDao = locator.getDao(ProjectAccountJoinDao.class);
- _projectInvitationJoinDao = locator.getDao(ProjectInvitationJoinDao.class);
- _hostJoinDao = locator.getDao(HostJoinDao.class);
- _volJoinDao = locator.getDao(VolumeJoinDao.class);
- _poolJoinDao = locator.getDao(StoragePoolJoinDao.class);
- _accountJoinDao = locator.getDao(AccountJoinDao.class);
- _jobJoinDao = locator.getDao(AsyncJobJoinDao.class);
-
- _physicalNetworkTrafficTypeDao = locator.getDao(PhysicalNetworkTrafficTypeDao.class);
- _physicalNetworkServiceProviderDao = locator.getDao(PhysicalNetworkServiceProviderDao.class);
- _firewallRuleDao = locator.getDao(FirewallRulesDao.class);
- _staticRouteDao = locator.getDao(StaticRouteDao.class);
- _vpcGatewayDao = locator.getDao(VpcGatewayDao.class);
- _asVmProfileDao = locator.getDao(AutoScaleVmProfileDao.class);
- _asVmGroupDao = locator.getDao(AutoScaleVmGroupDao.class);
- _vpcDao = locator.getDao(VpcDao.class);
- _vpcOfferingDao = locator.getDao(VpcOfferingDao.class);
- _snapshotPolicyDao = locator.getDao(SnapshotPolicyDao.class);
- _asyncJobDao = locator.getDao(AsyncJobDao.class);
- _diskOfferingJoinDao = locator.getDao(DiskOfferingJoinDao.class);
- _srvOfferingJoinDao = locator.getDao(ServiceOfferingJoinDao.class);
- _dcJoinDao = locator.getDao(DataCenterJoinDao.class);
+ static AsyncJobManager _asyncMgr;
+ static SecurityGroupManager _securityGroupMgr;
+ static StorageManager _storageMgr;
+ static UserVmManager _userVmMgr;
+ static NetworkModel _networkModel;
+ static NetworkManager _networkMgr;
+ static StatsCollector _statsCollector;
+
+ static AccountDao _accountDao;
+ static AccountVlanMapDao _accountVlanMapDao;
+ static ClusterDao _clusterDao;
+ static CapacityDao _capacityDao;
+ static DiskOfferingDao _diskOfferingDao;
++ static DiskOfferingJoinDao _diskOfferingJoinDao;
++ static DataCenterJoinDao _dcJoinDao;
+ static DomainDao _domainDao;
+ static DomainRouterDao _domainRouterDao;
+ static DomainRouterJoinDao _domainRouterJoinDao;
+ static GuestOSDao _guestOSDao;
+ static GuestOSCategoryDao _guestOSCategoryDao;
+ static HostDao _hostDao;
+ static IPAddressDao _ipAddressDao;
+ static LoadBalancerDao _loadBalancerDao;
+ static SecurityGroupDao _securityGroupDao;
+ static SecurityGroupJoinDao _securityGroupJoinDao;
++ static ServiceOfferingJoinDao _serviceOfferingJoinDao;
+ static NetworkRuleConfigDao _networkRuleConfigDao;
+ static HostPodDao _podDao;
+ static ServiceOfferingDao _serviceOfferingDao;
+ static SnapshotDao _snapshotDao;
+ static StoragePoolDao _storagePoolDao;
+ static VMTemplateDao _templateDao;
+ static VMTemplateDetailsDao _templateDetailsDao;
+ static VMTemplateHostDao _templateHostDao;
+ static VMTemplateSwiftDao _templateSwiftDao;
+ static VMTemplateS3Dao _templateS3Dao;
+ static UploadDao _uploadDao;
+ static UserDao _userDao;
+ static UserStatisticsDao _userStatsDao;
+ static UserVmDao _userVmDao;
+ static UserVmJoinDao _userVmJoinDao;
+ static VlanDao _vlanDao;
+ static VolumeDao _volumeDao;
+ static Site2SiteVpnGatewayDao _site2SiteVpnGatewayDao;
+ static Site2SiteCustomerGatewayDao _site2SiteCustomerGatewayDao;
+ static VolumeHostDao _volumeHostDao;
+ static DataCenterDao _zoneDao;
+ static NetworkOfferingDao _networkOfferingDao;
+ static NetworkDao _networkDao;
+ static PhysicalNetworkDao _physicalNetworkDao;
+ static ConfigurationService _configMgr;
+ static ConfigurationDao _configDao;
+ static ConsoleProxyDao _consoleProxyDao;
+ static FirewallRulesCidrsDao _firewallCidrsDao;
+ static VMInstanceDao _vmDao;
+ static ResourceLimitService _resourceLimitMgr;
+ static ProjectService _projectMgr;
+ static ResourceManager _resourceMgr;
+ static AccountDetailsDao _accountDetailsDao;
+ static NetworkDomainDao _networkDomainDao;
+ static HighAvailabilityManager _haMgr;
+ static VpcManager _vpcMgr;
+ static TaggedResourceService _taggedResourceService;
+ static UserVmDetailsDao _userVmDetailsDao;
+ static SSHKeyPairDao _sshKeyPairDao;
+
+ static ConditionDao _asConditionDao;
+ static AutoScalePolicyConditionMapDao _asPolicyConditionMapDao;
+ static AutoScaleVmGroupPolicyMapDao _asVmGroupPolicyMapDao;
+ static AutoScalePolicyDao _asPolicyDao;
+ static AutoScaleVmProfileDao _asVmProfileDao;
+ static AutoScaleVmGroupDao _asVmGroupDao;
+ static CounterDao _counterDao;
+ static ResourceTagJoinDao _tagJoinDao;
+ static EventJoinDao _eventJoinDao;
+ static InstanceGroupJoinDao _vmGroupJoinDao;
+ static UserAccountJoinDao _userAccountJoinDao;
+ static ProjectJoinDao _projectJoinDao;
+ static ProjectAccountJoinDao _projectAccountJoinDao;
+ static ProjectInvitationJoinDao _projectInvitationJoinDao;
+ static HostJoinDao _hostJoinDao;
+ static VolumeJoinDao _volJoinDao;
+ static StoragePoolJoinDao _poolJoinDao;
+ static AccountJoinDao _accountJoinDao;
+ static AsyncJobJoinDao _jobJoinDao;
+
+ static PhysicalNetworkTrafficTypeDao _physicalNetworkTrafficTypeDao;
+ static PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
+ static FirewallRulesDao _firewallRuleDao;
+ static StaticRouteDao _staticRouteDao;
+ static VpcGatewayDao _vpcGatewayDao;
+ static VpcDao _vpcDao;
+ static VpcOfferingDao _vpcOfferingDao;
+ static SnapshotPolicyDao _snapshotPolicyDao;
+ static AsyncJobDao _asyncJobDao;
+
+ @Inject private ManagementServer ms;
+ @Inject public AsyncJobManager asyncMgr;
+ @Inject private SecurityGroupManager securityGroupMgr;
+ @Inject private StorageManager storageMgr;
+ @Inject private UserVmManager userVmMgr;
+ @Inject private NetworkModel networkModel;
+ @Inject private NetworkManager networkMgr;
+ @Inject private StatsCollector statsCollector;
+
+ @Inject private AccountDao accountDao;
+ @Inject private AccountVlanMapDao accountVlanMapDao;
+ @Inject private ClusterDao clusterDao;
+ @Inject private CapacityDao capacityDao;
++ @Inject private DataCenterJoinDao dcJoinDao;
+ @Inject private DiskOfferingDao diskOfferingDao;
++ @Inject private DiskOfferingJoinDao diskOfferingJoinDao;
+ @Inject private DomainDao domainDao;
+ @Inject private DomainRouterDao domainRouterDao;
+ @Inject private DomainRouterJoinDao domainRouterJoinDao;
+ @Inject private GuestOSDao guestOSDao;
+ @Inject private GuestOSCategoryDao guestOSCategoryDao;
+ @Inject private HostDao hostDao;
+ @Inject private IPAddressDao ipAddressDao;
+ @Inject private LoadBalancerDao loadBalancerDao;
+ @Inject private SecurityGroupDao securityGroupDao;
+ @Inject private SecurityGroupJoinDao securityGroupJoinDao;
++ @Inject private ServiceOfferingJoinDao serviceOfferingJoinDao;
+ @Inject private NetworkRuleConfigDao networkRuleConfigDao;
+ @Inject private HostPodDao podDao;
+ @Inject private ServiceOfferingDao serviceOfferingDao;
+ @Inject private SnapshotDao snapshotDao;
+ @Inject private StoragePoolDao storagePoolDao;
+ @Inject private VMTemplateDao templateDao;
+ @Inject private VMTemplateDetailsDao templateDetailsDao;
+ @Inject private VMTemplateHostDao templateHostDao;
+ @Inject private VMTemplateSwiftDao templateSwiftDao;
+ @Inject private VMTemplateS3Dao templateS3Dao;
+ @Inject private UploadDao uploadDao;
+ @Inject private UserDao userDao;
+ @Inject private UserStatisticsDao userStatsDao;
+ @Inject private UserVmDao userVmDao;
+ @Inject private UserVmJoinDao userVmJoinDao;
+ @Inject private VlanDao vlanDao;
+ @Inject private VolumeDao volumeDao;
+ @Inject private Site2SiteVpnGatewayDao site2SiteVpnGatewayDao;
+ @Inject private Site2SiteCustomerGatewayDao site2SiteCustomerGatewayDao;
+ @Inject private VolumeHostDao volumeHostDao;
+ @Inject private DataCenterDao zoneDao;
+ @Inject private NetworkOfferingDao networkOfferingDao;
+ @Inject private NetworkDao networkDao;
+ @Inject private PhysicalNetworkDao physicalNetworkDao;
+ @Inject private ConfigurationService configMgr;
+ @Inject private ConfigurationDao configDao;
+ @Inject private ConsoleProxyDao consoleProxyDao;
+ @Inject private FirewallRulesCidrsDao firewallCidrsDao;
+ @Inject private VMInstanceDao vmDao;
+ @Inject private ResourceLimitService resourceLimitMgr;
+ @Inject private ProjectService projectMgr;
+ @Inject private ResourceManager resourceMgr;
+ @Inject private AccountDetailsDao accountDetailsDao;
+ @Inject private NetworkDomainDao networkDomainDao;
+ @Inject private HighAvailabilityManager haMgr;
+ @Inject private VpcManager vpcMgr;
+ @Inject private TaggedResourceService taggedResourceService;
+ @Inject private UserVmDetailsDao userVmDetailsDao;
+ @Inject private SSHKeyPairDao sshKeyPairDao;
+
+ @Inject private ConditionDao asConditionDao;
+ @Inject private AutoScalePolicyConditionMapDao asPolicyConditionMapDao;
+ @Inject private AutoScaleVmGroupPolicyMapDao asVmGroupPolicyMapDao;
+ @Inject private AutoScalePolicyDao asPolicyDao;
+ @Inject private AutoScaleVmProfileDao asVmProfileDao;
+ @Inject private AutoScaleVmGroupDao asVmGroupDao;
+ @Inject private CounterDao counterDao;
+ @Inject private ResourceTagJoinDao tagJoinDao;
+ @Inject private EventJoinDao eventJoinDao;
+ @Inject private InstanceGroupJoinDao vmGroupJoinDao;
+ @Inject private UserAccountJoinDao userAccountJoinDao;
+ @Inject private ProjectJoinDao projectJoinDao;
+ @Inject private ProjectAccountJoinDao projectAccountJoinDao;
+ @Inject private ProjectInvitationJoinDao projectInvitationJoinDao;
+ @Inject private HostJoinDao hostJoinDao;
+ @Inject private VolumeJoinDao volJoinDao;
+ @Inject private StoragePoolJoinDao poolJoinDao;
+ @Inject private AccountJoinDao accountJoinDao;
+ @Inject private AsyncJobJoinDao jobJoinDao;
+
+ @Inject private PhysicalNetworkTrafficTypeDao physicalNetworkTrafficTypeDao;
+ @Inject private PhysicalNetworkServiceProviderDao physicalNetworkServiceProviderDao;
+ @Inject private FirewallRulesDao firewallRuleDao;
+ @Inject private StaticRouteDao staticRouteDao;
+ @Inject private VpcGatewayDao vpcGatewayDao;
+ @Inject private VpcDao vpcDao;
+ @Inject private VpcOfferingDao vpcOfferingDao;
+ @Inject private SnapshotPolicyDao snapshotPolicyDao;
+ @Inject private AsyncJobDao asyncJobDao;
+
+ @PostConstruct
+ void init() {
+ _ms = ms;
+ _asyncMgr = asyncMgr;
+ _securityGroupMgr = securityGroupMgr;
+ _storageMgr = storageMgr;
+ _userVmMgr = userVmMgr;
+ _networkModel = networkModel;
+ _networkMgr = networkMgr;
+ _configMgr = configMgr;
+
+ _accountDao = accountDao;
+ _accountVlanMapDao = accountVlanMapDao;
+ _clusterDao = clusterDao;
+ _capacityDao = capacityDao;
++ _dcJoinDao = dcJoinDao;
+ _diskOfferingDao = diskOfferingDao;
++ _diskOfferingJoinDao = diskOfferingJoinDao;
+ _domainDao = domainDao;
+ _domainRouterDao = domainRouterDao;
+ _domainRouterJoinDao = domainRouterJoinDao;
+ _guestOSDao = guestOSDao;
+ _guestOSCategoryDao = guestOSCategoryDao;
+ _hostDao = hostDao;
+ _ipAddressDao = ipAddressDao;
+ _loadBalancerDao = loadBalancerDao;
+ _networkRuleConfigDao = networkRuleConfigDao;
+ _podDao = podDao;
+ _serviceOfferingDao = serviceOfferingDao;
++ _serviceOfferingJoinDao = serviceOfferingJoinDao;
+ _snapshotDao = snapshotDao;
+ _storagePoolDao = storagePoolDao;
+ _templateDao = templateDao;
+ _templateDetailsDao = templateDetailsDao;
+ _templateHostDao = templateHostDao;
+ _templateSwiftDao = templateSwiftDao;
+ _templateS3Dao = templateS3Dao;
+ _uploadDao = uploadDao;
+ _userDao = userDao;
+ _userStatsDao = userStatsDao;
+ _userVmDao = userVmDao;
+ _userVmJoinDao = userVmJoinDao;
+ _vlanDao = vlanDao;
+ _volumeDao = volumeDao;
+ _site2SiteVpnGatewayDao = site2SiteVpnGatewayDao;
+ _site2SiteCustomerGatewayDao = site2SiteCustomerGatewayDao;
+ _volumeHostDao = volumeHostDao;
+ _zoneDao = zoneDao;
+ _securityGroupDao = securityGroupDao;
+ _securityGroupJoinDao = securityGroupJoinDao;
+ _networkOfferingDao = networkOfferingDao;
+ _networkDao = networkDao;
+ _physicalNetworkDao = physicalNetworkDao;
+ _configDao = configDao;
+ _consoleProxyDao = consoleProxyDao;
+ _firewallCidrsDao = firewallCidrsDao;
+ _vmDao = vmDao;
+ _resourceLimitMgr = resourceLimitMgr;
+ _projectMgr = projectMgr;
+ _resourceMgr = resourceMgr;
+ _accountDetailsDao = accountDetailsDao;
+ _networkDomainDao = networkDomainDao;
+ _haMgr = haMgr;
+ _vpcMgr = vpcMgr;
+ _taggedResourceService = taggedResourceService;
+ _sshKeyPairDao = sshKeyPairDao;
+ _userVmDetailsDao = userVmDetailsDao;
+ _asConditionDao = asConditionDao;
+ _asPolicyDao = asPolicyDao;
+ _asPolicyConditionMapDao = asPolicyConditionMapDao;
+ _counterDao = counterDao;
+ _asVmGroupPolicyMapDao = asVmGroupPolicyMapDao;
+ _tagJoinDao = tagJoinDao;
+ _vmGroupJoinDao = vmGroupJoinDao;
+ _eventJoinDao = eventJoinDao;
+ _userAccountJoinDao = userAccountJoinDao;
+ _projectJoinDao = projectJoinDao;
+ _projectAccountJoinDao = projectAccountJoinDao;
+ _projectInvitationJoinDao = projectInvitationJoinDao;
+ _hostJoinDao = hostJoinDao;
+ _volJoinDao = volJoinDao;
+ _poolJoinDao = poolJoinDao;
+ _accountJoinDao = accountJoinDao;
+ _jobJoinDao = jobJoinDao;
+
+ _physicalNetworkTrafficTypeDao = physicalNetworkTrafficTypeDao;
+ _physicalNetworkServiceProviderDao = physicalNetworkServiceProviderDao;
+ _firewallRuleDao = firewallRuleDao;
+ _staticRouteDao = staticRouteDao;
+ _vpcGatewayDao = vpcGatewayDao;
+ _asVmProfileDao = asVmProfileDao;
+ _asVmGroupDao = asVmGroupDao;
+ _vpcDao = vpcDao;
+ _vpcOfferingDao = vpcOfferingDao;
+ _snapshotPolicyDao = snapshotPolicyDao;
+ _asyncJobDao = asyncJobDao;
// Note: stats collector should already have been initialized by this time, otherwise a null instance is returned
_statsCollector = StatsCollector.getInstance();
@@@ -1459,42 -1378,66 +1480,66 @@@
public static VolumeResponse fillVolumeDetails(VolumeResponse vrData, VolumeJoinVO vr){
return _volJoinDao.setVolumeResponse(vrData, vr);
- }
+ }
- public static List<VolumeJoinVO> newVolumeView(Volume vr){
- return _volJoinDao.newVolumeView(vr);
- }
+ public static List<VolumeJoinVO> newVolumeView(Volume vr){
+ return _volJoinDao.newVolumeView(vr);
+ }
- public static StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO vr) {
- return _poolJoinDao.newStoragePoolResponse(vr);
- }
+ public static StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO vr) {
+ return _poolJoinDao.newStoragePoolResponse(vr);
+ }
- public static StoragePoolResponse fillStoragePoolDetails(StoragePoolResponse vrData, StoragePoolJoinVO vr){
+ public static StoragePoolResponse fillStoragePoolDetails(StoragePoolResponse vrData, StoragePoolJoinVO vr){
return _poolJoinDao.setStoragePoolResponse(vrData, vr);
- }
+ }
- public static List<StoragePoolJoinVO> newStoragePoolView(StoragePool vr){
- return _poolJoinDao.newStoragePoolView(vr);
- }
+ public static List<StoragePoolJoinVO> newStoragePoolView(StoragePool vr){
+ return _poolJoinDao.newStoragePoolView(vr);
+ }
- public static AccountResponse newAccountResponse(AccountJoinVO ve) {
- return _accountJoinDao.newAccountResponse(ve);
- }
+ public static AccountResponse newAccountResponse(AccountJoinVO ve) {
+ return _accountJoinDao.newAccountResponse(ve);
+ }
- public static AccountJoinVO newAccountView(Account e){
- return _accountJoinDao.newAccountView(e);
- }
+ public static AccountJoinVO newAccountView(Account e){
+ return _accountJoinDao.newAccountView(e);
+ }
- public static AccountJoinVO findAccountViewById(Long accountId) {
- return _accountJoinDao.findByIdIncludingRemoved(accountId);
- }
+ public static AccountJoinVO findAccountViewById(Long accountId) {
+ return _accountJoinDao.findByIdIncludingRemoved(accountId);
+ }
- public static AsyncJobResponse newAsyncJobResponse(AsyncJobJoinVO ve) {
- return _jobJoinDao.newAsyncJobResponse(ve);
- }
+ public static AsyncJobResponse newAsyncJobResponse(AsyncJobJoinVO ve) {
+ return _jobJoinDao.newAsyncJobResponse(ve);
+ }
- public static AsyncJobJoinVO newAsyncJobView(AsyncJob e){
- return _jobJoinDao.newAsyncJobView(e);
- }
+ public static AsyncJobJoinVO newAsyncJobView(AsyncJob e){
+ return _jobJoinDao.newAsyncJobView(e);
+ }
+
+ public static DiskOfferingResponse newDiskOfferingResponse(DiskOfferingJoinVO offering) {
+ return _diskOfferingJoinDao.newDiskOfferingResponse(offering);
+ }
+
+ public static DiskOfferingJoinVO newDiskOfferingView(DiskOffering offering){
+ return _diskOfferingJoinDao.newDiskOfferingView(offering);
+ }
+
+ public static ServiceOfferingResponse newServiceOfferingResponse(ServiceOfferingJoinVO offering) {
- return _srvOfferingJoinDao.newServiceOfferingResponse(offering);
++ return _serviceOfferingJoinDao.newServiceOfferingResponse(offering);
+ }
+
+ public static ServiceOfferingJoinVO newServiceOfferingView(ServiceOffering offering){
- return _srvOfferingJoinDao.newServiceOfferingView(offering);
++ return _serviceOfferingJoinDao.newServiceOfferingView(offering);
+ }
+
+ public static ZoneResponse newDataCenterResponse(DataCenterJoinVO dc, Boolean showCapacities) {
+ return _dcJoinDao.newDataCenterResponse(dc, showCapacities);
+ }
+
+ public static DataCenterJoinVO newDataCenterView(DataCenter dc){
+ return _dcJoinDao.newDataCenterView(dc);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/api/ApiDispatcher.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiDispatcher.java
index eae07ba,f7d881d..8e3c5e0
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@@ -24,8 -24,10 +24,9 @@@ import java.text.ParseException
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
+ import java.util.Set;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
@@@ -129,34 -139,33 +130,33 @@@ public class ApiDispatcher
}
public void dispatch(BaseCmd cmd, Map<String, String> params) throws Exception {
- processParameters(cmd, params);
- UserContext ctx = UserContext.current();
- ctx.setAccountId(cmd.getEntityOwnerId());
- if (cmd instanceof BaseAsyncCmd) {
-
- BaseAsyncCmd asyncCmd = (BaseAsyncCmd) cmd;
- String startEventId = params.get("ctxStartEventId");
- ctx.setStartEventId(Long.valueOf(startEventId));
-
- // Synchronise job on the object if needed
- if (asyncCmd.getJob() != null && asyncCmd.getSyncObjId() != null && asyncCmd.getSyncObjType() != null) {
- Long queueSizeLimit = null;
- if (asyncCmd.getSyncObjType() != null && asyncCmd.getSyncObjType().equalsIgnoreCase(BaseAsyncCmd.snapshotHostSyncObject)) {
- queueSizeLimit = _createSnapshotQueueSizeLimit;
- } else {
- queueSizeLimit = 1L;
- }
+ processParameters(cmd, params);
+ UserContext ctx = UserContext.current();
+ ctx.setAccountId(cmd.getEntityOwnerId());
+ if (cmd instanceof BaseAsyncCmd) {
+
+ BaseAsyncCmd asyncCmd = (BaseAsyncCmd) cmd;
+ String startEventId = params.get("ctxStartEventId");
+ ctx.setStartEventId(Long.valueOf(startEventId));
+
+ // Synchronise job on the object if needed
+ if (asyncCmd.getJob() != null && asyncCmd.getSyncObjId() != null && asyncCmd.getSyncObjType() != null) {
+ Long queueSizeLimit = null;
+ if (asyncCmd.getSyncObjType() != null && asyncCmd.getSyncObjType().equalsIgnoreCase(BaseAsyncCmd.snapshotHostSyncObject)) {
+ queueSizeLimit = _createSnapshotQueueSizeLimit;
+ } else {
+ queueSizeLimit = 1L;
+ }
- if (queueSizeLimit != null) {
+ if (queueSizeLimit != null) {
- _asyncMgr
- .syncAsyncJobExecution(asyncCmd.getJob(), asyncCmd.getSyncObjType(), asyncCmd.getSyncObjId().longValue(), queueSizeLimit);
+ _asyncMgr.syncAsyncJobExecution(asyncCmd.getJob(), asyncCmd.getSyncObjType(), asyncCmd.getSyncObjId().longValue(), queueSizeLimit);
- } else {
- s_logger.trace("The queue size is unlimited, skipping the synchronizing");
+ } else {
+ s_logger.trace("The queue size is unlimited, skipping the synchronizing");
+ }
}
}
- }
- cmd.execute();
+ cmd.execute();
}
@@@ -183,10 -190,14 +183,9 @@@
}
}
- Field[] fields = ReflectUtil.getAllFieldsForClass(cmd.getClass(),
- new Class<?>[] {BaseCmd.class});
+ List<Field> fields = ReflectUtil.getAllFieldsForClass(cmd.getClass(), BaseCmd.class);
for (Field field : fields) {
- PlugService plugServiceAnnotation = field.getAnnotation(PlugService.class);
- if(plugServiceAnnotation != null){
- plugService(field, cmd);
- }
-
Parameter parameterAnnotation = field.getAnnotation(Parameter.class);
if ((parameterAnnotation == null) || !parameterAnnotation.expose()) {
continue;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiResponseHelper.java
index f4c4a42,1c8849a..61f906b
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@@ -759,77 -718,42 +721,42 @@@ public class ApiResponseHelper implemen
@Override
public ZoneResponse createZoneResponse(DataCenter dataCenter, Boolean showCapacities) {
- Account account = UserContext.current().getCaller();
- ZoneResponse zoneResponse = new ZoneResponse();
- zoneResponse.setId(dataCenter.getUuid());
- zoneResponse.setName(dataCenter.getName());
- zoneResponse.setSecurityGroupsEnabled(ApiDBUtils.isSecurityGroupEnabledInZone(dataCenter.getId()));
- zoneResponse.setLocalStorageEnabled(dataCenter.isLocalStorageEnabled());
-
- if ((dataCenter.getDescription() != null) && !dataCenter.getDescription().equalsIgnoreCase("null")) {
- zoneResponse.setDescription(dataCenter.getDescription());
+ DataCenterJoinVO vOffering = ApiDBUtils.newDataCenterView(dataCenter);
+ return ApiDBUtils.newDataCenterResponse(vOffering, showCapacities);
- }
+ }
- if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN)) {
- zoneResponse.setDns1(dataCenter.getDns1());
- zoneResponse.setDns2(dataCenter.getDns2());
- zoneResponse.setInternalDns1(dataCenter.getInternalDns1());
- zoneResponse.setInternalDns2(dataCenter.getInternalDns2());
- // FIXME zoneResponse.setVlan(dataCenter.get.getVnet());
- zoneResponse.setGuestCidrAddress(dataCenter.getGuestNetworkCidr());
- }
-
- if (showCapacities != null && showCapacities) {
- List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(dataCenter.getId(), null, null);
+ public static List<CapacityResponse> getDataCenterCapacityResponse(Long zoneId){
+ List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(zoneId, null, null);
- Set<CapacityResponse> capacityResponses = new HashSet<CapacityResponse>();
- float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor();
+ Set<CapacityResponse> capacityResponses = new HashSet<CapacityResponse>();
+ float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor();
- for (SummedCapacity capacity : capacities) {
- CapacityResponse capacityResponse = new CapacityResponse();
- capacityResponse.setCapacityType(capacity.getCapacityType());
- capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
- if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) {
- capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * cpuOverprovisioningFactor)));
- } else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
+ for (SummedCapacity capacity : capacities) {
+ CapacityResponse capacityResponse = new CapacityResponse();
+ capacityResponse.setCapacityType(capacity.getCapacityType());
+ capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
+ if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) {
+ capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * cpuOverprovisioningFactor)));
+ } else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
- List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(dataCenter.getId(), null, null);
+ List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(zoneId, null, null);
- capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
- capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity());
- } else {
- capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
- }
- if (capacityResponse.getCapacityTotal() != 0) {
- capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f));
- } else {
- capacityResponse.setPercentUsed(s_percentFormat.format(0L));
+ capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
+ capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity());
+ } else {
+ capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
+ }
+ if (capacityResponse.getCapacityTotal() != 0) {
+ capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f));
+ } else {
+ capacityResponse.setPercentUsed(s_percentFormat.format(0L));
+ }
+ capacityResponses.add(capacityResponse);
}
- capacityResponses.add(capacityResponse);
- }
- // Do it for stats as well.
+ // Do it for stats as well.
- capacityResponses.addAll(getStatsCapacityresponse(null, null, null, dataCenter.getId()));
-
- zoneResponse.setCapacitites(new ArrayList<CapacityResponse>(capacityResponses));
- }
-
- // set network domain info
- zoneResponse.setDomain(dataCenter.getDomain());
-
- // set domain info
- Long domainId = dataCenter.getDomainId();
- if (domainId != null) {
- Domain domain = ApiDBUtils.findDomainById(domainId);
- zoneResponse.setDomainId(domain.getId());
- zoneResponse.setDomainName(domain.getName());
- }
+ capacityResponses.addAll(getStatsCapacityresponse(null, null, null, zoneId));
- zoneResponse.setType(dataCenter.getNetworkType().toString());
- zoneResponse.setAllocationState(dataCenter.getAllocationState().toString());
- zoneResponse.setZoneToken(dataCenter.getZoneToken());
- zoneResponse.setDhcpProvider(dataCenter.getDhcpProvider());
- zoneResponse.setObjectName("zone");
- return zoneResponse;
+ return new ArrayList<CapacityResponse>(capacityResponses);
}
- private List<CapacityResponse> getStatsCapacityresponse(Long poolId, Long clusterId, Long podId, Long zoneId) {
+ private static List<CapacityResponse> getStatsCapacityresponse(Long poolId, Long clusterId, Long podId, Long zoneId) {
List<CapacityVO> capacities = new ArrayList<CapacityVO>();
capacities.add(ApiDBUtils.getStoragePoolUsedStats(poolId, clusterId, podId, zoneId));
if (clusterId == null && podId == null) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiServer.java
index f103e30,ed27200..80fffd3
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@@ -75,9 -61,9 +75,10 @@@ import org.apache.cloudstack.api.comman
import org.apache.cloudstack.api.command.user.vm.ListVMsCmd;
import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
+import org.apache.cloudstack.api.response.ExceptionResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+ import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
import org.apache.commons.codec.binary.Base64;
-import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.ConnectionClosedException;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
@@@ -106,9 -91,21 +107,11 @@@ import org.apache.http.protocol.Respons
import org.apache.http.protocol.ResponseDate;
import org.apache.http.protocol.ResponseServer;
import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
-import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
-import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
-import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
-import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
+ import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd;
+ import org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd;
-import org.apache.cloudstack.api.command.user.project.ListProjectInvitationsCmd;
-import org.apache.cloudstack.api.command.user.project.ListProjectsCmd;
-import org.apache.cloudstack.api.command.user.securitygroup.ListSecurityGroupsCmd;
-import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
import com.cloud.api.response.ApiResponseSerializer;
-import org.apache.cloudstack.api.response.ExceptionResponse;
-import org.apache.cloudstack.api.response.ListResponse;
-
import com.cloud.async.AsyncCommandQueued;
import com.cloud.async.AsyncJob;
import com.cloud.async.AsyncJobManager;
@@@ -124,8 -122,10 +127,9 @@@ import com.cloud.exception.CloudAuthent
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
+ import com.cloud.exception.RequestLimitException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.server.ManagementServer;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.DomainManager;
@@@ -598,11 -595,12 +606,12 @@@ public class ApiServer implements HttpR
// if userId not null, that mean that user is logged in
if (userId != null) {
- User user = ApiDBUtils.findUserById(userId);
+ User user = ApiDBUtils.findUserById(userId);
+
- try{
- checkCommandAvailable(user, commandName);
- }
- catch (PermissionDeniedException ex){
+ try{
+ checkCommandAvailable(user, commandName);
+ }
+ catch (PermissionDeniedException ex){
s_logger.debug("The given command:" + commandName + " does not exist or it is not available for user with id:" + userId);
throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "The given command does not exist or it is not available for user");
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiServlet.java
index c816404,0f8924a..fcf12a6
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@@ -296,13 -304,11 +296,11 @@@ public class ApiServlet extends HttpSer
* key mechanism updateUserContext(params, session != null ? session.getId() : null);
*/
- auditTrailSb.insert(0,
- "(userId=" + UserContext.current().getCallerUserId() + " accountId=" + UserContext.current().getCaller().getId() + " sessionId=" + (session != null ? session.getId() : null)
- + ")");
+ auditTrailSb.insert(0, "(userId=" + UserContext.current().getCallerUserId() + " accountId="
+ + UserContext.current().getCaller().getId() + " sessionId=" + (session != null ? session.getId() : null) + ")");
- String response = _apiServer.handleRequest(params, false, responseType, auditTrailSb);
- writeResponse(resp, response != null ? response : "", HttpServletResponse.SC_OK, responseType);
+ String response = _apiServer.handleRequest(params, false, responseType, auditTrailSb);
+ writeResponse(resp, response != null ? response : "", HttpServletResponse.SC_OK, responseType);
-
} else {
if (session != null) {
try {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/QueryManagerImpl.java
index 6760dec,cf240b1..97fd350
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@@ -18,11 -18,13 +18,13 @@@ package com.cloud.api.query
import java.util.ArrayList;
import java.util.Date;
+ import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
+ import java.util.Set;
import javax.ejb.Local;
+import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
@@@ -56,9 -63,9 +63,10 @@@ import org.apache.cloudstack.api.respon
import org.apache.cloudstack.api.response.UserResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.VolumeResponse;
+ import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.query.QueryService;
import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
import com.cloud.api.query.dao.AccountJoinDao;
import com.cloud.api.query.dao.AsyncJobJoinDao;
@@@ -106,6 -123,11 +124,8 @@@ import com.cloud.projects.ProjectManage
import com.cloud.projects.dao.ProjectAccountDao;
import com.cloud.projects.dao.ProjectDao;
import com.cloud.server.Criteria;
+ import com.cloud.service.ServiceOfferingVO;
+ import com.cloud.service.dao.ServiceOfferingDao;
-import com.cloud.storage.DiskOfferingVO;
-import com.cloud.storage.StoragePool;
-import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.Volume;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
@@@ -121,15 -144,16 +141,13 @@@ 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.vm.DomainRouterVO;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VirtualMachine;
+ import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.UserVmDao;
--/**
-- * @author minc
-- *
-- */
+@Component
@Local(value = {QueryService.class })
public class QueryManagerImpl implements QueryService, Manager {
@@@ -1887,5 -1930,426 +1923,426 @@@
}
+ @Override
+ public ListResponse<DiskOfferingResponse> searchForDiskOfferings(ListDiskOfferingsCmd cmd) {
+ Pair<List<DiskOfferingJoinVO>, Integer> result = searchForDiskOfferingsInternal(cmd);
+ ListResponse<DiskOfferingResponse> response = new ListResponse<DiskOfferingResponse>();
+ List<DiskOfferingResponse> offeringResponses = ViewResponseHelper.createDiskOfferingResponse(result.first().toArray(new DiskOfferingJoinVO[result.first().size()]));
+ response.setResponses(offeringResponses, result.second());
+ return response;
+ }
+
+ private Pair<List<DiskOfferingJoinVO>, Integer> searchForDiskOfferingsInternal(ListDiskOfferingsCmd cmd) {
+ // Note
+ // The list method for offerings is being modified in accordance with
+ // discussion with Will/Kevin
+ // For now, we will be listing the following based on the usertype
+ // 1. For root, we will list all offerings
+ // 2. For domainAdmin and regular users, we will list everything in
+ // their domains+parent domains ... all the way
+ // till
+ // root
+
+ Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
+ isAscending = (isAscending == null ? true : isAscending);
+ Filter searchFilter = new Filter(DiskOfferingJoinVO.class, "sortKey", isAscending, cmd.getStartIndex(), cmd.getPageSizeVal());
+ SearchBuilder<DiskOfferingJoinVO> sb = _diskOfferingJoinDao.createSearchBuilder();
+
+
+ Account account = UserContext.current().getCaller();
+ Object name = cmd.getDiskOfferingName();
+ Object id = cmd.getId();
+ Object keyword = cmd.getKeyword();
+ Long domainId = cmd.getDomainId();
+ // Keeping this logic consistent with domain specific zones
+ // if a domainId is provided, we just return the disk offering
+ // associated with this domain
+ if (domainId != null) {
+ if (account.getType() == Account.ACCOUNT_TYPE_ADMIN || isPermissible(account.getDomainId(), domainId) ) {
+ // check if the user's domain == do's domain || user's domain is
+ // a child of so's domain for non-root users
+ sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.EQ);
+ SearchCriteria<DiskOfferingJoinVO> sc = sb.create();
+ sc.setParameters("domainId", domainId);
+ return _diskOfferingJoinDao.searchAndCount(sc, searchFilter);
+ } else {
+ throw new PermissionDeniedException("The account:" + account.getAccountName()
+ + " does not fall in the same domain hierarchy as the disk offering");
+ }
+ }
+
+ sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
+ sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
+
+
+ boolean includePublicOfferings = false;
+ List<Long> domainIds = null;
+ // For non-root users, only return all offerings for the user's domain, and everything above till root
+ if ((account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)
+ || account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
+ // find all domain Id up to root domain for this account
+ domainIds = new ArrayList<Long>();
+ DomainVO domainRecord = _domainDao.findById(account.getDomainId());
+ if ( domainRecord == null ){
+ s_logger.error("Could not find the domainId for account:" + account.getAccountName());
+ throw new CloudAuthenticationException("Could not find the domainId for account:" + account.getAccountName());
+ }
+ domainIds.add(domainRecord.getId());
+ while (domainRecord.getParent() != null ){
+ domainRecord = _domainDao.findById(domainRecord.getParent());
+ domainIds.add(domainRecord.getId());
+ }
+ sb.and("domainIdIn", sb.entity().getDomainId(), SearchCriteria.Op.IN);
+
+ // include also public offering if no keyword, name and id specified
+ if ( keyword == null && name == null && id == null ){
+ includePublicOfferings = true;
+ }
+ }
+
+ SearchCriteria<DiskOfferingJoinVO> sc = sb.create();
+ if (keyword != null) {
+ SearchCriteria<DiskOfferingJoinVO> ssc = _diskOfferingJoinDao.createSearchCriteria();
+ ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+
+ sc.addAnd("name", SearchCriteria.Op.SC, ssc);
+ }
+
+ if (name != null) {
+ sc.setParameters("name", "%" + name + "%");
+ }
+
+ if (id != null) {
+ sc.setParameters("id", id);
+ }
+
+ if (domainIds != null ){
+ sc.setParameters("domainIdIn", domainIds);
+ }
+
+ if (includePublicOfferings){
+ SearchCriteria<DiskOfferingJoinVO> spc = _diskOfferingJoinDao.createSearchCriteria();
+ spc.addAnd("domainId", SearchCriteria.Op.NULL);
+ spc.addAnd("systemUse", SearchCriteria.Op.EQ, false);
+
+ sc.addOr("systemUse", SearchCriteria.Op.SC, spc);
+ }
+
+ // FIXME: disk offerings should search back up the hierarchy for
+ // available disk offerings...
+ /*
+ * sb.addAnd("domainId", sb.entity().getDomainId(),
+ * SearchCriteria.Op.EQ); if (domainId != null) {
+ * SearchBuilder<DomainVO> domainSearch =
+ * _domainDao.createSearchBuilder(); domainSearch.addAnd("path",
+ * domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
+ * sb.join("domainSearch", domainSearch, sb.entity().getDomainId(),
+ * domainSearch.entity().getId()); }
+ */
+
+ // FIXME: disk offerings should search back up the hierarchy for
+ // available disk offerings...
+ /*
+ * if (domainId != null) { sc.setParameters("domainId", domainId); //
+ * //DomainVO domain = _domainDao.findById((Long)domainId); // // I want
+ * to join on user_vm.domain_id = domain.id where domain.path like
+ * 'foo%' //sc.setJoinParameters("domainSearch", "path",
+ * domain.getPath() + "%"); // }
+ */
+
+ return _diskOfferingJoinDao.searchAndCount(sc, searchFilter);
+ }
+
+
+
+ @Override
+ public ListResponse<ServiceOfferingResponse> searchForServiceOfferings(ListServiceOfferingsCmd cmd) {
+ Pair<List<ServiceOfferingJoinVO>, Integer> result = searchForServiceOfferingsInternal(cmd);
+ ListResponse<ServiceOfferingResponse> response = new ListResponse<ServiceOfferingResponse>();
+ List<ServiceOfferingResponse> offeringResponses = ViewResponseHelper.createServiceOfferingResponse(result.first().toArray(new ServiceOfferingJoinVO[result.first().size()]));
+ response.setResponses(offeringResponses, result.second());
+ return response;
+ }
+
+ private Pair<List<ServiceOfferingJoinVO>, Integer> searchForServiceOfferingsInternal(ListServiceOfferingsCmd cmd) {
+ // Note
+ // The list method for offerings is being modified in accordance with
+ // discussion with Will/Kevin
+ // For now, we will be listing the following based on the usertype
+ // 1. For root, we will list all offerings
+ // 2. For domainAdmin and regular users, we will list everything in
+ // their domains+parent domains ... all the way
+ // till
+ // root
+ Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
+ isAscending = (isAscending == null ? true : isAscending);
+ Filter searchFilter = new Filter(ServiceOfferingJoinVO.class, "sortKey", isAscending, cmd.getStartIndex(), cmd.getPageSizeVal());
+ SearchCriteria<ServiceOfferingJoinVO> sc = _srvOfferingJoinDao.createSearchCriteria();
+
+ Account caller = UserContext.current().getCaller();
+ Object name = cmd.getServiceOfferingName();
+ Object id = cmd.getId();
+ Object keyword = cmd.getKeyword();
+ Long vmId = cmd.getVirtualMachineId();
+ Long domainId = cmd.getDomainId();
+ Boolean isSystem = cmd.getIsSystem();
+ String vmTypeStr = cmd.getSystemVmType();
+
+ if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && isSystem) {
+ throw new InvalidParameterValueException("Only ROOT admins can access system's offering");
+ }
+
+ // Keeping this logic consistent with domain specific zones
+ // if a domainId is provided, we just return the so associated with this
+ // domain
+ if (domainId != null && caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
+ // check if the user's domain == so's domain || user's domain is a
+ // child of so's domain
+ if (!isPermissible(caller.getDomainId(), domainId)) {
+ throw new PermissionDeniedException("The account:" + caller.getAccountName()
+ + " does not fall in the same domain hierarchy as the service offering");
+ }
+ }
+
+ boolean includePublicOfferings = false;
+ if ((caller.getType() == Account.ACCOUNT_TYPE_NORMAL || caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)
+ || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
+ // For non-root users
+ if (isSystem) {
+ throw new InvalidParameterValueException("Only root admins can access system's offering");
+ }
+ // find all domain Id up to root domain for this account
+ List<Long> domainIds = new ArrayList<Long>();
+ DomainVO domainRecord = _domainDao.findById(caller.getDomainId());
+ if ( domainRecord == null ){
+ s_logger.error("Could not find the domainId for account:" + caller.getAccountName());
+ throw new CloudAuthenticationException("Could not find the domainId for account:" + caller.getAccountName());
+ }
+ domainIds.add(domainRecord.getId());
+ while (domainRecord.getParent() != null ){
+ domainRecord = _domainDao.findById(domainRecord.getParent());
+ domainIds.add(domainRecord.getId());
+ }
+ sc.addAnd("domainId", SearchCriteria.Op.IN, domainIds);
+
+ // include also public offering if no keyword, name and id specified
+ if ( keyword == null && name == null && id == null ){
+ includePublicOfferings = true;
+ }
+ }
+ else {
+ // for root users
+ if (caller.getDomainId() != 1 && isSystem) { // NON ROOT admin
+ throw new InvalidParameterValueException("Non ROOT admins cannot access system's offering");
+ }
+ if (domainId != null) {
+ sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
+ }
+ }
+
+ if (keyword != null) {
+ SearchCriteria<ServiceOfferingJoinVO> ssc = _srvOfferingJoinDao.createSearchCriteria();
+ ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+
+ sc.addAnd("name", SearchCriteria.Op.SC, ssc);
+ } else if (vmId != null) {
+ UserVmVO vmInstance = _userVmDao.findById(vmId);
+ if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
+ InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with specified id");
+ ex.addProxyObject(vmInstance, vmId, "vmId");
+ throw ex;
+ }
+
+ _accountMgr.checkAccess(caller, null, true, vmInstance);
+
+ ServiceOfferingVO offering = _srvOfferingDao.findByIdIncludingRemoved(vmInstance.getServiceOfferingId());
+ sc.addAnd("id", SearchCriteria.Op.NEQ, offering.getId());
+
+ // Only return offerings with the same Guest IP type and storage
+ // pool preference
+ // sc.addAnd("guestIpType", SearchCriteria.Op.EQ,
+ // offering.getGuestIpType());
+ sc.addAnd("useLocalStorage", SearchCriteria.Op.EQ, offering.getUseLocalStorage());
+ }
+
+ if (id != null) {
+ sc.addAnd("id", SearchCriteria.Op.EQ, id);
+ }
+
+ if (isSystem != null) {
+ sc.addAnd("systemUse", SearchCriteria.Op.EQ, isSystem);
+ }
+
+ if (name != null) {
+ sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
+ }
+
+ if (vmTypeStr != null) {
+ sc.addAnd("vm_type", SearchCriteria.Op.EQ, vmTypeStr);
+ }
+
+ if (includePublicOfferings){
+ SearchCriteria<ServiceOfferingJoinVO> spc = _srvOfferingJoinDao.createSearchCriteria();
+ spc.addAnd("domainId", SearchCriteria.Op.NULL);
+ spc.addAnd("systemUse", SearchCriteria.Op.EQ, false);
+ sc.addOr("systemUse", SearchCriteria.Op.SC, spc);
+ }
+
+ return _srvOfferingJoinDao.searchAndCount(sc, searchFilter);
+
+ }
+
+
+
+
+ @Override
+ public ListResponse<ZoneResponse> listDataCenters(ListZonesByCmd cmd) {
+ Pair<List<DataCenterJoinVO>, Integer> result = listDataCentersInternal(cmd);
+ ListResponse<ZoneResponse> response = new ListResponse<ZoneResponse>();
+ List<ZoneResponse> dcResponses = ViewResponseHelper.createDataCenterResponse(cmd.getShowCapacities(), result.first().toArray(new DataCenterJoinVO[result.first().size()]));
+ response.setResponses(dcResponses, result.second());
+ return response;
+ }
+
+
+ private Pair<List<DataCenterJoinVO>, Integer> listDataCentersInternal(ListZonesByCmd cmd) {
+ Account account = UserContext.current().getCaller();
+ Long domainId = cmd.getDomainId();
+ Long id = cmd.getId();
+ String keyword = cmd.getKeyword();
+
+ Filter searchFilter = new Filter(DataCenterJoinVO.class, null, false, cmd.getStartIndex(), cmd.getPageSizeVal());
+ SearchCriteria<DataCenterJoinVO> sc = _dcJoinDao.createSearchCriteria();
+
+ if (id != null) {
+ sc.addAnd("id", SearchCriteria.Op.EQ, id);
+ } else {
+ if (keyword != null) {
+ SearchCriteria<DataCenterJoinVO> ssc = _dcJoinDao.createSearchCriteria();
+ ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ sc.addAnd("name", SearchCriteria.Op.SC, ssc);
+ }
+
+ if (domainId != null) {
+ // for domainId != null
+ // right now, we made the decision to only list zones associated
+ // with this domain, private zone
+ sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
+ } else if (account.getType() == Account.ACCOUNT_TYPE_NORMAL) {
+ // it was decided to return all zones for the user's domain, and
+ // everything above till root
+ // list all zones belonging to this domain, and all of its
+ // parents
+ // check the parent, if not null, add zones for that parent to
+ // list
+
+
+ // find all domain Id up to root domain for this account
+ List<Long> domainIds = new ArrayList<Long>();
+ DomainVO domainRecord = _domainDao.findById(account.getDomainId());
+ if ( domainRecord == null ){
+ s_logger.error("Could not find the domainId for account:" + account.getAccountName());
+ throw new CloudAuthenticationException("Could not find the domainId for account:" + account.getAccountName());
+ }
+ domainIds.add(domainRecord.getId());
+ while (domainRecord.getParent() != null ){
+ domainRecord = _domainDao.findById(domainRecord.getParent());
+ domainIds.add(domainRecord.getId());
+ }
+ // domainId == null (public zones) or domainId IN [all domain id up to root domain]
+ SearchCriteria<DataCenterJoinVO> sdc = _dcJoinDao.createSearchCriteria();
+ sdc.addOr("domainId", SearchCriteria.Op.IN, domainIds);
+ sdc.addOr("domainId", SearchCriteria.Op.NULL);
+ sc.addAnd("domain", SearchCriteria.Op.SC, sdc);
+
+ // remove disabled zones
+ sc.addAnd("allocationState", SearchCriteria.Op.NEQ, Grouping.AllocationState.Disabled);
+
+ } else if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
+ // it was decided to return all zones for the domain admin, and
+ // everything above till root, as well as zones till the domain leaf
+ List<Long> domainIds = new ArrayList<Long>();
+ DomainVO domainRecord = _domainDao.findById(account.getDomainId());
+ if ( domainRecord == null ){
+ s_logger.error("Could not find the domainId for account:" + account.getAccountName());
+ throw new CloudAuthenticationException("Could not find the domainId for account:" + account.getAccountName());
+ }
+ domainIds.add(domainRecord.getId());
+ // find all domain Ids till leaf
+ List<DomainVO> allChildDomains = _domainDao.findAllChildren(domainRecord.getPath(), domainRecord.getId());
+ for (DomainVO domain : allChildDomains) {
+ domainIds.add(domain.getId());
+ }
+ // then find all domain Id up to root domain for this account
+ while (domainRecord.getParent() != null ){
+ domainRecord = _domainDao.findById(domainRecord.getParent());
+ domainIds.add(domainRecord.getId());
+ }
+
+ // domainId == null (public zones) or domainId IN [all domain id up to root domain]
+ SearchCriteria<DataCenterJoinVO> sdc = _dcJoinDao.createSearchCriteria();
+ sdc.addOr("domainId", SearchCriteria.Op.IN, domainIds);
+ sdc.addOr("domainId", SearchCriteria.Op.NULL);
+ sc.addAnd("domain", SearchCriteria.Op.SC, sdc);
+
+ // remove disabled zones
+ sc.addAnd("allocationState", SearchCriteria.Op.NEQ, Grouping.AllocationState.Disabled);
+ }
+
+ // handle available=FALSE option, only return zones with at least one VM running there
+ Boolean available = cmd.isAvailable();
+ if (account != null) {
+ if ((available != null) && Boolean.FALSE.equals(available)) {
+ Set<Long> dcIds = new HashSet<Long>(); //data centers with at least one VM running
+ List<DomainRouterVO> routers = _routerDao.listBy(account.getId());
+ for (DomainRouterVO router : routers){
- dcIds.add(router.getDataCenterIdToDeployIn());
++ dcIds.add(router.getDataCenterId());
+ }
+ if ( dcIds.size() == 0) {
+ return new Pair<List<DataCenterJoinVO>, Integer>(new ArrayList<DataCenterJoinVO>(), 0);
+ }
+ else{
+ sc.addAnd("idIn", SearchCriteria.Op.IN, dcIds);
+ }
+
+ }
+ }
+ }
+
+ return _dcJoinDao.searchAndCount(sc, searchFilter);
+ }
+
+
+ // This method is used for permissions check for both disk and service
+ // offerings
+ private boolean isPermissible(Long accountDomainId, Long offeringDomainId) {
+
+ if (accountDomainId == offeringDomainId) {
+ return true; // account and service offering in same domain
+ }
+
+ DomainVO domainRecord = _domainDao.findById(accountDomainId);
+
+ if (domainRecord != null) {
+ while (true) {
+ if (domainRecord.getId() == offeringDomainId) {
+ return true;
+ }
+
+ // try and move on to the next domain
+ if (domainRecord.getParent() != null) {
+ domainRecord = _domainDao.findById(domainRecord.getParent());
+ } else {
+ break;
+ }
+ }
+ }
+
+ return false;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
index 0000000,4ef182b..667d855
mode 000000,100644..100644
--- a/server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
@@@ -1,0 -1,109 +1,110 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements. See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership. The ASF licenses this file
+ // 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,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied. See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package com.cloud.api.query.dao;
+
+ import java.util.List;
+ import javax.ejb.Local;
+
+ import org.apache.log4j.Logger;
+
+ import com.cloud.api.ApiDBUtils;
+ import com.cloud.api.ApiResponseHelper;
+ import com.cloud.api.query.vo.DataCenterJoinVO;
+ import com.cloud.dc.DataCenter;
+ import org.apache.cloudstack.api.response.ZoneResponse;
+
+ import com.cloud.user.Account;
+ import com.cloud.user.UserContext;
+ import com.cloud.utils.db.GenericDaoBase;
+ import com.cloud.utils.db.SearchBuilder;
+ import com.cloud.utils.db.SearchCriteria;
++import org.springframework.stereotype.Component;
+
-
++@Component
+ @Local(value={DataCenterJoinDao.class})
+ public class DataCenterJoinDaoImpl extends GenericDaoBase<DataCenterJoinVO, Long> implements DataCenterJoinDao {
+ public static final Logger s_logger = Logger.getLogger(DataCenterJoinDaoImpl.class);
+
+
+ private SearchBuilder<DataCenterJoinVO> dofIdSearch;
+
+ protected DataCenterJoinDaoImpl() {
+
+ dofIdSearch = createSearchBuilder();
+ dofIdSearch.and("id", dofIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+ dofIdSearch.done();
+
+ this._count = "select count(distinct id) from data_center_view WHERE ";
+ }
+
+
+
+ @Override
+ public ZoneResponse newDataCenterResponse(DataCenterJoinVO dataCenter, Boolean showCapacities) {
+
+ Account account = UserContext.current().getCaller();
+ ZoneResponse zoneResponse = new ZoneResponse();
+ zoneResponse.setId(dataCenter.getUuid());
+ zoneResponse.setName(dataCenter.getName());
+ zoneResponse.setSecurityGroupsEnabled(ApiDBUtils.isSecurityGroupEnabledInZone(dataCenter.getId()));
+ zoneResponse.setLocalStorageEnabled(dataCenter.isLocalStorageEnabled());
+
+ if ((dataCenter.getDescription() != null) && !dataCenter.getDescription().equalsIgnoreCase("null")) {
+ zoneResponse.setDescription(dataCenter.getDescription());
+ }
+
+ if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN)) {
+ zoneResponse.setDns1(dataCenter.getDns1());
+ zoneResponse.setDns2(dataCenter.getDns2());
+ zoneResponse.setInternalDns1(dataCenter.getInternalDns1());
+ zoneResponse.setInternalDns2(dataCenter.getInternalDns2());
+ // FIXME zoneResponse.setVlan(dataCenter.get.getVnet());
+ zoneResponse.setGuestCidrAddress(dataCenter.getGuestNetworkCidr());
+ }
+
+ if (showCapacities != null && showCapacities) {
+ zoneResponse.setCapacitites(ApiResponseHelper.getDataCenterCapacityResponse(dataCenter.getId()));
+ }
+
+ // set network domain info
+ zoneResponse.setDomain(dataCenter.getDomain());
+
+ // set domain info
+
+ zoneResponse.setDomainId(dataCenter.getDomainUuid());
+ zoneResponse.setDomainName(dataCenter.getDomainName());
+
+ zoneResponse.setType(dataCenter.getNetworkType().toString());
+ zoneResponse.setAllocationState(dataCenter.getAllocationState().toString());
+ zoneResponse.setZoneToken(dataCenter.getZoneToken());
+ zoneResponse.setDhcpProvider(dataCenter.getDhcpProvider());
+ zoneResponse.setObjectName("zone");
+ return zoneResponse;
+ }
+
+
+ @Override
+ public DataCenterJoinVO newDataCenterView(DataCenter dataCenter) {
+ SearchCriteria<DataCenterJoinVO> sc = dofIdSearch.create();
+ sc.setParameters("id", dataCenter.getId());
+ List<DataCenterJoinVO> dcs = searchIncludingRemoved(sc, null, null, false);
+ assert dcs != null && dcs.size() == 1 : "No data center found for data center id " + dataCenter.getId();
+ return dcs.get(0);
+ }
+
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
index 0000000,d877381..43c9d00
mode 000000,100644..100644
--- a/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
@@@ -1,0 -1,101 +1,102 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements. See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership. The ASF licenses this file
+ // 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,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied. See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package com.cloud.api.query.dao;
+
+ import java.util.List;
+
+ import javax.ejb.Local;
+
+ import org.apache.log4j.Logger;
+
+ import com.cloud.api.query.vo.DiskOfferingJoinVO;
+ import org.apache.cloudstack.api.response.DiskOfferingResponse;
+ import com.cloud.offering.DiskOffering;
+ import com.cloud.offering.ServiceOffering;
+ import com.cloud.storage.DiskOfferingVO;
+ import com.cloud.storage.DiskOfferingVO.Type;
+ import com.cloud.utils.db.Attribute;
+ import com.cloud.utils.db.Filter;
+ import com.cloud.utils.db.GenericDaoBase;
+ import com.cloud.utils.db.SearchBuilder;
+ import com.cloud.utils.db.SearchCriteria;
+ import com.cloud.utils.db.SearchCriteria.Op;
++import org.springframework.stereotype.Component;
+
-
++@Component
+ @Local(value={DiskOfferingJoinDao.class})
+ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO, Long> implements DiskOfferingJoinDao {
+ public static final Logger s_logger = Logger.getLogger(DiskOfferingJoinDaoImpl.class);
+
+
+ private SearchBuilder<DiskOfferingJoinVO> dofIdSearch;
+ private final Attribute _typeAttr;
+
+ protected DiskOfferingJoinDaoImpl() {
+
+ dofIdSearch = createSearchBuilder();
+ dofIdSearch.and("id", dofIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+ dofIdSearch.done();
+
+ _typeAttr = _allAttributes.get("type");
+
+ this._count = "select count(distinct id) from disk_offering_view WHERE ";
+ }
+
+
+
+ @Override
+ public DiskOfferingResponse newDiskOfferingResponse(DiskOfferingJoinVO offering) {
+
+ DiskOfferingResponse diskOfferingResponse = new DiskOfferingResponse();
+ diskOfferingResponse.setId(offering.getUuid());
+ diskOfferingResponse.setName(offering.getName());
+ diskOfferingResponse.setDisplayText(offering.getDisplayText());
+ diskOfferingResponse.setCreated(offering.getCreated());
+ diskOfferingResponse.setDiskSize(offering.getDiskSize() / (1024 * 1024 * 1024));
+
+ diskOfferingResponse.setDomain(offering.getDomainName());
+ diskOfferingResponse.setDomainId(offering.getDomainUuid());
+
+ diskOfferingResponse.setTags(offering.getTags());
+ diskOfferingResponse.setCustomized(offering.isCustomized());
+ diskOfferingResponse.setStorageType(offering.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
+ diskOfferingResponse.setObjectName("diskoffering");
+ return diskOfferingResponse;
+ }
+
+
+ @Override
+ public DiskOfferingJoinVO newDiskOfferingView(DiskOffering offering) {
+ SearchCriteria<DiskOfferingJoinVO> sc = dofIdSearch.create();
+ sc.setParameters("id", offering.getId());
+ List<DiskOfferingJoinVO> offerings = searchIncludingRemoved(sc, null, null, false);
+ assert offerings != null && offerings.size() == 1 : "No disk offering found for offering id " + offering.getId();
+ return offerings.get(0);
+ }
+
+ @Override
+ public List<DiskOfferingJoinVO> searchIncludingRemoved(SearchCriteria<DiskOfferingJoinVO> sc, final Filter filter, final Boolean lock, final boolean cache) {
+ sc.addAnd(_typeAttr, Op.EQ, Type.Disk);
+ return super.searchIncludingRemoved(sc, filter, lock, cache);
+ }
+
+ @Override
+ public <K> List<K> customSearchIncludingRemoved(SearchCriteria<K> sc, final Filter filter) {
+ sc.addAnd(_typeAttr, Op.EQ, Type.Disk);
+ return super.customSearchIncludingRemoved(sc, filter);
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
index 0000000,8827c48..9795fef
mode 000000,100644..100644
--- a/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
@@@ -1,0 -1,91 +1,92 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements. See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership. The ASF licenses this file
+ // 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,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied. See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package com.cloud.api.query.dao;
+
+ import java.util.List;
+
+ import javax.ejb.Local;
+
+ import org.apache.log4j.Logger;
+
+ import com.cloud.api.query.vo.ServiceOfferingJoinVO;
+ import org.apache.cloudstack.api.response.ServiceOfferingResponse;
+
+ import com.cloud.offering.ServiceOffering;
+ import com.cloud.utils.db.GenericDaoBase;
+ import com.cloud.utils.db.SearchBuilder;
+ import com.cloud.utils.db.SearchCriteria;
++import org.springframework.stereotype.Component;
+
-
++@Component
+ @Local(value={ServiceOfferingJoinDao.class})
+ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJoinVO, Long> implements ServiceOfferingJoinDao {
+ public static final Logger s_logger = Logger.getLogger(ServiceOfferingJoinDaoImpl.class);
+
+
+ private SearchBuilder<ServiceOfferingJoinVO> sofIdSearch;
+
+ protected ServiceOfferingJoinDaoImpl() {
+
+ sofIdSearch = createSearchBuilder();
+ sofIdSearch.and("id", sofIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+ sofIdSearch.done();
+
+ this._count = "select count(distinct id) from service_offering_view WHERE ";
+ }
+
+
+
+ @Override
+ public ServiceOfferingResponse newServiceOfferingResponse(ServiceOfferingJoinVO offering) {
+
+ ServiceOfferingResponse offeringResponse = new ServiceOfferingResponse();
+ offeringResponse.setId(offering.getUuid());
+ offeringResponse.setName(offering.getName());
+ offeringResponse.setIsSystemOffering(offering.isSystemUse());
+ offeringResponse.setDefaultUse(offering.isDefaultUse());
+ offeringResponse.setSystemVmType(offering.getSystemVmType());
+ offeringResponse.setDisplayText(offering.getDisplayText());
+ offeringResponse.setCpuNumber(offering.getCpu());
+ offeringResponse.setCpuSpeed(offering.getSpeed());
+ offeringResponse.setMemory(offering.getRamSize());
+ offeringResponse.setCreated(offering.getCreated());
+ offeringResponse.setStorageType(offering.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString()
+ : ServiceOffering.StorageType.shared.toString());
+ offeringResponse.setOfferHa(offering.isOfferHA());
+ offeringResponse.setLimitCpuUse(offering.isLimitCpuUse());
+ offeringResponse.setTags(offering.getTags());
+ offeringResponse.setDomain(offering.getDomainName());
+ offeringResponse.setDomainId(offering.getDomainUuid());
+ offeringResponse.setNetworkRate(offering.getRateMbps());
+ offeringResponse.setHostTag(offering.getHostTag());
+ offeringResponse.setObjectName("serviceoffering");
+
+ return offeringResponse;
+ }
+
+
+ @Override
+ public ServiceOfferingJoinVO newServiceOfferingView(ServiceOffering offering) {
+ SearchCriteria<ServiceOfferingJoinVO> sc = sofIdSearch.create();
+ sc.setParameters("id", offering.getId());
+ List<ServiceOfferingJoinVO> offerings = searchIncludingRemoved(sc, null, null, false);
+ assert offerings != null && offerings.size() == 1 : "No service offering found for offering id " + offering.getId();
+ return offerings.get(0);
+ }
+
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/dao/EntityManagerImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/NetworkServiceImpl.java
index dc09db6,7530e94..b39feb7
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@@ -1815,10 -1813,7 +1815,7 @@@ public class NetworkServiceImpl impleme
} catch (NumberFormatException e) {
throw new InvalidParameterValueException("Please specify valid integers for the vlan range.");
}
-
+
- //check for vnet conflicts with other physical network(s) in the zone
- checkGuestVnetsConflicts(zoneId, vnetStart, vnetEnd, null);
-
if ((vnetStart > vnetEnd) || (vnetStart < 0) || (vnetEnd > 4096)) {
s_logger.warn("Invalid vnet range: start range:" + vnetStart + " end range:" + vnetEnd);
throw new InvalidParameterValueException("Vnet range should be between 0-4096 and start range should be lesser than or equal to end range");
@@@ -1996,10 -1991,7 +1993,7 @@@
if (newStartVnet > newEndVnet) {
throw new InvalidParameterValueException("Vnet range has to be" + rangeMessage + " and start range should be lesser than or equal to stop range");
}
-
+
- //check if new vnet conflicts with vnet ranges of other physical networks
- checkGuestVnetsConflicts(network.getDataCenterId(), newStartVnet, newEndVnet, network.getId());
-
if (physicalNetworkHasAllocatedVnets(network.getDataCenterId(), network.getId())) {
String[] existingRange = network.getVnet().split("-");
int existingStartVnet = Integer.parseInt(existingRange[0]);