[GitHub] cloudstack pull request: verifying template creation permission ba...

2015-06-22 Thread shwetaag
Github user shwetaag commented on the pull request:

https://github.com/apache/cloudstack/pull/153#issuecomment-114021543
  
@gauravaradhye  and @DaanHoogland  another request for this was created 

https://github.com/apache/cloudstack/pull/184
and @sanjeevneelarapu reviewed it and checked it . Most of your review 
comments were incorporated in the new request except moving it to maintenance 
folder. 





---
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: verifying template creation permission ba...

2015-06-22 Thread shwetaag
Github user shwetaag closed the pull request at:

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


---
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: verifying template creation permission ba...

2015-06-19 Thread DaanHoogland
Github user DaanHoogland commented on the pull request:

https://github.com/apache/cloudstack/pull/153#issuecomment-113523123
  
@gauravaradhye is it to be merged, is extra work necessary?


---
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: verifying template creation permission ba...

2015-06-19 Thread DaanHoogland
Github user DaanHoogland commented on the pull request:

https://github.com/apache/cloudstack/pull/153#issuecomment-113523348
  
@shwetaag are you still working on this? (if not can you close it?)


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


[GitHub] cloudstack pull request: verifying template creation permission ba...

2015-06-19 Thread gauravaradhye
Github user gauravaradhye commented on the pull request:

https://github.com/apache/cloudstack/pull/153#issuecomment-113532279
  
@DaanHoogland Let's wait for @shwetaag  to respond. The patch is not yet 
updated after the review comments.


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


[GitHub] cloudstack pull request: verifying template creation permission ba...

2015-06-02 Thread gauravaradhye
Github user gauravaradhye commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/153#discussion_r31500491
  
--- Diff: test/integration/component/test_escalations_templates.py ---
@@ -55,23 +63,68 @@ def setUpClass(cls):
 cls.hypervisor = cls.testClient.getHypervisorInfo()
 cls.services['mode'] = cls.zone.networktype
 
+cls.mgtSvrDetails = cls.config.__dict__[mgtSvr][0].__dict__
+
 builtin_info = get_builtin_template_info(cls.api_client, 
cls.zone.id)
 cls.services[privatetemplate][url] = builtin_info[0]
 cls.services[privatetemplate][hypervisor] = builtin_info[1]
 cls.services[privatetemplate][format] = builtin_info[2]
+cls.services[templates][url] = builtin_info[0]
+cls.services[templates][hypervisor] = builtin_info[1]
+cls.services[templates][format] = builtin_info[2]
+if cls.zone.localstorageenabled:
+cls.storagetype = 'local'
+cls.services[service_offerings][
+tiny][storagetype] = 'local'
+cls.services[disk_offering][storagetype] = 'local'
+else:
+cls.storagetype = 'shared'
+cls.services[service_offerings][
+tiny][storagetype] = 'shared'
+cls.services[disk_offering][storagetype] = 'shared'
+cls.services[virtual_machine][hypervisor] = cls.hypervisor
+cls.services[virtual_machine][zoneid] = cls.zone.id
+cls.services[virtual_machine][template] = cls.template.id
+cls.services[custom_volume][zoneid] = cls.zone.id
+cls.service_offering = ServiceOffering.create(
+cls.api_client,
+cls.services[service_offerings][tiny]
+)
+cls._cleanup.append(cls.service_offering)
 except Exception as e:
 cls.tearDownClass()
 raise Exception(Warning: Exception in setup : %s % e)
 return
 
+@classmethod
+def RestartServers(cls):
+ Restart management server and usage server 
+
+sshClient = SshClient(
+cls.mgtSvrDetails[mgtSvrIp],
+22,
+cls.mgtSvrDetails[user],
+cls.mgtSvrDetails[passwd]
+)
+command = service cloudstack-management restart
+sshClient.execute(command)
+return
+@classmethod
+def updateConfigurAndRestart(cls,name, value):
+Configurations.update(cls.api_client,
+  name,value )
--- End diff --

Fix pep8 issues. You can do this using autopep8 tool.
pip install autopep8.
autopep8 -i -a -a fileName.py

Then check for any issues remaining to be fixed using pep8 fileName.py 
command. If there are any, fix them manually. 
Autopep8 will fix most of the issues but not all.


