[GitHub] cloudstack pull request: CLOUDSTACK-8755: xs-tools.iso missing fro...

2015-08-25 Thread shwetaag
Github user shwetaag commented on the pull request:

https://github.com/apache/cloudstack/pull/727#issuecomment-134504724
  
Result information : 

Test delete ISO ... === TestName: test_07_list_default_iso | Status : 
SUCCESS ===
ok

--
Ran 1 test in 384.111s

OK



---
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: CLOUDSTACK-8766: Fix infinite scrolling p...

2015-08-25 Thread karuturi
Github user karuturi commented on the pull request:

https://github.com/apache/cloudstack/pull/740#issuecomment-134504869
  
What is the page size? can you attach a screenshot?


---
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: CLOUDSTACK-8766: Fix infinite scrolling p...

2015-08-25 Thread bhaisaab
Github user bhaisaab commented on the pull request:

https://github.com/apache/cloudstack/pull/740#issuecomment-134508369
  
@karuturi the sharedFunctions.js defines a global pagesize (fixed to value 
20)

See in the screenshot; the listTemplates call does not call the API with a 
page, pagesize - this causes the infinite scroll to flood the list every time 
to drag it if the number of zones exceed what could fit in that table view. 
This patch fixes that.

![screen shot 2015-08-25 at 12 50 04 
pm](https://cloud.githubusercontent.com/assets/95203/9460948/0a3c198c-4b28-11e5-9a2e-af0b260633e6.png)



---
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: CLOUDSTACK-8766: Fix infinite scrolling p...

2015-08-25 Thread bhaisaab
Github user bhaisaab commented on the pull request:

https://github.com/apache/cloudstack/pull/740#issuecomment-134509669
  
@karuturi this is the screenshot from chrome devtools with the UI fix, as 
you can see pagination is implemented

![screenshot from 2015-08-25 12 54 
50](https://cloud.githubusercontent.com/assets/95203/9461039/b216fe2e-4b28-11e5-8e45-be8c557c1bb0.png)



---
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.
---


Re: review wanted

2015-08-25 Thread sebgoa

On Aug 25, 2015, at 12:41 AM, Rafael Weingärtner  
wrote:

> Hi Daan,
> I think that we should do a proper introduction.
> It might seem kind of odd to some people that a bunch of folks suddenly
> started working for free.
> 
> Our first PR was done a while ago:
> https://github.com/apache/cloudstack/pull/560. Then we did
> https://github.com/apache/cloudstack/pull/700, and the last one was the
> https://github.com/apache/cloudstack/pull/714, that is still in the review
> process.
> 
> Until now you know Pedro (PR 714) and Critofolini (PR 700), but we are a
> team of five. We work under the same project and the improvements/clean ups
> that we have been doing to the ACS is a way we found to improve our
> knowledge of the software that we are using.
> 
> I am a Ph. D. candidate, researching/developing autonomic models that can
> be used to manage and optimize a cloud computing environment that provide
> infrastructure as a service. We have done an extensive work comparing and
> discussing cloud computing orchestration platforms that are most widely
> used. CloudStack was the orchestration tool chosen to develop my proposals,
> in order to test and validate them.
> 
> I have several undergrad students working with me; none of them had real
> experience developing java web applications, the PRs we are creating is the
> way we found to teach them some Java developing skills, while getting to
> know a little better of ACS core and architecture. At the same time we are
> contributing to the software we use.
> 
> The team that works with me and you will probably see creating more PRs is
> the following:
> 
>   - Gabriel Beims Bräscher
>   - Pedro Henrique Pereira Martins
>   - Lucas Berri Cristofolini
>   - Alexandre Santana
> 
> 
> All of them are Computer Science student. They all are developing their
> graduation projects within my thesis.  Sadly, some of the things we are
> doing here and that we have already prototyped, we cannot commit to the ACS
> community (at least not yet); hence it is part of a thesis project.
> However, once we start publishing papers, I think you will like what we
> have been working on.
> 
> Hope we can keep up the good work and keep learning with you all guys from
> the ACS community.
> Waiting to hear the feedbacks on PR 714 ;)
> 
> 

Hi Rafael, thanks a lot for the introduction. That's exactly the type of 
commitment that the community needs.

We will look out for PRs from this group and hopefully will benefit from your 
thesis work at a latter date.

Welcome,

-sebastien


> On Sat, Aug 22, 2015 at 1:10 AM, Daan Hoogland 
> wrote:
>> 
>> everybody, I will LGTM PR #714 [1] and I would like to have more then one
>> extra pair of eyes this time. Some group of folks, I know there is at
> least
>> three of them, have decided to invest in cleaning some code in CS and I
>> think their work deserves full attention. they worked on refactoring some
>> of the CitrixResourceBase hierarchy [2] and now they are busy on the
>> ComponentLifecycleBase
>> hierarchy.
>> 
>> Please have a look,
>> 
>> [1] https://github.com/apache/cloudstack/pull/714
>> [2] https://github.com/apache/cloudstack/pull/700
>> 
>> --
>> Daan
> 
> 
> 
> 
> --
> Rafael Weingärtner



Re: review wanted

2015-08-25 Thread Daan Hoogland
Thanks Rafael, I had no idea of the formation and origin of the group and
your introduction as well as your contributions are very welcome.

On Tue, Aug 25, 2015 at 9:40 AM, sebgoa  wrote:

>
> On Aug 25, 2015, at 12:41 AM, Rafael Weingärtner <
> rafaelweingart...@gmail.com> wrote:
>
> > Hi Daan,
> > I think that we should do a proper introduction.
> > It might seem kind of odd to some people that a bunch of folks suddenly
> > started working for free.
> >
> > Our first PR was done a while ago:
> > https://github.com/apache/cloudstack/pull/560. Then we did
> > https://github.com/apache/cloudstack/pull/700, and the last one was the
> > https://github.com/apache/cloudstack/pull/714, that is still in the
> review
> > process.
> >
> > Until now you know Pedro (PR 714) and Critofolini (PR 700), but we are a
> > team of five. We work under the same project and the improvements/clean
> ups
> > that we have been doing to the ACS is a way we found to improve our
> > knowledge of the software that we are using.
> >
> > I am a Ph. D. candidate, researching/developing autonomic models that can
> > be used to manage and optimize a cloud computing environment that provide
> > infrastructure as a service. We have done an extensive work comparing and
> > discussing cloud computing orchestration platforms that are most widely
> > used. CloudStack was the orchestration tool chosen to develop my
> proposals,
> > in order to test and validate them.
> >
> > I have several undergrad students working with me; none of them had real
> > experience developing java web applications, the PRs we are creating is
> the
> > way we found to teach them some Java developing skills, while getting to
> > know a little better of ACS core and architecture. At the same time we
> are
> > contributing to the software we use.
> >
> > The team that works with me and you will probably see creating more PRs
> is
> > the following:
> >
> >   - Gabriel Beims Bräscher
> >   - Pedro Henrique Pereira Martins
> >   - Lucas Berri Cristofolini
> >   - Alexandre Santana
> >
> >
> > All of them are Computer Science student. They all are developing their
> > graduation projects within my thesis.  Sadly, some of the things we are
> > doing here and that we have already prototyped, we cannot commit to the
> ACS
> > community (at least not yet); hence it is part of a thesis project.
> > However, once we start publishing papers, I think you will like what we
> > have been working on.
> >
> > Hope we can keep up the good work and keep learning with you all guys
> from
> > the ACS community.
> > Waiting to hear the feedbacks on PR 714 ;)
> >
> >
>
> Hi Rafael, thanks a lot for the introduction. That's exactly the type of
> commitment that the community needs.
>
> We will look out for PRs from this group and hopefully will benefit from
> your thesis work at a latter date.
>
> Welcome,
>
> -sebastien
>
>
> > On Sat, Aug 22, 2015 at 1:10 AM, Daan Hoogland 
> > wrote:
> >>
> >> everybody, I will LGTM PR #714 [1] and I would like to have more then
> one
> >> extra pair of eyes this time. Some group of folks, I know there is at
> > least
> >> three of them, have decided to invest in cleaning some code in CS and I
> >> think their work deserves full attention. they worked on refactoring
> some
> >> of the CitrixResourceBase hierarchy [2] and now they are busy on the
> >> ComponentLifecycleBase
> >> hierarchy.
> >>
> >> Please have a look,
> >>
> >> [1] https://github.com/apache/cloudstack/pull/714
> >> [2] https://github.com/apache/cloudstack/pull/700
> >>
> >> --
> >> Daan
> >
> >
> >
> >
> > --
> > Rafael Weingärtner
>
>


