cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

[UI] Add option to specify account/project while deploying VMs and creating networks

Open BryanMLima opened this issue 10 months ago • 38 comments

Description

This PR adds a new component (OwnershipSelection) to specify the account/project when creating a VM and networks (can also be used for other resources in the future). This component makes it easy for operators with roles Admin and Domain Admin to create VMs for any account and/or project that it has permission.

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)
  • [ ] build/CI

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • [ ] Major
  • [x] Minor

Bug Severity

  • [ ] BLOCKER
  • [ ] Critical
  • [ ] Major
  • [ ] Minor
  • [ ] Trivial

Screenshots (if appropriate):

image

How Has This Been Tested?

I deployed a number of VMs using different accounts and projects in different domains.

How did you try to break this feature and the system with this change?

I tried to verify that the UI only showed the permissions according to the account/project selected.

BryanMLima avatar Apr 15 '24 19:04 BryanMLima

@BryanMLima , have you also logged in as the other user to manipulate/delete the resources created? (nice feature btw)

DaanHoogland avatar Apr 16 '24 06:04 DaanHoogland

@blueorangutan ui

DaanHoogland avatar Apr 16 '24 06:04 DaanHoogland

@DaanHoogland a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

blueorangutan avatar Apr 16 '24 06:04 blueorangutan

UI build: :heavy_check_mark: Live QA URL: https://qa.cloudstack.cloud/simulator/pr/8919 (QA-JID-313)

blueorangutan avatar Apr 16 '24 06:04 blueorangutan

It doesn't work in qa. maybe due to an older backend.

DaanHoogland avatar Apr 16 '24 06:04 DaanHoogland

@blueorangutan package

DaanHoogland avatar Apr 16 '24 06:04 DaanHoogland

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Apr 16 '24 06:04 blueorangutan

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9272

blueorangutan avatar Apr 16 '24 07:04 blueorangutan

@blueorangutan test alma9 kvm-alma9 keepEnv

DaanHoogland avatar Apr 16 '24 08:04 DaanHoogland

@DaanHoogland a [SL] Trillian-Jenkins test job (alma9 mgmt + kvm-alma9) has been kicked to run smoke tests

blueorangutan avatar Apr 16 '24 08:04 blueorangutan

[SF] Trillian test result (tid-9846) Environment: kvm-alma9 (x2), Advanced Networking with Mgmt server a9 Total time taken: 50560 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8919-t9846-kvm-alma9.zip Smoke tests completed. 127 look OK, 2 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_events_resource Error 313.81 test_events_resource.py
test_01_events_resource Error 313.82 test_events_resource.py
test_04_deploy_vm_for_other_user_and_test_vm_operations Failure 97.86 test_network_permissions.py
ContextSuite context=TestNetworkPermissions>:teardown Error 1.67 test_network_permissions.py

blueorangutan avatar Apr 16 '24 22:04 blueorangutan

tested ok, Note that during VM deployment the target user must already have a network to deploy the VM in or there will be no option to the admin to deploy

@DaanHoogland, thanks for testing. In the view of VM deploy, you can create a new network and specify the domain and account, therefore, there is no need to pre-create the network for the account.

image

@BryanMLima , have you also logged in as the other user to manipulate/delete the resources created? (nice feature btw)

Yes, I was able to manage the resources (VM and network) as expected.

BryanMLima avatar Apr 19 '24 14:04 BryanMLima

lgtm, also tested manipulating the VMs in the user end in both domain and project scopes and it is working fine. Tested stopping, resuming, rebooting, scaling and deleting

KlausDornsbach avatar Apr 22 '24 12:04 KlausDornsbach

@BryanMLima are you going to do more work or can we merge?

DaanHoogland avatar Apr 23 '24 07:04 DaanHoogland

@BryanMLima are you going to do more work or can we merge?

I added the component to the Isolated and L2 networks forms (shared networks already has the scope field, so I didn't want to change that). Now, root and domain admins can also create network to any account and project while deploying VMs (and when only creating networks, as it is the same component).

We just need another round of tests for this one.

BryanMLima avatar Apr 23 '24 13:04 BryanMLima

@DaanHoogland, I also removed the duplicate fields mentioned in https://github.com/apache/cloudstack/pull/6442#discussion_r1575706183.

image

BryanMLima avatar Apr 23 '24 14:04 BryanMLima

Nice addition. Tested, it works fine for the cases aforementioned

KlausDornsbach avatar Apr 23 '24 16:04 KlausDornsbach

@blueorangutan ui

DaanHoogland avatar Apr 24 '24 06:04 DaanHoogland

@DaanHoogland a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

blueorangutan avatar Apr 24 '24 06:04 blueorangutan

UI build: :heavy_check_mark: Live QA URL: https://qa.cloudstack.cloud/simulator/pr/8919 (QA-JID-318)

blueorangutan avatar Apr 24 '24 07:04 blueorangutan

@BryanMLima looks good, one issue; if I choose to create in domain A user a and then choose to create a network in domain B I get an error. This makes sense but the error looks like:

image

We can keep this out of scope for this work. JFYI

DaanHoogland avatar Apr 24 '24 08:04 DaanHoogland

@BryanMLima looks good, one issue; if I choose to create in domain A user a and then choose to create a network in domain B I get an error. This makes sense but the error looks like:

image

We can keep this out of scope for this work. JFYI

Thanks for testing @DaanHoogland, I got this error in the QA environment, though it is using the 4.19 branch to build it. However, when I built locally with the main branch, this situation does not occur, I am able to create a network for a different account in the deployment view.

Could you reproduce this error when building locally? This might be a problem with the QA environment.

BryanMLima avatar Apr 24 '24 12:04 BryanMLima

@blueorangutan package

DaanHoogland avatar Apr 24 '24 13:04 DaanHoogland

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Apr 24 '24 13:04 blueorangutan

Thanks for testing @DaanHoogland, I got this error in the QA environment, though it is using the 4.19 branch to build it. However, when I built locally with the main branch, this situation does not occur, I am able to create a network for a different account in the deployment view.

Could you reproduce this error when building locally? This might be a problem with the QA environment.

I actually think it should fail (while deploying in domain A creating a network in domain B), but i'll give it a go anyway.

DaanHoogland avatar Apr 24 '24 13:04 DaanHoogland

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9404

blueorangutan avatar Apr 24 '24 14:04 blueorangutan

[SF] Trillian Build Failed (tid-9988)

blueorangutan avatar Apr 24 '24 14:04 blueorangutan

[SF] Trillian Build Failed (tid-9989)

blueorangutan avatar Apr 24 '24 14:04 blueorangutan

Thanks for testing @DaanHoogland, I got this error in the QA environment, though it is using the 4.19 branch to build it. However, when I built locally with the main branch, this situation does not occur, I am able to create a network for a different account in the deployment view. Could you reproduce this error when building locally? This might be a problem with the QA environment.

I actually think it should fail (while deploying in domain A creating a network in domain B), but i'll give it a go anyway.

The DeployVM view utilizes the component CreateNetwork, indirectly. And the CreateNetwork component is agnostic, therefore, I do not see a problem allowing privilege users to create a network different from the VM's owner — even if it does not make sense. This was already the previous behaviour, the ownership component just gave it more flexibility allowing to create for projects as well.

BryanMLima avatar Apr 24 '24 16:04 BryanMLima

Did some more testing @BryanMLima the illusive "Request failed." actually happens when selecting a domain in your dialog that doesn't contain any account/users.

DaanHoogland avatar Apr 24 '24 20:04 DaanHoogland