---
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: verifying template creation permission ba...

2015-06-02 Thread gauravaradhye
Github user gauravaradhye commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/153#discussion_r31500922
  
--- Diff: test/integration/component/test_escalations_templates.py ---
@@ -55,23 +63,68 @@ def setUpClass(cls):
 cls.hypervisor = cls.testClient.getHypervisorInfo()
 cls.services['mode'] = cls.zone.networktype
 
+cls.mgtSvrDetails = cls.config.__dict__[mgtSvr][0].__dict__
+
 builtin_info = get_builtin_template_info(cls.api_client, 
cls.zone.id)
 cls.services[privatetemplate][url] = builtin_info[0]
 cls.services[privatetemplate][hypervisor] = builtin_info[1]
 cls.services[privatetemplate][format] = builtin_info[2]
+cls.services[templates][url] = builtin_info[0]
+cls.services[templates][hypervisor] = builtin_info[1]
+cls.services[templates][format] = builtin_info[2]
+if cls.zone.localstorageenabled:
+cls.storagetype = 'local'
+cls.services[service_offerings][
+tiny][storagetype] = 'local'
+cls.services[disk_offering][storagetype] = 'local'
+else:
+cls.storagetype = 'shared'
+cls.services[service_offerings][
+tiny][storagetype] = 'shared'
+cls.services[disk_offering][storagetype] = 'shared'
+cls.services[virtual_machine][hypervisor] = cls.hypervisor
+cls.services[virtual_machine][zoneid] = cls.zone.id
+cls.services[virtual_machine][template] = cls.template.id
+cls.services[custom_volume][zoneid] = cls.zone.id
+cls.service_offering = ServiceOffering.create(
+cls.api_client,
+cls.services[service_offerings][tiny]
+)
+cls._cleanup.append(cls.service_offering)
 except Exception as e:
 cls.tearDownClass()
 raise Exception(Warning: Exception in setup : %s % e)
 return
 
+@classmethod
+def RestartServers(cls):
+ Restart management server and usage server 
+
+sshClient = SshClient(
+cls.mgtSvrDetails[mgtSvrIp],
+22,
+cls.mgtSvrDetails[user],
+cls.mgtSvrDetails[passwd]
+)
+command = service cloudstack-management restart
+sshClient.execute(command)
+return
+@classmethod
+def updateConfigurAndRestart(cls,name, value):
--- End diff --

Restarting management server through test case can impact other test cases 
running in parallel.
Move the test to /component/maint/ folder so that it is run serially.


---
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: verifying template creation permission ba...

2015-06-02 Thread gauravaradhye
Github user gauravaradhye commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/153#discussion_r31501000
  
--- Diff: test/integration/component/test_escalations_templates.py ---
@@ -915,3 +968,223 @@ def test_04_copy_template(self):
 )
 del self.services[privatetemplate][ostype]
 return