-- 
Daan


Fwd: Returned post for annou...@cloudstack.apache.org

2015-08-25 Thread Daan Hoogland
Just now I got this message and realize that 4.4.4 has never been announced
as the mail (from d...@apache.org) had not been moderated. I did not see a
moderation mail. Anything that should have been done?

-- Forwarded message --
From: 
Date: Tue, Aug 25, 2015 at 7:07 AM
Subject: Returned post for annou...@cloudstack.apache.org
To: d...@apache.org



Hi! This is the ezmlm program. I'm managing the
annou...@cloudstack.apache.org mailing list.

I'm sorry, the list moderators for the announce list
have failed to act on your post. Thus, I'm returning it to you.
If you feel that this is in error, please repost the message
or contact a list moderator directly.

--- Enclosed, please find the message you sent.




-- Forwarded message --
From: Daan Hoogland 
To: annou...@cloudstack.apache.org, annou...@apache.org,
market...@cloudstack.apache.org, dev@cloudstack.apache.org,
us...@cloudstack.apache.org
Cc:
Date: Fri, 26 Jun 2015 13:53:58 +0200
Subject: {ANNOUNCE] Apache CloudSack 4.4.4 released
CloudStack v4.4.4 is a minor release with several fixes and backports.

A complete overview of all new enhancements can be found in the project
release notes at
http://docs.cloudstack.apache.org/projects/cloudstack-release-notes/en/4.4.4/

CloudStack v4.4.4 is available immediately as a free download from
http://cloudstack.apache.org/downloads.html. Apache CloudStack
software is released under the Apache License v2.0.

please meetup with us at

CloudStack Days Seattle 2015 , 20th August 2015,
http://events.linuxfoundation.org/events/cloudstack-seattle

and

CloudStack Collaboration Conference 2015 in Dublin, 8th and 9th of
October 2015, http://cloudstackcollab.org


kind regards,

-- 
Daan Hoogland





-- 
Daan


[GitHub] cloudstack pull request: CLOUDSTACK-8685: Fix for missing defaultr...

2015-08-25 Thread jayapalu
Github user jayapalu commented on the pull request:

https://github.com/apache/cloudstack/pull/738#issuecomment-134521171
  
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: CLOUDSTACK-8766: Fix infinite scrolling p...

2015-08-25 Thread karuturi
Github user karuturi commented on the pull request:

https://github.com/apache/cloudstack/pull/740#issuecomment-134522578
  
tested it and confirm the behaviour in the screenshots before and after the 
fix. :+1: 


---
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: CLOUDSTACK-8766: Fix infinite scrolling p...

2015-08-25 Thread karuturi
Github user karuturi commented on the pull request:

https://github.com/apache/cloudstack/pull/739#issuecomment-134522790
  
:+1:  as per #740 (I havent tested it on 4.5)


---
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: CLOUDSTACK-8443: Support CentOS 7 as KVM ...

2015-08-25 Thread remibergsma
Github user remibergsma commented on the pull request:

https://github.com/apache/cloudstack/pull/731#issuecomment-134523092
  
Thanks for testing and verifying @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: CLOUDSTACK-8443: Support CentOS 7 as KVM ...

2015-08-25 Thread asfgit
Github user asfgit closed the pull request at:

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


---
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: CLOUDSTACK-8766: Fix infinite scrolling p...

2015-08-25 Thread bhaisaab
Github user bhaisaab commented on the pull request:

https://github.com/apache/cloudstack/pull/739#issuecomment-134523852
  
thanks @karuturi the screenshots are from a 4.5 env, I've tested this on 4.5


---
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: CLOUDSTACK-8685: Fix for missing defaultr...

2015-08-25 Thread asfgit
Github user asfgit closed the pull request at:

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


---
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.
---


CCC Dublin Oct 8-9 2015

2015-08-25 Thread Sebastien Goasguen
It’s coming up fast,

http://events.linuxfoundation.org/events/cloudstack-collaboration-conference-europe

Register soon, so we can all share, collaborate and have fun

-sebastien

Re: review wanted

2015-08-25 Thread Remi Bergsma
Great! Welcome :-)

> On 25 Aug 2015, at 00:41, Rafael Weingärtner  
> wrote:
> 
> Hi Daan,
> I think that we should do a proper introduction.
> It might seem kind of odd to some people that a bunch of folks suddenly
> started working for free.
> 
> Our first PR was done a while ago:
> https://github.com/apache/cloudstack/pull/560. Then we did
> https://github.com/apache/cloudstack/pull/700, and the last one was the
> https://github.com/apache/cloudstack/pull/714, that is still in the review
> process.
> 
> Until now you know Pedro (PR 714) and Critofolini (PR 700), but we are a
> team of five. We work under the same project and the improvements/clean ups
> that we have been doing to the ACS is a way we found to improve our
> knowledge of the software that we are using.
> 
> I am a Ph. D. candidate, researching/developing autonomic models that can
> be used to manage and optimize a cloud computing environment that provide
> infrastructure as a service. We have done an extensive work comparing and
> discussing cloud computing orchestration platforms that are most widely
> used. CloudStack was the orchestration tool chosen to develop my proposals,
> in order to test and validate them.
> 
> I have several undergrad students working with me; none of them had real
> experience developing java web applications, the PRs we are creating is the
> way we found to teach them some Java developing skills, while getting to
> know a little better of ACS core and architecture. At the same time we are
> contributing to the software we use.
> 
> The team that works with me and you will probably see creating more PRs is
> the following:
> 
>   - Gabriel Beims Bräscher
>   - Pedro Henrique Pereira Martins
>   - Lucas Berri Cristofolini
>   - Alexandre Santana
> 
> 
> All of them are Computer Science student. They all are developing their
> graduation projects within my thesis.  Sadly, some of the things we are
> doing here and that we have already prototyped, we cannot commit to the ACS
> community (at least not yet); hence it is part of a thesis project.
> However, once we start publishing papers, I think you will like what we
> have been working on.
> 
> Hope we can keep up the good work and keep learning with you all guys from
> the ACS community.
> Waiting to hear the feedbacks on PR 714 ;)
> 
> 
> On Sat, Aug 22, 2015 at 1:10 AM, Daan Hoogland 
> wrote:
>> 
>> everybody, I will LGTM PR #714 [1] and I would like to have more then one
>> extra pair of eyes this time. Some group of folks, I know there is at
> least
>> three of them, have decided to invest in cleaning some code in CS and I
>> think their work deserves full attention. they worked on refactoring some
>> of the CitrixResourceBase hierarchy [2] and now they are busy on the
>> ComponentLifecycleBase
>> hierarchy.
>> 
>> Please have a look,
>> 
>> [1] https://github.com/apache/cloudstack/pull/714
>> [2] https://github.com/apache/cloudstack/pull/700
>> 
>> --
>> Daan
> 
> 
> 
> 
> --
> Rafael Weingärtner



[GitHub] cloudstack pull request: Made following fixes in simulator

2015-08-25 Thread koushik-das
GitHub user koushik-das opened a pull request:

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

