soreana opened a new pull request #4774:
URL: https://github.com/apache/cloudstack/pull/4774
### Description
As a cloud provider, we don't want our customers to see other templates.
This pr limits template access to the domain.
<!-- For new features, provide link to FS, dev ML discussion etc. -->
<!-- In case of bug fix, the expected and actual behaviours, steps to
reproduce. -->
<!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be
closed when this PR gets merged -->
<!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
<!-- Fixes: # -->
<!---
*********************************************************************************
-->
<!--- NOTE: AUTOMATATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE
DOCUMENTATION. -->
<!--- PLEASE PUT AN 'X' in only **ONE** box -->
<!---
*********************************************************************************
-->
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
### Feature/Enhancement Scale or Bug Severity
#### Feature/Enhancement Scale
- [ ] Major
- [x] Minor
### How Has This Been Tested?
To test this feature, I created two domains named Test1 and Test2, each with
their respective domain admins (test1 and test2).
I used cloudmonkey command to list different combination of templateFilters
( **all**, **featured**, **self**, **selfexecutable**, **sharedexecutable**,
**executable** and **community** ) and accounts ( **admin**, **test1** and
**test2** ).
#### To test this feature:
1. Create two domain with their respective domain admin accounts.
2. Register new template in one of those domains. e.g: Debian.
3. Set global setting `restrict.public.access.to.templates` to **off**. This
is the community's default. Justify output of cloudmonkey listTemplates with
third column of last table.
4. Set global setting `restrict.public.access.to.templates` to **on**.
Justify output of cloudmonkey listTemplates with fourth column of last table.
Template | Owner
--------------|--------------
CentOS | Admin
Debian | Test1
SystemVM | Admin
Ubuntu | Admin
<table>
<thead>
<tr>
<th> Account </th>
<th> templatefilter </th>
<th> global setting=false </th>
<th> global setting=true </th>
<tbody>
<tr>
<td rowspan=7>Admin</td>
<td>all</td>
<td>CentOs<br>Debian<br>SystemVm<br>Ubuntu</td>
<td>No change</td>
</tr>
<tr>
<td>featured</td>
<td>CentOs<br>Ubuntu</td>
<td>No change</td>
</tr>
<tr>
<td> self </td>
<td>Ubuntu<br>SystemVm</td>
<td>No change</td>
</tr>
<tr>
<td> selfexecutable </td>
<td>Ubuntu</td>
<td>No change</td>
</tr>
<tr>
<td> sharedexecutable </td>
<td>Nothing</td>
<td>No change</td>
</tr>
<tr>
<td>executable</td>
<td>CentOs<br>Debian<br>SystemVm<br>Ubuntu</td>
<td>No change</td>
</tr>
<tr>
<td> community </td>
<td>Debian</td>
<td>No change</td>
</tr>
<tr>
<td rowspan=7>test1</td>
<td>all</td>
<td>CentOs<br>Debian<br>Ubuntu</td>
<td>No change</td>
</tr>
<tr>
<td>featured</td>
<td>CentOs<br>Ubuntu</td>
<td>No change</td>
</tr>
<tr>
<td> self </td>
<td>Debian</td>
<td>No change</td>
</tr>
<tr>
<td> selfexecutable </td>
<td> Debian </td>
<td>No change</td>
</tr>
<tr>
<td> sharedexecutable </td>
<td>Nothing</td>
<td>No change</td>
</tr>
<tr>
<td>executable</td>
<td>CentOs<br>Debian<br>Ubuntu</td>
<td>No change</td>
</tr>
<tr>
<td> community </td>
<td>Debian</td>
<td>No change</td>
</tr>
<tr>
<td rowspan=7>test2</td>
<td>all</td>
<td>CentOs<br>Debian<br>Ubuntu</td>
<td>CentOs<br>Ubuntu</td>
</tr>
<tr>
<td>featured</td>
<td>CentOs<br>Ubuntu</td>
<td>No change</td>
</tr>
<tr>
<td> self </td>
<td>Nothing</td>
<td>No change</td>
</tr>
<tr>
<td> selfexecutable </td>
<td> Nothing </td>
<td>No change</td>
</tr>
<tr>
<td> sharedexecutable </td>
<td>Nothing</td>
<td>No change</td>
</tr>
<tr>
<td>executable</td>
<td>CentOs<br>Debian<br>Ubuntu</td>
<td>CentOs<br>Ubuntu</td>
</tr>
<tr>
<td> community </td>
<td>Debian</td>
<td> Nothing </td>
</tr>
</tbody>
</table>
I wrote
[this](https://gist.github.com/soreana/7c20dd1b5bca00cfdfee5018c13add6a) script
to test this pr, you can find it in the following link. You need the `cmk`
command and you should put `admin`, `test1`, and `test2` users info in the cmk
configuration file. How to run this?
- Put account names in accounts array defined at top of the script
- ./listTemplates.sh will list all filter for all accounts
- ./listTemplates.sh <account name> list all templates using all possible
filters for <account name>
- ./listTemplates.sh <template filter> list all templates for accounts in
('admin' 'test' 'test2') using <template filter>
- ./listTemplates.sh <account name> <template filter> list all templates for
<accounts name> using <template filter>
<!-- Please read the
[CONTRIBUTING](https://github.com/apache/cloudstack/blob/master/CONTRIBUTING.md)
document -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]