[GitHub] cloudstack pull request #1958: CLOUDSTACK-5806: add presetup to storage type...

2017-02-21 Thread abhinandanprateek
GitHub user abhinandanprateek opened a pull request:

https://github.com/apache/cloudstack/pull/1958

CLOUDSTACK-5806: add presetup to storage types that support over prov…

…isioning

Ideally this should be configurable via global settings

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack CLOUDSTACK-5806

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/1958.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1958


commit 6ad3429085abf2943ff3183288b7f2e7e0165963
Author: Abhinandan Prateek 
Date:   2017-02-22T06:48:35Z

CLOUDSTACK-5806: add presetup to storage types that support over 
provisioning
Ideally this should be configurable via global settings




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #815: CLOUDSTACK-8841: Storage XenMotion from XS 6.2...

2017-02-23 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/815#discussion_r102671303
  
--- Diff: server/src/com/cloud/vm/UserVmManagerImpl.java ---
@@ -4717,8 +4717,8 @@ public VirtualMachine 
migrateVirtualMachineWithVolume(Long vmId, Host destinatio
 }
 
 // Check if the source and destination hosts are of the same type 
and support storage motion.
-if 
(!(srcHost.getHypervisorType().equals(destinationHost.getHypervisorType()) && 
srcHost.getHypervisorVersion().equals(destinationHost.getHypervisorVersion( 
{
-throw new CloudRuntimeException("The source and destination 
hosts are not of the same type and version. " + "Source hypervisor type and 
version: "
+if 
(!(srcHost.getHypervisorType().equals(destinationHost.getHypervisorType( {
+throw new CloudRuntimeException("The source and destination 
hosts are not of the same type. " + "Source hypervisor type and version: "
--- End diff --

The Xenserver version on the target host can be same or higher, please see 
if the version check can be further improved.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1958: CLOUDSTACK-5806: add presetup to storage type...

2017-02-24 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1958#discussion_r102918123
  
--- Diff: server/src/com/cloud/configuration/ConfigurationManagerImpl.java 
---
@@ -508,7 +507,7 @@ public String updateConfiguration(final long userId, 
final String name, final St
 throw new InvalidParameterValueException("unable to 
find storage pool by id " + resourceId);
 }
 
if(name.equals(CapacityManager.StorageOverprovisioningFactor.key())) {
-if(pool.getPoolType() != 
StoragePoolType.NetworkFilesystem && pool.getPoolType() != 
StoragePoolType.VMFS) {
+if(pool.getPoolType().supportsOverProvisioning() ) {
--- End diff --

yep ! thanks @serg38 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1958: CLOUDSTACK-5806: add presetup to storage types that ...

2017-02-24 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1958
  
@borisstoyanov a condition got inverted by the change (serg38 pointed that 
out above), it is fixed now. Can you rerun the tests.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1960: [4.11/Future] CLOUDSTACK-9782: Host HA and KVM HA pr...

2017-02-28 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1960
  
@koushik-das The current framework is specifically implemented for Host HA 
with KVM HA as the initial implementation. This framework is supposed to 
replace the framework that is specifically written for VM-HA. @rhtyd 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1278: CLOUDSTACK-9198: Virtual router gets deployed in dis...

2017-02-28 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1278
  
@anshul1886 Should not we disallow any VM to be deployed in a disabled Pod, 
why just the VR ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1278: CLOUDSTACK-9198: Virtual router gets deployed in dis...

2017-02-28 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1278
  
@anshul1886 Should not we disallow any VM to be deployed in a disabled Pod, 
why just the VR ?
cc @rhtyd @karuturi

Lets merge this shapeblue/cloudstack-apple@359f652 instead


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1278: CLOUDSTACK-9198: Virtual router gets deployed in dis...

2017-02-28 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1278
  
@anshul1886 Should not we disallow any VM to be deployed in a disabled Pod, 
why just the VR ?
cc @rhtyd @karuturi



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1675: CLOUDSTACK-9453: WIP

2017-02-28 Thread abhinandanprateek
Github user abhinandanprateek closed the pull request at:

https://github.com/apache/cloudstack/pull/1675


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1675: CLOUDSTACK-9453: WIP

2017-02-28 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1675
  
@rhtyd closing this PR as relevant portion of this are already in codebase 
via other VRs.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1278: CLOUDSTACK-9198: Virtual router gets deployed in dis...

2017-02-28 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1278
  
@anshul1886 I am not sure I thought deployment planner for VR and a regular 
VM is same. If a regular VM is not allowed in a cluster that is under disabled 
pod then the VR should also be not allowed. Is there some override somewhere ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1278: CLOUDSTACK-9198: Virtual router gets deployed in dis...

2017-03-01 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1278
  
@anshul1886 If you trace the method planDeployment in 
DeploymentPlanningManagerImpl then you will see that orderCluster is getting 
invoked at line 500. By that time I think the deployment plan for a VM that has 
hostid or lasthost id populated is already returned (line 472 and 369). This 
will allow vm to be started on a disabled pod as well as any VM that is created 
for a host in a disabled pod to be allowed as host id is pre-set for such VMs. 
There should be additional checks above to disallow a disabled pod.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1979: CLOUDSTACK-9198: Donot allow VMs to be deplye...

2017-03-01 Thread abhinandanprateek
GitHub user abhinandanprateek opened a pull request:

https://github.com/apache/cloudstack/pull/1979

CLOUDSTACK-9198: Donot allow VMs to be deplyed on host that are in di…

…sabled pod


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack CLOUDSTACK-9198

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/1979.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1979


commit c7ba2124bbfd03ca2835b5b1affc8fc876fb4154
Author: Abhinandan Prateek 
Date:   2017-01-13T08:07:42Z

CLOUDSTACK-9198: Donot allow VMs to be deplyed on host that are in disabled 
pod

Signed-off-by: Abhinandan Prateek 




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1278: CLOUDSTACK-9198: Virtual router gets deployed in dis...

2017-03-01 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1278
  
@koushik-das @anshul1886 If we allow admin to deploy resources on disabled 
resources then this fix is fine. Even with the fix a non admin user will be 
able to restart a VM on a disabled resource, so limited by that. Boils down to 
definition of disabled.
I had done a fix in past that will prevent deployment on disabled pods even 
for admin, created a Pr for that now, check this out too: 
https://github.com/apache/cloudstack/pull/1979/files. I think it just boils 
down to the definition of disabled.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1278: CLOUDSTACK-9198: Virtual router gets deployed in dis...

2017-03-01 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1278
  
@anshul1886 @koushik-das I think with above info the fix looks good.

LGTM.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1979: CLOUDSTACK-9198: Donot allow VMs to be deplye...

2017-03-02 Thread abhinandanprateek
Github user abhinandanprateek closed the pull request at:

https://github.com/apache/cloudstack/pull/1979


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1989: WIP: support for multidisk OVA files

2017-03-05 Thread abhinandanprateek
GitHub user abhinandanprateek opened a pull request:

https://github.com/apache/cloudstack/pull/1989

WIP: support for multidisk OVA files

Signed-off-by: Abhinandan Prateek 

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack multidisk-OVA

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/1989.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1989


commit f8a0494d0420dc6b847e6e2f80139942c31a0847
Author: Abhinandan Prateek 
Date:   2017-03-06T05:04:16Z

support for multidisk OVA files

Signed-off-by: Abhinandan Prateek 




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-06 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@serg38 Yes, the aim of the PR is to enable deployment from templates with 
multiple data disks.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-06 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-06 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan test vmware



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-06 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan test vmware-55u3


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-06 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan test centos7 vmware-55u3


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1779: CLOUDSTACK-9610: Disabled Host Keeps Being up...

2017-03-07 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1779#discussion_r104609930
  
--- Diff: server/src/com/cloud/resource/ResourceManagerImpl.java ---
@@ -2488,6 +2488,22 @@ public boolean maintenanceFailed(final long hostId) {
 }
 
 @Override
+public List listAllHosts(Type type, Long clusterId, Long 
podId, long dcId) {
--- End diff --

make the input params final.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-07 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan cancel


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-07 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1779: CLOUDSTACK-9610: Disabled Host Keeps Being up status...

2017-03-07 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1779
  
code review LGTM


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-07 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-07 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-07 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-08 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-08 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-08 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: support for multidisk OVA files

2017-03-08 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1995: CLOUDSTACK-9828: GetDomRVersionCommand fails ...

2017-03-09 Thread abhinandanprateek
GitHub user abhinandanprateek opened a pull request:

https://github.com/apache/cloudstack/pull/1995

CLOUDSTACK-9828: GetDomRVersionCommand fails to get the correct versi…

…on as output

Fix tries to return the output as a single command, instead of appending 
output from two commands

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack CLOUDSTACK-9828

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/1995.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1995


commit e303eee8e6edd8dda9f6dd25b59dbdfeaa435275
Author: Abhinandan Prateek 
Date:   2017-03-06T05:04:16Z

CLOUDSTACK-9828: GetDomRVersionCommand fails to get the correct version as 
output
Fix tries to return the output as a single command, instead of appending 
output from two commands




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1995: CLOUDSTACK-9828: GetDomRVersionCommand fails to get ...

2017-03-09 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1995
  
@ustcweizhou the file exists and the script works on the VR. It is not able 
to return the complete output though via the router_proxy. The signature file 
is part of the template.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1995: CLOUDSTACK-9828: GetDomRVersionCommand fails to get ...

2017-03-09 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1995
  
@ustcweizhou another observation is that with the same systemvm.iso and VR 
templates; get version works on with some hosts while consistently failing in 
some cases.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1989: WIP: CLOUDSTACK-4757: support for multidisk OVA file...

2017-03-09 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1989
  
This PR is basically merging 
https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=shortlog;h=refs/heads/multiple-disk-ova.
 And continue to build on it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1989: WIP: CLOUDSTACK-4757: support for multidisk O...

2017-03-09 Thread abhinandanprateek
Github user abhinandanprateek closed the pull request at:

https://github.com/apache/cloudstack/pull/1989


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1989: WIP: CLOUDSTACK-4757: support for multidisk O...

2017-03-09 Thread abhinandanprateek
GitHub user abhinandanprateek reopened a pull request:

https://github.com/apache/cloudstack/pull/1989

WIP: CLOUDSTACK-4757:  support for multidisk OVA files

Signed-off-by: Abhinandan Prateek 

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack multidisk-OVA

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/1989.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1989


commit f8a0494d0420dc6b847e6e2f80139942c31a0847
Author: Abhinandan Prateek 
Date:   2017-03-06T05:04:16Z

support for multidisk OVA files

Signed-off-by: Abhinandan Prateek 

commit b1ba37db6f5ca13e0cd85096745e849af984c162
Author: Abhinandan Prateek 
Date:   2017-03-06T15:18:46Z

multidiskOVA: instrumented code and fixes

commit 9b9f79ae60305542501d5715bac5023ba130a98e
Author: Abhinandan Prateek 
Date:   2017-03-07T05:02:50Z

multidisk-OVA: temporarily fixing, disabling some tests

commit 84982c296f5d9d95e57377b1f01da00ba84d034f
Author: Abhinandan Prateek 
Date:   2017-03-07T08:27:55Z

multidiskOVA add db upgrade scripts

commit 1c00aac33da9cb04d61f9c7148eb0e270e4d5c9a
Author: Abhinandan Prateek 
Date:   2017-03-08T04:43:36Z

multidiskOVA: hitting the VR version issues




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1989: WIP: CLOUDSTACK-4757: support for multidisk O...

2017-03-09 Thread abhinandanprateek
Github user abhinandanprateek closed the pull request at:

https://github.com/apache/cloudstack/pull/1989


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1998: Multidisk ova

2017-03-09 Thread abhinandanprateek
GitHub user abhinandanprateek opened a pull request:

https://github.com/apache/cloudstack/pull/1998

Multidisk ova



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack multidisk-OVA

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/1998.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1998


commit f8a0494d0420dc6b847e6e2f80139942c31a0847
Author: Abhinandan Prateek 
Date:   2017-03-06T05:04:16Z

support for multidisk OVA files

Signed-off-by: Abhinandan Prateek 

commit b1ba37db6f5ca13e0cd85096745e849af984c162
Author: Abhinandan Prateek 
Date:   2017-03-06T15:18:46Z

multidiskOVA: instrumented code and fixes

commit 9b9f79ae60305542501d5715bac5023ba130a98e
Author: Abhinandan Prateek 
Date:   2017-03-07T05:02:50Z

multidisk-OVA: temporarily fixing, disabling some tests

commit 84982c296f5d9d95e57377b1f01da00ba84d034f
Author: Abhinandan Prateek 
Date:   2017-03-07T08:27:55Z

multidiskOVA add db upgrade scripts

commit 1c00aac33da9cb04d61f9c7148eb0e270e4d5c9a
Author: Abhinandan Prateek 
Date:   2017-03-08T04:43:36Z

multidiskOVA: hitting the VR version issues




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1998: CLOUDSTACK-4757: WIP: support for multidisk OVA file...

2017-03-09 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1998
  
@sateesh-chodapuneedi you have worked on it, will you list down what needs 
to be additionally done on this PR to make it production ready. Will be really 
good if you can participate too. I too have found some issues and improvements, 
will wait for your inputs to prioritize. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1998: CLOUDSTACK-4757: WIP: support for multidisk O...

2017-03-10 Thread abhinandanprateek
Github user abhinandanprateek closed the pull request at:

https://github.com/apache/cloudstack/pull/1998


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2014: IR24:WIP

2017-03-21 Thread abhinandanprateek
GitHub user abhinandanprateek opened a pull request:

https://github.com/apache/cloudstack/pull/2014

IR24:WIP



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack ir24

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/2014.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2014


commit 03c050360bf2e8f904222ade2bfbe48627ed7e54
Author: Abhinandan Prateek 
Date:   2017-03-22T06:54:19Z

IR24:WIP




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2014: WIP

2017-03-21 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2014
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2014: WIP

2017-03-23 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2014
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2020: IR25: WIP

2017-03-28 Thread abhinandanprateek
GitHub user abhinandanprateek opened a pull request:

https://github.com/apache/cloudstack/pull/2020

IR25: WIP



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack ir25

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/2020.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2020


commit ae959c110f3237b8823d227c390f74cc9d692653
Author: Abhinandan Prateek 
Date:   2017-03-28T12:07:59Z

IR25: WIP




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2020: IR25: WIP

2017-03-28 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2020
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2014: WIP: Fix primary storage usage for vm snaphot

2017-03-31 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2014
  
@blueorangutan package



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2020: WIP: Expire VM snapshots

2017-04-02 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2020
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2024: CLOUDSTACK-9857: With this change if agent di...

2017-04-03 Thread abhinandanprateek
GitHub user abhinandanprateek opened a pull request:

https://github.com/apache/cloudstack/pull/2024

CLOUDSTACK-9857: With this change if agent dies the systemd will catc…

…h it properly and show process as exited

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack CLOUDSTACK-9857

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/2024.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2024


commit 3eb633a100a71193c4999172f494f6ce2175866d
Author: Abhinandan Prateek 
Date:   2017-04-03T10:46:21Z

CLOUDSTACK-9857: With this change if agent dies the systemd will catch it 
properly and show process as exited




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2014: WIP: Fix primary storage usage for vm snaphot

2017-04-04 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2014
  
@borisstoyanov checking


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2020: WIP: Expire VM snapshots

2017-04-04 Thread abhinandanprateek
Github user abhinandanprateek closed the pull request at:

https://github.com/apache/cloudstack/pull/2020


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2026: CLOUDSTACK-9861: Expire VM snapshots after co...

2017-04-04 Thread abhinandanprateek
GitHub user abhinandanprateek opened a pull request:

https://github.com/apache/cloudstack/pull/2026

CLOUDSTACK-9861: Expire VM snapshots after configured duration

Default value of the account level global config vmsnapshot.expire.interval 
is -1 that conforms to legacy behaviour
A positive value will expire the VM snapshots for the respective account in 
that many hours

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack ir25-2

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/2026.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2026


commit 1c6a30a0e65f2bc9b1d97920d1562b35f3b682ee
Author: Abhinandan Prateek 
Date:   2017-03-28T12:07:59Z

CLOUDSTACK-9861: Expire VM snapshots after configured duration
Default value of the account level global config vmsnapshot.expire.interval 
is -1 that conforms to legacy behaviour
A positive value will expire the VM snapshots for the respective account in 
that many hours




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2014: WIP: Fix primary storage usage for vm snaphot

2017-04-04 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2014
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2026: CLOUDSTACK-9861: Expire VM snapshots after configure...

2017-04-04 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2026
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2014: WIP: Fix primary storage usage for vm snaphot

2017-04-04 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2014
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2014: WIP: Fix primary storage usage for vm snaphot

2017-04-04 Thread abhinandanprateek
Github user abhinandanprateek closed the pull request at:

https://github.com/apache/cloudstack/pull/2014


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2029: CLOUDSTACK-9857: With this change if agent di...

2017-04-06 Thread abhinandanprateek
GitHub user abhinandanprateek opened a pull request:

https://github.com/apache/cloudstack/pull/2029

CLOUDSTACK-9857: With this change if agent dies the systemd will catc…

…h it properly and show process as exited

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack CLOUDSTACK-9857-2

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/2029.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2029


commit f5b952939b0fbffcdedc6f369e60502f771d0ac9
Author: Abhinandan Prateek 
Date:   2017-04-03T10:46:21Z

CLOUDSTACK-9857: With this change if agent dies the systemd will catch it 
properly and show process as exited




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2024: CLOUDSTACK-9857: With this change if agent dies the ...

2017-04-06 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2024
  
@rhtyd @karuturi here is the cherry picked PR on 4.9 
https://github.com/apache/cloudstack/pull/2029


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2029: CLOUDSTACK-9857: With this change if agent di...

2017-04-06 Thread abhinandanprateek
Github user abhinandanprateek closed the pull request at:

https://github.com/apache/cloudstack/pull/2029


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2001: CLOUDSTACK-9830 Fix DST bug in QuotaAlertManagerTest

2017-04-06 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2001
  
@LGTM on code review


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2030: WIP: CLOUDSTACK-9864 cleanup stale worker VMs...

2017-04-06 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/2030#discussion_r110145761
  
--- Diff: 
plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
 ---
@@ -128,6 +129,7 @@
 public class VmwareManagerImpl extends ManagerBase implements 
VmwareManager, VmwareStorageMount, Listener, VmwareDatacenterService, 
Configurable {
 private static final Logger s_logger = 
Logger.getLogger(VmwareManagerImpl.class);
 
+private static final long MILISECONDS_PER_MINUTE = 6;
--- End diff --

MILI typo MILLISECONDS ..


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2030: WIP: CLOUDSTACK-9864 cleanup stale worker VMs...

2017-04-06 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/2030#discussion_r110145877
  
--- Diff: 
plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
 ---
@@ -550,15 +552,21 @@ public boolean needRecycle(String workerTag) {
 return true;
 }
 
-// disable time-out check until we have found out a VMware API 
that can check if
-// there are pending tasks on the subject VM
-/*
-if(System.currentTimeMillis() - startTick > 
_hungWorkerTimeout) {
-if(s_logger.isInfoEnabled())
-s_logger.info("Worker VM expired, seconds elapsed: 
" + (System.currentTimeMillis() - startTick) / 1000);
-return true;
-}
- */
+// this time-out check was disabled
+// "until we have found out a VMware API that can check if there 
are pending tasks on the subject VM"
+// but as we expire jobs and those stale worker VMs stay around 
untill an MS reboot we opt in to have them removed anyway
+Long hungWorkerTimeout = 2 * 
(AsyncJobManagerImpl.JobExpireMinutes.value() + 
AsyncJobManagerImpl.JobCancelThresholdMinutes.value()) * MILISECONDS_PER_MINUTE;
+Long letsSayNow = System.currentTimeMillis();
+if(s_vmwareCleanOldWorderVMs.value() && letsSayNow - startTick > 
hungWorkerTimeout) {
+if(s_logger.isInfoEnabled()) {
+s_logger.info("Worker VM expired, seconds elapsed: " + 
(System.currentTimeMillis() - startTick) / 1000);
+}
--- End diff --

For timeouts you may want to use java Duration, that is much cleaner.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2035: CLOUDSTACK-9867:VM snapshot on primary storag...

2017-04-07 Thread abhinandanprateek
GitHub user abhinandanprateek opened a pull request:

https://github.com/apache/cloudstack/pull/2035

CLOUDSTACK-9867:VM snapshot on primary storage usage metrics



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack ir24

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/2035.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2035


commit 8f9e93316c66907246be1d653da27ae9feb5a27c
Author: Abhinandan Prateek 
Date:   2017-03-22T06:54:19Z

CLOUDSTACK-9867:VM snapshot on primary storage usage metrics




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2035: CLOUDSTACK-9867:VM snapshot on primary storage usage...

2017-04-07 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2035
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #1960: [4.11/Future] CLOUDSTACK-9782: Host HA and KVM HA pr...

2017-04-09 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/1960
  
@koushik-das I see that main issue is that this is being confused as VM HA 
framework. Will like to again add that this framework is not for VM-HA but for 
host HA. With this implementation of OOBM framework, Cloudstack is now in the 
position to control and HA a host. These developments helped us in putting 
together a Host HA framework. Only that while designing and coding we tried to 
keep it flexible so that later other entities that can be HAed can be added to 
the framework.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2026: CLOUDSTACK-9861: Expire VM snapshots after co...

2017-04-10 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/2026#discussion_r110594291
  
--- Diff: setup/db/db/schema-4920to41000.sql ---
@@ -232,3 +232,5 @@ WHERE (o.cpu is null AND o.speed IS NULL AND o.ram_size 
IS NULL) AND
 
 -- CLOUDSTACK-9827: Storage tags stored in multiple places
 DROP VIEW IF EXISTS `cloud`.`storage_tag_view`;
+
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 
'VMSanpshotManager', 'vmsnapshot.expire.interval', '-1', 'VM Snapshot expire 
interval in hours','-1', NULL, 'Account', 0);
--- End diff --

@rhtd removed the upgrade sql


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack issue #2035: CLOUDSTACK-9867:VM snapshot on primary storage usage...

2017-04-12 Thread abhinandanprateek
Github user abhinandanprateek commented on the issue:

https://github.com/apache/cloudstack/pull/2035
  
@blueorangutan package


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request:

2015-05-01 Thread abhinandanprateek
Github user abhinandanprateek commented on the pull request:


https://github.com/apache/cloudstack/commit/fb0bfd5d4f446656cdb136f2a05e5b27f680578a#commitcomment-10998674
  
Rajani, you want to merge your commit ? It looks good to me. The first set 
of tests have usually run without failing with unit tests included.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: return a state instead of null in Abstrac...

2015-05-01 Thread abhinandanprateek
Github user abhinandanprateek commented on the pull request:

https://github.com/apache/cloudstack/pull/211#issuecomment-98087158
  
The way HA is implemented, “null” is a valid return value from an 
investigator. The valid values are Up, Down or null.

https://cwiki.apache.org/confluence/display/CLOUDSTACK/High+Availability+Developer's+Guide
The other values may not be handled by HA impl., please check.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: return a state instead of null in Abstrac...

2015-05-01 Thread abhinandanprateek
Github user abhinandanprateek commented on the pull request:

https://github.com/apache/cloudstack/pull/211#issuecomment-98091401
  
I agree with Koushik here. The purpose of an HA investigator is to either 
say that host is UP or Down or it does not know for sure.  A host that has not 
returned some pings is in an indeterministic state, HA recognises it as "null" 
and not as Alert.
That apart there are there places that the method changed gets called. If 
you look at the code the Alert state does not have any affect on the code flow. 
I hope I did not miss out some.
I will say check again, as introduction of Alert state may confuse people 
looking at the code. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: return a state instead of null in Abstrac...

2015-05-01 Thread abhinandanprateek
Github user abhinandanprateek commented on the pull request:

https://github.com/apache/cloudstack/pull/211#issuecomment-98093700
  
Daan, 
  Yes, I agree. We can define a proper state and introduce it. I guess 
there is some tribal knowledge involved here that Koushik and myself were 
trying to convey. The HA related timeouts are very delicately balanced. On 
further looking at the code around the commit, my guess is it actually does not 
make difference to code-flow. But we should replace the "null" with say a new 
state like "UNKNOWN" and make sure that it is handled in the call hierarchy.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: return a state instead of null in Abstrac...

2015-05-01 Thread abhinandanprateek
Github user abhinandanprateek commented on the pull request:

https://github.com/apache/cloudstack/pull/211#issuecomment-98148840
  
Another thing to note is that while changing some of this legacy 
understanding, it is not just the code that needs improvement/change, it is all 
the existing documentation around it that also needs to be revamped. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: server: Introduce Unknown Status to be us...

2015-05-02 Thread abhinandanprateek
Github user abhinandanprateek commented on the pull request:

https://github.com/apache/cloudstack/pull/222#issuecomment-98430113
  
The issue has got entangled, let me try to summarise what each of us has 
been trying to do:

The initial fix itself takes a step into right direction. Use of a proper 
state instead of null is a good idea. Right now that change is localised in 
only one of the investigator method. On the whole there is no change to code 
flow and the change makes it even more readable.

If you look at the HA code holistically then this breaks a pattern for the 
good, but then the whole code should be made consistent, which means when any 
investigator i.e. a host investigator or a vm investigator does not know the 
state of the resource for sure it passes 'UNKNOWN' and not 'null'. I think that 
will be bit disruptive for a maintenance release, but if can be done that is 
fine too.

So if majority agrees that they will continue to work on making this code 
consistent eventually then that is best way forward . As of now it does not 
change code flow but only effects the semantic consistency.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41826727
  
--- Diff: 
framework/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java ---
@@ -0,0 +1,81 @@
+//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 org.apache.cloudstack.quota.dao;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.TransactionLegacy;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Component
+@Local(value = { QuotaUsageDao.class })
+public class QuotaUsageDaoImpl extends GenericDaoBase 
implements QuotaUsageDao {
+private static final Logger s_logger = 
Logger.getLogger(QuotaUsageDaoImpl.class.getName());
+
+@Override
+public BigDecimal findTotalQuotaUsage(final Long accountId, final Long 
domainId, final Integer usageType, final Date startDate, final Date endDate) {
+List quotaUsage = findQuotaUsage(accountId, 
domainId, null, startDate, endDate);
+BigDecimal total = new BigDecimal(0);
+for (QuotaUsageVO quotaRecord: quotaUsage) {
+total = total.add(quotaRecord.getQuotaUsed());
+}
+return total;
+}
+
+@SuppressWarnings("deprecation")
+@Override
+public List findQuotaUsage(final Long accountId, final 
Long domainId, final Integer usageType, final Date startDate, final Date 
endDate) {
+final short opendb = 
TransactionLegacy.currentTxn().getDatabaseId();
+List quotaUsageRecords = new 
ArrayList();
+try (TransactionLegacy txn = 
TransactionLegacy.open(TransactionLegacy.USAGE_DB)) {
+// TODO instead of max value query with reasonable number and 
iterate
--- End diff --

TODO item is mostly to reduce  the memory usage. Instead of querying the 
full usage table, do it in chunks of say 100 or 1000. Important only when both 
accountId and domainId are null.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41826803
  
--- Diff: 
framework/quota/src/org/apache/cloudstack/quota/dao/QuotaTariffDaoImpl.java ---
@@ -0,0 +1,137 @@
+//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 org.apache.cloudstack.quota.dao;
+
+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.TransactionLegacy;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.quota.constant.QuotaTypes;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Component
+@Local(value = { QuotaTariffDao.class })
+public class QuotaTariffDaoImpl extends GenericDaoBase implements QuotaTariffDao {
+private static final Logger s_logger = 
Logger.getLogger(QuotaTariffDaoImpl.class.getName());
+
+private final SearchBuilder searchUsageType;
+private final SearchBuilder listAllIncludedUsageType;
+
+public QuotaTariffDaoImpl() {
+super();
+searchUsageType = createSearchBuilder();
+searchUsageType.and("usage_type", 
searchUsageType.entity().getUsageType(), SearchCriteria.Op.EQ);
+searchUsageType.done();
+
+listAllIncludedUsageType = createSearchBuilder();
+listAllIncludedUsageType.and("onorbefore", 
listAllIncludedUsageType.entity().getEffectiveOn(), SearchCriteria.Op.LTEQ);
+listAllIncludedUsageType.and("quotatype", 
listAllIncludedUsageType.entity().getUsageType(), SearchCriteria.Op.EQ);
+listAllIncludedUsageType.done();
+}
+
+@Override
+public QuotaTariffVO findTariffPlanByUsageType(final int quotaType, 
final Date effectiveDate) {
+final short opendb = 
TransactionLegacy.currentTxn().getDatabaseId();
+List result = new ArrayList<>();
+try (TransactionLegacy txn = 
TransactionLegacy.open(TransactionLegacy.USAGE_DB)) {
+final Filter filter = new Filter(QuotaTariffVO.class, 
"effectiveOn", false, 0L, 1L);
+final SearchCriteria sc = 
listAllIncludedUsageType.create();
+sc.setParameters("onorbefore", effectiveDate);
+sc.setParameters("quotatype", quotaType);
+result = search(sc, filter);
+} catch (Exception e) {
+throw new CloudRuntimeException("Unable to find tariff plan by 
usage type");
+} finally {
+TransactionLegacy.open(opendb).close();
+}
+if (result.size() > 0) {
+if (s_logger.isDebugEnabled()){
+
s_logger.debug("QuotaTariffDaoImpl::findTariffPlanByUsageType: " + 
effectiveDate + "quota type " + quotaType  + " val=" + 
result.get(0).getCurrencyValue());
+}
+return result.get(0);
+} else {
+if (s_logger.isDebugEnabled()){
+
s_logger.info("QuotaTariffDaoImpl::findTariffPlanByUsageType: Missing quota 
type " + quotaType);
+}
+return null;
+}
+}
+
+@Override
+public List listAllTariffPlans(final Date 
effectiveDate) {
+final short opendb = 
TransactionLegacy.currentTxn().getDatabaseId();
+List tariffs = new ArrayList();
+try (TransactionLegacy txn = 
TransactionLegacy.open(TransactionLegacy.USAGE_DB)) {
+final Filter filter = new Filter(QuotaTariffVO.class, 
"effectiveOn", false, 0L, 1L);
+final SearchCrit

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41826854
  
--- Diff: 
framework/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java ---
@@ -0,0 +1,81 @@
+//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 org.apache.cloudstack.quota.dao;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.TransactionLegacy;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Component
+@Local(value = { QuotaUsageDao.class })
+public class QuotaUsageDaoImpl extends GenericDaoBase 
implements QuotaUsageDao {
+private static final Logger s_logger = 
Logger.getLogger(QuotaUsageDaoImpl.class.getName());
+
+@Override
+public BigDecimal findTotalQuotaUsage(final Long accountId, final Long 
domainId, final Integer usageType, final Date startDate, final Date endDate) {
+List quotaUsage = findQuotaUsage(accountId, 
domainId, null, startDate, endDate);
+BigDecimal total = new BigDecimal(0);
+for (QuotaUsageVO quotaRecord: quotaUsage) {
+total = total.add(quotaRecord.getQuotaUsed());
+}
+return total;
+}
+
+@SuppressWarnings("deprecation")
+@Override
+public List findQuotaUsage(final Long accountId, final 
Long domainId, final Integer usageType, final Date startDate, final Date 
endDate) {
+final short opendb = 
TransactionLegacy.currentTxn().getDatabaseId();
+List quotaUsageRecords = new 
ArrayList();
+try (TransactionLegacy txn = 
TransactionLegacy.open(TransactionLegacy.USAGE_DB)) {
+// TODO instead of max value query with reasonable number and 
iterate
+SearchCriteria sc = createSearchCriteria();
+if (accountId != null) {
+sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
+}
+if (domainId != null) {
+sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
+}
+if (usageType != null) {
+sc.addAnd("usageType", SearchCriteria.Op.EQ, usageType);
+}
+if ((startDate != null) && (endDate != null) && 
startDate.before(endDate)) {
+sc.addAnd("startDate", SearchCriteria.Op.BETWEEN, 
startDate, endDate);
+sc.addAnd("endDate", SearchCriteria.Op.BETWEEN, startDate, 
endDate);
+} else {
+return new ArrayList();
+}
+quotaUsageRecords = listBy(sc);
+} catch (Exception e) {
+s_logger.error("QuotaUsageDaoImpl::findQuotaUsage() failed due 
to: " + e.getMessage());
--- End diff --

All error call should have exception passed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827227
  
--- Diff: 
framework/quota/src/org/apache/cloudstack/quota/dao/ServiceOfferingDaoImpl.java 
---
@@ -0,0 +1,86 @@
+// 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 org.apache.cloudstack.quota.dao;
+
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+import org.apache.cloudstack.quota.vo.ServiceOfferingVO;
+
+import com.cloud.event.UsageEventVO;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.TransactionLegacy;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Component
+@Local(value = { ServiceOfferingDao.class })
+@DB()
+public class ServiceOfferingDaoImpl extends 
GenericDaoBase implements ServiceOfferingDao {
+protected static final Logger s_logger = 
Logger.getLogger(ServiceOfferingDaoImpl.class);
+
+@Inject
+UserVmDetailsDao userVmDetailsDao;
+
+@Override
+public ServiceOfferingVO findServiceOffering(final Long vmId, final 
long serviceOfferingId) {
+final short opendb = 
TransactionLegacy.currentTxn().getDatabaseId();
+ServiceOfferingVO result = null;
+try (TransactionLegacy txn = 
TransactionLegacy.open(TransactionLegacy.CLOUD_DB)) {
+result = findById(vmId, serviceOfferingId);
+} catch (Exception e) {
+s_logger.error("Quota 
ServiceOfferingDaoImpl::findServiceOffering() failed due to: " + 
e.getMessage());
+throw new CloudRuntimeException("Unable to find service 
offering for quota calculations");
+} finally {
+TransactionLegacy.open(opendb).close();
+}
+return result;
+}
+
+private ServiceOfferingVO findById(Long vmId, long serviceOfferingId) {
+ServiceOfferingVO offering = super.findById(serviceOfferingId);
+if (offering.isDynamic()) {
+if (vmId == null) {
+throw new CloudRuntimeException("missing argument vmId");
+}
+offering.setDynamicFlag(true);
+Map dynamicOffering = 
userVmDetailsDao.listDetailsKeyPairs(vmId);
+return getcomputeOffering(offering, dynamicOffering);
+}
+return offering;
+}
+
+private ServiceOfferingVO getcomputeOffering(ServiceOfferingVO 
serviceOffering, Map customParameters) {
--- End diff --

Yes, it should be. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827287
  
--- Diff: 
framework/quota/src/org/apache/cloudstack/quota/dao/UserVmDetailsDaoImpl.java 
---
@@ -0,0 +1,62 @@
+// 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 org.apache.cloudstack.quota.dao;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+import org.apache.cloudstack.quota.vo.UserVmDetailVO;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value = UserVmDetailsDao.class)
+public class UserVmDetailsDaoImpl extends GenericDaoBase implements UserVmDetailsDao {
+private SearchBuilder AllFieldsSearch;
+
+public UserVmDetailsDaoImpl() {
+AllFieldsSearch = createSearchBuilder();
+AllFieldsSearch.and("resourceId", 
AllFieldsSearch.entity().getResourceId(), SearchCriteria.Op.EQ);
+AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), 
SearchCriteria.Op.EQ);
+AllFieldsSearch.and("value", AllFieldsSearch.entity().getValue(), 
SearchCriteria.Op.EQ);
+// FIXME SnapshotDetailsVO doesn't have a display field
--- End diff --

Yes it is fixed we can remove the 'if'.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827329
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java
 ---
@@ -0,0 +1,147 @@
+//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 org.apache.cloudstack.api.command;
+
+import com.cloud.user.Account;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.QuotaCreditsResponse;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.quota.QuotaService;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+
+@APICommand(name = "quotaCredits", responseObject = 
QuotaCreditsResponse.class, description = "Add +-credits to an account", since 
= "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class QuotaCreditsCmd extends BaseCmd {
+
+@Inject
+QuotaResponseBuilder _responseBuilder;
+
+@Inject
+QuotaService _quotaService;
+
+public static final Logger s_logger = 
Logger.getLogger(QuotaStatementCmd.class.getName());
+
+private static final String s_name = "quotacreditsresponse";
+
+@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, 
required = true, description = "Account Id for which quota credits need to be 
added")
+private String accountName;
+
+@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, 
required = true, entityType = DomainResponse.class, description = "Domain for 
which quota credits need to be added")
+private Long domainId;
+
+@Parameter(name = ApiConstants.VALUE, type = CommandType.DOUBLE, 
required = true, description = "Value of the credits to be added+, subtracted-")
+private Double value;
+
+@Parameter(name = "min_balance", type = CommandType.DOUBLE, required = 
false, description = "Minimum balance threshold of the account")
+private Double minBalance;
+
+@Parameter(name = "quota_enforce", type = CommandType.BOOLEAN, 
required = false, description = "Account for which quota enforce is set to 
false will not be locked when there is no credit balance")
+private Boolean quotaEnforce;
+
+public Double getMinBalance() {
+return minBalance;
+}
+
+public void setMinBalance(Double minBalance) {
+this.minBalance = minBalance;
+}
+
+public Boolean getQuotaEnforce() {
+return quotaEnforce;
+}
+
+public void setQuotaEnforce(Boolean quotaEnforce) {
+this.quotaEnforce = quotaEnforce;
+}
+
+public String getAccountName() {
+return accountName;
+}
+
+public void setAccountName(String accountName) {
+this.accountName = accountName;
+}
+
+public Long getDomainId() {
+return domainId;
+}
+
+public void setDomainId(Long domainId) {
+this.domainId = domainId;
+}
+
+public Double getValue() {
+return value;
+}
+
+public void setValue(Double value) {
+this.value = value;
+}
+
+public QuotaCreditsCmd() {
+super();
+}
+
+@Override
+public String getCommandName() {
+return s_name;
+}
+
+@Override
+public void execute() {
+Long accountId = nul

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827414
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,422 @@
+//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 org.apache.cloudstack.api.response;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountVO;
+import com.cloud.user.User;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.user.dao.UserDao;
+import com.cloud.utils.db.TransactionLegacy;
+
+import org.apache.cloudstack.api.command.QuotaBalanceCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd;
+import org.apache.cloudstack.api.command.QuotaStatementCmd;
+import org.apache.cloudstack.api.command.QuotaTariffListCmd;
+import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd;
+import org.apache.cloudstack.quota.QuotaService;
+import org.apache.cloudstack.quota.constant.QuotaConfig;
+import org.apache.cloudstack.quota.constant.QuotaTypes;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaCreditsDao;
+import org.apache.cloudstack.quota.dao.QuotaEmailTemplatesDao;
+import org.apache.cloudstack.quota.dao.QuotaTariffDao;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaCreditsVO;
+import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.region.RegionManager;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+@Component
+@Local(value = QuotaResponseBuilderImpl.class)
+public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
+private static final Logger s_logger = 
Logger.getLogger(QuotaResponseBuilderImpl.class.getName());
+
+@Inject
+private QuotaTariffDao _quotaTariffDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private QuotaCreditsDao _quotaCreditsDao;
+@Inject
+private QuotaEmailTemplatesDao _quotaEmailTemplateDao;
+
+@Inject
+private UserDao _userDao;
+@Inject
+private QuotaService _quotaService;
+@Inject
+AccountDao _accountDao;
+@Inject
+private RegionManager _regionMgr;
+
+@Override
+public QuotaTariffResponse createQuotaTariffResponse(QuotaTariffVO 
tariff) {
+final QuotaTariffResponse response = new QuotaTariffResponse();
+response.setUsageType(tariff.getUsageType());
+response.setUsageName(tariff.getUsageName());
+response.setUsageUnit(tariff.getUsageUnit());
+response.setUsageDiscriminator(tariff.getUsageDiscriminator());
+response.setTariffValue(tariff.getCurrencyValue());
+response.setEffectiveOn(tariff.getEffectiveOn());
+response.setDescription(tariff.getDescription());
+response.setCurrency(QuotaConfig.QuotaCurrencySymbol.value());
+return response;
+}
+
+@Override
+public QuotaBalanceResponse 
createQuotaBalanceResponse(List quotaBalance, Date startDate, 
Date endDate) {
+if (quotaBalance == null || quotaBalance.size() == 0) {

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827531
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,422 @@
+//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 org.apache.cloudstack.api.response;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountVO;
+import com.cloud.user.User;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.user.dao.UserDao;
+import com.cloud.utils.db.TransactionLegacy;
+
+import org.apache.cloudstack.api.command.QuotaBalanceCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd;
+import org.apache.cloudstack.api.command.QuotaStatementCmd;
+import org.apache.cloudstack.api.command.QuotaTariffListCmd;
+import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd;
+import org.apache.cloudstack.quota.QuotaService;
+import org.apache.cloudstack.quota.constant.QuotaConfig;
+import org.apache.cloudstack.quota.constant.QuotaTypes;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaCreditsDao;
+import org.apache.cloudstack.quota.dao.QuotaEmailTemplatesDao;
+import org.apache.cloudstack.quota.dao.QuotaTariffDao;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaCreditsVO;
+import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.region.RegionManager;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+@Component
+@Local(value = QuotaResponseBuilderImpl.class)
+public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
+private static final Logger s_logger = 
Logger.getLogger(QuotaResponseBuilderImpl.class.getName());
+
+@Inject
+private QuotaTariffDao _quotaTariffDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private QuotaCreditsDao _quotaCreditsDao;
+@Inject
+private QuotaEmailTemplatesDao _quotaEmailTemplateDao;
+
+@Inject
+private UserDao _userDao;
+@Inject
+private QuotaService _quotaService;
+@Inject
+AccountDao _accountDao;
+@Inject
+private RegionManager _regionMgr;
+
+@Override
+public QuotaTariffResponse createQuotaTariffResponse(QuotaTariffVO 
tariff) {
+final QuotaTariffResponse response = new QuotaTariffResponse();
+response.setUsageType(tariff.getUsageType());
+response.setUsageName(tariff.getUsageName());
+response.setUsageUnit(tariff.getUsageUnit());
+response.setUsageDiscriminator(tariff.getUsageDiscriminator());
+response.setTariffValue(tariff.getCurrencyValue());
+response.setEffectiveOn(tariff.getEffectiveOn());
+response.setDescription(tariff.getDescription());
+response.setCurrency(QuotaConfig.QuotaCurrencySymbol.value());
+return response;
+}
+
+@Override
+public QuotaBalanceResponse 
createQuotaBalanceResponse(List quotaBalance, Date startDate, 
Date endDate) {
+if (quotaBalance == null || quotaBalance.size() == 0) {

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827559
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,422 @@
+//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 org.apache.cloudstack.api.response;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountVO;
+import com.cloud.user.User;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.user.dao.UserDao;
+import com.cloud.utils.db.TransactionLegacy;
+
+import org.apache.cloudstack.api.command.QuotaBalanceCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd;
+import org.apache.cloudstack.api.command.QuotaStatementCmd;
+import org.apache.cloudstack.api.command.QuotaTariffListCmd;
+import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd;
+import org.apache.cloudstack.quota.QuotaService;
+import org.apache.cloudstack.quota.constant.QuotaConfig;
+import org.apache.cloudstack.quota.constant.QuotaTypes;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaCreditsDao;
+import org.apache.cloudstack.quota.dao.QuotaEmailTemplatesDao;
+import org.apache.cloudstack.quota.dao.QuotaTariffDao;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaCreditsVO;
+import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.region.RegionManager;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+@Component
+@Local(value = QuotaResponseBuilderImpl.class)
+public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
+private static final Logger s_logger = 
Logger.getLogger(QuotaResponseBuilderImpl.class.getName());
+
+@Inject
+private QuotaTariffDao _quotaTariffDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private QuotaCreditsDao _quotaCreditsDao;
+@Inject
+private QuotaEmailTemplatesDao _quotaEmailTemplateDao;
+
+@Inject
+private UserDao _userDao;
+@Inject
+private QuotaService _quotaService;
+@Inject
+AccountDao _accountDao;
+@Inject
+private RegionManager _regionMgr;
+
+@Override
+public QuotaTariffResponse createQuotaTariffResponse(QuotaTariffVO 
tariff) {
+final QuotaTariffResponse response = new QuotaTariffResponse();
+response.setUsageType(tariff.getUsageType());
+response.setUsageName(tariff.getUsageName());
+response.setUsageUnit(tariff.getUsageUnit());
+response.setUsageDiscriminator(tariff.getUsageDiscriminator());
+response.setTariffValue(tariff.getCurrencyValue());
+response.setEffectiveOn(tariff.getEffectiveOn());
+response.setDescription(tariff.getDescription());
+response.setCurrency(QuotaConfig.QuotaCurrencySymbol.value());
+return response;
+}
+
+@Override
+public QuotaBalanceResponse 
createQuotaBalanceResponse(List quotaBalance, Date startDate, 
Date endDate) {
+if (quotaBalance == null || quotaBalance.size() == 0) {

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827602
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,422 @@
+//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 org.apache.cloudstack.api.response;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountVO;
+import com.cloud.user.User;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.user.dao.UserDao;
+import com.cloud.utils.db.TransactionLegacy;
+
+import org.apache.cloudstack.api.command.QuotaBalanceCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd;
+import org.apache.cloudstack.api.command.QuotaStatementCmd;
+import org.apache.cloudstack.api.command.QuotaTariffListCmd;
+import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd;
+import org.apache.cloudstack.quota.QuotaService;
+import org.apache.cloudstack.quota.constant.QuotaConfig;
+import org.apache.cloudstack.quota.constant.QuotaTypes;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaCreditsDao;
+import org.apache.cloudstack.quota.dao.QuotaEmailTemplatesDao;
+import org.apache.cloudstack.quota.dao.QuotaTariffDao;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaCreditsVO;
+import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.region.RegionManager;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+@Component
+@Local(value = QuotaResponseBuilderImpl.class)
+public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
+private static final Logger s_logger = 
Logger.getLogger(QuotaResponseBuilderImpl.class.getName());
+
+@Inject
+private QuotaTariffDao _quotaTariffDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private QuotaCreditsDao _quotaCreditsDao;
+@Inject
+private QuotaEmailTemplatesDao _quotaEmailTemplateDao;
+
+@Inject
+private UserDao _userDao;
+@Inject
+private QuotaService _quotaService;
+@Inject
+AccountDao _accountDao;
+@Inject
+private RegionManager _regionMgr;
+
+@Override
+public QuotaTariffResponse createQuotaTariffResponse(QuotaTariffVO 
tariff) {
+final QuotaTariffResponse response = new QuotaTariffResponse();
+response.setUsageType(tariff.getUsageType());
+response.setUsageName(tariff.getUsageName());
+response.setUsageUnit(tariff.getUsageUnit());
+response.setUsageDiscriminator(tariff.getUsageDiscriminator());
+response.setTariffValue(tariff.getCurrencyValue());
+response.setEffectiveOn(tariff.getEffectiveOn());
+response.setDescription(tariff.getDescription());
+response.setCurrency(QuotaConfig.QuotaCurrencySymbol.value());
+return response;
+}
+
+@Override
+public QuotaBalanceResponse 
createQuotaBalanceResponse(List quotaBalance, Date startDate, 
Date endDate) {
+if (quotaBalance == null || quotaBalance.size() == 0) {

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827702
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,422 @@
+//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 org.apache.cloudstack.api.response;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountVO;
+import com.cloud.user.User;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.user.dao.UserDao;
+import com.cloud.utils.db.TransactionLegacy;
+
+import org.apache.cloudstack.api.command.QuotaBalanceCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd;
+import org.apache.cloudstack.api.command.QuotaStatementCmd;
+import org.apache.cloudstack.api.command.QuotaTariffListCmd;
+import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd;
+import org.apache.cloudstack.quota.QuotaService;
+import org.apache.cloudstack.quota.constant.QuotaConfig;
+import org.apache.cloudstack.quota.constant.QuotaTypes;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaCreditsDao;
+import org.apache.cloudstack.quota.dao.QuotaEmailTemplatesDao;
+import org.apache.cloudstack.quota.dao.QuotaTariffDao;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaCreditsVO;
+import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.region.RegionManager;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+@Component
+@Local(value = QuotaResponseBuilderImpl.class)
+public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
+private static final Logger s_logger = 
Logger.getLogger(QuotaResponseBuilderImpl.class.getName());
+
+@Inject
+private QuotaTariffDao _quotaTariffDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private QuotaCreditsDao _quotaCreditsDao;
+@Inject
+private QuotaEmailTemplatesDao _quotaEmailTemplateDao;
+
+@Inject
+private UserDao _userDao;
+@Inject
+private QuotaService _quotaService;
+@Inject
+AccountDao _accountDao;
+@Inject
+private RegionManager _regionMgr;
+
+@Override
+public QuotaTariffResponse createQuotaTariffResponse(QuotaTariffVO 
tariff) {
+final QuotaTariffResponse response = new QuotaTariffResponse();
+response.setUsageType(tariff.getUsageType());
+response.setUsageName(tariff.getUsageName());
+response.setUsageUnit(tariff.getUsageUnit());
+response.setUsageDiscriminator(tariff.getUsageDiscriminator());
+response.setTariffValue(tariff.getCurrencyValue());
+response.setEffectiveOn(tariff.getEffectiveOn());
+response.setDescription(tariff.getDescription());
+response.setCurrency(QuotaConfig.QuotaCurrencySymbol.value());
+return response;
+}
+
+@Override
+public QuotaBalanceResponse 
createQuotaBalanceResponse(List quotaBalance, Date startDate, 
Date endDate) {
+if (quotaBalance == null || quotaBalance.size() == 0) {

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827796
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaStatementResponse.java
 ---
@@ -0,0 +1,130 @@
+//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 org.apache.cloudstack.api.response;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.BaseResponse;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.Date;
+import java.util.List;
+
+public class QuotaStatementResponse  extends BaseResponse {
+
+@SerializedName("accountid")
+@Param(description = "account id")
+private Long accountId;
+
+@SerializedName("account")
+@Param(description = "account name")
+private String accountName;
+
+@SerializedName("domain")
+@Param(description = "domain id")
+private Long domainId;
+
+@SerializedName("quotausage")
+@Param(description = "list of quota usage under various types", 
responseObject = QuotaStatementItemResponse.class)
+private List lineItem;
+
+@SerializedName("totalquota")
+@Param(description = "total quota used during this period")
+private BigDecimal totalQuota;
+
+@SerializedName("startdate")
+@Param(description = "start date")
+private Date startDate = null;
+
+@SerializedName("enddate")
+@Param(description = "end date")
+private Date endDate = null;
+
+@SerializedName("currency")
+@Param(description = "currency")
+private String currency;
+
+public QuotaStatementResponse() {
--- End diff --

@jburwell spring issues, though i agree, may require another 6 months to 
fix.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827959
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,304 @@
+//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 org.apache.cloudstack.quota;
+
+import com.cloud.configuration.Config;
+import com.cloud.domain.dao.DomainDao;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.TransactionLegacy;
+
+import org.apache.cloudstack.api.command.QuotaBalanceCmd;
+import org.apache.cloudstack.api.command.QuotaCreditsCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd;
+import org.apache.cloudstack.api.command.QuotaStatementCmd;
+import org.apache.cloudstack.api.command.QuotaTariffListCmd;
+import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.Configurable;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.quota.constant.QuotaConfig;
+import org.apache.cloudstack.quota.dao.QuotaAccountDao;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaUsageDao;
+import org.apache.cloudstack.quota.vo.QuotaAccountVO;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.utils.usage.UsageUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+@Component
+@Local(value = QuotaService.class)
+public class QuotaServiceImpl extends ManagerBase implements QuotaService, 
Configurable, QuotaConfig {
+private static final Logger s_logger = 
Logger.getLogger(QuotaServiceImpl.class.getName());
+
+@Inject
+private AccountDao _accountDao;
+@Inject
+private QuotaAccountDao _quotaAcc;
+@Inject
+private QuotaUsageDao _quotaUsageDao;
+@Inject
+private DomainDao _domainDao;
+@Inject
+private ConfigurationDao _configDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private QuotaResponseBuilder _respBldr;
+
+private TimeZone _usageTimezone;
+private int _aggregationDuration = 0;
+
+final static BigDecimal s_hoursInMonth = new BigDecimal(30 * 24);
+final static BigDecimal s_minutesInMonth = new BigDecimal(30 * 24 * 
60);
+final static BigDecimal s_gb = new BigDecimal(1024 * 1024 * 1024);
+
+public QuotaServiceImpl() {
+super();
+}
+
+@Override
+public boolean configure(String name, Map params) 
throws ConfigurationException {
+super.configure(name, params);
+String timeZoneStr = 
_configDao.getValue(Config.UsageAggregationTimezone.toString());
+String aggregationRange = 
_configDao.getValue(Config.UsageStatsJobAggregationRange.toString());
+if (timeZoneStr == null) {
+timeZoneStr = "GMT";
+}
+_usageT

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827948
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,304 @@
+//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 org.apache.cloudstack.quota;
+
+import com.cloud.configuration.Config;
+import com.cloud.domain.dao.DomainDao;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.TransactionLegacy;
+
+import org.apache.cloudstack.api.command.QuotaBalanceCmd;
+import org.apache.cloudstack.api.command.QuotaCreditsCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd;
+import org.apache.cloudstack.api.command.QuotaStatementCmd;
+import org.apache.cloudstack.api.command.QuotaTariffListCmd;
+import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.Configurable;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.quota.constant.QuotaConfig;
+import org.apache.cloudstack.quota.dao.QuotaAccountDao;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaUsageDao;
+import org.apache.cloudstack.quota.vo.QuotaAccountVO;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.utils.usage.UsageUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+@Component
+@Local(value = QuotaService.class)
+public class QuotaServiceImpl extends ManagerBase implements QuotaService, 
Configurable, QuotaConfig {
+private static final Logger s_logger = 
Logger.getLogger(QuotaServiceImpl.class.getName());
+
+@Inject
+private AccountDao _accountDao;
+@Inject
+private QuotaAccountDao _quotaAcc;
+@Inject
+private QuotaUsageDao _quotaUsageDao;
+@Inject
+private DomainDao _domainDao;
+@Inject
+private ConfigurationDao _configDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private QuotaResponseBuilder _respBldr;
+
+private TimeZone _usageTimezone;
+private int _aggregationDuration = 0;
+
+final static BigDecimal s_hoursInMonth = new BigDecimal(30 * 24);
+final static BigDecimal s_minutesInMonth = new BigDecimal(30 * 24 * 
60);
+final static BigDecimal s_gb = new BigDecimal(1024 * 1024 * 1024);
+
+public QuotaServiceImpl() {
+super();
+}
+
+@Override
+public boolean configure(String name, Map params) 
throws ConfigurationException {
+super.configure(name, params);
+String timeZoneStr = 
_configDao.getValue(Config.UsageAggregationTimezone.toString());
+String aggregationRange = 
_configDao.getValue(Config.UsageStatsJobAggregationRange.toString());
+if (timeZoneStr == null) {
+timeZoneStr = "GMT";
+}
+_usageT

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41827968
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,304 @@
+//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 org.apache.cloudstack.quota;
+
+import com.cloud.configuration.Config;
+import com.cloud.domain.dao.DomainDao;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.TransactionLegacy;
+
+import org.apache.cloudstack.api.command.QuotaBalanceCmd;
+import org.apache.cloudstack.api.command.QuotaCreditsCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd;
+import org.apache.cloudstack.api.command.QuotaStatementCmd;
+import org.apache.cloudstack.api.command.QuotaTariffListCmd;
+import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.Configurable;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.quota.constant.QuotaConfig;
+import org.apache.cloudstack.quota.dao.QuotaAccountDao;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaUsageDao;
+import org.apache.cloudstack.quota.vo.QuotaAccountVO;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.utils.usage.UsageUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+@Component
+@Local(value = QuotaService.class)
+public class QuotaServiceImpl extends ManagerBase implements QuotaService, 
Configurable, QuotaConfig {
+private static final Logger s_logger = 
Logger.getLogger(QuotaServiceImpl.class.getName());
+
+@Inject
+private AccountDao _accountDao;
+@Inject
+private QuotaAccountDao _quotaAcc;
+@Inject
+private QuotaUsageDao _quotaUsageDao;
+@Inject
+private DomainDao _domainDao;
+@Inject
+private ConfigurationDao _configDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private QuotaResponseBuilder _respBldr;
+
+private TimeZone _usageTimezone;
+private int _aggregationDuration = 0;
+
+final static BigDecimal s_hoursInMonth = new BigDecimal(30 * 24);
+final static BigDecimal s_minutesInMonth = new BigDecimal(30 * 24 * 
60);
+final static BigDecimal s_gb = new BigDecimal(1024 * 1024 * 1024);
+
+public QuotaServiceImpl() {
+super();
+}
+
+@Override
+public boolean configure(String name, Map params) 
throws ConfigurationException {
+super.configure(name, params);
+String timeZoneStr = 
_configDao.getValue(Config.UsageAggregationTimezone.toString());
+String aggregationRange = 
_configDao.getValue(Config.UsageStatsJobAggregationRange.toString());
+if (timeZoneStr == null) {
+timeZoneStr = "GMT";
+}
+_usageT

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41828072
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,304 @@
+//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 org.apache.cloudstack.quota;
+
+import com.cloud.configuration.Config;
+import com.cloud.domain.dao.DomainDao;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.TransactionLegacy;
+
+import org.apache.cloudstack.api.command.QuotaBalanceCmd;
+import org.apache.cloudstack.api.command.QuotaCreditsCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd;
+import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd;
+import org.apache.cloudstack.api.command.QuotaStatementCmd;
+import org.apache.cloudstack.api.command.QuotaTariffListCmd;
+import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.Configurable;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.quota.constant.QuotaConfig;
+import org.apache.cloudstack.quota.dao.QuotaAccountDao;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaUsageDao;
+import org.apache.cloudstack.quota.vo.QuotaAccountVO;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.utils.usage.UsageUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+@Component
+@Local(value = QuotaService.class)
+public class QuotaServiceImpl extends ManagerBase implements QuotaService, 
Configurable, QuotaConfig {
+private static final Logger s_logger = 
Logger.getLogger(QuotaServiceImpl.class.getName());
+
+@Inject
+private AccountDao _accountDao;
+@Inject
+private QuotaAccountDao _quotaAcc;
+@Inject
+private QuotaUsageDao _quotaUsageDao;
+@Inject
+private DomainDao _domainDao;
+@Inject
+private ConfigurationDao _configDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private QuotaResponseBuilder _respBldr;
+
+private TimeZone _usageTimezone;
+private int _aggregationDuration = 0;
+
+final static BigDecimal s_hoursInMonth = new BigDecimal(30 * 24);
+final static BigDecimal s_minutesInMonth = new BigDecimal(30 * 24 * 
60);
+final static BigDecimal s_gb = new BigDecimal(1024 * 1024 * 1024);
+
+public QuotaServiceImpl() {
+super();
+}
+
+@Override
+public boolean configure(String name, Map params) 
throws ConfigurationException {
+super.configure(name, params);
+String timeZoneStr = 
_configDao.getValue(Config.UsageAggregationTimezone.toString());
+String aggregationRange = 
_configDao.getValue(Config.UsageStatsJobAggregationRange.toString());
+if (timeZoneStr == null) {
+timeZoneStr = "GMT";
+}
+_usageT

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41828093
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java 
---
@@ -0,0 +1,444 @@
+//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 org.apache.cloudstack.quota;
+
+import com.cloud.domain.DomainVO;
+import com.cloud.domain.dao.DomainDao;
+import com.cloud.user.Account;
+import com.cloud.user.Account.State;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.user.dao.UserDao;
+import com.cloud.utils.DateUtil;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.TransactionLegacy;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.sun.mail.smtp.SMTPMessage;
+import com.sun.mail.smtp.SMTPSSLTransport;
+import com.sun.mail.smtp.SMTPTransport;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.quota.constant.QuotaConfig;
+import 
org.apache.cloudstack.quota.constant.QuotaConfig.QuotaEmailTemplateTypes;
+import org.apache.cloudstack.quota.dao.QuotaAccountDao;
+import org.apache.cloudstack.quota.dao.QuotaEmailTemplatesDao;
+import org.apache.cloudstack.quota.dao.QuotaUsageDao;
+import org.apache.cloudstack.quota.vo.QuotaAccountVO;
+import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO;
+import org.apache.commons.lang3.text.StrSubstitutor;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.mail.Authenticator;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.URLName;
+import javax.mail.internet.InternetAddress;
+import javax.naming.ConfigurationException;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+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.Properties;
+import java.util.concurrent.TimeUnit;
+
+@Component
+@Local(value = QuotaAlertManager.class)
+public class QuotaAlertManagerImpl extends ManagerBase implements 
QuotaAlertManager {
+private static final Logger s_logger = 
Logger.getLogger(QuotaAlertManagerImpl.class.getName());
+
+@Inject
+private AccountDao _accountDao;
+@Inject
+private QuotaAccountDao _quotaAcc;
+@Inject
+private UserDao _userDao;
+@Inject
+private DomainDao _domainDao;
+@Inject
+private QuotaEmailTemplatesDao _quotaEmailTemplateDao;
+@Inject
+private ConfigurationDao _configDao;
+@Inject
+private QuotaUsageDao _quotaUsage;
+
+private EmailQuotaAlert _emailQuotaAlert;
+private boolean _lockAccountEnforcement = false;
+
+final static BigDecimal s_hoursInMonth = new BigDecimal(30 * 24);
+final static BigDecimal s_minutesInMonth = new BigDecimal(30 * 24 * 
60);
+final static BigDecimal s_gb = new BigDecimal(1024 * 1024 * 1024);
+
+boolean _smtpDebug = false;
+
+int _pid = 0;
+
+public QuotaAlertManagerImpl() {
+super();
+}
+
+private void mergeConfigs(Map dbParams, Map xmlParams) {
+for (Map.Entry param : xmlParams.entrySet()) {
+dbParams.put(param.getKey(), (String) param.getValue());
+}
+}
+
+@Override
+public boolean configure(String name, Map params) 
throws ConfigurationException {
+super.configure(name, params);
+
+Map configs = _configDao.getConfiguration(params);
+
+  

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41828125
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaManagerImpl.java ---
@@ -0,0 +1,397 @@
+//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 org.apache.cloudstack.quota;
--- End diff --

yes should be done.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41828171
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaManagerImpl.java ---
@@ -0,0 +1,397 @@
+//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 org.apache.cloudstack.quota;
+
+import com.cloud.usage.UsageVO;
+import com.cloud.usage.dao.UsageDao;
+import com.cloud.user.AccountVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.TransactionLegacy;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.quota.constant.QuotaTypes;
+import org.apache.cloudstack.quota.dao.QuotaAccountDao;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaTariffDao;
+import org.apache.cloudstack.quota.dao.QuotaUsageDao;
+import org.apache.cloudstack.quota.dao.ServiceOfferingDao;
+import org.apache.cloudstack.quota.vo.QuotaAccountVO;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.quota.vo.ServiceOfferingVO;
+import org.apache.cloudstack.utils.usage.UsageUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+@Component
+@Local(value = QuotaManager.class)
+public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
+private static final Logger s_logger = 
Logger.getLogger(QuotaManagerImpl.class.getName());
+
+@Inject
+private AccountDao _accountDao;
+@Inject
+private QuotaAccountDao _quotaAcc;
+@Inject
+private UsageDao _usageDao;
+@Inject
+private QuotaTariffDao _quotaTariffDao;
+@Inject
+private QuotaUsageDao _quotaUsageDao;
+@Inject
+private ServiceOfferingDao _serviceOfferingDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private ConfigurationDao _configDao;
+
+private TimeZone _usageTimezone;
+private int _aggregationDuration = 0;
+
+final static BigDecimal s_hoursInMonth = new BigDecimal(30 * 24);
+final static BigDecimal s_minutesInMonth = new BigDecimal(30 * 24 * 
60);
+final static BigDecimal s_gb = new BigDecimal(1024 * 1024 * 1024);
+
+int _pid = 0;
+
+public QuotaManagerImpl() {
+super();
+}
+
+private void mergeConfigs(Map dbParams, Map xmlParams) {
+for (Map.Entry param : xmlParams.entrySet()) {
+dbParams.put(param.getKey(), (String) param.getValue());
+}
+}
+
+@Override
+public boolean configure(String name, Map params) 
throws ConfigurationException {
+super.configure(name, params);
+
+Map configs = _configDao.getConfiguration(params);
+
+if (params != null) {
+mergeConfigs(configs, params);
+}
+
+String aggregationRange = 
configs.get("usage.stats.job.aggregation.range");
+String timeZoneStr = configs.get("usage.aggregation.timezone");
+
+if (timeZoneStr == null) {
+timeZoneStr = "GMT";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
+
+_aggregationDuration = Integer.parseInt(aggregationRange);
+if (_aggregatio

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41828178
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaManagerImpl.java ---
@@ -0,0 +1,397 @@
+//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 org.apache.cloudstack.quota;
+
+import com.cloud.usage.UsageVO;
+import com.cloud.usage.dao.UsageDao;
+import com.cloud.user.AccountVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.TransactionLegacy;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.quota.constant.QuotaTypes;
+import org.apache.cloudstack.quota.dao.QuotaAccountDao;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaTariffDao;
+import org.apache.cloudstack.quota.dao.QuotaUsageDao;
+import org.apache.cloudstack.quota.dao.ServiceOfferingDao;
+import org.apache.cloudstack.quota.vo.QuotaAccountVO;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.quota.vo.ServiceOfferingVO;
+import org.apache.cloudstack.utils.usage.UsageUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+@Component
+@Local(value = QuotaManager.class)
+public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
+private static final Logger s_logger = 
Logger.getLogger(QuotaManagerImpl.class.getName());
+
+@Inject
+private AccountDao _accountDao;
+@Inject
+private QuotaAccountDao _quotaAcc;
+@Inject
+private UsageDao _usageDao;
+@Inject
+private QuotaTariffDao _quotaTariffDao;
+@Inject
+private QuotaUsageDao _quotaUsageDao;
+@Inject
+private ServiceOfferingDao _serviceOfferingDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private ConfigurationDao _configDao;
+
+private TimeZone _usageTimezone;
+private int _aggregationDuration = 0;
+
+final static BigDecimal s_hoursInMonth = new BigDecimal(30 * 24);
+final static BigDecimal s_minutesInMonth = new BigDecimal(30 * 24 * 
60);
+final static BigDecimal s_gb = new BigDecimal(1024 * 1024 * 1024);
+
+int _pid = 0;
+
+public QuotaManagerImpl() {
+super();
+}
+
+private void mergeConfigs(Map dbParams, Map xmlParams) {
+for (Map.Entry param : xmlParams.entrySet()) {
+dbParams.put(param.getKey(), (String) param.getValue());
+}
+}
+
+@Override
+public boolean configure(String name, Map params) 
throws ConfigurationException {
+super.configure(name, params);
+
+Map configs = _configDao.getConfiguration(params);
+
+if (params != null) {
+mergeConfigs(configs, params);
+}
+
+String aggregationRange = 
configs.get("usage.stats.job.aggregation.range");
+String timeZoneStr = configs.get("usage.aggregation.timezone");
+
+if (timeZoneStr == null) {
+timeZoneStr = "GMT";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
+
+_aggregationDuration = Integer.parseInt(aggregationRange);
+if (_aggregatio

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41828218
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaManagerImpl.java ---
@@ -0,0 +1,397 @@
+//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 org.apache.cloudstack.quota;
+
+import com.cloud.usage.UsageVO;
+import com.cloud.usage.dao.UsageDao;
+import com.cloud.user.AccountVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.TransactionLegacy;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.quota.constant.QuotaTypes;
+import org.apache.cloudstack.quota.dao.QuotaAccountDao;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaTariffDao;
+import org.apache.cloudstack.quota.dao.QuotaUsageDao;
+import org.apache.cloudstack.quota.dao.ServiceOfferingDao;
+import org.apache.cloudstack.quota.vo.QuotaAccountVO;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.quota.vo.ServiceOfferingVO;
+import org.apache.cloudstack.utils.usage.UsageUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+@Component
+@Local(value = QuotaManager.class)
+public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
+private static final Logger s_logger = 
Logger.getLogger(QuotaManagerImpl.class.getName());
+
+@Inject
+private AccountDao _accountDao;
+@Inject
+private QuotaAccountDao _quotaAcc;
+@Inject
+private UsageDao _usageDao;
+@Inject
+private QuotaTariffDao _quotaTariffDao;
+@Inject
+private QuotaUsageDao _quotaUsageDao;
+@Inject
+private ServiceOfferingDao _serviceOfferingDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private ConfigurationDao _configDao;
+
+private TimeZone _usageTimezone;
+private int _aggregationDuration = 0;
+
+final static BigDecimal s_hoursInMonth = new BigDecimal(30 * 24);
+final static BigDecimal s_minutesInMonth = new BigDecimal(30 * 24 * 
60);
+final static BigDecimal s_gb = new BigDecimal(1024 * 1024 * 1024);
+
+int _pid = 0;
+
+public QuotaManagerImpl() {
+super();
+}
+
+private void mergeConfigs(Map dbParams, Map xmlParams) {
+for (Map.Entry param : xmlParams.entrySet()) {
+dbParams.put(param.getKey(), (String) param.getValue());
+}
+}
+
+@Override
+public boolean configure(String name, Map params) 
throws ConfigurationException {
+super.configure(name, params);
+
+Map configs = _configDao.getConfiguration(params);
+
+if (params != null) {
+mergeConfigs(configs, params);
+}
+
+String aggregationRange = 
configs.get("usage.stats.job.aggregation.range");
+String timeZoneStr = configs.get("usage.aggregation.timezone");
+
+if (timeZoneStr == null) {
+timeZoneStr = "GMT";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
+
+_aggregationDuration = Integer.parseInt(aggregationRange);
+if (_aggregatio

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41828211
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaManagerImpl.java ---
@@ -0,0 +1,397 @@
+//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 org.apache.cloudstack.quota;
+
+import com.cloud.usage.UsageVO;
+import com.cloud.usage.dao.UsageDao;
+import com.cloud.user.AccountVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.TransactionLegacy;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.quota.constant.QuotaTypes;
+import org.apache.cloudstack.quota.dao.QuotaAccountDao;
+import org.apache.cloudstack.quota.dao.QuotaBalanceDao;
+import org.apache.cloudstack.quota.dao.QuotaTariffDao;
+import org.apache.cloudstack.quota.dao.QuotaUsageDao;
+import org.apache.cloudstack.quota.dao.ServiceOfferingDao;
+import org.apache.cloudstack.quota.vo.QuotaAccountVO;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+import org.apache.cloudstack.quota.vo.ServiceOfferingVO;
+import org.apache.cloudstack.utils.usage.UsageUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+@Component
+@Local(value = QuotaManager.class)
+public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
+private static final Logger s_logger = 
Logger.getLogger(QuotaManagerImpl.class.getName());
+
+@Inject
+private AccountDao _accountDao;
+@Inject
+private QuotaAccountDao _quotaAcc;
+@Inject
+private UsageDao _usageDao;
+@Inject
+private QuotaTariffDao _quotaTariffDao;
+@Inject
+private QuotaUsageDao _quotaUsageDao;
+@Inject
+private ServiceOfferingDao _serviceOfferingDao;
+@Inject
+private QuotaBalanceDao _quotaBalanceDao;
+@Inject
+private ConfigurationDao _configDao;
+
+private TimeZone _usageTimezone;
+private int _aggregationDuration = 0;
+
+final static BigDecimal s_hoursInMonth = new BigDecimal(30 * 24);
+final static BigDecimal s_minutesInMonth = new BigDecimal(30 * 24 * 
60);
+final static BigDecimal s_gb = new BigDecimal(1024 * 1024 * 1024);
+
+int _pid = 0;
+
+public QuotaManagerImpl() {
+super();
+}
+
+private void mergeConfigs(Map dbParams, Map xmlParams) {
+for (Map.Entry param : xmlParams.entrySet()) {
+dbParams.put(param.getKey(), (String) param.getValue());
+}
+}
+
+@Override
+public boolean configure(String name, Map params) 
throws ConfigurationException {
+super.configure(name, params);
+
+Map configs = _configDao.getConfiguration(params);
+
+if (params != null) {
+mergeConfigs(configs, params);
+}
+
+String aggregationRange = 
configs.get("usage.stats.job.aggregation.range");
+String timeZoneStr = configs.get("usage.aggregation.timezone");
+
+if (timeZoneStr == null) {
+timeZoneStr = "GMT";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
+
+_aggregationDuration = Integer.parseInt(aggregationRange);
+if (_aggregatio

[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41828262
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java
 ---
@@ -0,0 +1,132 @@
+//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 org.apache.cloudstack.api.command;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.AccountResponse;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.QuotaBalanceResponse;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.api.response.QuotaStatementItemResponse;
+
+import com.cloud.user.Account;
+
+@APICommand(name = "quotaBalance", responseObject = 
QuotaStatementItemResponse.class, description = "Create a quota balance 
statement", since = "4.6.0", requestHasSensitiveInfo = false, 
responseHasSensitiveInfo = false)
+public class QuotaBalanceCmd extends BaseCmd {
--- End diff --

@jburwell can you comment if project needs to be accounted for ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41828291
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java
 ---
@@ -0,0 +1,132 @@
+//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 org.apache.cloudstack.api.command;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.AccountResponse;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.QuotaBalanceResponse;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+import org.apache.cloudstack.api.response.QuotaStatementItemResponse;
+
+import com.cloud.user.Account;
+
+@APICommand(name = "quotaBalance", responseObject = 
QuotaStatementItemResponse.class, description = "Create a quota balance 
statement", since = "4.6.0", requestHasSensitiveInfo = false, 
responseHasSensitiveInfo = false)
+public class QuotaBalanceCmd extends BaseCmd {
--- End diff --

@pdube at this point quota is not calculated for projects but yes it is an 
interesting thing to add - showing quota per project.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request: Quota

2015-10-12 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/768#discussion_r41828868
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java
 ---
@@ -0,0 +1,147 @@
+//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 org.apache.cloudstack.api.command;
+
+import com.cloud.user.Account;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.QuotaCreditsResponse;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.quota.QuotaService;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+
+@APICommand(name = "quotaCredits", responseObject = 
QuotaCreditsResponse.class, description = "Add +-credits to an account", since 
= "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class QuotaCreditsCmd extends BaseCmd {
+
+@Inject
+QuotaResponseBuilder _responseBuilder;
+
+@Inject
+QuotaService _quotaService;
+
+public static final Logger s_logger = 
Logger.getLogger(QuotaStatementCmd.class);
+
+private static final String s_name = "quotacreditsresponse";
+
+@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, 
required = true, description = "Account Id for which quota credits need to be 
added")
+private String accountName;
+
+@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, 
required = true, entityType = DomainResponse.class, description = "Domain for 
which quota credits need to be added")
+private Long domainId;
+
+@Parameter(name = ApiConstants.VALUE, type = CommandType.DOUBLE, 
required = true, description = "Value of the credits to be added+, subtracted-")
+private Double value;
+
+@Parameter(name = "min_balance", type = CommandType.DOUBLE, required = 
false, description = "Minimum balance threshold of the account")
+private Double minBalance;
+
+@Parameter(name = "quota_enforce", type = CommandType.BOOLEAN, 
required = false, description = "Account for which quota enforce is set to 
false will not be locked when there is no credit balance")
+private Boolean quotaEnforce;
+
+public Double getMinBalance() {
+return minBalance;
+}
+
+public void setMinBalance(Double minBalance) {
+this.minBalance = minBalance;
+}
+
+public Boolean getQuotaEnforce() {
+return quotaEnforce;
+}
+
+public void setQuotaEnforce(Boolean quotaEnforce) {
+this.quotaEnforce = quotaEnforce;
+}
+
+public String getAccountName() {
+return accountName;
+}
+
+public void setAccountName(String accountName) {
+this.accountName = accountName;
+}
+
+public Long getDomainId() {
+return domainId;
+}
+
+public void setDomainId(Long domainId) {
+this.domainId = domainId;
+}
+
+public Double getValue() {
+return value;
+}
+
+public void setValue(Double value) {
+this.value = value;
+}
+
+public QuotaCreditsCmd() {
+super();
+}
+
+@Override
+public String getCommandName() {
+return s_name;
+}
+
+@Override
+public void execute() {
+Long accountId = nul

  1   2   3   4   5   >