+
+@attr(tags=[advanced, basic], required_hardware=true)
+def test_05_template_permissions(self):
+
+@Desc: Test to create Public Template by registering or by 
snapshot and volume when
+Global parameter 'allow.public.user.template' is set to  False
+@steps:
+1.Set Global parameter 'allow.public.user.template' as False. 
Restart Management server
+2. Create a domain
+3. Create a domain admin and a domain user
+4. Create a vm as domain user
+5. take snapshot of root disk as user vm
+6. try to create public template from snapshot . It should fail
+7. stop the VM
+8. take the public template from volume. it should fail
+9. register a public template as a domain user . it should fail
+10. create a VM  as domain admin
+11. create a snapshot of root disk as domain admin
+12 create a public template of the snapshot .it should fail
+13. Register a public template as domain admin. it should fail
+14 Stop the vm as domain admin
+15. Create a template from volume as domain admin . it should fail
+
+
+self.updateConfigurAndRestart(allow.public.user.templates, 
false)
+
+subdomain = Domain.create(
+self.api_client,
+self.services[domain],
+)
+
+admin_account = Account.create(
+self.api_client,
+self.services[account],
+admin=True,
+domainid=subdomain.id
+)
+user_account = Account.create(
+self.api_client,
+self.services[account2],
+admin=False,
+domainid=subdomain.id
+)
+admin_user = admin_account.user[0]
+self.admin_api_client = self.testClient.getUserApiClient(
+admin_user.username,
+subdomain.name)
+user = user_account.user[0]
+self.user_api_client = self.testClient.getUserApiClient(
+user.username,
+subdomain.name)
+
+self.services[templates][ispublic] = True
+# Register new public template as domain user
+# Exception should be raised for registering public template
+try:
+template = Template.register(
+self.user_api_client,
+self.services[templates],
+zoneid=self.zone.id,
+account=user_account.name,
+domainid=user_account.domainid,
+hypervisor=self.hypervisor
+)
+self.updateConfigurAndRestart(allow.public.user.templates, 
true)
+self.fail(Template creation passed for user)
+except CloudstackAPIException  as e:
+self.assertRaises(Exception Raised : %s % e)
+# Register new public template as domain admin
+# Exception should be raised for registering public template
+try:
+template = Template.register(
+self.admin_api_client,
+self.services[templates],
+zoneid=self.zone.id,
+account=admin_account.name,
+domainid=admin_account.domainid,
+hypervisor=self.hypervisor
+)
+self.updateConfigurAndRestart(allow.public.user.templates, 
true)
+self.fail(Template creation passed for domain admin)
+except CloudstackAPIException  as e:
+self.assertRaises(Exception Raised : %s % e)
+
+if self.hypervisor.lower() in ['hyperv', 'lxc']:
--- End diff --

Reason of this operation?


---
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: verifying template creation permission ba...

2015-06-02 Thread gauravaradhye
Github user gauravaradhye commented on the pull request:

https://github.com/apache/cloudstack/pull/153#issuecomment-107853053
  
@terbolous yes I will review 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: verifying template creation permission ba...

2015-06-02 Thread gauravaradhye
Github user gauravaradhye commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/153#discussion_r31500783
  
--- Diff: test/integration/component/test_escalations_templates.py ---
@@ -915,3 +968,223 @@ def test_04_copy_template(self):
 )
 del self.services[privatetemplate][ostype]
 return
+
+@attr(tags=[advanced, basic], required_hardware=true)
+def test_05_template_permissions(self):
+
+@Desc: Test to create Public Template by registering or by 
snapshot and volume when
+Global parameter 'allow.public.user.template' is set to  False
+@steps:
+1.Set Global parameter 'allow.public.user.template' as False. 
Restart Management server
+2. Create a domain
+3. Create a domain admin and a domain user
+4. Create a vm as domain user
+5. take snapshot of root disk as user vm
+6. try to create public template from snapshot . It should fail
+7. stop the VM
+8. take the public template from volume. it should fail
+9. register a public template as a domain user . it should fail
+10. create a VM  as domain admin
+11. create a snapshot of root disk as domain admin
+12 create a public template of the snapshot .it should fail
+13. Register a public template as domain admin. it should fail
+14 Stop the vm as domain admin
+15. Create a template from volume as domain admin . it should fail
+
+
+self.updateConfigurAndRestart(allow.public.user.templates, 
false)
+
+subdomain = Domain.create(
+self.api_client,
+self.services[domain],
+)
+
+admin_account = Account.create(
+self.api_client,
+self.services[account],
+admin=True,
+domainid=subdomain.id
+)
+user_account = Account.create(
+self.api_client,
+self.services[account2],
+admin=False,
+domainid=subdomain.id
+)
+admin_user = admin_account.user[0]
+self.admin_api_client = self.testClient.getUserApiClient(
+admin_user.username,
+subdomain.name)
+user = user_account.user[0]
+self.user_api_client = self.testClient.getUserApiClient(
+user.username,
+subdomain.name)
+
+self.services[templates][ispublic] = True
+# Register new public template as domain user
+# Exception should be raised for registering public template
+try:
+template = Template.register(
+self.user_api_client,
+self.services[templates],
+zoneid=self.zone.id,
+account=user_account.name,
+domainid=user_account.domainid,
+hypervisor=self.hypervisor
+)
+self.updateConfigurAndRestart(allow.public.user.templates, 
true)
+self.fail(Template creation passed for user)
+except CloudstackAPIException  as e:
+self.assertRaises(Exception Raised : %s % e)
+# Register new public template as domain admin
+# Exception should be raised for registering public template
+try:
+template = Template.register(
+self.admin_api_client,
+self.services[templates],
+zoneid=self.zone.id,
+account=admin_account.name,
+domainid=admin_account.domainid,
+hypervisor=self.hypervisor
+)
+self.updateConfigurAndRestart(allow.public.user.templates, 
true)
+self.fail(Template creation passed for domain admin)
--- End diff --