Made following fixes in simulator

- Support for ScaleVmCommand/NetworkRulesVmSecondaryIpCommand in resource 
layer
- Added support for scaling up a running VM in simulator
- Fixed some method names not following convention

In order to test PR https://github.com/apache/cloudstack/pull/725 using 
simulator some of these changes are needed.

Based on the way HV check is present in the scale VM API, had to explicitly 
put simulator related check to allow support. The ideal way would be to remove 
all these HV specific check from code and made them some configuration (by 
putting them in hypervisor_capabilities table in DB). But that will be a bigger 
effort outside the scope of this PR.

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

$ git pull https://github.com/koushik-das/cloudstack simulator_fixes

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

https://github.com/apache/cloudstack/pull/741.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 #741


commit 86684cd4bc1966ffcc4b337641fc8bf814724eb1
Author: Koushik Das 
Date:   2015-08-25T09:22:48Z

Made following fixes in simulator
- Support for ScaleVmCommand/NetworkRulesVmSecondaryIpCommand in resource 
layer
- Added support for scaling up a running VM in simulator
- Fixed some method names not following convention




---
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.
---


Re: How does the parameter startdate/enddate of api listEvents() use new time format like 'yyyy-MM-dd HH:mm:ss' ?

2015-08-25 Thread Abhinandan Prateek
Yes, as per  
https://cloudstack.apache.org/api/apidocs-4.2/root_admin/listEvents.html


> On 24-Aug-2015, at 2:08 pm, tony_caot...@163.com wrote:
>
> Hello Every.
>
> I know this is a very simple question to most of you. but it is really hard 
> for me to continue my work.
>
> So could Anyone spend your three minutes to give me some advice, it will be 
> very usefull to me.
>
> my question is:
>
>How does the parameter startdate/enddate of api listEvents() use new time 
> format  like '-MM-dd HH:mm:ss' ?
>
>
> >>> Event({'listall':'True', 'startdate':'2015-08-24 00:00:00'})
> http://10.0.1.100:8080/client/api?apiKey=hjZ12EQ4JfFasIHO3RCXBLji-3RbBmdC973utGwCL5388WypVKwtaNsDso-JzVQIZXUVwfaT1vANdDUJs3Vkkg&command=listEvents&listall=True&response=json&startdate=2015-08-24+00%3A00%3A00&signature=z4LQCw7yzGmTK5B7TzAbzl1biXI%3D
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "SignedAPICall.py", line 67, in Event
>a = api.listEvents(request)
>  File "SignedAPICall.py", line 49, in handlerFunction
>return self._make_request(name, args[0])
>  File "SignedAPICall.py", line 61, in _make_request
>data = self._http_get(self.value)
>  File "SignedAPICall.py", line 54, in _http_get
>response = urllib.urlopen(url)
>  File "/usr/lib64/python2.7/urllib.py", line 87, in urlopen
>return opener.open(url)
>  File "/usr/lib64/python2.7/urllib.py", line 208, in open
>return getattr(self, name)(url)
>  File "/usr/lib64/python2.7/urllib.py", line 359, in open_http
>return self.http_error(url, fp, errcode, errmsg, headers)
>  File "/usr/lib64/python2.7/urllib.py", line 372, in http_error
>result = method(url, fp, errcode, errmsg, headers)
>  File "/usr/lib64/python2.7/urllib.py", line 683, in http_error_401
>errcode, errmsg, headers)
>  File "/usr/lib64/python2.7/urllib.py", line 381, in http_error_default
>raise IOError, ('http error', errcode, errmsg, headers)
> IOError: ('http error', 401, 'Unauthorized',  0x7f083da78998>)
>
> ---
> Cao Tong
>
> On 08/19/2015 10:32 AM, tony_caot...@163.com wrote:
>>
>> Hi All:
>>
>>Does any one have any idea ? Thanks.
>>
>> ---
>> Cao Tong
>>
>> On 08/18/2015 06:04 PM, tony_caot...@163.com wrote:
>>>
>>> In ParamProcessWorker::setFieldValue() I found this lins:
>>>
>>>   case DATE:
>>>// This piece of code is for maintaining backward 
>>> compatibility
>>>// and support both the date formats(Bug 9724)
>>>
>>> Is it related to my problem?  Where can I found the descriptions about 
>>> BUG9724 ?
>>>
>>> ---
>>> Cao Tong
>>>
>>> On 08/18/2015 05:54 PM, tony_caot...@163.com wrote:

 Hello,

 When I use timestamp format startdate="2015-07-31", it works find.
 When I use it like this startdate="2015-07-31 13:00:00".
 It return a error
 IOError: ('http error', 401, 'Unauthorized', >>> at 0x16dca70>)

 Could anyone tell me why ?

 I have read the code "DefaultLoginAPIAuthenticatorCmd::authenticate()" , 
 but I am still not understand what was happening,
 it seems authenticate failed, but why??

 ---
 Cao Tong

 On 07/31/2015 07:07 PM, tony_caot...@163.com wrote:
>
> Hi,
>
>was this format is enabled in ACS 4.5.1 like /"-MM-dd HH:mm:ss"
>
>
> /I found it in 4.5.0 API doc, but it seems not enabled.
>
> http://cloudstack.apache.org/api/apidocs-4.5/user/listEvents.html
>
>>>> api.listEvents(startdate="2015-07-31 13:00:00")
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "call.py", line 48, in handlerFunction
>return self._make_request(name, kwargs)
>  File "call.py", line 60, in _make_request
>data = self._http_get(self.value)
>  File "call.py", line 53, in _http_get
>response = urllib.urlopen(url)
>  File "/usr/lib64/python2.7/urllib.py", line 87, in urlopen
>return opener.open(url)
>  File "/usr/lib64/python2.7/urllib.py", line 208, in open
>return getattr(self, name)(url)
>  File "/usr/lib64/python2.7/urllib.py", line 359, in open_http
>return self.http_error(url, fp, errcode, errmsg, headers)
>  File "/usr/lib64/python2.7/urllib.py", line 372, in http_error
>result = method(url, fp, errcode, errmsg, headers)
>  File "/usr/lib64/python2.7/urllib.py", line 683, in http_error_401
>errcode, errmsg, headers)
>  File "/usr/lib64/python2.7/urllib.py", line 381, in http_error_default
>raise IOError, ('http error', errcode, errmsg, headers)
> IOError: ('http error', 401, 'Unauthorized',  instance at 0x16dca70>)
> >>>
>
>
> my ACS version:
>
> [root@cs ~]# rpm -qa |grep cloud
> cloudstack-management-4.5.1-shapeblue0.el6.x86_64
> cloudstack-awsapi-4.5.1-shapeblue0.el6.x86_64
> cloudstack-agent-4.5.1-shapeblue0.el6.x86_64
> cloudstack-common-4.5.1-shapeblue0.el6.x

Re: How does the parameter startdate/enddate of api listEvents() use new time format like 'yyyy-MM-dd HH:mm:ss' ?

2015-08-25 Thread Daan Hoogland
Tony/Cao Tong,


just as a guess and as I see you are chinese; the chacter between the date
and the time is a 32 (uri encoded %20)? Not sure if that is your problem
but it might be.

Looking at the stack trace you might as well want to look at the version of
your client library as it seems to refuse the format client side.


regards,
Daan

On Tue, Aug 25, 2015 at 12:16 PM, Abhinandan Prateek <
abhinandan.prat...@shapeblue.com> wrote:

> Yes, as per
> https://cloudstack.apache.org/api/apidocs-4.2/root_admin/listEvents.html
>
>
> > On 24-Aug-2015, at 2:08 pm, tony_caot...@163.com wrote:
> >
> > Hello Every.
> >
> > I know this is a very simple question to most of you. but it is really
> hard for me to continue my work.
> >
> > So could Anyone spend your three minutes to give me some advice, it will
> be very usefull to me.
> >
> > my question is:
> >
> >How does the parameter startdate/enddate of api listEvents() use new
> time format  like '-MM-dd HH:mm:ss' ?
> >
> >
> > >>> Event({'listall':'True', 'startdate':'2015-08-24 00:00:00'})
> >
> http://10.0.1.100:8080/client/api?apiKey=hjZ12EQ4JfFasIHO3RCXBLji-3RbBmdC973utGwCL5388WypVKwtaNsDso-JzVQIZXUVwfaT1vANdDUJs3Vkkg&command=listEvents&listall=True&response=json&startdate=2015-08-24+00%3A00%3A00&signature=z4LQCw7yzGmTK5B7TzAbzl1biXI%3D
> > Traceback (most recent call last):
> >  File "", line 1, in 
> >  File "SignedAPICall.py", line 67, in Event
> >a = api.listEvents(request)
> >  File "SignedAPICall.py", line 49, in handlerFunction
> >return self._make_request(name, args[0])
> >  File "SignedAPICall.py", line 61, in _make_request
> >data = self._http_get(self.value)
> >  File "SignedAPICall.py", line 54, in _http_get
> >response = urllib.urlopen(url)
> >  File "/usr/lib64/python2.7/urllib.py", line 87, in urlopen
> >return opener.open(url)
> >  File "/usr/lib64/python2.7/urllib.py", line 208, in open
> >return getattr(self, name)(url)
> >  File "/usr/lib64/python2.7/urllib.py", line 359, in open_http
> >return self.http_error(url, fp, errcode, errmsg, headers)
> >  File "/usr/lib64/python2.7/urllib.py", line 372, in http_error
> >result = method(url, fp, errcode, errmsg, headers)
> >  File "/usr/lib64/python2.7/urllib.py", line 683, in http_error_401
> >errcode, errmsg, headers)
> >  File "/usr/lib64/python2.7/urllib.py", line 381, in http_error_default
> >raise IOError, ('http error', errcode, errmsg, headers)
> > IOError: ('http error', 401, 'Unauthorized',  instance at 0x7f083da78998>)
> >
> > ---
> > Cao Tong
> >
> > On 08/19/2015 10:32 AM, tony_caot...@163.com wrote:
> >>
> >> Hi All:
> >>
> >>Does any one have any idea ? Thanks.
> >>
> >> ---
> >> Cao Tong
> >>
> >> On 08/18/2015 06:04 PM, tony_caot...@163.com wrote:
> >>>
> >>> In ParamProcessWorker::setFieldValue() I found this lins:
> >>>
> >>>   case DATE:
> >>>// This piece of code is for maintaining backward
> compatibility
> >>>// and support both the date formats(Bug 9724)
> >>>
> >>> Is it related to my problem?  Where can I found the descriptions about
> BUG9724 ?
> >>>
> >>> ---
> >>> Cao Tong
> >>>
> >>> On 08/18/2015 05:54 PM, tony_caot...@163.com wrote:
> 
>  Hello,
> 
>  When I use timestamp format startdate="2015-07-31", it works find.
>  When I use it like this startdate="2015-07-31 13:00:00".
>  It return a error
>  IOError: ('http error', 401, 'Unauthorized',  instance at 0x16dca70>)
> 
>  Could anyone tell me why ?
> 
>  I have read the code
> "DefaultLoginAPIAuthenticatorCmd::authenticate()" , but I am still not
> understand what was happening,
>  it seems authenticate failed, but why??
> 
>  ---
>  Cao Tong
> 
>  On 07/31/2015 07:07 PM, tony_caot...@163.com wrote:
> >
> > Hi,
> >
> >was this format is enabled in ACS 4.5.1 like /"-MM-dd
> HH:mm:ss"
> >
> >
> > /I found it in 4.5.0 API doc, but it seems not enabled.
> >
> > http://cloudstack.apache.org/api/apidocs-4.5/user/listEvents.html
> >
> >>>> api.listEvents(startdate="2015-07-31 13:00:00")
> > Traceback (most recent call last):
> >  File "", line 1, in 
> >  File "call.py", line 48, in handlerFunction
> >return self._make_request(name, kwargs)
> >  File "call.py", line 60, in _make_request
> >data = self._http_get(self.value)
> >  File "call.py", line 53, in _http_get
> >response = urllib.urlopen(url)
> >  File "/usr/lib64/python2.7/urllib.py", line 87, in urlopen
> >return opener.open(url)
> >  File "/usr/lib64/python2.7/urllib.py", line 208, in open
> >return getattr(self, name)(url)
> >  File "/usr/lib64/python2.7/urllib.py", line 359, in open_http
> >return self.http_error(url, fp, errcode, errmsg, headers)
> >  File "/usr/lib64/python2.7/urllib.py", line 372, in http_error
> >resul

[GitHub] cloudstack pull request: CLOUDSTACK-5863: revert volume snapshot f...

2015-08-25 Thread milamberspace
Github user milamberspace commented on the pull request:

https://github.com/apache/cloudstack/pull/732#issuecomment-134553590
  
LGTM to me too.

Tested on a master test deployment (Ubuntu 14.04 / KVM / NFS)
Success with a manual snapshot from cloudmonkey and web ui
Success on bad condition (error message if the VM is running)


---
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: Made following fixes in simulator

2015-08-25 Thread bhaisaab
Github user bhaisaab commented on the pull request:

https://github.com/apache/cloudstack/pull/741#issuecomment-134556011
  
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: CLOUDSTACK-5863: revert volume snapshot f...

2015-08-25 Thread bhaisaab
Github user bhaisaab commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/732#discussion_r37854506
  
