[GitHub] cloudstack pull request: CLOUDSTACK-9106 - As a Developer I want t...
Github user DaanHoogland commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1179#discussion_r46767881 --- Diff: plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java --- @@ -488,50 +494,54 @@ public boolean applyPFRules(final Network network, final List
[GitHub] cloudstack pull request: CLOUDSTACK-8964: Ovm3HypervisorGuru handl...
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/1177#issuecomment-162286584 LGTM based on these tests: ``` nosetests --with-marvin --marvin-config=${marvinCfg} -s -a tags=advanced,required_hardware=true \ component/test_vpc_redundant.py \ component/test_routers_iptables_default_policy.py \ component/test_routers_network_ops.py \ component/test_vpc_router_nics.py \ smoke/test_loadbalance.py \ smoke/test_internal_lb.py \ smoke/test_ssvm.py \ smoke/test_network.py ``` Result: ``` Create a redundant VPC with two networks with two VMs in each network ... === TestName: test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL | Status : SUCCESS === ok Create a redundant VPC with two networks with two VMs in each network and check default routes ... === TestName: test_02_redundant_VPC_default_routes | Status : SUCCESS === ok Create a redundant VPC with two networks with two VMs in each network ... === TestName: test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers | Status : SUCCESS === ok Test iptables default INPUT/FORWARD policy on RouterVM ... === TestName: test_02_routervm_iptables_policies | Status : SUCCESS === ok Test iptables default INPUT/FORWARD policies on VPC router ... === TestName: test_01_single_VPC_iptables_policies | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_01_isolate_network_FW_PF_default_routes_egress_true | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_02_isolate_network_FW_PF_default_routes_egress_false | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false | Status : SUCCESS === ok Create a VPC with two networks with one VM in each network and test nics after destroy ... === TestName: test_01_VPC_nics_after_destroy | Status : SUCCESS === ok Create a VPC with two networks with one VM in each network and test default routes ... === TestName: test_02_VPC_default_routes | Status : SUCCESS === ok Check the password file in the Router VM ... === TestName: test_isolate_network_password_server | Status : SUCCESS === ok Check that the /etc/dhcphosts.txt doesn't contain duplicate IPs ... === TestName: test_router_dhcphosts | Status : SUCCESS === ok Test to create Load balancing rule with source NAT ... === TestName: test_01_create_lb_rule_src_nat | Status : SUCCESS === ok Test to create Load balancing rule with non source NAT ... === TestName: test_02_create_lb_rule_non_nat | Status : SUCCESS === ok Test for assign & removing load balancing rule ... === TestName: test_assign_and_removal_lb | Status : SUCCESS === ok Test to verify access to loadbalancer haproxy admin stats page ... === TestName: test02_internallb_haproxy_stats_on_all_interfaces | Status : SUCCESS === ok Test create, assign, remove of an Internal LB with roundrobin http traffic to 3 vm's ... === TestName: test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80 | Status : SUCCESS === ok Test SSVM Internals ... === TestName: test_03_ssvm_internals | Status : SUCCESS === ok Test CPVM Internals ... === TestName: test_04_cpvm_internals | Status : SUCCESS === ok Test stop SSVM ... === TestName: test_05_stop_ssvm | Status : SUCCESS === ok Test stop CPVM ... === TestName: test_06_stop_cpvm | Status : SUCCESS === ok Test reboot SSVM ... === TestName: test_07_reboot_ssvm | Status : SUCCESS === ok Test reboot CPVM ... === TestName: test_08_reboot_cpvm | Status : SUCCESS === ok Test destroy SSVM ... === TestName: test_09_destroy_ssvm | Status : SUCCESS === ok Test destroy CPVM ... === TestName: test_10_destroy_cpvm | Status : SUCCESS === ok Test Remote Access VPN in VPC ... === TestName: test_vpc_remote_access_vpn | Status : SUCCESS === ok Test VPN in VPC ... === TestName: test_vpc_site2site_vpn | Status : SUCCESS === ok Test for port forwarding on source NAT ... === TestName: test_01_port_fwd_on_src_nat | Status : SUCCESS === ok Test for port forwarding on non source NAT ... === TestName: test_02_port_fwd_on_non_src_nat | Status : SUCCESS === ok Test for reboot router ... === TestName: test_reboot_router | Status : SUCCESS === ok Test for Router rules for network rules on acquired public IP ... === TestName: test_network_rules_acquired_public_ip_1_static_nat_rule | Status : SUCCESS === ok Test for Router rules for network rules on acquired public IP ... === TestName: test_network_rules_acquired_public_ip_2_nat_rule | Status : SUCCESS ===
[GitHub] cloudstack pull request: [4.6/master] rate-limit: increase JVM mem...
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/1175#issuecomment-162286626 LGTM based on these tests: ``` nosetests --with-marvin --marvin-config=${marvinCfg} -s -a tags=advanced,required_hardware=true \ component/test_vpc_redundant.py \ component/test_routers_iptables_default_policy.py \ component/test_routers_network_ops.py \ component/test_vpc_router_nics.py \ smoke/test_loadbalance.py \ smoke/test_internal_lb.py \ smoke/test_ssvm.py \ smoke/test_network.py ``` Result: ``` Create a redundant VPC with two networks with two VMs in each network ... === TestName: test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL | Status : SUCCESS === ok Create a redundant VPC with two networks with two VMs in each network and check default routes ... === TestName: test_02_redundant_VPC_default_routes | Status : SUCCESS === ok Create a redundant VPC with two networks with two VMs in each network ... === TestName: test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers | Status : SUCCESS === ok Test iptables default INPUT/FORWARD policy on RouterVM ... === TestName: test_02_routervm_iptables_policies | Status : SUCCESS === ok Test iptables default INPUT/FORWARD policies on VPC router ... === TestName: test_01_single_VPC_iptables_policies | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_01_isolate_network_FW_PF_default_routes_egress_true | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_02_isolate_network_FW_PF_default_routes_egress_false | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false | Status : SUCCESS === ok Create a VPC with two networks with one VM in each network and test nics after destroy ... === TestName: test_01_VPC_nics_after_destroy | Status : SUCCESS === ok Create a VPC with two networks with one VM in each network and test default routes ... === TestName: test_02_VPC_default_routes | Status : SUCCESS === ok Check the password file in the Router VM ... === TestName: test_isolate_network_password_server | Status : SUCCESS === ok Check that the /etc/dhcphosts.txt doesn't contain duplicate IPs ... === TestName: test_router_dhcphosts | Status : SUCCESS === ok Test to create Load balancing rule with source NAT ... === TestName: test_01_create_lb_rule_src_nat | Status : SUCCESS === ok Test to create Load balancing rule with non source NAT ... === TestName: test_02_create_lb_rule_non_nat | Status : SUCCESS === ok Test for assign & removing load balancing rule ... === TestName: test_assign_and_removal_lb | Status : SUCCESS === ok Test to verify access to loadbalancer haproxy admin stats page ... === TestName: test02_internallb_haproxy_stats_on_all_interfaces | Status : SUCCESS === ok Test create, assign, remove of an Internal LB with roundrobin http traffic to 3 vm's ... === TestName: test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80 | Status : SUCCESS === ok Test SSVM Internals ... === TestName: test_03_ssvm_internals | Status : SUCCESS === ok Test CPVM Internals ... === TestName: test_04_cpvm_internals | Status : SUCCESS === ok Test stop SSVM ... === TestName: test_05_stop_ssvm | Status : SUCCESS === ok Test stop CPVM ... === TestName: test_06_stop_cpvm | Status : SUCCESS === ok Test reboot SSVM ... === TestName: test_07_reboot_ssvm | Status : SUCCESS === ok Test reboot CPVM ... === TestName: test_08_reboot_cpvm | Status : SUCCESS === ok Test destroy SSVM ... === TestName: test_09_destroy_ssvm | Status : SUCCESS === ok Test destroy CPVM ... === TestName: test_10_destroy_cpvm | Status : SUCCESS === ok Test Remote Access VPN in VPC ... === TestName: test_vpc_remote_access_vpn | Status : SUCCESS === ok Test VPN in VPC ... === TestName: test_vpc_site2site_vpn | Status : SUCCESS === ok Test for port forwarding on source NAT ... === TestName: test_01_port_fwd_on_src_nat | Status : SUCCESS === ok Test for port forwarding on non source NAT ... === TestName: test_02_port_fwd_on_non_src_nat | Status : SUCCESS === ok Test for reboot router ... === TestName: test_reboot_router | Status : SUCCESS === ok Test for Router rules for network rules on acquired public IP ... === TestName: test_network_rules_acquired_public_ip_1_static_nat_rule | Status : SUCCESS === ok Test for Router rules for network rules on acquired public IP ... === TestName: test_network_rules_acquired_public_ip_2_nat_rule | Status : SUCCESS ===
[GitHub] cloudstack pull request: CLOUDSTACK-9106 - As a Developer I want t...
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/1179#issuecomment-162287415 LGTM based on these tests: ``` nosetests --with-marvin --marvin-config=${marvinCfg} -s -a tags=advanced,required_hardware=true \ component/test_vpc_redundant.py \ component/test_routers_iptables_default_policy.py \ component/test_routers_network_ops.py \ component/test_vpc_router_nics.py \ smoke/test_loadbalance.py \ smoke/test_internal_lb.py \ smoke/test_ssvm.py \ smoke/test_network.py ``` Result: ``` Create a redundant VPC with two networks with two VMs in each network ... === TestName: test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL | Status : SUCCESS === ok Create a redundant VPC with two networks with two VMs in each network and check default routes ... === TestName: test_02_redundant_VPC_default_routes | Status : SUCCESS === ok Create a redundant VPC with two networks with two VMs in each network ... === TestName: test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers | Status : SUCCESS === ok Test iptables default INPUT/FORWARD policy on RouterVM ... === TestName: test_02_routervm_iptables_policies | Status : SUCCESS === ok Test iptables default INPUT/FORWARD policies on VPC router ... === TestName: test_01_single_VPC_iptables_policies | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_01_isolate_network_FW_PF_default_routes_egress_true | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_02_isolate_network_FW_PF_default_routes_egress_false | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false | Status : SUCCESS === ok Create a VPC with two networks with one VM in each network and test nics after destroy ... === TestName: test_01_VPC_nics_after_destroy | Status : SUCCESS === ok Create a VPC with two networks with one VM in each network and test default routes ... === TestName: test_02_VPC_default_routes | Status : SUCCESS === ok Check the password file in the Router VM ... === TestName: test_isolate_network_password_server | Status : SUCCESS === ok Check that the /etc/dhcphosts.txt doesn't contain duplicate IPs ... === TestName: test_router_dhcphosts | Status : SUCCESS === ok Test to create Load balancing rule with source NAT ... === TestName: test_01_create_lb_rule_src_nat | Status : SUCCESS === ok Test to create Load balancing rule with non source NAT ... === TestName: test_02_create_lb_rule_non_nat | Status : SUCCESS === ok Test for assign & removing load balancing rule ... === TestName: test_assign_and_removal_lb | Status : SUCCESS === ok Test to verify access to loadbalancer haproxy admin stats page ... === TestName: test02_internallb_haproxy_stats_on_all_interfaces | Status : SUCCESS === ok Test create, assign, remove of an Internal LB with roundrobin http traffic to 3 vm's ... === TestName: test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80 | Status : SUCCESS === ok Test SSVM Internals ... === TestName: test_03_ssvm_internals | Status : SUCCESS === ok Test CPVM Internals ... === TestName: test_04_cpvm_internals | Status : SUCCESS === ok Test stop SSVM ... === TestName: test_05_stop_ssvm | Status : SUCCESS === ok Test stop CPVM ... === TestName: test_06_stop_cpvm | Status : SUCCESS === ok Test reboot SSVM ... === TestName: test_07_reboot_ssvm | Status : SUCCESS === ok Test reboot CPVM ... === TestName: test_08_reboot_cpvm | Status : SUCCESS === ok Test destroy SSVM ... === TestName: test_09_destroy_ssvm | Status : SUCCESS === ok Test destroy CPVM ... === TestName: test_10_destroy_cpvm | Status : SUCCESS === ok Test Remote Access VPN in VPC ... === TestName: test_vpc_remote_access_vpn | Status : SUCCESS === ok Test VPN in VPC ... === TestName: test_vpc_site2site_vpn | Status : SUCCESS === ok Test for port forwarding on source NAT ... === TestName: test_01_port_fwd_on_src_nat | Status : SUCCESS === ok Test for port forwarding on non source NAT ... === TestName: test_02_port_fwd_on_non_src_nat | Status : SUCCESS === ok Test for reboot router ... === TestName: test_reboot_router | Status : SUCCESS === ok Test for Router rules for network rules on acquired public IP ... === TestName: test_network_rules_acquired_public_ip_1_static_nat_rule | Status : SUCCESS === ok Test for Router rules for network rules on acquired public IP ... === TestName: test_network_rules_acquired_public_ip_2_nat_rule | Status : SUCCESS ===
[GitHub] cloudstack pull request: Cwe 190
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/1057#issuecomment-162287862 LGTM based on these tests: ``` nosetests --with-marvin --marvin-config=${marvinCfg} -s -a tags=advanced,required_hardware=true \ component/test_vpc_redundant.py \ component/test_routers_iptables_default_policy.py \ component/test_routers_network_ops.py \ component/test_vpc_router_nics.py \ smoke/test_loadbalance.py \ smoke/test_internal_lb.py \ smoke/test_ssvm.py \ smoke/test_network.py ``` Result: ``` Create a redundant VPC with two networks with two VMs in each network ... === TestName: test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL | Status : SUCCESS === ok Create a redundant VPC with two networks with two VMs in each network and check default routes ... === TestName: test_02_redundant_VPC_default_routes | Status : SUCCESS === ok Create a redundant VPC with two networks with two VMs in each network ... === TestName: test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers | Status : SUCCESS === ok Test iptables default INPUT/FORWARD policy on RouterVM ... === TestName: test_02_routervm_iptables_policies | Status : SUCCESS === ok Test iptables default INPUT/FORWARD policies on VPC router ... === TestName: test_01_single_VPC_iptables_policies | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_01_isolate_network_FW_PF_default_routes_egress_true | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_02_isolate_network_FW_PF_default_routes_egress_false | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false | Status : SUCCESS === ok Create a VPC with two networks with one VM in each network and test nics after destroy ... === TestName: test_01_VPC_nics_after_destroy | Status : SUCCESS === ok Create a VPC with two networks with one VM in each network and test default routes ... === TestName: test_02_VPC_default_routes | Status : SUCCESS === ok Check the password file in the Router VM ... === TestName: test_isolate_network_password_server | Status : SUCCESS === ok Check that the /etc/dhcphosts.txt doesn't contain duplicate IPs ... === TestName: test_router_dhcphosts | Status : SUCCESS === ok Test to create Load balancing rule with source NAT ... === TestName: test_01_create_lb_rule_src_nat | Status : SUCCESS === ok Test to create Load balancing rule with non source NAT ... === TestName: test_02_create_lb_rule_non_nat | Status : SUCCESS === ok Test for assign & removing load balancing rule ... === TestName: test_assign_and_removal_lb | Status : SUCCESS === ok Test to verify access to loadbalancer haproxy admin stats page ... === TestName: test02_internallb_haproxy_stats_on_all_interfaces | Status : SUCCESS === ok Test create, assign, remove of an Internal LB with roundrobin http traffic to 3 vm's ... === TestName: test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80 | Status : SUCCESS === ok Test SSVM Internals ... === TestName: test_03_ssvm_internals | Status : SUCCESS === ok Test CPVM Internals ... === TestName: test_04_cpvm_internals | Status : SUCCESS === ok Test stop SSVM ... === TestName: test_05_stop_ssvm | Status : SUCCESS === ok Test stop CPVM ... === TestName: test_06_stop_cpvm | Status : SUCCESS === ok Test reboot SSVM ... === TestName: test_07_reboot_ssvm | Status : SUCCESS === ok Test reboot CPVM ... === TestName: test_08_reboot_cpvm | Status : SUCCESS === ok Test destroy SSVM ... === TestName: test_09_destroy_ssvm | Status : SUCCESS === ok Test destroy CPVM ... === TestName: test_10_destroy_cpvm | Status : SUCCESS === ok Test Remote Access VPN in VPC ... === TestName: test_vpc_remote_access_vpn | Status : SUCCESS === ok Test VPN in VPC ... === TestName: test_vpc_site2site_vpn | Status : SUCCESS === ok Test for port forwarding on source NAT ... === TestName: test_01_port_fwd_on_src_nat | Status : SUCCESS === ok Test for port forwarding on non source NAT ... === TestName: test_02_port_fwd_on_non_src_nat | Status : SUCCESS === ok Test for reboot router ... === TestName: test_reboot_router | Status : SUCCESS === ok Test for Router rules for network rules on acquired public IP ... === TestName: test_network_rules_acquired_public_ip_1_static_nat_rule | Status : SUCCESS === ok Test for Router rules for network rules on acquired public IP ... === TestName: test_network_rules_acquired_public_ip_2_nat_rule | Status : SUCCESS ===
[GitHub] cloudstack pull request: Prevent live-lock in NSX API client
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/1178#issuecomment-162287978 LGTM based on these tests: ``` nosetests --with-marvin --marvin-config=${marvinCfg} -s -a tags=advanced,required_hardware=true \ component/test_vpc_redundant.py \ component/test_routers_iptables_default_policy.py \ component/test_routers_network_ops.py \ component/test_vpc_router_nics.py \ smoke/test_loadbalance.py \ smoke/test_internal_lb.py \ smoke/test_ssvm.py \ smoke/test_network.py ``` Result: ``` Create a redundant VPC with two networks with two VMs in each network ... === TestName: test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL | Status : SUCCESS === ok Create a redundant VPC with two networks with two VMs in each network and check default routes ... === TestName: test_02_redundant_VPC_default_routes | Status : SUCCESS === ok Create a redundant VPC with two networks with two VMs in each network ... === TestName: test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers | Status : SUCCESS === ok Test iptables default INPUT/FORWARD policy on RouterVM ... === TestName: test_02_routervm_iptables_policies | Status : SUCCESS === ok Test iptables default INPUT/FORWARD policies on VPC router ... === TestName: test_01_single_VPC_iptables_policies | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_01_isolate_network_FW_PF_default_routes_egress_true | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_02_isolate_network_FW_PF_default_routes_egress_false | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true | Status : SUCCESS === ok Test redundant router internals ... === TestName: test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false | Status : SUCCESS === ok Create a VPC with two networks with one VM in each network and test nics after destroy ... === TestName: test_01_VPC_nics_after_destroy | Status : SUCCESS === ok Create a VPC with two networks with one VM in each network and test default routes ... === TestName: test_02_VPC_default_routes | Status : SUCCESS === ok Check the password file in the Router VM ... === TestName: test_isolate_network_password_server | Status : SUCCESS === ok Check that the /etc/dhcphosts.txt doesn't contain duplicate IPs ... === TestName: test_router_dhcphosts | Status : SUCCESS === ok Test to create Load balancing rule with source NAT ... === TestName: test_01_create_lb_rule_src_nat | Status : SUCCESS === ok Test to create Load balancing rule with non source NAT ... === TestName: test_02_create_lb_rule_non_nat | Status : SUCCESS === ok Test for assign & removing load balancing rule ... === TestName: test_assign_and_removal_lb | Status : SUCCESS === ok Test to verify access to loadbalancer haproxy admin stats page ... === TestName: test02_internallb_haproxy_stats_on_all_interfaces | Status : SUCCESS === ok Test create, assign, remove of an Internal LB with roundrobin http traffic to 3 vm's ... === TestName: test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80 | Status : SUCCESS === ok Test SSVM Internals ... === TestName: test_03_ssvm_internals | Status : SUCCESS === ok Test CPVM Internals ... === TestName: test_04_cpvm_internals | Status : SUCCESS === ok Test stop SSVM ... === TestName: test_05_stop_ssvm | Status : SUCCESS === ok Test stop CPVM ... === TestName: test_06_stop_cpvm | Status : SUCCESS === ok Test reboot SSVM ... === TestName: test_07_reboot_ssvm | Status : SUCCESS === ok Test reboot CPVM ... === TestName: test_08_reboot_cpvm | Status : SUCCESS === ok Test destroy SSVM ... === TestName: test_09_destroy_ssvm | Status : SUCCESS === ok Test destroy CPVM ... === TestName: test_10_destroy_cpvm | Status : SUCCESS === ok Test Remote Access VPN in VPC ... === TestName: test_vpc_remote_access_vpn | Status : SUCCESS === ok Test VPN in VPC ... === TestName: test_vpc_site2site_vpn | Status : SUCCESS === ok Test for port forwarding on source NAT ... === TestName: test_01_port_fwd_on_src_nat | Status : SUCCESS === ok Test for port forwarding on non source NAT ... === TestName: test_02_port_fwd_on_non_src_nat | Status : SUCCESS === ok Test for reboot router ... === TestName: test_reboot_router | Status : SUCCESS === ok Test for Router rules for network rules on acquired public IP ... === TestName: test_network_rules_acquired_public_ip_1_static_nat_rule | Status : SUCCESS === ok Test for Router rules for network rules on acquired public IP ... === TestName: test_network_rules_acquired_public_ip_2_nat_rule | Status : SUCCESS ===
[GitHub] cloudstack pull request: CLOUDSTACK-9074: Support shared networkin...
Github user miguelaferreira commented on the pull request: https://github.com/apache/cloudstack/pull/1094#issuecomment-162302939 @nvazquez I've been able to verify that the existing tests did not break with your PR, however I can't seem to get an NSX configuration for running the two additional test you added. Here's my network config: ``` start IP = 192.168.23.2 end IP = 192.168.23.20 netmask = 255.255.255.0 gateway = 192.168.23.1 ``` The VLAN config ``` VLAN= 50 VLAN_UUID = 2eea1553-837e-4a3e-bfbb-872c4cb2a49a ``` The VLAN_UUID is the UUID of a LRouter I've created in NSX. That LRouter is connected to an LSwitch. The pictures bellow show the LRouter and LSwitch. https://cloud.githubusercontent.com/assets/4670993/11612955/a094b276-9c0f-11e5-9774-657ae8b21f9f.png";> https://cloud.githubusercontent.com/assets/4670993/11612956/a64278ca-9c0f-11e5-8206-a8ab3afd0d96.png";> https://cloud.githubusercontent.com/assets/4670993/11612958/abe15d32-9c0f-11e5-8fd8-60f0d2f9bc59.png";> https://cloud.githubusercontent.com/assets/4670993/11612959/afd87a24-9c0f-11e5-92f6-08dfe0491c5a.png";> If you could help me fix my config, I'll test your PR today. --- 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: [jira] [Commented] (CLOUDSTACK-9111) cloudstack-management start failed (CloudStack 4.6.1 + CentOS7)
It is in the admin guide already. > On 06 Dec 2015, at 12:00, Rohit Yadav (JIRA) wrote: > > >[ > https://issues.apache.org/jira/browse/CLOUDSTACK-9111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15043822#comment-15043822 > ] > > Rohit Yadav commented on CLOUDSTACK-9111: > - > > This needs to be in docs, to use cloudstack-setup-management --tomcat7 on > CentOS7 (if it's not in docs already). cc [~remibergsma] > >> cloudstack-management start failed (CloudStack 4.6.1 + CentOS7) >> --- >> >>Key: CLOUDSTACK-9111 >>URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9111 >>Project: CloudStack >> Issue Type: Bug >> Security Level: Public(Anyone can view this level - this is the >> default.) >> Components: Management Server >> Affects Versions: 4.6.1 >>Environment: CloudStack 4.6.1 , CentOS7 >> http://packages.shapeblue.com/cloudstack/upstream/centos7/4.6/ >> Reporter: satoru nakaya >> >> Steps to reproduce: >> 1)clean install CloudStack 4.6.1 on CentOS7 >> use http://packages.shapeblue.com/cloudstack/upstream/centos7/4.6/ >> [root@acs ~]# cat /etc/redhat-release >> CentOS Linux release 7.1.1503 (Core) >> [root@acs ~]# >> [root@acs ~]# rpm -qa | grep cloudstack >> cloudstack-management-4.6.1-shapeblue0.el7.centos.x86_64 >> cloudstack-common-4.6.1-shapeblue0.el7.centos.x86_64 >> [root@acs ~]# >> 2)cloudstack-setup-databases...(snip) >> 3)cloudstack-setup-management (Failed) >> [root@acs ~]# cloudstack-setup-management >> Starting to configure CloudStack Management Server: >> Configure Firewall ...[OK] >> Configure CloudStack Management Server ...[Failed] >> Cannot find /etc/cloudstack/management/server-nonssl.xml or >> /etc/cloudstack/management/tomcat6-nonssl.conf, https enable failed >> Try to restore your system: >> Restore Firewall ... [OK] >> Restore CloudStack Management Server ...[OK] >> [root@acs ~]# >> 4)check log (/var/log/messages) >> Dec 6 10:08:51 acs server: WARNING: Unable to load server configuration >> from [/usr/share/cloudstack-management/conf/server.xml] >> 5)check service status (failed) >> [root@acs ~]# systemctl status cloudstack-management.service >> cloudstack-management.service - CloudStack Management Server >> Loaded: loaded (/usr/lib/systemd/system/cloudstack-management.service; >> enabled) >> Active: failed (Result: exit-code) since Sun 2015-12-06 10:08:52 JST; 11s >> ago >> Process: 3061 ExecStop=/usr/libexec/tomcat/server stop (code=exited, >> status=1/FAILURE) >> Process: 3026 ExecStart=/usr/libexec/tomcat/server start (code=exited, >> status=0/SUCCESS) >> Main PID: 3026 (code=exited, status=0/SUCCESS) >> Dec 06 10:08:52 acs.dom.local server[3061]: at >> java.io.FileInputStream.(FileInputStream.java:146) >> Dec 06 10:08:52 acs.dom.local server[3061]: at >> org.apache.catalina.startup.Catalina.stopServer(Catalina.java:466) >> Dec 06 10:08:52 acs.dom.local server[3061]: at >> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> Dec 06 10:08:52 acs.dom.local server[3061]: at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >> Dec 06 10:08:52 acs.dom.local server[3061]: at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI...va:43) >> Dec 06 10:08:52 acs.dom.local server[3061]: at >> java.lang.reflect.Method.invoke(Method.java:606) >> Dec 06 10:08:52 acs.dom.local server[3061]: at >> org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:370) >> Dec 06 10:08:52 acs.dom.local server[3061]: at >> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:457) >> Dec 06 10:08:52 acs.dom.local systemd[1]: cloudstack-management.service: >> control process exited, code=exited status=1 >> Dec 06 10:08:52 acs.dom.local systemd[1]: Unit cloudstack-management.service >> entered failed state. >> Hint: Some lines were ellipsized, use -l to show in full. >> [root@acs ~]# >> workaround: >> The correct do not know whether or not , but it worked. >> 6)check file >> [root@acs ~]# ls -la /etc/cloudstack/management >> total 132 >> drwxr-xr-x. 3 root root 4096 Dec 5 17:59 . >> drwxr-xr-x. 3 root root 4096 Dec 5 17:53 .. >> drwxrwx---. 3 root cloud 4096 Dec 5 17:53 Catalina >> -rw-r--r--. 1 root root 8945 Dec 1 20:22 catalina.policy >> -rw-r--r--. 1 root root 3794 Dec 1 20:22 catalina.properties >> -rw-r--r--. 1 root root 1653 Dec 1 20:22 classpath.conf >> -rw-r--r--. 1 root root 1357 Dec 1 20:22 commons-logging.properties >> -rw-r-. 1 root cloud 3137 Dec 5 17:59 db.properties >> -rw-r--r--. 1 root root979 Dec 1 20:22 environment.properties >> -rw-r--r--. 1 root root927 Dec 1 20:22 java.security.ciphers >> -rw-r--r--. 1 root root 8 Dec 5 17:55 key >> -rw-r--r--. 1 root root 7020 Dec 1 20:22 log4j-cloud.x
[GitHub] cloudstack pull request: CLOUDSTACK-9025: Fixed can't create usabl...
Github user DaanHoogland commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1176#discussion_r46769041 --- Diff: plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java --- @@ -185,7 +185,8 @@ public boolean trackVmHostChange() { DataTO srcData = cpyCommand.getSrcTO(); DataTO destData = cpyCommand.getDestTO(); -if (srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) { +if (srcData.getHypervisorType() == HypervisorType.XenServer && srcData.getObjectType() == DataObjectType.SNAPSHOT && --- End diff -- @anshul1886 What you show is implementation dependent. Unless the specification confirms this behaviour, I think .equals is better. --- 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: confirm unsubscribe from dev@cloudstack.apache.org
Zitat von dev-h...@cloudstack.apache.org: Hi! This is the ezmlm program. I'm managing the dev@cloudstack.apache.org mailing list. I'm working for my owner, who can be reached at dev-ow...@cloudstack.apache.org. To confirm that you would like norbert.kl...@infosecprojects.net removed from the dev mailing list, please send a short reply to this address: dev-uc.1449404515.dcbgcliodiiplfcfknem-norbert.klein=infosecprojects@cloudstack.apache.org Usually, this happens when you just hit the "reply" button. If this does not work, simply copy the address and paste it into the "To:" field of a new message. or click here: mailto:dev-uc.1449404515.dcbgcliodiiplfcfknem-norbert.klein=infosecprojects@cloudstack.apache.org I haven't checked whether your address is currently on the mailing list. To see what address you used to subscribe, look at the messages you are receiving from the mailing list. Each message has your address hidden inside its return path; for example, m...@xdd.ff.com receives messages with return path: -mary=xdd.ff@cloudstack.apache.org. Some mail programs are broken and cannot handle long addresses. If you cannot reply to this request, instead send a message to and put the entire address listed above into the "Subject:" line. --- Administrative commands for the dev list --- I can handle administrative requests automatically. Please do not send them to the list address! Instead, send your message to the correct command address: To subscribe to the list, send a message to: To remove your address from the list, send a message to: Send mail to the following for info and FAQ for this list: Similar addresses exist for the digest list: To get messages 123 through 145 (a maximum of 100 per request), mail: To get an index with subject and author for messages 123-456 , mail: They are always returned as sets of 100, max 2000 per request, so you'll actually get 100-499. To receive all messages with the same subject as message 12345, send a short message to: The messages should contain one line or word of text to avoid being treated as sp@m, but I will ignore their content. Only the ADDRESS you send to is important. You can start a subscription for an alternate address, for example "john@host.domain", just add a hyphen and your address (with '=' instead of '@') after the command word: To stop subscription for this address, mail: In both cases, I'll send a confirmation message to that address. When you receive it, simply reply to it to complete your subscription. If despite following these instructions, you do not get the desired results, please contact my owner at dev-ow...@cloudstack.apache.org. Please be patient, my owner is a lot slower than I am ;-) --- Enclosed is a copy of the request I received. Return-Path: Received: (qmail 4607 invoked by uid 99); 6 Dec 2015 12:21:55 - Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Dec 2015 12:21:55 + Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id D7DC3180984 for ; Sun, 6 Dec 2015 12:21:54 + (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=6.31 tests=[none] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 7B-owdF5u0dA for ; Sun, 6 Dec 2015 12:21:48 + (UTC) Received: from www164.your-server.de (www164.your-server.de [213.133.104.164]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 8E10A20ECF for ; Sun, 6 Dec 2015 12:21:47 + (UTC) Received: from [88.198.220.131] (helo=sslproxy02.your-server.de) by www164.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85) (envelope-from ) id 1a5YJx-000141-Da for dev-unsubscr...@cloudstack.apache.org; Sun, 06 Dec 2015 13:21:41 +0100 Received: from [192.168.0.30] (helo=webmail01.your-server.de) by sslproxy02.your-server.de with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.84) (envelope-from ) id 1a5YJx-0007w5-76 for dev-unsubscr...@cloudstack.apache.org; Sun, 06 Dec 2015 13:21:41 +0100 Received: from p5B2DDF3B.dip0.t-ipconnect.de (p5B2DDF3B.dip0.t-ipconnect.de [91.45.223.59]) by webmail.your-server.de (Horde Framework) with HTTP; Sun, 06 Dec 2015 13:21:40 +0100 Date: Sun, 06 Dec 2015 13:21:40 +0100 Message-ID: <20151206132140.horde.cz4n7iszbuq_y8u1hexl...@webmail.your-server.de> From: norbert.kl...@infosecprojects.net To: dev-unsubscr...@cloudstack.apache.org Subject: unsubscribe User-Agent: Horde Application Framework 5
[GitHub] cloudstack pull request: CLOUDSTACK-9106 - As a Developer I want t...
Github user wilderrodrigues commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1179#discussion_r46769789 --- Diff: plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java --- @@ -488,50 +494,54 @@ public boolean applyPFRules(final Network network, final List
[GitHub] cloudstack pull request: CLOUDSTACK-9106 - As a Developer I want t...
Github user wilderrodrigues commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1179#discussion_r46769848 --- Diff: server/src/com/cloud/network/element/VirtualRouterElement.java --- @@ -841,24 +857,26 @@ public VirtualRouterProvider addElement(final Long nspId, final Type providerTyp @Override public boolean applyPFRules(final Network network, final List rules) throws ResourceUnavailableException { +boolean result = false; if (canHandle(network, Service.PortForwarding)) { final List routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); -return true; +result = true; --- End diff -- Yes, it would. But I won't change because I don't agree with the approach of returning true/false in several places. 1. A method that returns something should have only one point where it actually returns. So those several returns is a bad practice. A way to make it not so bad is to assign the return to a variable, so people looking at the code in the future won't miss a hidden "return true" somewhere. I did not change all of it because in some places it requires a better refactor. 2. If a method execution cannot proceed due to some condition, it should fail - exception. A return false should be used when one wants to check is something is valid/exists or not. --- 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-9074: Support shared networkin...
Github user serg38 commented on the pull request: https://github.com/apache/cloudstack/pull/1094#issuecomment-162319994 Since you are testing L3 connectivity existing switch patch to router shouldn't overlap an ip range used by the new subnet. Cidr #1 should work fine . You might also try disconnect existing switch from router to see if test passes. For test #4 we tested we lrouter patched over to l3 gateway without existing switch . For test# 3 you need to have l2 gateway to match the one specified for nvp device. The issue we observed was if any of the test fail for any reason the cleanup on nsx side doesn't work so a manual cleanup might require to remove existing router port left over from previous tests that has overlapping cidr --- 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-9074: Support shared networkin...
Github user miguelaferreira commented on the pull request: https://github.com/apache/cloudstack/pull/1094#issuecomment-162321883 @serg38 I will use CIDR 1 and disconnect the switch from the router, to se if that works. I haven't' seen any think left behind after testing. That is, the clean up seems to be working fine for me. --- 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-9106 - As a Developer I want t...
Github user DaanHoogland commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1179#discussion_r46771839 --- Diff: server/src/com/cloud/network/element/VirtualRouterElement.java --- @@ -841,24 +857,26 @@ public VirtualRouterProvider addElement(final Long nspId, final Type providerTyp @Override public boolean applyPFRules(final Network network, final List rules) throws ResourceUnavailableException { +boolean result = false; if (canHandle(network, Service.PortForwarding)) { final List routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); -return true; +result = true; --- End diff -- I agree with your consideration and I am not forcing you to change to win my lgtm. I just want to make sure we discuss the consideration here for posterity and change only if a simple good alternative comes up. I noticed line 874 and wondered about this and the &= thingy upstairs. I would use a combination of first trying all of them and then throw the exception if any of them failed --- 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-9106 - As a Developer I want t...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1179#issuecomment-162324443 @remibergsma I think I am being captain obvious (as my new colleagues like to call each other) but let's add them to the standard run. --- 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-8964: Ovm3HypervisorGuru handl...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1177#issuecomment-162331595 lgtm, but can you squash these commits to no longer include a revert, @ustcweizhou ? thanks --- 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-8964: Ovm3HypervisorGuru handl...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1177#issuecomment-162331667 @snuf are you, as the author of the ovm3 hypervisor plugin, alright with this? --- 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-9025: Fixed can't create usabl...
Github user DaanHoogland commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1176#discussion_r46773579 --- Diff: plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java --- @@ -185,7 +185,8 @@ public boolean trackVmHostChange() { DataTO srcData = cpyCommand.getSrcTO(); DataTO destData = cpyCommand.getDestTO(); -if (srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) { +if (srcData.getHypervisorType() == HypervisorType.XenServer && srcData.getObjectType() == DataObjectType.SNAPSHOT && --- End diff -- @anshul1886 I looked it up. @bhaisaab @ustcweizhou Anshul is right about the equals versus ==, for readability it makes sense to leave this as is. from 8.9 in the language specs: Because there is only one instance of each enum constant, it is permitted to use the == operator in place of the equals method when comparing two object references if it is known that at least one of them refers to an enum constant. --- 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-9025: Fixed can't create usabl...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1176#issuecomment-162332724 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: [4.7] CLOUDSTACK-8746: VM Snapshotting im...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/977#issuecomment-162334352 @wido any reason we shouldn't merge this in before 4.7? --- 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-9051: update nic IP address of...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1086#issuecomment-162335446 two lgtm, no response to the the answers on reviews so merging --- 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-9051: update nic IP address of...
Github user asfgit closed the pull request at: https://github.com/apache/cloudstack/pull/1086 --- 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: [UI] fix bug: Cannot delete SSH keypairs ...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1154#issuecomment-162336048 code looks good to me --- 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-9101: fix some issues in resiz...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1161#issuecomment-162336211 lgtm, merging --- 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-9101: fix some issues in resiz...
Github user asfgit closed the pull request at: https://github.com/apache/cloudstack/pull/1161 --- 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-8845: set isRevertable of snap...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1168#issuecomment-162336441 code lgtm and since @ustcweizhou and @anshul1886 agree on how to solve this and @remibergsma did the tests, i am merging this --- 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-8964: Ovm3HypervisorGuru handl...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1177#issuecomment-162337123 lgtm, merging --- 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-8964: Ovm3HypervisorGuru handl...
Github user asfgit closed the pull request at: https://github.com/apache/cloudstack/pull/1177 --- 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-8845: set isRevertable of snap...
Github user asfgit closed the pull request at: https://github.com/apache/cloudstack/pull/1168 --- 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: Cwe 190
Github user asfgit closed the pull request at: https://github.com/apache/cloudstack/pull/1057 --- 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-9047 rename enums
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1049#issuecomment-162337898 merging --- 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-9047 rename enums
Github user asfgit closed the pull request at: https://github.com/apache/cloudstack/pull/1049 --- 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-8656: tests ignoring exception...
Github user asfgit closed the pull request at: https://github.com/apache/cloudstack/pull/850 --- 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: CID-1338387: remove logicless execution c...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1056#issuecomment-162339708 #1177 obsoleted this --- 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: CID-1338387: remove logicless execution c...
Github user DaanHoogland closed the pull request at: https://github.com/apache/cloudstack/pull/1056 --- 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-9054 use of google-optional as...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1060#issuecomment-162339782 @rafaelweingartner we still allow for 1.7 so no 1.8 only features for now --- 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: CID-1338387: remove logicless execution c...
Github user rafaelweingartner commented on the pull request: https://github.com/apache/cloudstack/pull/1056#issuecomment-162339992 Actually, the one that obsoleted this is #1124 --- 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-9025: Fixed can't create usabl...
Github user asfgit closed the pull request at: https://github.com/apache/cloudstack/pull/1176 --- 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: [4.6/master] rate-limit: increase JVM mem...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1175#issuecomment-162340165 lgtm merging --- 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: [4.6/master] rate-limit: increase JVM mem...
Github user asfgit closed the pull request at: https://github.com/apache/cloudstack/pull/1175 --- 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-9105: Logging enhancement: Han...
Github user asfgit closed the pull request at: https://github.com/apache/cloudstack/pull/1167 --- 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-9104: VM naming convention in ...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1165#issuecomment-162341273 @priyankparihar I do not know any vmware users @bhaisaab Do you have any insight on this change? or do you know any candidate reviewer for this? --- 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-9106 - As a Developer I want t...
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/1179#issuecomment-162341294 @DaanHoogland Yes, sir! See linked PR above. --- 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: Add support for not (re)starting server a...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1162#issuecomment-162341391 lgtm @remibergsma can you schedule a regression? --- 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-9025: Fixed can't create usabl...
Github user ustcweizhou commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1176#discussion_r46774983 --- Diff: plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java --- @@ -185,7 +185,8 @@ public boolean trackVmHostChange() { DataTO srcData = cpyCommand.getSrcTO(); DataTO destData = cpyCommand.getDestTO(); -if (srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) { +if (srcData.getHypervisorType() == HypervisorType.XenServer && srcData.getObjectType() == DataObjectType.SNAPSHOT && --- End diff -- ok, cool --- 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-9074: Support shared networkin...
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/1094#issuecomment-162342223 Guys, I cannot build a cloud from this branch any more. The build itself works, but the database deployment gives an SQL error: `Can't DROP 'logicalrouter_uuid'; check that column/key exists` Details: ``` [INFO] --- exec-maven-plugin:1.2.1:java (create-schema) @ cloud-developer --- log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. > WARNING: Provided file does not exist: /data/git/cs1/cloudstack/developer/../utils/conf/db.properties.override > WARNING: Provided file does not exist: /data/git/cs1/cloudstack/developer/developer-prefill.sql.override > Initializing database=cloud with host=localhost port=3306 username=cloud password=cloud > Running query: drop database if exists `cloud` > Running query: create database `cloud` > Running query: GRANT ALL ON cloud.* to 'cloud'@`localhost` identified by 'cloud' > Running query: GRANT ALL ON cloud.* to 'cloud'@`%` identified by 'cloud' > Initializing database=cloud_usage with host=localhost port=3306 username=cloud password=cloud > Running query: drop database if exists `cloud_usage` > Running query: create database `cloud_usage` > Running query: GRANT ALL ON cloud_usage.* to 'cloud'@`localhost` identified by 'cloud' > Running query: GRANT ALL ON cloud_usage.* to 'cloud'@`%` identified by 'cloud' > Processing SQL file at /data/git/cs1/cloudstack/developer/target/db/create-schema.sql > Processing SQL file at /data/git/cs1/cloudstack/developer/target/db/create-schema-premium.sql > Processing SQL file at /data/git/cs1/cloudstack/developer/target/db/templates.sql > Processing SQL file at /data/git/cs1/cloudstack/developer/developer-prefill.sql > Processing upgrade: com.cloud.upgrade.DatabaseUpgradeChecker [WARNING] java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297) at java.lang.Thread.run(Thread.java:745) Caused by: com.cloud.utils.exception.CloudRuntimeException: Unable to execute upgrade script: /data/git/cs1/cloudstack/developer/target/db/db/schema-410to420-cleanup.sql at com.cloud.upgrade.DatabaseUpgradeChecker.runScript(DatabaseUpgradeChecker.java:290) at com.cloud.upgrade.DatabaseUpgradeChecker.upgrade(DatabaseUpgradeChecker.java:425) at com.cloud.upgrade.DatabaseUpgradeChecker.check(DatabaseUpgradeChecker.java:474) at com.cloud.upgrade.DatabaseCreator.main(DatabaseCreator.java:217) ... 6 more Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'logicalrouter_uuid'; check that column/key exists at com.cloud.utils.db.ScriptRunner.runScript(ScriptRunner.java:185) at com.cloud.utils.db.ScriptRunner.runScript(ScriptRunner.java:87) at com.cloud.upgrade.DatabaseUpgradeChecker.runScript(DatabaseUpgradeChecker.java:281) ... 9 more [INFO] [INFO] BUILD FAILURE [INFO] [INFO] Total time: 19.639s (Wall Clock) [INFO] Finished at: Sun Dec 06 09:07:53 GMT 2015 [INFO] Final Memory: 43M/259M [INFO] [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (create-schema) on project cloud-developer: An exception occured while executing the Java class. null: InvocationTargetException: Unable to execute upgrade script: /data/git/cs1/cloudstack/developer/target/db/db/schema-410to420-cleanup.sql: Can't DROP 'logicalrouter_uuid'; check that column/key exists -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoEx
[GitHub] cloudstack pull request: CLOUDSTACK-9106 - As a Developer I want t...
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/1179#issuecomment-162342338 Run this test: `nosetests --with-marvin --marvin-config=${marvinCfg} -s -a tags=advanced,required_hardware=true smoke/test_privategw_acl.py` Result: ``` test_01_vpc_privategw_acl (integration.smoke.test_privategw_acl.TestPrivateGwACL) ... === TestName: test_01_vpc_privategw_acl | Status : SUCCESS === ok test_02_vpc_privategw_static_routes (integration.smoke.test_privategw_acl.TestPrivateGwACL) ... === TestName: test_02_vpc_privategw_static_routes | Status : SUCCESS === ok test_03_rvpc_privategw_static_routes (integration.smoke.test_privategw_acl.TestPrivateGwACL) ... === TestName: test_03_rvpc_privategw_static_routes | Status : SUCCESS === ok -- Ran 3 tests in 2057.520s OK ``` Nice work @wilderrodrigues ! --- 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-9099: SecretKey is returned fr...
Github user DaanHoogland commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1152#discussion_r46775072 --- Diff: api/src/com/cloud/user/AccountService.java --- @@ -136,4 +140,6 @@ void checkAccess(Account account, AccessType accessType, boolean sameOwner, Stri */ UserAccount getUserAccountById(Long userId); +public String[] getKeys(ListKeysCmd cmd); --- End diff -- I agree with @jburwell --- 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-9099: SecretKey is returned fr...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1152#issuecomment-162342597 @kansal looking forward to your update. your intended change makes sense --- 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: Fixed issues with test_vpc_vpn script
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/1156#issuecomment-162342696 @sanju1010 Thanks for the PR. Can you make it PEP8 compliant again please? Most tests seem to create the offering the test needs. Isn't that a better idea? I will run your version of the test. The previous one always succeeds for me, but I agree with the hypervisor specific part. That should be generic. Will run it and report back. --- 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: Add support for not (re)starting server a...
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/1162#issuecomment-162342893 @DaanHoogland That makes no sense. We should build RPMs and install mgt server from it and test both the new and existing features. The integration tests do not hit this code as far as I know. --- 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-8968: UI icon over VM snapshot...
Github user DaanHoogland commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1150#discussion_r46775285 --- Diff: ui/scripts/instanceWizard.js --- @@ -731,25 +746,33 @@ //step 1 : select zone $.extend(deployVmData, { -zoneid : args.data.zoneid +zoneid : selectedZoneObj.id }); //step 2: select template -$.extend(deployVmData, { -templateid : args.data.templateid -}); +if (snapshotObjs) { +$.extend(deployVmData, { +vmsnapshotid : selectedSnapshotObj.id +}); +} +else { +$.extend(deployVmData, { +templateid : args.data.templateid +}); +} $.extend(deployVmData, { hypervisor : selectedHypervisor }); -if (args.$wizard.find('input[name=rootDiskSize]').parent().css('display') != 'none') { -if (args.$wizard.find('input[name=rootDiskSize]').val().length > 0) { -$.extend(deployVmData, { -rootdisksize : args.$wizard.find('input[name=rootDiskSize]').val() -}); -} -} +//Currently it is not supporting in backend +//if (args.$wizard.find('input[name=rootDiskSize]').parent().css('display') != 'none') { --- End diff -- please do not leave code commented in. this block should be deleted. --- 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: Update JuniperSrxResource.java
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1148#issuecomment-162344831 @wenwenxiong can you add tests and or test data to this? any combination of - unit tests - marvin tests - test procedure thanks --- 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: CID-1338387: remove logicless execution c...
Github user DaanHoogland commented on the pull request: https://github.com/apache/cloudstack/pull/1056#issuecomment-162345306 @rafaelweingartner you better read #1177, part of #1124 will no longer merge cleanly because of the ovm3 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: CLOUDSTACK-8858: listVolumes API fails fo...
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/830#issuecomment-162345934 PIng @DaanHoogland can you review this please? I'll run some tests. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request: CLOUDSTACK-8847: ListServiceOfferings is ...
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/823#issuecomment-162346076 Pinging @DaanHoogland to review. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request: CLOUDSTACK-8841: Storage XenMotion from X...
Github user remibergsma commented on the pull request: https://github.com/apache/cloudstack/pull/815#issuecomment-162346266 Pinging @DaanHoogland to review. Will run some tests. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request: CID-1338387: remove logicless execution c...
Github user rafaelweingartner commented on the pull request: https://github.com/apache/cloudstack/pull/1056#issuecomment-162353745 @DaanHoogland PR #1124 rebased on top of master. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46777687 --- Diff: api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java --- @@ -111,6 +111,30 @@ public Long getProjectId() { public String getUsageId() { return usageId; } +public void setAccountName(String accountName) { +this.accountName = accountName; +} + +public void setDomainId(Long domainId) { +this.domainId = domainId; +} + +public void setEndDate(Date endDate) { +this.endDate = endDate; +} + +public void setStartDate(Date startDate) { +this.startDate = startDate; --- End diff -- Since ``Date`` instances are mutable, the ``this.startDate`` should be a copy of ``startDate``. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46777696 --- Diff: api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java --- @@ -111,6 +111,30 @@ public Long getProjectId() { public String getUsageId() { return usageId; } +public void setAccountName(String accountName) { +this.accountName = accountName; +} + +public void setDomainId(Long domainId) { +this.domainId = domainId; +} + +public void setEndDate(Date endDate) { +this.endDate = endDate; --- End diff -- Since ``Date`` instances are mutable, the ``this.endDate`` should be a copy of ``endDate`` to avoid side-effects. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r4622 --- Diff: engine/schema/src/com/cloud/upgrade/dao/Upgrade461to470.java --- @@ -51,8 +53,23 @@ public boolean supportsRollingUpgrade() { return new File[] {new File(script)}; } +public void alterAddColumnToCloudUsage(final Connection conn) { +final String alterTableSql = "ALTER TABLE `cloud_usage`.`cloud_usage` ADD COLUMN `quota_calculated` tinyint(1) DEFAULT 0 NOT NULL COMMENT 'quota calculation status'"; +try (PreparedStatement pstmt = conn.prepareStatement(alterTableSql)) { +pstmt.executeUpdate(); +s_logger.info("Altered usage table and added column quota_calculated"); --- End diff -- The log statement to should reflect the actual name of table, ``cloud_usage``, altered in order to avoid ambiguity. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r4624 --- Diff: engine/schema/src/com/cloud/upgrade/dao/Upgrade461to470.java --- @@ -51,8 +53,23 @@ public boolean supportsRollingUpgrade() { return new File[] {new File(script)}; } +public void alterAddColumnToCloudUsage(final Connection conn) { +final String alterTableSql = "ALTER TABLE `cloud_usage`.`cloud_usage` ADD COLUMN `quota_calculated` tinyint(1) DEFAULT 0 NOT NULL COMMENT 'quota calculation status'"; +try (PreparedStatement pstmt = conn.prepareStatement(alterTableSql)) { +pstmt.executeUpdate(); +s_logger.info("Altered usage table and added column quota_calculated"); +} catch (SQLException e) { +if (e.getMessage().contains("quota_calculated")) { +s_logger.warn("Usage table already has a column called quota_calculated"); --- End diff -- The log statement to should reflect the actual name of table, cloud_usage, altered in order to avoid ambiguity. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r4638 --- Diff: engine/schema/src/com/cloud/usage/UsageVO.java --- @@ -328,4 +339,48 @@ public Date getStartDate() { public Date getEndDate() { return endDate; } + +public void setId(Long id) { +this.id = id; +} + +public void setType(String type) { +this.type = type; +} + +public void setStartDate(Date startDate) { +this.startDate = startDate; +} + +public void setEndDate(Date endDate) { +this.endDate = endDate; --- End diff -- Since Date instances are mutable, the ``this.endDate`` should be a copy of ``endDate`` to avoid side-effects. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r4633 --- Diff: engine/schema/src/com/cloud/usage/UsageVO.java --- @@ -328,4 +339,48 @@ public Date getStartDate() { public Date getEndDate() { return endDate; } + +public void setId(Long id) { +this.id = id; +} + +public void setType(String type) { +this.type = type; +} + +public void setStartDate(Date startDate) { +this.startDate = startDate; --- End diff -- Since Date instances are mutable, the ``this.startDate`` should be a copy of ``startDate`` to avoid side-effects. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46777893 --- Diff: framework/db/src/com/cloud/utils/db/Transaction.java --- @@ -35,18 +35,15 @@ if (currentTxn != null) { databaseId = currentTxn.getDatabaseId(); } -TransactionLegacy txn = TransactionLegacy.open(name, databaseId, false); -try { -//if (txn.dbTxnStarted()){ -//String warnMsg = "Potential Wrong Usage: TRANSACTION.EXECUTE IS WRAPPED INSIDE ANOTHER DB TRANSACTION!"; -//s_logger.warn(warnMsg, new CloudRuntimeException(warnMsg)); -//} +try (final TransactionLegacy txn = TransactionLegacy.open(name, databaseId, false)) { +// if (txn.dbTxnStarted()){ +// String warnMsg = "Potential Wrong Usage: TRANSACTION.EXECUTE IS WRAPPED INSIDE ANOTHER DB TRANSACTION!"; +// s_logger.warn(warnMsg, new CloudRuntimeException(warnMsg)); +// } --- End diff -- Please remove crufty commented code. git history/bisect is a far better tool to understand the evolution of code. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46782245 --- Diff: framework/quota/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java --- @@ -0,0 +1,408 @@ +//Licensed to the Apache Software Foundation (ASF) under one +//or more contributor license agreements. See the NOTICE file +//distributed with this work for additional information +//regarding copyright ownership. The ASF licenses this file +//to you under the Apache License, Version 2.0 (the +//"License"); you may not use this file except in compliance +//with the License. You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +//Unless required by applicable law or agreed to in writing, +//software distributed under the License is distributed on an +//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +//KIND, either express or implied. See the License for the +//specific language governing permissions and limitations +//under the License. +package org.apache.cloudstack.quota; + +import com.cloud.domain.DomainVO; +import com.cloud.domain.dao.DomainDao; +import com.cloud.user.Account; +import com.cloud.user.Account.State; +import com.cloud.user.AccountVO; +import com.cloud.user.UserVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.user.dao.UserDao; +import com.cloud.utils.NumbersUtil; +import com.cloud.utils.component.ManagerBase; +import com.cloud.utils.db.TransactionLegacy; +import com.cloud.utils.exception.CloudRuntimeException; +import com.google.common.base.Strings; +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.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); + +@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; + +boolean _smtpDebug = false; + +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); + +if (params != null) { +mergeConfigs(configs, params); +} + +final String smtpHost = configs.get(QuotaConfig.QuotaSmtpHost.key()); +int smtpPort = NumbersUtil.parseInt(configs.get(QuotaConfig.QuotaSmtpPort.key()), 25); +String useAuthStr = configs.get(QuotaConfig.Quot
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46782964 --- Diff: framework/quota/src/org/apache/cloudstack/quota/QuotaStatementImpl.java --- @@ -0,0 +1,376 @@ +//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 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.concurrent.TimeUnit; + +import javax.ejb.Local; +import javax.inject.Inject; +import javax.naming.ConfigurationException; + +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.QuotaAlertManagerImpl.DeferredQuotaEmail; +import org.apache.cloudstack.quota.constant.QuotaConfig; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; + +import com.cloud.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.component.ManagerBase; + +@Component +@Local(value = QuotaStatement.class) +public class QuotaStatementImpl extends ManagerBase implements QuotaStatement { +private static final Logger s_logger = Logger.getLogger(QuotaStatementImpl.class); + +@Inject +private AccountDao _accountDao; +@Inject +private QuotaAccountDao _quotaAcc; +@Inject +private QuotaUsageDao _quotaUsage; +@Inject +private QuotaAlertManager _quotaAlert; +@Inject +private ConfigurationDao _configDao; + +final public static int s_LAST_STATEMENT_SENT_DAYS = 6; //ideally should be less than 7 days + +public enum STATEMENT_PERIODS { +BIMONTHLY, MONTHLY, QUATERLY, HALFYEARLY, YEARLY +}; + +private STATEMENT_PERIODS _period = STATEMENT_PERIODS.MONTHLY; + +public QuotaStatementImpl() { +super(); +} + +private void mergeConfigs(Map dbParams, Map xmlParams) { +for (Map.Entry param : xmlParams.entrySet()) { +dbParams.put(param.getKey(), (String)param.getValue()); +} +} + +@Override +public boolean configure(String name, Map params) throws ConfigurationException { +super.configure(name, params); + +Map configs = _configDao.getConfiguration(params); + +if (params != null) { +mergeConfigs(configs, params); +} +String period_str = configs.get(QuotaConfig.QuotaStatementPeriod.key()); +int period = period_str == null ? 1 : Integer.valueOf(period_str); + +STATEMENT_PERIODS _period = STATEMENT_PERIODS.values()[period]; +return true; +} + +@Override +public boolean start() { +if (s_logger.isInfoEnabled()) { +s_logger.info("Starting Alert Manager"); --- End diff -- This log message seems deceptive. This class is about quota statements not alerts. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46782968 --- Diff: framework/quota/src/org/apache/cloudstack/quota/QuotaStatementImpl.java --- @@ -0,0 +1,376 @@ +//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 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.concurrent.TimeUnit; + +import javax.ejb.Local; +import javax.inject.Inject; +import javax.naming.ConfigurationException; + +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.QuotaAlertManagerImpl.DeferredQuotaEmail; +import org.apache.cloudstack.quota.constant.QuotaConfig; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; + +import com.cloud.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.component.ManagerBase; + +@Component +@Local(value = QuotaStatement.class) +public class QuotaStatementImpl extends ManagerBase implements QuotaStatement { +private static final Logger s_logger = Logger.getLogger(QuotaStatementImpl.class); + +@Inject +private AccountDao _accountDao; +@Inject +private QuotaAccountDao _quotaAcc; +@Inject +private QuotaUsageDao _quotaUsage; +@Inject +private QuotaAlertManager _quotaAlert; +@Inject +private ConfigurationDao _configDao; + +final public static int s_LAST_STATEMENT_SENT_DAYS = 6; //ideally should be less than 7 days + +public enum STATEMENT_PERIODS { +BIMONTHLY, MONTHLY, QUATERLY, HALFYEARLY, YEARLY +}; + +private STATEMENT_PERIODS _period = STATEMENT_PERIODS.MONTHLY; + +public QuotaStatementImpl() { +super(); +} + +private void mergeConfigs(Map dbParams, Map xmlParams) { +for (Map.Entry param : xmlParams.entrySet()) { +dbParams.put(param.getKey(), (String)param.getValue()); +} +} + +@Override +public boolean configure(String name, Map params) throws ConfigurationException { +super.configure(name, params); + +Map configs = _configDao.getConfiguration(params); + +if (params != null) { +mergeConfigs(configs, params); +} +String period_str = configs.get(QuotaConfig.QuotaStatementPeriod.key()); +int period = period_str == null ? 1 : Integer.valueOf(period_str); + +STATEMENT_PERIODS _period = STATEMENT_PERIODS.values()[period]; +return true; +} + +@Override +public boolean start() { +if (s_logger.isInfoEnabled()) { +s_logger.info("Starting Alert Manager"); +} +return true; +} + +@Override +public boolean stop() { +if (s_logger.isInfoEnabled()) { +s_logger.info("Stopping Alert Manager"); --- End diff -- This log message seems deceptive. This class is about quota statements not alerts. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46783089 --- Diff: framework/quota/src/org/apache/cloudstack/quota/constant/QuotaConfig.java --- @@ -0,0 +1,53 @@ +//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.constant; + +import org.apache.cloudstack.framework.config.ConfigKey; + +public interface QuotaConfig { --- End diff -- @abhinandanprateek it is idiomatic to exclude the unnecessary access modifiers for maintainability reasons. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46783125 --- Diff: framework/quota/src/org/apache/cloudstack/quota/constant/QuotaConfig.java --- @@ -0,0 +1,53 @@ +//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.constant; + +import org.apache.cloudstack.framework.config.ConfigKey; + +public interface QuotaConfig { + +public static final ConfigKey QuotaPluginEnabled = new ConfigKey("Advanced", Boolean.class, "quota.enable.service", "false", "Indicates whether Quota plugin is enabled or not", +true); + +public static final ConfigKey QuotaEnableEnforcement = new ConfigKey("Advanced", String.class, "quota.enable.enforcement", "false", +"Enable the usage quota enforcement, i.e. on true when exceeding quota the respective account will be locked.", true); + +public static final ConfigKey QuotaCurrencySymbol = new ConfigKey("Advanced", String.class, "quota.currency.symbol", "R", "The symbol for the currency in use to measure usage.", +true); + +public static final ConfigKey QuotaSmtpHost = new ConfigKey("Advanced", String.class, "quota.usage.smtp.host", "", "Quota SMTP host for quota related emails", true); + +public static final ConfigKey QuotaSmtpTimeout = new ConfigKey("Advanced", String.class, "quota.usage.smtp.connection.timeout", "60", +"Quota SMTP server connection timeout duration", true); + +public static final ConfigKey QuotaSmtpUser = new ConfigKey("Advanced", String.class, "quota.usage.smtp.user", "", "Quota SMTP server username", true); + +public static final ConfigKey QuotaSmtpPassword = new ConfigKey("Advanced", String.class, "quota.usage.smtp.password", "", "Quota SMTP server password", true); + +public static final ConfigKey QuotaSmtpPort = new ConfigKey("Advanced", String.class, "quota.usage.smtp.port", "", "Quota SMTP port", true); + +public static final ConfigKey QuotaSmtpAuthType = new ConfigKey("Advanced", String.class, "quota.usage.smtp.useAuth", "", +"If true, use secure SMTP authentication when sending emails.", true); + +public static final ConfigKey QuotaSmtpSender = new ConfigKey("Advanced", String.class, "quota.usage.smtp.sender", "", +"Sender of quota alert email (will be in the From header of the email)", true); + --- End diff -- @abhinandanprateek why are they necessary? Under what circumstances would a user have a separate mail server for quota alerts and all other CloudStack alerts? --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46783314 --- Diff: framework/quota/src/org/apache/cloudstack/quota/dao/QuotaTariffDaoImpl.java --- @@ -0,0 +1,131 @@ +//Licensed to the Apache Software Foundation (ASF) under one +//or more contributor license agreements. See the NOTICE file +//distributed with this work for additional information +//regarding copyright ownership. The ASF licenses this file +//to you under the Apache License, Version 2.0 (the +//"License"); you may not use this file except in compliance +//with the License. You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +//Unless required by applicable law or agreed to in writing, +//software distributed under the License is distributed on an +//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +//KIND, either express or implied. See the License for the +//specific language governing permissions and limitations +//under the License. +package org.apache.cloudstack.quota.dao; + +import com.cloud.utils.db.Filter; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; +import com.cloud.utils.db.TransactionCallback; +import com.cloud.utils.db.TransactionLegacy; +import com.cloud.utils.db.TransactionStatus; +import org.apache.cloudstack.quota.constant.QuotaTypes; +import org.apache.cloudstack.quota.vo.QuotaTariffVO; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; + +import javax.ejb.Local; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Component +@Local(value = {QuotaTariffDao.class}) +public class QuotaTariffDaoImpl extends GenericDaoBase implements QuotaTariffDao { +private static final Logger s_logger = Logger.getLogger(QuotaTariffDaoImpl.class.getName()); + +private final SearchBuilder searchUsageType; +private final SearchBuilder listAllIncludedUsageType; + +public QuotaTariffDaoImpl() { +super(); +searchUsageType = createSearchBuilder(); +searchUsageType.and("usage_type", searchUsageType.entity().getUsageType(), SearchCriteria.Op.EQ); +searchUsageType.done(); + +listAllIncludedUsageType = createSearchBuilder(); +listAllIncludedUsageType.and("onorbefore", listAllIncludedUsageType.entity().getEffectiveOn(), SearchCriteria.Op.LTEQ); +listAllIncludedUsageType.and("quotatype", listAllIncludedUsageType.entity().getUsageType(), SearchCriteria.Op.EQ); +listAllIncludedUsageType.done(); +} + +public QuotaTariffVO findTariffPlanByUsageType(final int quotaType, final Date effectiveDate) { +return Transaction.execute(TransactionLegacy.USAGE_DB, new TransactionCallback() { +@Override +public QuotaTariffVO doInTransaction(final TransactionStatus status) { +List result = new ArrayList<>(); +final Filter filter = new Filter(QuotaTariffVO.class, "updatedOn", false, 0L, 1L); +final SearchCriteria sc = listAllIncludedUsageType.create(); +sc.setParameters("onorbefore", effectiveDate); +sc.setParameters("quotatype", quotaType); +result = search(sc, filter); +if (result != null && !result.isEmpty()) { +return result.get(0); +} else { +if (s_logger.isDebugEnabled()) { + s_logger.debug("QuotaTariffDaoImpl::findTariffPlanByUsageType: Missing quota type " + quotaType); +} +return null; +} +} +}); +} + +public List listAllTariffPlans() { +return Transaction.execute(TransactionLegacy.USAGE_DB, new TransactionCallback>() { +@Override +public List doInTransaction(final TransactionStatus status) { +return listAll(); +} +}); +} + +public List listAllTariffPlans(final Date effectiveDate) { +return Transaction.execute(TransactionLegacy.USAGE_DB, new TransactionCallback>() { +@Override +public List doInTransaction(final TransactionStatus status) { +List tariffs = new ArrayList(); +final Filter filter = new Filter(QuotaTariffVO.class, "updatedOn", false, 0L, 1L); +final SearchCriteria sc = listAllIncludedUsageType.create();
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46783388 --- Diff: framework/quota/src/org/apache/cloudstack/quota/vo/QuotaUsageVO.java --- @@ -0,0 +1,177 @@ +//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.vo; + +import java.math.BigDecimal; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.cloudstack.api.InternalIdentity; + +@Entity +@Table(name = "quota_usage") +public class QuotaUsageVO implements InternalIdentity { + +private static final long serialVersionUID = -7117933845287204781L; + +@Id +@Column(name = "id") +private Long id; + +@Column(name = "zone_id") +private Long zoneId = null; + +@Column(name = "account_id") +private Long accountId = null; + +@Column(name = "domain_id") +private Long domainId = null; + +@Column(name = "usage_item_id") +private Long usageItemId; + +@Column(name = "usage_type") +private int usageType; + +@Column(name = "quota_used") +private BigDecimal quotaUsed; + +@Column(name = "start_date") +@Temporal(value = TemporalType.TIMESTAMP) +private Date startDate = null; + +@Column(name = "end_date") +@Temporal(value = TemporalType.TIMESTAMP) +private Date endDate = null; + +public QuotaUsageVO() { +usageType = -1; +quotaUsed = new BigDecimal(0); +endDate = new Date(); +startDate = new Date(); +} + +public QuotaUsageVO(Long usageItemId, Long zoneId, Long accountId, Long domainId, int usageType, BigDecimal quotaUsed, Date startDate, Date endDate) { +super(); +this.usageItemId = usageItemId; +this.zoneId = zoneId; +this.accountId = accountId; +this.domainId = domainId; +this.usageType = usageType; +this.quotaUsed = quotaUsed; +this.startDate = startDate; +this.endDate = endDate; +} + +public QuotaUsageVO(QuotaUsageVO toclone) { +super(); +this.usageItemId = toclone.usageItemId; +this.zoneId = toclone.zoneId; +this.accountId = toclone.accountId; +this.domainId = toclone.domainId; +this.usageType = toclone.usageType; +this.quotaUsed = toclone.quotaUsed; +this.startDate = toclone.startDate; +this.endDate = toclone.endDate; +} + +public Long getZoneId() { +return zoneId; +} + +public void setZoneId(Long zoneId) { +this.zoneId = zoneId; +} + +public Long getAccountId() { +return accountId; +} + +public void setAccountId(Long accountId) { +this.accountId = accountId; +} + +public Long getDomainId() { +return domainId; +} + +public void setDomainId(Long domainId) { +this.domainId = domainId; +} + +@Override +public long getId() { +return id; +} + +public Long getUsageItemId() { +return usageItemId; +} + +public void setUsageItemId(Long usageItemId) { +this.usageItemId = usageItemId; +} + +public int getUsageType() { +return usageType; +} + +public void setUsageType(int usageType) { +this.usageType = usageType; +} + +public BigDecimal getQuotaUsed() { +return quotaUsed; +} + +public void setQuotaUsed(BigDecimal quotaUsed) { +this.quotaUsed = quotaUsed; +
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46783384 --- Diff: framework/quota/src/org/apache/cloudstack/quota/vo/QuotaUsageVO.java --- @@ -0,0 +1,177 @@ +//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.vo; + +import java.math.BigDecimal; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.cloudstack.api.InternalIdentity; + +@Entity +@Table(name = "quota_usage") +public class QuotaUsageVO implements InternalIdentity { + +private static final long serialVersionUID = -7117933845287204781L; + +@Id +@Column(name = "id") +private Long id; + +@Column(name = "zone_id") +private Long zoneId = null; + +@Column(name = "account_id") +private Long accountId = null; + +@Column(name = "domain_id") +private Long domainId = null; + +@Column(name = "usage_item_id") +private Long usageItemId; + +@Column(name = "usage_type") +private int usageType; + +@Column(name = "quota_used") +private BigDecimal quotaUsed; + +@Column(name = "start_date") +@Temporal(value = TemporalType.TIMESTAMP) +private Date startDate = null; + +@Column(name = "end_date") +@Temporal(value = TemporalType.TIMESTAMP) +private Date endDate = null; + +public QuotaUsageVO() { +usageType = -1; +quotaUsed = new BigDecimal(0); +endDate = new Date(); +startDate = new Date(); +} + +public QuotaUsageVO(Long usageItemId, Long zoneId, Long accountId, Long domainId, int usageType, BigDecimal quotaUsed, Date startDate, Date endDate) { +super(); +this.usageItemId = usageItemId; +this.zoneId = zoneId; +this.accountId = accountId; +this.domainId = domainId; +this.usageType = usageType; +this.quotaUsed = quotaUsed; +this.startDate = startDate; +this.endDate = endDate; +} + +public QuotaUsageVO(QuotaUsageVO toclone) { +super(); +this.usageItemId = toclone.usageItemId; +this.zoneId = toclone.zoneId; +this.accountId = toclone.accountId; +this.domainId = toclone.domainId; +this.usageType = toclone.usageType; +this.quotaUsed = toclone.quotaUsed; +this.startDate = toclone.startDate; +this.endDate = toclone.endDate; +} + +public Long getZoneId() { +return zoneId; +} + +public void setZoneId(Long zoneId) { +this.zoneId = zoneId; +} + +public Long getAccountId() { +return accountId; +} + +public void setAccountId(Long accountId) { +this.accountId = accountId; +} + +public Long getDomainId() { +return domainId; +} + +public void setDomainId(Long domainId) { +this.domainId = domainId; +} + +@Override +public long getId() { +return id; +} + +public Long getUsageItemId() { +return usageItemId; +} + +public void setUsageItemId(Long usageItemId) { +this.usageItemId = usageItemId; +} + +public int getUsageType() { +return usageType; +} + +public void setUsageType(int usageType) { +this.usageType = usageType; +} + +public BigDecimal getQuotaUsed() { +return quotaUsed; +} + +public void setQuotaUsed(BigDecimal quotaUsed) { +this.quotaUsed = quotaUsed; +
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46783406 --- Diff: framework/quota/src/org/apache/cloudstack/quota/vo/QuotaUsageVO.java --- @@ -0,0 +1,177 @@ +//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.vo; + +import java.math.BigDecimal; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.cloudstack.api.InternalIdentity; + +@Entity +@Table(name = "quota_usage") +public class QuotaUsageVO implements InternalIdentity { + +private static final long serialVersionUID = -7117933845287204781L; + +@Id +@Column(name = "id") +private Long id; + +@Column(name = "zone_id") +private Long zoneId = null; + +@Column(name = "account_id") +private Long accountId = null; + +@Column(name = "domain_id") +private Long domainId = null; + +@Column(name = "usage_item_id") +private Long usageItemId; + +@Column(name = "usage_type") +private int usageType; + +@Column(name = "quota_used") +private BigDecimal quotaUsed; + +@Column(name = "start_date") +@Temporal(value = TemporalType.TIMESTAMP) +private Date startDate = null; + +@Column(name = "end_date") +@Temporal(value = TemporalType.TIMESTAMP) +private Date endDate = null; + +public QuotaUsageVO() { +usageType = -1; +quotaUsed = new BigDecimal(0); +endDate = new Date(); +startDate = new Date(); +} + +public QuotaUsageVO(Long usageItemId, Long zoneId, Long accountId, Long domainId, int usageType, BigDecimal quotaUsed, Date startDate, Date endDate) { +super(); +this.usageItemId = usageItemId; +this.zoneId = zoneId; +this.accountId = accountId; +this.domainId = domainId; +this.usageType = usageType; +this.quotaUsed = quotaUsed; +this.startDate = startDate; +this.endDate = endDate; +} + +public QuotaUsageVO(QuotaUsageVO toclone) { +super(); +this.usageItemId = toclone.usageItemId; +this.zoneId = toclone.zoneId; +this.accountId = toclone.accountId; +this.domainId = toclone.domainId; +this.usageType = toclone.usageType; +this.quotaUsed = toclone.quotaUsed; +this.startDate = toclone.startDate; +this.endDate = toclone.endDate; +} + +public Long getZoneId() { +return zoneId; +} + +public void setZoneId(Long zoneId) { +this.zoneId = zoneId; +} + +public Long getAccountId() { +return accountId; +} + +public void setAccountId(Long accountId) { +this.accountId = accountId; +} + +public Long getDomainId() { +return domainId; +} + +public void setDomainId(Long domainId) { +this.domainId = domainId; +} + +@Override +public long getId() { +return id; +} + +public Long getUsageItemId() { +return usageItemId; +} + +public void setUsageItemId(Long usageItemId) { +this.usageItemId = usageItemId; +} + +public int getUsageType() { +return usageType; +} + +public void setUsageType(int usageType) { +this.usageType = usageType; +} + +public BigDecimal getQuotaUsed() { +return quotaUsed; +} + +public void setQuotaUsed(BigDecimal quotaUsed) { +this.quotaUsed = quotaUsed; +
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784092 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaStatementTest.java --- @@ -0,0 +1,248 @@ +// 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.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.QuotaStatementImpl.STATEMENT_PERIODS; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.naming.ConfigurationException; + +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaStatementTest extends TestCase { + +@Mock +AccountDao accountDao; +@Mock +QuotaAccountDao quotaAcc; +@Mock +ConfigurationDao configDao; +@Mock +QuotaUsageDao quotaUsage; +@Mock +QuotaAlertManager emailQuotaAlert; + +@Spy +QuotaStatementImpl quotaStatement = new QuotaStatementImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaStatementImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaStatement, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaStatementImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(configDao, "_configDao"); +injectMockToField(quotaUsage, "_quotaUsage"); +injectMockToField(emailQuotaAlert, "_quotaAlert"); +} + +@Test +public void testStartStop() { +try { +quotaStatement.start(); // expected to fail as pid is not available +} catch (NumberFormatException ignored) { +} +assertTrue(quotaStatement.stop()); +} + +@Test +public void testStatementPeriodBIMONTHLY() { +Calendar date = Calendar.getInstance(); + +//BIMONTHLY - first statement of month +date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 1); +Calendar period[] = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period == null); + +//1 of this month +date.set(Calendar.DATE, 1); +period = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period != null); +assertTrue(period[0].toString(), period[0].before(period[1])); +assertTrue(period[0].toString(), period[0].get(Calendar.DATE) == 1); +assertTrue(period[1].toString(), period[1].get(Calendar.DATE) == 15); + +//BIMONTHLY - second statement of month +date = Calendar.getInstance(); +date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 16); +period = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period == null); + +//17 of this month
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784117 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaStatementTest.java --- @@ -0,0 +1,248 @@ +// 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.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.QuotaStatementImpl.STATEMENT_PERIODS; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.naming.ConfigurationException; + +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaStatementTest extends TestCase { + +@Mock +AccountDao accountDao; +@Mock +QuotaAccountDao quotaAcc; +@Mock +ConfigurationDao configDao; +@Mock +QuotaUsageDao quotaUsage; +@Mock +QuotaAlertManager emailQuotaAlert; + +@Spy +QuotaStatementImpl quotaStatement = new QuotaStatementImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaStatementImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaStatement, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaStatementImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(configDao, "_configDao"); +injectMockToField(quotaUsage, "_quotaUsage"); +injectMockToField(emailQuotaAlert, "_quotaAlert"); +} + +@Test +public void testStartStop() { +try { +quotaStatement.start(); // expected to fail as pid is not available +} catch (NumberFormatException ignored) { +} +assertTrue(quotaStatement.stop()); +} + +@Test +public void testStatementPeriodBIMONTHLY() { +Calendar date = Calendar.getInstance(); + +//BIMONTHLY - first statement of month +date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 1); +Calendar period[] = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period == null); + +//1 of this month +date.set(Calendar.DATE, 1); +period = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period != null); +assertTrue(period[0].toString(), period[0].before(period[1])); +assertTrue(period[0].toString(), period[0].get(Calendar.DATE) == 1); +assertTrue(period[1].toString(), period[1].get(Calendar.DATE) == 15); + +//BIMONTHLY - second statement of month +date = Calendar.getInstance(); +date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 16); +period = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period == null); + +//17 of this month
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784126 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaStatementTest.java --- @@ -0,0 +1,248 @@ +// 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.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.QuotaStatementImpl.STATEMENT_PERIODS; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.naming.ConfigurationException; + +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaStatementTest extends TestCase { + +@Mock +AccountDao accountDao; +@Mock +QuotaAccountDao quotaAcc; +@Mock +ConfigurationDao configDao; +@Mock +QuotaUsageDao quotaUsage; +@Mock +QuotaAlertManager emailQuotaAlert; + +@Spy +QuotaStatementImpl quotaStatement = new QuotaStatementImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaStatementImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaStatement, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaStatementImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(configDao, "_configDao"); +injectMockToField(quotaUsage, "_quotaUsage"); +injectMockToField(emailQuotaAlert, "_quotaAlert"); +} + +@Test +public void testStartStop() { +try { +quotaStatement.start(); // expected to fail as pid is not available +} catch (NumberFormatException ignored) { +} +assertTrue(quotaStatement.stop()); +} + +@Test +public void testStatementPeriodBIMONTHLY() { +Calendar date = Calendar.getInstance(); + +//BIMONTHLY - first statement of month +date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 1); +Calendar period[] = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period == null); + +//1 of this month +date.set(Calendar.DATE, 1); +period = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period != null); +assertTrue(period[0].toString(), period[0].before(period[1])); +assertTrue(period[0].toString(), period[0].get(Calendar.DATE) == 1); +assertTrue(period[1].toString(), period[1].get(Calendar.DATE) == 15); + +//BIMONTHLY - second statement of month +date = Calendar.getInstance(); +date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 16); +period = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period == null); + +//17 of this month
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784145 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaStatementTest.java --- @@ -0,0 +1,248 @@ +// 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.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.QuotaStatementImpl.STATEMENT_PERIODS; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.naming.ConfigurationException; + +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaStatementTest extends TestCase { + +@Mock +AccountDao accountDao; +@Mock +QuotaAccountDao quotaAcc; +@Mock +ConfigurationDao configDao; +@Mock +QuotaUsageDao quotaUsage; +@Mock +QuotaAlertManager emailQuotaAlert; + +@Spy +QuotaStatementImpl quotaStatement = new QuotaStatementImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaStatementImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaStatement, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaStatementImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(configDao, "_configDao"); +injectMockToField(quotaUsage, "_quotaUsage"); +injectMockToField(emailQuotaAlert, "_quotaAlert"); +} + +@Test +public void testStartStop() { +try { +quotaStatement.start(); // expected to fail as pid is not available --- End diff -- If this is expected to fail the line 84 should a ``fail`` call since it is expected that this operation will throw an exception. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784176 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaStatementTest.java --- @@ -0,0 +1,248 @@ +// 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.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.QuotaStatementImpl.STATEMENT_PERIODS; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.naming.ConfigurationException; + +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaStatementTest extends TestCase { + +@Mock +AccountDao accountDao; +@Mock +QuotaAccountDao quotaAcc; +@Mock +ConfigurationDao configDao; +@Mock +QuotaUsageDao quotaUsage; +@Mock +QuotaAlertManager emailQuotaAlert; + +@Spy +QuotaStatementImpl quotaStatement = new QuotaStatementImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaStatementImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaStatement, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaStatementImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(configDao, "_configDao"); +injectMockToField(quotaUsage, "_quotaUsage"); +injectMockToField(emailQuotaAlert, "_quotaAlert"); +} + +@Test +public void testStartStop() { +try { +quotaStatement.start(); // expected to fail as pid is not available +} catch (NumberFormatException ignored) { +} +assertTrue(quotaStatement.stop()); --- End diff -- Why would we test the ``stop`` operation in a test where we expect the ``start`` operation to fail? --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784185 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaStatementTest.java --- @@ -0,0 +1,248 @@ +// 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.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.QuotaStatementImpl.STATEMENT_PERIODS; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.naming.ConfigurationException; + +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaStatementTest extends TestCase { + +@Mock +AccountDao accountDao; +@Mock +QuotaAccountDao quotaAcc; +@Mock +ConfigurationDao configDao; +@Mock +QuotaUsageDao quotaUsage; +@Mock +QuotaAlertManager emailQuotaAlert; + +@Spy +QuotaStatementImpl quotaStatement = new QuotaStatementImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaStatementImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaStatement, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaStatementImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(configDao, "_configDao"); +injectMockToField(quotaUsage, "_quotaUsage"); +injectMockToField(emailQuotaAlert, "_quotaAlert"); +} + +@Test +public void testStartStop() { +try { +quotaStatement.start(); // expected to fail as pid is not available +} catch (NumberFormatException ignored) { +} +assertTrue(quotaStatement.stop()); +} + +@Test +public void testStatementPeriodBIMONTHLY() { +Calendar date = Calendar.getInstance(); + +//BIMONTHLY - first statement of month +date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 1); +Calendar period[] = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period == null); + +//1 of this month +date.set(Calendar.DATE, 1); +period = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period != null); +assertTrue(period[0].toString(), period[0].before(period[1])); +assertTrue(period[0].toString(), period[0].get(Calendar.DATE) == 1); +assertTrue(period[1].toString(), period[1].get(Calendar.DATE) == 15); + +//BIMONTHLY - second statement of month +date = Calendar.getInstance(); +date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 16); +period = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY); +assertTrue(period == null); + +//17 of this month
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784229 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaManagerImplTest.java --- @@ -0,0 +1,203 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.quota; + +import com.cloud.usage.UsageVO; +import com.cloud.usage.dao.UsageDao; +import com.cloud.user.Account; +import com.cloud.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.Pair; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaBalanceDao; +import org.apache.cloudstack.quota.dao.QuotaTariffDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.dao.ServiceOfferingDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.apache.cloudstack.quota.vo.QuotaTariffVO; +import org.apache.cloudstack.quota.vo.QuotaUsageVO; +import org.apache.cloudstack.usage.UsageTypes; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.naming.ConfigurationException; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaManagerImplTest extends TestCase { + +@Mock +private AccountDao accountDao; +@Mock +private QuotaAccountDao quotaAcc; +@Mock +private UsageDao usageDao; +@Mock +private QuotaTariffDao quotaTariffDao; +@Mock +private QuotaUsageDao quotaUsageDao; +@Mock +private ServiceOfferingDao serviceOfferingDao; +@Mock +private QuotaBalanceDao quotaBalanceDao; +@Mock +private ConfigurationDao configDao; + +@Spy +QuotaManagerImpl quotaManager = new QuotaManagerImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaManagerImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaManager, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaManagerImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(usageDao, "_usageDao"); +injectMockToField(quotaTariffDao, "_quotaTariffDao"); +injectMockToField(quotaUsageDao, "_quotaUsageDao"); +injectMockToField(serviceOfferingDao, "_serviceOfferingDao"); +injectMockToField(quotaBalanceDao, "_quotaBalanceDao"); +injectMockToField(configDao, "_configDao"); +} + +@Test +public void testStartStop() { +try { +quotaManager.start(); // expected to fail as pid is not available +} catch (NumberFormatException ignored) { +} +assertTrue(quotaManager.stop()); +} + +@Test +public void testConfig() throws ConfigurationException { + Mockito.when(configDao.getConfiguration(Mockito.anyMapOf(String.class, Object.class))).thenReturn(new HashMap()); +Map map = new HashMap<>(); +map.put("usage.stats.job.aggregation.range", "0"); +assertTrue(quotaManager.confi
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784268 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaManagerImplTest.java --- @@ -0,0 +1,203 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.quota; + +import com.cloud.usage.UsageVO; +import com.cloud.usage.dao.UsageDao; +import com.cloud.user.Account; +import com.cloud.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.Pair; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaBalanceDao; +import org.apache.cloudstack.quota.dao.QuotaTariffDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.dao.ServiceOfferingDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.apache.cloudstack.quota.vo.QuotaTariffVO; +import org.apache.cloudstack.quota.vo.QuotaUsageVO; +import org.apache.cloudstack.usage.UsageTypes; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.naming.ConfigurationException; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaManagerImplTest extends TestCase { + +@Mock +private AccountDao accountDao; +@Mock +private QuotaAccountDao quotaAcc; +@Mock +private UsageDao usageDao; +@Mock +private QuotaTariffDao quotaTariffDao; +@Mock +private QuotaUsageDao quotaUsageDao; +@Mock +private ServiceOfferingDao serviceOfferingDao; +@Mock +private QuotaBalanceDao quotaBalanceDao; +@Mock +private ConfigurationDao configDao; + +@Spy +QuotaManagerImpl quotaManager = new QuotaManagerImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaManagerImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaManager, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaManagerImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(usageDao, "_usageDao"); +injectMockToField(quotaTariffDao, "_quotaTariffDao"); +injectMockToField(quotaUsageDao, "_quotaUsageDao"); +injectMockToField(serviceOfferingDao, "_serviceOfferingDao"); +injectMockToField(quotaBalanceDao, "_quotaBalanceDao"); +injectMockToField(configDao, "_configDao"); +} + +@Test +public void testStartStop() { +try { +quotaManager.start(); // expected to fail as pid is not available --- End diff -- If this is expected to fail the line 102 should call ``fail`` since it is expected that this operation will throw an exception. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784283 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaManagerImplTest.java --- @@ -0,0 +1,203 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.quota; + +import com.cloud.usage.UsageVO; +import com.cloud.usage.dao.UsageDao; +import com.cloud.user.Account; +import com.cloud.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.Pair; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaBalanceDao; +import org.apache.cloudstack.quota.dao.QuotaTariffDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.dao.ServiceOfferingDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.apache.cloudstack.quota.vo.QuotaTariffVO; +import org.apache.cloudstack.quota.vo.QuotaUsageVO; +import org.apache.cloudstack.usage.UsageTypes; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.naming.ConfigurationException; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaManagerImplTest extends TestCase { + +@Mock +private AccountDao accountDao; +@Mock +private QuotaAccountDao quotaAcc; +@Mock +private UsageDao usageDao; +@Mock +private QuotaTariffDao quotaTariffDao; +@Mock +private QuotaUsageDao quotaUsageDao; +@Mock +private ServiceOfferingDao serviceOfferingDao; +@Mock +private QuotaBalanceDao quotaBalanceDao; +@Mock +private ConfigurationDao configDao; + +@Spy +QuotaManagerImpl quotaManager = new QuotaManagerImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaManagerImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaManager, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaManagerImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(usageDao, "_usageDao"); +injectMockToField(quotaTariffDao, "_quotaTariffDao"); +injectMockToField(quotaUsageDao, "_quotaUsageDao"); +injectMockToField(serviceOfferingDao, "_serviceOfferingDao"); +injectMockToField(quotaBalanceDao, "_quotaBalanceDao"); +injectMockToField(configDao, "_configDao"); +} + +@Test +public void testStartStop() { +try { +quotaManager.start(); // expected to fail as pid is not available +} catch (NumberFormatException ignored) { +} +assertTrue(quotaManager.stop()); --- End diff -- Why is the ``stop`` operation being tested when the ``start`` operation was expected to fail? --- 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 infrastr
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784327 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaAlertManagerImplTest.java --- @@ -0,0 +1,205 @@ +// 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.AccountVO; +import com.cloud.user.UserVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.user.dao.UserDao; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +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.QuotaEmailTemplatesDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO; +import org.joda.time.DateTime; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.mail.MessagingException; +import javax.naming.ConfigurationException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaAlertManagerImplTest extends TestCase { + +@Mock +AccountDao accountDao; +@Mock +QuotaAccountDao quotaAcc; +@Mock +UserDao userDao; +@Mock +DomainDao domainDao; +@Mock +QuotaEmailTemplatesDao quotaEmailTemplateDao; +@Mock +ConfigurationDao configDao; +@Mock +QuotaUsageDao quotaUsage; +@Mock +QuotaAlertManagerImpl.EmailQuotaAlert emailQuotaAlert; + +@Spy +QuotaAlertManagerImpl quotaAlertManager = new QuotaAlertManagerImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaAlertManagerImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaAlertManager, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaAlertManagerImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(userDao, "_userDao"); +injectMockToField(domainDao, "_domainDao"); +injectMockToField(quotaEmailTemplateDao, "_quotaEmailTemplateDao"); +injectMockToField(configDao, "_configDao"); +injectMockToField(quotaUsage, "_quotaUsage"); +injectMockToField(emailQuotaAlert, "_emailQuotaAlert"); +} + +@Test +public void testStartStop() { +try { +quotaAlertManager.start(); // expected to fail as pid is not available +} catch (NumberFormatException ignored) { +} +assertTrue(quotaAlertManager.stop()); +} + +@Test +public void testCheckAndSendQuotaAlertEmails() { +AccountVO accountVO = new AccountVO(); +accountVO.setId(2L); +accountVO.setDomainId(1L); +accountVO.setType(Account.ACCOUNT_TYPE_NORMAL); + Mockito.when(accountDao.findById(Mockito.anyLong())).thenReturn(accountVO); + +QuotaAccountVO acc = new QuotaAccountV
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784388 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaAlertManagerImplTest.java --- @@ -0,0 +1,205 @@ +// 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.AccountVO; +import com.cloud.user.UserVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.user.dao.UserDao; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +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.QuotaEmailTemplatesDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO; +import org.joda.time.DateTime; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.mail.MessagingException; +import javax.naming.ConfigurationException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaAlertManagerImplTest extends TestCase { + +@Mock +AccountDao accountDao; +@Mock +QuotaAccountDao quotaAcc; +@Mock +UserDao userDao; +@Mock +DomainDao domainDao; +@Mock +QuotaEmailTemplatesDao quotaEmailTemplateDao; +@Mock +ConfigurationDao configDao; +@Mock +QuotaUsageDao quotaUsage; +@Mock +QuotaAlertManagerImpl.EmailQuotaAlert emailQuotaAlert; + +@Spy +QuotaAlertManagerImpl quotaAlertManager = new QuotaAlertManagerImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaAlertManagerImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaAlertManager, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaAlertManagerImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(userDao, "_userDao"); +injectMockToField(domainDao, "_domainDao"); +injectMockToField(quotaEmailTemplateDao, "_quotaEmailTemplateDao"); +injectMockToField(configDao, "_configDao"); +injectMockToField(quotaUsage, "_quotaUsage"); +injectMockToField(emailQuotaAlert, "_emailQuotaAlert"); +} + +@Test +public void testStartStop() { +try { +quotaAlertManager.start(); // expected to fail as pid is not available +} catch (NumberFormatException ignored) { +} +assertTrue(quotaAlertManager.stop()); +} + +@Test +public void testCheckAndSendQuotaAlertEmails() { +AccountVO accountVO = new AccountVO(); +accountVO.setId(2L); +accountVO.setDomainId(1L); +accountVO.setType(Account.ACCOUNT_TYPE_NORMAL); + Mockito.when(accountDao.findById(Mockito.anyLong())).thenReturn(accountVO); + +QuotaAccountVO acc = new QuotaAccountV
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784395 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaAlertManagerImplTest.java --- @@ -0,0 +1,205 @@ +// 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.AccountVO; +import com.cloud.user.UserVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.user.dao.UserDao; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +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.QuotaEmailTemplatesDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO; +import org.joda.time.DateTime; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.mail.MessagingException; +import javax.naming.ConfigurationException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaAlertManagerImplTest extends TestCase { + +@Mock +AccountDao accountDao; +@Mock +QuotaAccountDao quotaAcc; +@Mock +UserDao userDao; +@Mock +DomainDao domainDao; +@Mock +QuotaEmailTemplatesDao quotaEmailTemplateDao; +@Mock +ConfigurationDao configDao; +@Mock +QuotaUsageDao quotaUsage; +@Mock +QuotaAlertManagerImpl.EmailQuotaAlert emailQuotaAlert; + +@Spy +QuotaAlertManagerImpl quotaAlertManager = new QuotaAlertManagerImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaAlertManagerImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaAlertManager, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaAlertManagerImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(userDao, "_userDao"); +injectMockToField(domainDao, "_domainDao"); +injectMockToField(quotaEmailTemplateDao, "_quotaEmailTemplateDao"); +injectMockToField(configDao, "_configDao"); +injectMockToField(quotaUsage, "_quotaUsage"); +injectMockToField(emailQuotaAlert, "_emailQuotaAlert"); +} + +@Test +public void testStartStop() { +try { +quotaAlertManager.start(); // expected to fail as pid is not available --- End diff -- If this is expected to fail the line 101 should call ``fail`` since it is expected that this operation will throw an exception. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784408 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaAlertManagerImplTest.java --- @@ -0,0 +1,205 @@ +// 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.AccountVO; +import com.cloud.user.UserVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.user.dao.UserDao; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +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.QuotaEmailTemplatesDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO; +import org.joda.time.DateTime; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.mail.MessagingException; +import javax.naming.ConfigurationException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaAlertManagerImplTest extends TestCase { + +@Mock +AccountDao accountDao; +@Mock +QuotaAccountDao quotaAcc; +@Mock +UserDao userDao; +@Mock +DomainDao domainDao; +@Mock +QuotaEmailTemplatesDao quotaEmailTemplateDao; +@Mock +ConfigurationDao configDao; +@Mock +QuotaUsageDao quotaUsage; +@Mock +QuotaAlertManagerImpl.EmailQuotaAlert emailQuotaAlert; + +@Spy +QuotaAlertManagerImpl quotaAlertManager = new QuotaAlertManagerImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaAlertManagerImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaAlertManager, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaAlertManagerImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(userDao, "_userDao"); +injectMockToField(domainDao, "_domainDao"); +injectMockToField(quotaEmailTemplateDao, "_quotaEmailTemplateDao"); +injectMockToField(configDao, "_configDao"); +injectMockToField(quotaUsage, "_quotaUsage"); +injectMockToField(emailQuotaAlert, "_emailQuotaAlert"); +} + +@Test +public void testStartStop() { +try { +quotaAlertManager.start(); // expected to fail as pid is not available +} catch (NumberFormatException ignored) { +} +assertTrue(quotaAlertManager.stop()); --- End diff -- Why are we testing the ``stop`` operation when the test method expects the ``start`` operation to fail? --- 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 fi
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784435 --- Diff: framework/quota/test/org/apache/cloudstack/quota/QuotaManagerImplTest.java --- @@ -0,0 +1,203 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.quota; + +import com.cloud.usage.UsageVO; +import com.cloud.usage.dao.UsageDao; +import com.cloud.user.Account; +import com.cloud.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.Pair; +import com.cloud.utils.db.TransactionLegacy; +import junit.framework.TestCase; +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaBalanceDao; +import org.apache.cloudstack.quota.dao.QuotaTariffDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.dao.ServiceOfferingDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.apache.cloudstack.quota.vo.QuotaTariffVO; +import org.apache.cloudstack.quota.vo.QuotaUsageVO; +import org.apache.cloudstack.usage.UsageTypes; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; + +import javax.naming.ConfigurationException; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaManagerImplTest extends TestCase { + +@Mock +private AccountDao accountDao; +@Mock +private QuotaAccountDao quotaAcc; +@Mock +private UsageDao usageDao; +@Mock +private QuotaTariffDao quotaTariffDao; +@Mock +private QuotaUsageDao quotaUsageDao; +@Mock +private ServiceOfferingDao serviceOfferingDao; +@Mock +private QuotaBalanceDao quotaBalanceDao; +@Mock +private ConfigurationDao configDao; + +@Spy +QuotaManagerImpl quotaManager = new QuotaManagerImpl(); + +private void injectMockToField(Object mock, String fieldName) throws NoSuchFieldException, IllegalAccessException { +Field f = QuotaManagerImpl.class.getDeclaredField(fieldName); +f.setAccessible(true); +f.set(quotaManager, mock); +} + +@Before +public void setup() throws IllegalAccessException, NoSuchFieldException, ConfigurationException { +// Dummy transaction stack setup +TransactionLegacy.open("QuotaManagerImplTest"); + +injectMockToField(accountDao, "_accountDao"); +injectMockToField(quotaAcc, "_quotaAcc"); +injectMockToField(usageDao, "_usageDao"); +injectMockToField(quotaTariffDao, "_quotaTariffDao"); +injectMockToField(quotaUsageDao, "_quotaUsageDao"); +injectMockToField(serviceOfferingDao, "_serviceOfferingDao"); +injectMockToField(quotaBalanceDao, "_quotaBalanceDao"); +injectMockToField(configDao, "_configDao"); +} + +@Test +public void testStartStop() { +try { +quotaManager.start(); // expected to fail as pid is not available +} catch (NumberFormatException ignored) { +} +assertTrue(quotaManager.stop()); +} + +@Test +public void testConfig() throws ConfigurationException { + Mockito.when(configDao.getConfiguration(Mockito.anyMapOf(String.class, Object.class))).thenReturn(new HashMap()); +Map map = new HashMap<>(); +map.put("usage.stats.job.aggregation.range", "0"); +assertTrue(quotaManager.confi
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784536 --- Diff: plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java --- @@ -0,0 +1,125 @@ +//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.quota.vo.QuotaBalanceVO; +import org.apache.cloudstack.api.response.QuotaStatementItemResponse; + +@APICommand(name = "quotaBalance", responseObject = QuotaStatementItemResponse.class, description = "Create a quota balance statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class QuotaBalanceCmd extends BaseCmd { + +public static final Logger s_logger = Logger.getLogger(QuotaBalanceCmd.class); + +private static final String s_name = "quotabalanceresponse"; + +@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "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 = "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); --- End diff -- Since ``Date``s are mutable, ``endDate`` should be copied before being passed into ``_responseBuilder.startOfNextDay`` to avoid downstream side-effects. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784547 --- Diff: plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java --- @@ -0,0 +1,125 @@ +//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.quota.vo.QuotaBalanceVO; +import org.apache.cloudstack.api.response.QuotaStatementItemResponse; + +@APICommand(name = "quotaBalance", responseObject = QuotaStatementItemResponse.class, description = "Create a quota balance statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class QuotaBalanceCmd extends BaseCmd { + +public static final Logger s_logger = Logger.getLogger(QuotaBalanceCmd.class); + +private static final String s_name = "quotabalanceresponse"; + +@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "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 = "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; --- End diff -- Since ``Date``s are mutable, ``endDate`` should be copied before being set to ``this.endDate`` to avoid downstream side-effects. --- 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784552 --- Diff: plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java --- @@ -0,0 +1,125 @@ +//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.quota.vo.QuotaBalanceVO; +import org.apache.cloudstack.api.response.QuotaStatementItemResponse; + +@APICommand(name = "quotaBalance", responseObject = QuotaStatementItemResponse.class, description = "Create a quota balance statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class QuotaBalanceCmd extends BaseCmd { + +public static final Logger s_logger = Logger.getLogger(QuotaBalanceCmd.class); + +private static final String s_name = "quotabalanceresponse"; + +@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "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 = "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; --- End diff -- Since ``Date``s are mutable, ``startDate`` should be copied before being set to ``this.startDate`` to avoid downstream side-effects. --- 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
[GitHub] cloudstack pull request: Quota
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784560 --- Diff: plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java --- @@ -0,0 +1,125 @@ +//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.quota.vo.QuotaBalanceVO; +import org.apache.cloudstack.api.response.QuotaStatementItemResponse; + +@APICommand(name = "quotaBalance", responseObject = QuotaStatementItemResponse.class, description = "Create a quota balance statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class QuotaBalanceCmd extends BaseCmd { + +public static final Logger s_logger = Logger.getLogger(QuotaBalanceCmd.class); + +private static final String s_name = "quotabalanceresponse"; + +@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "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 = "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; --- End diff -- Since ``Date``s are mutable, a copy of ``startDate`` should be returned to avoid downstream side-effects. --- 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
Github user abhinandanprateek commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784647 --- Diff: api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java --- @@ -111,6 +111,30 @@ public Long getProjectId() { public String getUsageId() { return usageId; } +public void setAccountName(String accountName) { +this.accountName = accountName; +} + +public void setDomainId(Long domainId) { +this.domainId = domainId; +} + +public void setEndDate(Date endDate) { +this.endDate = endDate; +} + +public void setStartDate(Date startDate) { +this.startDate = startDate; --- End diff -- Not part of 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784609 --- Diff: plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java --- @@ -0,0 +1,141 @@ +//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.QuotaResponseBuilder; +import org.apache.cloudstack.api.response.QuotaStatementResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.quota.vo.QuotaUsageVO; +import org.apache.cloudstack.api.response.QuotaStatementItemResponse; + +import com.cloud.user.Account; + +@APICommand(name = "quotaStatement", responseObject = QuotaStatementItemResponse.class, description = "Create a quota statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class QuotaStatementCmd extends BaseCmd { + +public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class); + +private static final String s_name = "quotastatementresponse"; + +@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, required = true, 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, required = true, 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.TYPE, type = CommandType.INTEGER, description = "List quota usage records for the specified usage type") +private Integer usageType; + +@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 Integer getUsageType() { +return usageType; +} + +public void setUsageType(Integer usageType) { +this.usageType = usageType; +} + +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 _responseBuilder.startOfNextDay(endDate == null ? new Date() : endDate); +} + +public void setEndDate(Date endDate) { +this.endDate = endDate; --- End diff -
[GitHub] cloudstack pull request: Quota
Github user abhinandanprateek commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784636 --- Diff: api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java --- @@ -111,6 +111,30 @@ public Long getProjectId() { public String getUsageId() { return usageId; } +public void setAccountName(String accountName) { +this.accountName = accountName; +} + +public void setDomainId(Long domainId) { +this.domainId = domainId; +} + +public void setEndDate(Date endDate) { +this.endDate = endDate; --- End diff -- Not part of 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784622 --- Diff: plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java --- @@ -0,0 +1,141 @@ +//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.QuotaResponseBuilder; +import org.apache.cloudstack.api.response.QuotaStatementResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.quota.vo.QuotaUsageVO; +import org.apache.cloudstack.api.response.QuotaStatementItemResponse; + +import com.cloud.user.Account; + +@APICommand(name = "quotaStatement", responseObject = QuotaStatementItemResponse.class, description = "Create a quota statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class QuotaStatementCmd extends BaseCmd { + +public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class); + +private static final String s_name = "quotastatementresponse"; + +@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, required = true, 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, required = true, 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.TYPE, type = CommandType.INTEGER, description = "List quota usage records for the specified usage type") +private Integer usageType; + +@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 Integer getUsageType() { +return usageType; +} + +public void setUsageType(Integer usageType) { +this.usageType = usageType; +} + +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 _responseBuilder.startOfNextDay(endDate == null ? new Date() : endDate); +} + +public void setEndDate(Date endDate) { +this.endDate = endDate; +} +
[GitHub] cloudstack pull request: Quota
Github user abhinandanprateek commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784658 --- Diff: engine/schema/src/com/cloud/usage/UsageVO.java --- @@ -328,4 +339,48 @@ public Date getStartDate() { public Date getEndDate() { return endDate; } + +public void setId(Long id) { +this.id = id; +} + +public void setType(String type) { +this.type = type; +} + +public void setStartDate(Date startDate) { +this.startDate = startDate; --- End diff -- Not part of 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
Github user abhinandanprateek commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784665 --- Diff: framework/db/src/com/cloud/utils/db/Transaction.java --- @@ -35,18 +35,15 @@ if (currentTxn != null) { databaseId = currentTxn.getDatabaseId(); } -TransactionLegacy txn = TransactionLegacy.open(name, databaseId, false); -try { -//if (txn.dbTxnStarted()){ -//String warnMsg = "Potential Wrong Usage: TRANSACTION.EXECUTE IS WRAPPED INSIDE ANOTHER DB TRANSACTION!"; -//s_logger.warn(warnMsg, new CloudRuntimeException(warnMsg)); -//} +try (final TransactionLegacy txn = TransactionLegacy.open(name, databaseId, false)) { +// if (txn.dbTxnStarted()){ +// String warnMsg = "Potential Wrong Usage: TRANSACTION.EXECUTE IS WRAPPED INSIDE ANOTHER DB TRANSACTION!"; +// s_logger.warn(warnMsg, new CloudRuntimeException(warnMsg)); +// } --- End diff -- Not part of 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
Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46784639 --- Diff: plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java --- @@ -0,0 +1,141 @@ +//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.QuotaResponseBuilder; +import org.apache.cloudstack.api.response.QuotaStatementResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.quota.vo.QuotaUsageVO; +import org.apache.cloudstack.api.response.QuotaStatementItemResponse; + +import com.cloud.user.Account; + +@APICommand(name = "quotaStatement", responseObject = QuotaStatementItemResponse.class, description = "Create a quota statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class QuotaStatementCmd extends BaseCmd { + +public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class); + +private static final String s_name = "quotastatementresponse"; + +@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, required = true, 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, required = true, 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.TYPE, type = CommandType.INTEGER, description = "List quota usage records for the specified usage type") +private Integer usageType; + +@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 Integer getUsageType() { +return usageType; +} + +public void setUsageType(Integer usageType) { +this.usageType = usageType; +} + +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 _responseBuilder.startOfNextDay(endDate == null ? new Date() : endDate); +} + +public void setEndDate(Date endDate) { +this.endDate = endDate; +} +