Same. Didn't get purpose of self.fail. Change it according to previous 
comment at all places.


---
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: verifying template creation permission ba...

2015-06-02 Thread gauravaradhye
Github user gauravaradhye commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/153#discussion_r31500745
  
--- Diff: test/integration/component/test_escalations_templates.py ---
@@ -915,3 +968,223 @@ def test_04_copy_template(self):
 )
 del self.services[privatetemplate][ostype]
 return
+
+@attr(tags=[advanced, basic], required_hardware=true)
+def test_05_template_permissions(self):
+
+@Desc: Test to create Public Template by registering or by 
snapshot and volume when
+Global parameter 'allow.public.user.template' is set to  False
+@steps:
+1.Set Global parameter 'allow.public.user.template' as False. 
Restart Management server
+2. Create a domain
+3. Create a domain admin and a domain user
+4. Create a vm as domain user
+5. take snapshot of root disk as user vm
+6. try to create public template from snapshot . It should fail
+7. stop the VM
+8. take the public template from volume. it should fail
+9. register a public template as a domain user . it should fail
+10. create a VM  as domain admin
+11. create a snapshot of root disk as domain admin
+12 create a public template of the snapshot .it should fail
+13. Register a public template as domain admin. it should fail
+14 Stop the vm as domain admin
+15. Create a template from volume as domain admin . it should fail
+
+
+self.updateConfigurAndRestart(allow.public.user.templates, 
false)
+
+subdomain = Domain.create(
+self.api_client,
+self.services[domain],
+)
+
+admin_account = Account.create(
+self.api_client,
+self.services[account],
+admin=True,
+domainid=subdomain.id
+)
+user_account = Account.create(
+self.api_client,
+self.services[account2],
+admin=False,
+domainid=subdomain.id
+)
+admin_user = admin_account.user[0]
+self.admin_api_client = self.testClient.getUserApiClient(
+admin_user.username,
+subdomain.name)
+user = user_account.user[0]
+self.user_api_client = self.testClient.getUserApiClient(
+user.username,
+subdomain.name)
+
+self.services[templates][ispublic] = True
+# Register new public template as domain user
+# Exception should be raised for registering public template
+try:
+template = Template.register(
+self.user_api_client,
+self.services[templates],
+zoneid=self.zone.id,
+account=user_account.name,
+domainid=user_account.domainid,
+hypervisor=self.hypervisor
+)
+self.updateConfigurAndRestart(allow.public.user.templates, 
true)
+self.fail(Template creation passed for user)
--- End diff --

Why failing the test case using self.fail?
Use 

with self.assertRaises(Exception):
Template.register()
# Or any code block which should raise 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: verifying template creation permission ba...

2015-06-02 Thread gauravaradhye
Github user gauravaradhye commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/153#discussion_r31500546
  
--- Diff: tools/marvin/marvin/config/test_data.py ---
@@ -791,6 +791,8 @@
 displaytext: xs,
 name: xs,
 passwordenabled: False,
+ostype: CentOS 5.6 (64-bit)
--- End diff --

Please don't use hard-coded values. Will this work when template os type 
changes in the setup?


---
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: verifying template creation permission ba...

2015-06-02 Thread gauravaradhye
Github user gauravaradhye commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/153#discussion_r31501168
  
--- Diff: test/integration/component/test_escalations_templates.py ---
@@ -915,3 +968,223 @@ def test_04_copy_template(self):
 )
 del self.services[privatetemplate][ostype]
 return