--- Diff: 
api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java 
---
@@ -91,7 +102,6 @@ public void execute() {
 boolean result = _snapshotService.revertSnapshot(getId());
 if (result) {
 SuccessResponse response = new 
SuccessResponse(getCommandName());
-response.setResponseName(getCommandName());
--- End diff --

this might cause API response 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: CLOUDSTACK-5863: revert volume snapshot f...

2015-08-25 Thread bhaisaab
Github user bhaisaab commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/732#discussion_r37854560
  
--- Diff: 
api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java 
---
@@ -31,25 +31,36 @@
 import org.apache.cloudstack.api.response.SnapshotResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.storage.Snapshot;
 import com.cloud.user.Account;
 
-@APICommand(name = "revertSnapshot", description = "revert a volume 
snapshot.", responseObject = SnapshotResponse.class, entityType = 
{Snapshot.class},
+@APICommand(name = "revertSnapshot", description = "revert a volume 
snapshot.", responseObject = SuccessResponse.class, entityType = 
{Snapshot.class},
--- End diff --

I think for API backward compatibility, please revert this to send 
SnapshotResponse as the responseobject, unless this really needs to be fixed 
(the older implementation got it wrong). Please comment.


---
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: CLOUDSTACK-5863: revert volume snapshot f...

2015-08-25 Thread bhaisaab
Github user bhaisaab commented on the pull request:

https://github.com/apache/cloudstack/pull/732#issuecomment-134558876
  
In general LGTM, please see if you could fix the response class and object 
of the API (pl see the comments).


---
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: CLOUDSTACK-8758: Handle redirects in comm...

2015-08-25 Thread snuf
Github user snuf commented on the pull request:

https://github.com/apache/cloudstack/pull/737#issuecomment-134558902
  
Wow, great code and tests!. Love what you did with the Restclient, will be 
using that for sure soon :).

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: CLOUDSTACK-8443: Support CentOS 7 as KVM ...

2015-08-25 Thread bhaisaab
Github user bhaisaab commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/731#discussion_r37855588
  
--- Diff: 
plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
 ---
@@ -699,17 +698,6 @@ public boolean configure(final String name, final 
Map params) th
 _hypervisorType = HypervisorType.KVM;
 }
 
-//Verify that cpu,cpuacct cgroups are not co-mounted
-if(HypervisorType.LXC.equals(getHypervisorType())){
--- End diff --

@kishankavala can you review this patch, it removes some of the cgroup 
setting stuff for LXC?


---
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: CLOUDSTACK-8765: fix vm migration failure...

2015-08-25 Thread remibergsma
Github user remibergsma commented on the pull request:

https://github.com/apache/cloudstack/pull/736#issuecomment-134567460
  
LGTM, tested deployment of 2 KVM hypervisors on CentOS 7 and could live 
migrate without 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: [Automation]Volume migration between pool...

2015-08-25 Thread nitt10prashant
GitHub user nitt10prashant opened a pull request:

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

[Automation]Volume migration between pools times out in ACS, but  but the 
migration completes on Xenserve


Ticket :CLOUDSTACK-8771

description:
Volume migration between pools times out in ACS, but the migration 
completes on Xenserver

steps:
-

test results

put storage in maintenance mode and start ha vm and check usage ... === 
TestName: test_migrate_volume_timeout | Status : SUCCESS ===
ok

--
Ran 1 test in 250.958s

OK


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

$ git pull https://github.com/nitt10prashant/cloudstack migrate_volume

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

https://github.com/apache/cloudstack/pull/742.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 #742


commit d7f1f4b0c0b95f127be8353854e8d3d1cb609fb6
Author: nitt10prashant 
Date:   2015-08-25T12:25:11Z

CLOUDSTACK-8771:[Automation]Volume migration between pools times out in 
ACS, but the migration completes on Xenserver

Adding descriptions




---
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: CLOUDSTACK-8758: Handle redirects in comm...

2015-08-25 Thread miguelaferreira
Github user miguelaferreira commented on the pull request:

https://github.com/apache/cloudstack/pull/737#issuecomment-134576306
  
Force pushed to fix typos in license header of file 
`utils/src/test/java/com/cloud/utils/rest/RESTServiceConnectorTest.java`


---
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: CLOUDSTACK-8758: Handle redirects in comm...

2015-08-25 Thread miguelaferreira
Github user miguelaferreira commented on the pull request:

https://github.com/apache/cloudstack/pull/737#issuecomment-134579465
  
Force pushed again to add the missing license headers.


---
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: CLOUDSTACK-8749: Add checks to prevent ma...

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/735#discussion_r37865908
  
--- Diff: 
plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
 ---
@@ -286,7 +287,11 @@ private void deleteExitingLinkLocalRouteTable(String 
linkLocalBr) {
 String[] lines = parser.getLines().split("\\n");
 for (String line : lines) {
 String[] tokens = line.split(" ");
-if (!tokens[2].equalsIgnoreCase(linkLocalBr)) {
+if (tokens != null && tokens.length < 2) {
+continue;
+}
+final String device = tokens[2];
+if (!Strings.isNullOrEmpty(device) && 
!device.equalsIgnoreCase(linkLocalBr)) {
--- End diff --

Reading through this block, it feels like lines 289-293 should be extracted 
to a private method:

```
static parseDevice(final String line) {
 final String[] tokens = line.split( " ");
 if (tokens != null && tokens.length < 2) {
return "";
 }
 
 final String device = tokens[2];
 return Strings.isNullOrEmpty(device) : " " ? device;
} 
```

The extraction of this method would not only shorten the 
deleteExitingLinkLocalLocalRoutetTable method, but clearly express the intent.  
It also allows a unit test to be written to verify that parsing works as 
expected for different types of input.


---
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: CLOUDSTACK-8749: Add checks to prevent ma...

2015-08-25 Thread jburwell
Github user jburwell commented on the pull request:

https://github.com/apache/cloudstack/pull/735#issuecomment-134591140
  
While it is a small nit and not expressly within the scope of this PR, 
could you fix the spelling mistake in the ``deleteExitingLinkLocalRouteTable`` 
name? 


---
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: CLOUDSTACK-8749: Add checks to prevent ma...

2015-08-25 Thread jburwell
Github user jburwell commented on the pull request:

https://github.com/apache/cloudstack/pull/733#issuecomment-134595147
  
See comments on PR #735 regarding extracting the parsing logic and unit 
testing.


---
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: CLOUDSTACK-8758: Handle redirects in comm...

2015-08-25 Thread miguelaferreira
Github user miguelaferreira commented on the pull request:

https://github.com/apache/cloudstack/pull/737#issuecomment-134595872
  
Force pushed again for two more license headers


---
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: CLOUDSTACK-8443: Support CentOS 7 as KVM ...

2015-08-25 Thread remibergsma
Github user remibergsma commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/731#discussion_r37874182
  
--- Diff: 
plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
 ---
@@ -699,17 +698,6 @@ public boolean configure(final String name, final 
Map params) th
 _hypervisorType = HypervisorType.KVM;
 }
 
-//Verify that cpu,cpuacct cgroups are not co-mounted
-if(HypervisorType.LXC.equals(getHypervisorType())){
--- End diff --

@bhaisaab I just tested LXC and it works just fine with the co-mounted 
cgroups. The problem this code works-around has been solved. I think we're fine.


---
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: CLOUDSTACK-8758: Handle redirects in comm...

2015-08-25 Thread miguelaferreira
Github user miguelaferreira commented on the pull request:

https://github.com/apache/cloudstack/pull/737#issuecomment-134632894
  
Force pushed again to fix NiciraNvp module structure refactoring that left 
out the resources configuration in pom.xml


---
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: CLOUDSTACK-8443: Support CentOS 7 as KVM ...

2015-08-25 Thread kishankavala
Github user kishankavala commented on the pull request:

https://github.com/apache/cloudstack/pull/731#issuecomment-134636230
  
@remibergsma changes looks fine. I would like to test it and get back to 
you, hopefully by tomorrow.


---
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: CLOUDSTACK-8443: Support CentOS 7 as KVM ...

2015-08-25 Thread remibergsma
Github user remibergsma commented on the pull request:

https://github.com/apache/cloudstack/pull/731#issuecomment-134664222
  
@kishankavala Thanks, that would be great! Let me know if I can be of any 
help.


---
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: CLOUDSTACK-8758: Handle redirects in comm...

2015-08-25 Thread remibergsma
Github user remibergsma commented on the pull request:

https://github.com/apache/cloudstack/pull/737#issuecomment-134695303
  
LGTM - Deployed a full stack Nicira environment: 3 controllers, a manager, 
a service node and 2 KVM hypervisors, all inside my development VM:

```
# virsh list
 IdName   State

 42nsxmgr1running
 43nsxcon1running
 44nsxsvc1running
 48kvm1   running
 49nsxcon2running
 50nsxcon3running
 52kvm2   running
 54cs1running
```

Then I ran the Marvin tests:

```
# nosetests --with-marvin 
--marvin-config=/data/shared/marvin/mct-zone1-kvm1-NVP.cfg -s -a 
tags=advanced,required_hardware=true 
test/integration/smoke/test_nicira_controller.py

test_01_nicira_controller 
(integration.smoke.test_nicira_controller.TestNiciraContoller) ... === 
TestName: test_01_nicira_controller | Status : SUCCESS ===
ok
Nicira clusters will redirect clients (in this case ACS) to the master 
node. ... === TestName: test_02_nicira_controller_redirect | Status : SUCCESS 
===
ok

--
Ran 2 tests in 766.910s

OK
```

BTW: The Marvin data center config file is available here: 
https://github.com/schubergphilis/MCT-shared/blob/master/marvin/mct-zone1-kvm1-NVP.cfg



---
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: CLOUDSTACK-8758: Handle redirects in comm...

2015-08-25 Thread remibergsma
Github user remibergsma commented on the pull request:

https://github.com/apache/cloudstack/pull/737#issuecomment-134699346
  
All builds are passing and we have 2xLGTM. Will merge it. Thanks 
@miguelaferreira !


---
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: CLOUDSTACK-8758: Handle redirects in comm...

2015-08-25 Thread asfgit
Github user asfgit closed the pull request at:

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


---
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: CLOUDSTACK-8757:FTP modules are not loade...

2015-08-25 Thread remibergsma
Github user remibergsma commented on the pull request:

https://github.com/apache/cloudstack/pull/729#issuecomment-134706080
  
@shwetaag Thanks. I was also able to run your test. Please change the 
title, see previous comment.

```
[root@cs2 cloudstack]# cat 
/tmp//MarvinLogs/test_escalations_routers_G3E8EO/results.txt
@desc: Verify FTP modules are loaded in VR of advance zone ... === 
TestName: test_01_FTPModulesInVR | Status : SUCCESS ===
ok

--
Ran 1 test in 415.669s

OK
```



---
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: CLOUDSTACK-8756:Incorrect guest os mappin...

2015-08-25 Thread remibergsma
Github user remibergsma commented on the pull request:

https://github.com/apache/cloudstack/pull/728#issuecomment-134706537
  
@shwetaag I have no VMware so cannot run this test. Is there any way to 
make the test more generic? 


---
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: CLOUDSTACK-8725 RVR functionality is brok...

2015-08-25 Thread remibergsma
Github user remibergsma commented on the pull request:

https://github.com/apache/cloudstack/pull/692#issuecomment-134707371
  
@bvbharatk Had a quick look and it seems to solve the problem. Can you 
please rebase against latest master so we can have a clean merge? Thanks!

@DaanHoogland Any more questions on this one?


---
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.
---


Re: How does the parameter startdate/enddate of api listEvents() use new time format like 'yyyy-MM-dd HH:mm:ss' ?

2015-08-25 Thread Yiping Zhang
Tony:

Your date format seems to be OK. I just tried on my cs 4.5.1 with cloudmonkey 
5.3.1:

(local) 🐵 > list events startdate='2015-08-25 15:20:00'
count = 1
event:
id = 983c0369-80f2-4431-801c-273bffd925e5
account = admin
created = 2015-08-25T15:29:54-0500
description = user has logged in from IP Address 10.0.248.86
domain = ROOT
domainid = 994ff03e-bb8f-11e4-b7d5-36d1d14da5e9
level = INFO
state = Completed
type = USER.LOGIN
username = admin
(local) 🐵 > 


So your problem is somewhere else.  Can you access other API’s with that 
apikey/secretkey pair ? What client are you using to make api calls ?  You gave 
stack trace from client side, what’s the error message in CloudStack logs say ?

Good luck

Yiping


On 8/25/15, 3:22 AM, "Daan Hoogland"  wrote:

>Tony/Cao Tong,
>
>
>just as a guess and as I see you are chinese; the chacter between the date
>and the time is a 32 (uri encoded %20)? Not sure if that is your problem
>but it might be.
>
>Looking at the stack trace you might as well want to look at the version of
>your client library as it seems to refuse the format client side.
>
>
>regards,
>Daan
>
>On Tue, Aug 25, 2015 at 12:16 PM, Abhinandan Prateek <
>abhinandan.prat...@shapeblue.com> wrote:
>
>> Yes, as per
>> https://cloudstack.apache.org/api/apidocs-4.2/root_admin/listEvents.html
>>
>>
>> > On 24-Aug-2015, at 2:08 pm, tony_caot...@163.com wrote:
>> >
>> > Hello Every.
>> >
>> > I know this is a very simple question to most of you. but it is really
>> hard for me to continue my work.
>> >
>> > So could Anyone spend your three minutes to give me some advice, it will
>> be very usefull to me.
>> >
>> > my question is:
>> >
>> >How does the parameter startdate/enddate of api listEvents() use new
>> time format  like '-MM-dd HH:mm:ss' ?
>> >
>> >
>> > >>> Event({'listall':'True', 'startdate':'2015-08-24 00:00:00'})
>> >
>> http://10.0.1.100:8080/client/api?apiKey=hjZ12EQ4JfFasIHO3RCXBLji-3RbBmdC973utGwCL5388WypVKwtaNsDso-JzVQIZXUVwfaT1vANdDUJs3Vkkg&command=listEvents&listall=True&response=json&startdate=2015-08-24+00%3A00%3A00&signature=z4LQCw7yzGmTK5B7TzAbzl1biXI%3D
>> > Traceback (most recent call last):
>> >  File "", line 1, in 
>> >  File "SignedAPICall.py", line 67, in Event
>> >a = api.listEvents(request)
>> >  File "SignedAPICall.py", line 49, in handlerFunction
>> >return self._make_request(name, args[0])
>> >  File "SignedAPICall.py", line 61, in _make_request
>> >data = self._http_get(self.value)
>> >  File "SignedAPICall.py", line 54, in _http_get
>> >response = urllib.urlopen(url)
>> >  File "/usr/lib64/python2.7/urllib.py", line 87, in urlopen
>> >return opener.open(url)
>> >  File "/usr/lib64/python2.7/urllib.py", line 208, in open
>> >return getattr(self, name)(url)
>> >  File "/usr/lib64/python2.7/urllib.py", line 359, in open_http
>> >return self.http_error(url, fp, errcode, errmsg, headers)
>> >  File "/usr/lib64/python2.7/urllib.py", line 372, in http_error
>> >result = method(url, fp, errcode, errmsg, headers)
>> >  File "/usr/lib64/python2.7/urllib.py", line 683, in http_error_401
>> >errcode, errmsg, headers)
>> >  File "/usr/lib64/python2.7/urllib.py", line 381, in http_error_default
>> >raise IOError, ('http error', errcode, errmsg, headers)
>> > IOError: ('http error', 401, 'Unauthorized', > instance at 0x7f083da78998>)
>> >
>> > ---
>> > Cao Tong
>> >
>> > On 08/19/2015 10:32 AM, tony_caot...@163.com wrote:
>> >>
>> >> Hi All:
>> >>
>> >>Does any one have any idea ? Thanks.
>> >>
>> >> ---
>> >> Cao Tong
>> >>
>> >> On 08/18/2015 06:04 PM, tony_caot...@163.com wrote:
>> >>>
>> >>> In ParamProcessWorker::setFieldValue() I found this lins:
>> >>>
>> >>>   case DATE:
>> >>>// This piece of code is for maintaining backward
>> compatibility
>> >>>// and support both the date formats(Bug 9724)
>> >>>
>> >>> Is it related to my problem?  Where can I found the descriptions about
>> BUG9724 ?
>> >>>
>> >>> ---
>> >>> Cao Tong
>> >>>
>> >>> On 08/18/2015 05:54 PM, tony_caot...@163.com wrote:
>> 
>>  Hello,
>> 
>>  When I use timestamp format startdate="2015-07-31", it works find.
>>  When I use it like this startdate="2015-07-31 13:00:00".
>>  It return a error
>>  IOError: ('http error', 401, 'Unauthorized', > instance at 0x16dca70>)
>> 
>>  Could anyone tell me why ?
>> 
>>  I have read the code
>> "DefaultLoginAPIAuthenticatorCmd::authenticate()" , but I am still not
>> understand what was happening,
>>  it seems authenticate failed, but why??
>> 
>>  ---
>>  Cao Tong
>> 
>>  On 07/31/2015 07:07 PM, tony_caot...@163.com wrote:
>> >
>> > Hi,
>> >
>> >was this format is enabled in ACS 4.5.1 like /"-MM-dd
>> HH:mm:ss"
>> >
>> >
>> > /I found it in 4.5.0 API doc, but it seems not enabled.
>> >
>> > http://cloudstack.apache.org/api/apidocs-4.5/user/

[GitHub] cloudstack pull request: CLOUDSTACK-5863: revert volume snapshot f...

2015-08-25 Thread karuturi
Github user karuturi commented on the pull request:

https://github.com/apache/cloudstack/pull/732#issuecomment-134820562
  
Can you add some tests please?


---
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: Removed unused agent command AttachVolume...

2015-08-25 Thread koushik-das
GitHub user koushik-das opened a pull request:

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

Removed unused agent command AttachVolumeCommand and corresponding an…

…swer AttachVolumeAnswer

These types are not used anywhere in the orchestration layer.

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

$ git pull https://github.com/koushik-das/cloudstack code_cleanup

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

https://github.com/apache/cloudstack/pull/743.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 #743


commit e1db6efc7457b79e2bad90ebf16ad04d74247215
Author: Koushik Das 
Date:   2015-08-26T04:20:23Z

Removed unused agent command AttachVolumeCommand and corresponding answer 
AttachVolumeAnswer




---
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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37946859
  
--- Diff: 
framework/quota/src/org/apache/cloudstack/quota/dao/ServiceOfferingDaoImpl.java 
---
@@ -0,0 +1,85 @@
+// 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();
+TransactionLegacy txn = 
TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
+ServiceOfferingVO result;
+try {
+result = findById(vmId, serviceOfferingId);
+} finally {
+txn.close();
+}
+TransactionLegacy.open(opendb).close();
+return result;
+}
+
+public ServiceOfferingVO findById(Long vmId, long serviceOfferingId) {
+ServiceOfferingVO offering = super.findById(serviceOfferingId);
+if (offering.isDynamic()) {
+offering.setDynamicFlag(true);
+if (vmId == null) {
+throw new CloudRuntimeException("missing argument vmId");
+}
--- End diff --

By convention, parameter checks should be at the top of the method to fail 
fast.  The ``com.google.common.base.Preconditions#checkArgument`` method 
provides a concise, syntactic sugar for checking arguments.


---
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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37946936
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java
 ---
@@ -0,0 +1,136 @@
+//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.2.0", requestHasSensitiveInfo = false, 
responseHasSensitiveInfo = false)
--- End diff --

The value of the ``since`` parameter should be ``4.6.0`` rather than 
``4.2.0``.


---
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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947002
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java
 ---
@@ -0,0 +1,136 @@
+//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.2.0", requestHasSensitiveInfo = false, 
responseHasSensitiveInfo = false)
+public class QuotaBalanceCmd extends BaseCmd {
+
+public static final Logger s_logger = 
Logger.getLogger(QuotaBalanceCmd.class.getName());
+
+private static final String s_name = "quotabalanceresponse";
+
+@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, 
required = true, description = "Optional, Account Id for which statement needs 
to be generated")
+private String accountName;
+
+@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, 
required = true, entityType = DomainResponse.class, description = "Optional, If 
domain Id is given and the caller is domain admin then the statement is 
generated for domain.")
+private Long domainId;
+
+@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, 
description = "End date range for quota query. Use -MM-dd as the date 
format, e.g. startDate=2009-06-03.")
+private Date endDate;
+
+@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, 
description = "Start date range quota query. Use -MM-dd as the date format, 
e.g. startDate=2009-06-01.")
+private Date startDate;
+
+@Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, 
entityType = AccountResponse.class, description = "List usage records for the 
specified account")
+private Long accountId;
+
+@Inject
+QuotaResponseBuilder _responseBuilder;
+
+public Long getAccountId() {
+return accountId;
+}
+
+public void setAccountId(Long accountId) {
+this.accountId = accountId;
+}
+
+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 Date getEndDate() {
+return endDate == null ? null : 
_responseBuilder.startOfNextDay(endDate);
+}
+
+public void setEndDate(Date endDate) {
+this.endDate = endDate;
+}
+
+public Date getStartDate() {
+return startDate;
+}
+
+public void setStartDate(Date startDate) {
+this.startDate = startDate;
+}
+
+public QuotaBalanceCmd() {
+super();
+}
+
+@Override
+public String getCommandName() {
+return s_name;
+}
+
+@Override
+public long getEnt

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947073
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilder.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.api.response;
+
+
+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.vo.QuotaBalanceVO;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+
+import java.util.Date;
+import java.util.List;
+
+public interface QuotaResponseBuilder {
+
+QuotaTariffVO updateQuotaTariffPlan(QuotaTariffUpdateCmd cmd);
+
+List listQuotaTariffPlans(QuotaTariffListCmd cmd);
+
+QuotaTariffResponse createQuotaTariffResponse(QuotaTariffVO 
configuration);
+
+QuotaStatementResponse createQuotaStatementResponse(List 
quotaUsage);
+
+QuotaBalanceResponse createQuotaBalanceResponse(List 
quotaUsage, Date startDate, Date endDate);
+
+QuotaBalanceResponse 
createQuotaLastBalanceResponse(List quotaBalance, Date 
startDate);
+
+QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId, 
Double amount, Long updatedBy, Date despositedOn);
+
+public List getQuotaUsage(QuotaStatementCmd cmd);
--- End diff --

The accessor modifier is unnecessary on an interface definition.


---
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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947136
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947139
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947194
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: CLOUDSTACK-8761: Replace some profiler.ge...

2015-08-25 Thread wilderrodrigues
Github user wilderrodrigues commented on the pull request:

https://github.com/apache/cloudstack/pull/730#issuecomment-134834411
  
@ustcweizhou is just calling the wrapper for the system in millis, which 
was added to the profiler. For the remaining cases, the nano time will be used 
(getDuration()).

His use of getDurationInMillis() looks good because inside the method I 
convert the nanoseconds to milliseconds:

(stopTickNanoSeconds - startTickNanoSeconds) / 
(long)Math.pow(MILLIS_FACTOR, EXPONENT);

LGTM :+1: 

Cheers,
Wilder


---
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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947237
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947252
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947294
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947297
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947561
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947679
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947704
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947741
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947791
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37947918
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37948373
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37948706
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37948797
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37948835
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
 ---
@@ -0,0 +1,419 @@
+//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.size() == 0) {
+new InvalidParameterValueException("The request period does 
not 

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37948903
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37948934
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37948942
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37948979
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949008
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949049
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949030
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949069
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949073
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949093
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949107
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949186
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949195
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949444
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZoneStr);
  

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949568
  
--- Diff: server/src/com/cloud/api/dispatch/ParamProcessWorker.java ---
@@ -294,6 +294,14 @@ private void setFieldValue(final Field field, final 
BaseCmd cmdObj, final Object
 field.set(cmdObj, Float.valueOf(paramObj.toString()));
 }
 break;
+case DOUBLE:
+// Assuming that the parameters have been checked for 
required before now,
+// we ignore blank or null values and defer to the command 
to set a default
+// value for optional parameters ...
+if (paramObj != null && isNotBlank(paramObj.toString())) {
--- End diff --

Consider using ``com.google.common.base.Strings#isNullorEmpty`` method 
which consolidates the null and blank checks.


---
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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949627
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java 
---
@@ -0,0 +1,471 @@
+//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.AccountManager;
--- End diff --

Please remove commented code as it builds up cruft.


---
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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949667
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java 
---
@@ -0,0 +1,471 @@
+//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.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.Account.State;
+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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949700
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java 
---
@@ -0,0 +1,471 @@
+//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.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.Account.State;
+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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949748
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java 
---
@@ -0,0 +1,471 @@
+//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.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.Account.State;
+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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949824
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java 
---
@@ -0,0 +1,471 @@
+//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.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.Account.State;
+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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949885
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java 
---
@@ -0,0 +1,471 @@
+//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.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.Account.State;
+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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37949858
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java 
---
@@ -0,0 +1,471 @@
+//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.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.Account.State;
+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 master

2015-08-25 Thread abhinandanprateek
Github user abhinandanprateek commented on the pull request:

https://github.com/apache/cloudstack/pull/689#issuecomment-134855999
  
@jburwell was looking at com.cloud.utils.db.Transaction class the db is 
hardcoded in there:

execute()
short databaseId = TransactionLegacy.CLOUD_DB;

I think whole revamping of transactions is a separate sub-project that we 
should work on and should not be clubbed with Quota changes.


---
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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37950136
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java 
---
@@ -0,0 +1,471 @@
+//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.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.Account.State;
+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: [Automation]Volume migration between pool...

2015-08-25 Thread sanju1010
Github user sanju1010 commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/742#discussion_r37950149
  
--- Diff: test/integration/component/maint/test_migrate_volume_timeout.py 
---
@@ -0,0 +1,286 @@
+#!/usr/bin/env python
+# 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.
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import (cleanup_resources,
+  validateList)
+from marvin.lib.base import (Account,
+ VirtualMachine,
+ ServiceOffering,
+ Cluster,
+ StoragePool,
+ Volume,
+ DiskOffering,
+ Configurations,
+ Zone)
+from marvin.lib.common import (get_zone,
+   get_domain,
+   get_template,
+   list_hosts,
+   find_storage_pool_type
+   )
+from marvin.codes import PASS
+from marvin.sshClient import SshClient
+from requests.exceptions import ConnectionError
+import time
+
+
+def restart_ms(self):
+"""Restart MS
+#1-ssh into m/c running MS
+#2-restart ms
+#3-verify the response
+#4-loop until you get list_zone api answer """
+sshClient = SshClient(
+self.mgtSvrDetails["mgtSvrIp"],
+22,
+self.mgtSvrDetails["user"],
+self.mgtSvrDetails["passwd"]
+)
+command = "service cloudstack-management restart"
+ms_restart_response = sshClient.execute(command)
+self.assertEqual(
+validateList(ms_restart_response)[0],
+PASS,
+"Check the MS restart response")
+self.assertEqual(
+ms_restart_response[0],
+'Stopping cloudstack-management:[  OK  ]',
+"MS i not stopped"
+)
+self.assertEqual(
+ms_restart_response[1],
+'Starting cloudstack-management: [  OK  ]',
+"MS not started"
+)
+timeout = self.services["timeout"]
+while True:
+time.sleep(self.services["sleep"])
+try:
+list_response = Zone.list(
+self.api_client
+)
+if validateList(list_response)[0] == PASS:
+break
+except ConnectionError as e:
+self.debug("list zone response is not available due to  %s" % 
e)
+
+if timeout == 0:
+raise Exception("Ms is not comming up !")
+timeout = timeout - 1
+
+
+class testMigrateVolumeTimeout(cloudstackTestCase):
+
+@classmethod
+def setUpClass(cls):
+try:
+cls._cleanup = []
+cls.testClient = super(
+testMigrateVolumeTimeout,
+cls).getClsTestClient()
+cls.api_client = cls.testClient.getApiClient()
+cls.services = cls.testClient.getParsedTestDataConfig()
+# Get Domain, Zone, Template
+cls.domain = get_domain(cls.api_client)
+cls.zone = get_zone(
+cls.api_client,
+cls.testClient.getZoneForTests())
+cls.template = get_template(
+cls.api_client,
+cls.zone.id,
+cls.services["ostype"]
+)
+cls.hypervisor = cls.testClient.getHypervisorInfo()
+cls.services['mode'] = cls.zone.networktype
+cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
+cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+cls.services["virtual_machine"]["template"] = cls.template.id
+cls

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37950152
  
--- Diff: server/src/com/cloud/api/dispatch/ParamProcessWorker.java ---
@@ -294,6 +294,14 @@ private void setFieldValue(final Field field, final 
BaseCmd cmdObj, final Object
 field.set(cmdObj, Float.valueOf(paramObj.toString()));
 }
 break;
+case DOUBLE:
+// Assuming that the parameters have been checked for 
required before now,
+// we ignore blank or null values and defer to the command 
to set a default
+// value for optional parameters ...
+if (paramObj != null && isNotBlank(paramObj.toString())) {
--- End diff --

I personally do not like to include a google package just to validate data.


---
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: CLOUDSTACK-8761: Replace some profiler.ge...

2015-08-25 Thread asfgit
Github user asfgit closed the pull request at:

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


---
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: [Automation]Volume migration between pool...

2015-08-25 Thread sanju1010
Github user sanju1010 commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/742#discussion_r37950166
  
--- Diff: test/integration/component/maint/test_migrate_volume_timeout.py 
---
@@ -0,0 +1,286 @@
+#!/usr/bin/env python
+# 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.
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import (cleanup_resources,
+  validateList)
+from marvin.lib.base import (Account,
+ VirtualMachine,
+ ServiceOffering,
+ Cluster,
+ StoragePool,
+ Volume,
+ DiskOffering,
+ Configurations,
+ Zone)
+from marvin.lib.common import (get_zone,
+   get_domain,
+   get_template,
+   list_hosts,
+   find_storage_pool_type
+   )
+from marvin.codes import PASS
+from marvin.sshClient import SshClient
+from requests.exceptions import ConnectionError
+import time
+
+
+def restart_ms(self):
+"""Restart MS
+#1-ssh into m/c running MS
+#2-restart ms
+#3-verify the response
+#4-loop until you get list_zone api answer """
+sshClient = SshClient(
+self.mgtSvrDetails["mgtSvrIp"],
+22,
+self.mgtSvrDetails["user"],
+self.mgtSvrDetails["passwd"]
+)
+command = "service cloudstack-management restart"
+ms_restart_response = sshClient.execute(command)
+self.assertEqual(
+validateList(ms_restart_response)[0],
+PASS,
+"Check the MS restart response")
+self.assertEqual(
+ms_restart_response[0],
+'Stopping cloudstack-management:[  OK  ]',
+"MS i not stopped"
+)
+self.assertEqual(
+ms_restart_response[1],
+'Starting cloudstack-management: [  OK  ]',
+"MS not started"
+)
+timeout = self.services["timeout"]
+while True:
+time.sleep(self.services["sleep"])
+try:
+list_response = Zone.list(
+self.api_client
+)
+if validateList(list_response)[0] == PASS:
+break
+except ConnectionError as e:
+self.debug("list zone response is not available due to  %s" % 
e)
+
+if timeout == 0:
+raise Exception("Ms is not comming up !")
+timeout = timeout - 1
+
+
+class testMigrateVolumeTimeout(cloudstackTestCase):
+
+@classmethod
+def setUpClass(cls):
+try:
+cls._cleanup = []
+cls.testClient = super(
+testMigrateVolumeTimeout,
+cls).getClsTestClient()
+cls.api_client = cls.testClient.getApiClient()
+cls.services = cls.testClient.getParsedTestDataConfig()
+# Get Domain, Zone, Template
+cls.domain = get_domain(cls.api_client)
+cls.zone = get_zone(
+cls.api_client,
+cls.testClient.getZoneForTests())
+cls.template = get_template(
+cls.api_client,
+cls.zone.id,
+cls.services["ostype"]
+)
+cls.hypervisor = cls.testClient.getHypervisorInfo()
+cls.services['mode'] = cls.zone.networktype
+cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
+cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+cls.services["virtual_machine"]["template"] = cls.template.id
+cls

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread abhinandanprateek
Github user abhinandanprateek commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37950196
  
--- Diff: 
plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java ---
@@ -0,0 +1,296 @@
+//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";
+}
+_usageTimezone = TimeZone.getTimeZone(timeZon

[GitHub] cloudstack pull request: Quota master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37950222
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java 
---
@@ -0,0 +1,471 @@
+//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.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.Account.State;
+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 master

2015-08-25 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/689#discussion_r37950233
  
--- Diff: usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java 
---
@@ -0,0 +1,471 @@
+//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.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.Account.State;
+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);

  1   2   >