+
+@attr(tags=[advanced, basic], required_hardware=true)
+def test_05_template_permissions(self):
+
+@Desc: Test to create Public Template by registering or by 
snapshot and volume when
+Global parameter 'allow.public.user.template' is set to  False
+@steps:
+1.Set Global parameter 'allow.public.user.template' as False. 
Restart Management server
+2. Create a domain
+3. Create a domain admin and a domain user
+4. Create a vm as domain user
+5. take snapshot of root disk as user vm
+6. try to create public template from snapshot . It should fail
+7. stop the VM
+8. take the public template from volume. it should fail
+9. register a public template as a domain user . it should fail
+10. create a VM  as domain admin
+11. create a snapshot of root disk as domain admin
+12 create a public template of the snapshot .it should fail
+13. Register a public template as domain admin. it should fail
+14 Stop the vm as domain admin
+15. Create a template from volume as domain admin . it should fail
+
+
+self.updateConfigurAndRestart(allow.public.user.templates, 
false)
+
+subdomain = Domain.create(
+self.api_client,
+self.services[domain],
+)
+
+admin_account = Account.create(
+self.api_client,
+self.services[account],
+admin=True,
+domainid=subdomain.id
+)
+user_account = Account.create(
+self.api_client,
+self.services[account2],
+admin=False,
+domainid=subdomain.id
+)
+admin_user = admin_account.user[0]
+self.admin_api_client = self.testClient.getUserApiClient(
+admin_user.username,
+subdomain.name)
+user = user_account.user[0]
+self.user_api_client = self.testClient.getUserApiClient(
+user.username,
+subdomain.name)
+
+self.services[templates][ispublic] = True
+# Register new public template as domain user
+# Exception should be raised for registering public template
+try:
+template = Template.register(
+self.user_api_client,
+self.services[templates],
+zoneid=self.zone.id,
+account=user_account.name,
+domainid=user_account.domainid,
+hypervisor=self.hypervisor
+)
+self.updateConfigurAndRestart(allow.public.user.templates, 
true)
+self.fail(Template creation passed for user)
+except CloudstackAPIException  as e:
+self.assertRaises(Exception Raised : %s % e)
+# Register new public template as domain admin
+# Exception should be raised for registering public template
+try:
+template = Template.register(
+self.admin_api_client,
+self.services[templates],
+zoneid=self.zone.id,
+account=admin_account.name,
+domainid=admin_account.domainid,
+hypervisor=self.hypervisor
+)
+self.updateConfigurAndRestart(allow.public.user.templates, 
true)
+self.fail(Template creation passed for domain admin)
+except CloudstackAPIException  as e:
+self.assertRaises(Exception Raised : %s % e)
+
+if self.hypervisor.lower() in ['hyperv', 'lxc']:
+self.updateConfigurAndRestart(allow.public.user.templates, 
true)
+return
+else:
+user_vm_created = VirtualMachine.create(
+self.user_api_client,
+self.services[virtual_machine],
+accountid=user_account.name,
+domainid=user_account.domainid,
+serviceofferingid=self.service_offering.id,
+)
+self.assertIsNotNone(user_vm_created,
+ VM creation failed
+)
+# Get the Root disk of VM
+volume = list_volumes(
+

[GitHub] cloudstack pull request: verifying template creation permission ba...

2015-04-09 Thread shwetaag
GitHub user shwetaag opened a pull request:

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

verifying template creation permission based on global parameter

Test to create Public Template by registering or by snapshot and volume when
Global parameter 'allow.public.user.template' is set to  False
@steps:
1.Set Global parameter 'allow.public.user.template' as False. 
Restart Management server
2. Create a domain
3. Create a domain admin and a domain user
4. Create a vm as domain user
5. take snapshot of root disk as user vm
6. try to create public template from snapshot . It should fail
7. stop the VM
8. take the public template from volume. it should fail
9. register a public template as a domain user . it should fail
10. create a VM  as domain admin
11. create a snapshot of root disk as domain admin
12 create a public template of the snapshot .it should fail
13. Register a public template as domain admin. it should fail
14 Stop the vm as domain admin
15. Create a template from volume as domain admin . it should fail

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

$ git pull https://github.com/shwetaag/cloudstack escalations

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

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

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

This closes #153


commit 01f86972a9317ebf98a1c4677d15f7c1cc0c0698
Author: shweta agarwal shweta.agar...@citrix.com
Date:   2015-04-09T11:21:50Z

verifying template creation permission




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