Skip to content

Refactoring of the project creation component to enable domain, account, and user specification - #12646

Open
erikbocks wants to merge 2 commits into
apache:4.20from
scclouds:add-ownership-selection-to-project-creation
Open

erikbocks wants to merge 2 commits into
apache:4.20from
scclouds:add-ownership-selection-to-project-creation

Conversation

@erikbocks

Copy link
Copy Markdown
Collaborator

Description

Currently, it is not possible to specify in the GUI which domain that the project will be created in, neither the account or the user that will be assigned as the project owner, automatically assigning the project to the current user. The project creation component was refactored to allow the specification of the domain, account or user of the project during the project creation.

The current user's account and domain are automatically selected. If the current user does not belong to the selected domain, the first account returned in the listing is selected.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • 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
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Screenshots (if appropriate):

image
Projects created with the new form image

How Has This Been Tested?

First, the subdomain domain was created, the normalroot account was created in the ROOT domain, and the subdomainuser account was created in the subdomain domain. The subDomainAnotherUser user was also created in the subdomainuser account. Then, using the new project creation component, I created the following projects:

  • Project in the ROOT domain with the admin account as the owner;
  • Project in the ROOT domain with the normalroot account as the owner;
  • Project in the subdomain domain with the subdomainuser account as the owner;
  • Project in the subdomain domain with the subDomainAnotherUser user from the subdomainuser account as the owner.

Logged in as a normal user, I validated that the ownership selection component was not shown, and when the project was created, it was automatically assigned to the current account.

I also validated that other features flows that use the OwnershipSelection component (VM deployment, VM assignment and Guest Network creation) were not affected by the changes.

@codecov

codecov Bot commented Feb 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 16.46%. Comparing base (e6f193d) to head (9020bc8).

Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #12646   +/-   ##
=========================================
  Coverage     16.45%   16.46%           
- Complexity    13710    13712    +2     
=========================================
  Files          5669     5670    +1     
  Lines        501734   501769   +35     
  Branches      60961    60965    +4     
=========================================
+ Hits          82584    82616   +32     
- Misses       409895   409897    +2     
- Partials       9255     9256    +1     
Flag Coverage Δ
uitests 4.16% <ø> (-0.01%) ⬇️
unittests 17.33% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

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

@winterhazel

Copy link
Copy Markdown
Member

@erikbocks as this is a simple enhancement, could you target the next 4.20/4.22 minor?

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan ui

@blueorangutan

Copy link
Copy Markdown

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

@erikbocks
erikbocks changed the base branch from main to 4.20 April 14, 2026 19:37
@erikbocks
erikbocks force-pushed the add-ownership-selection-to-project-creation branch from 84f3cfa to 7c7776a Compare April 14, 2026 19:37
@erikbocks
erikbocks requested a review from winterhazel April 14, 2026 19:39
@winterhazel winterhazel added this to the 4.20.4 milestone May 1, 2026
Comment thread ui/src/views/project/CreateProject.vue Resolved
@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan ui

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

UI build: ✔️
Live QA URL: https://qa.cloudstack.cloud/simulator/pr/12646 (QA-JID-932)

@winterhazel

Copy link
Copy Markdown
Member

@erikbocks could you have a look at @bernardodemarco's suggestion at #12646 (comment)?

@erikbocks

Copy link
Copy Markdown
Collaborator Author

Hello, @bernardodemarco, @JoaoJandre and @winterhazel

@bernardodemarco, regarding your suggestion (#12646 (comment)), I tried to find the createProject API parameters behavior that you mentioned, but could not find it. I analyzed the project creation code, and below are my findings about the usage of the accountname and accountid parameters:

accountname

It determines which account will be the owner of the project. When it is informed in the API, there are two different behaviors based on the role of the calling account. For admins, the account with that name is fetched and the caller's access to the resource is validated. If the caller is a normal user, it is validated that the parameter value is equal to the caller's account name. The account found by this name is defined as owner of the project.

Account selection by name
if (isAdmin(caller.getId()) && accountName != null && domainId != null) {
    Domain domain = _domainMgr.getDomain(domainId);
    if (domain == null) {
        throw new InvalidParameterValueException("Unable to find the domain by id=" + domainId);
    }

    Account owner = _accountDao.findActiveAccount(accountName, domainId);
    if (owner == null) {
        throw new InvalidParameterValueException(String.format("Unable to find account %s in domain %s", accountName, domain));
    }
    checkAccess(caller, domain);

    return owner;
} else if (!isAdmin(caller.getId()) && accountName != null && domainId != null) {
    if (!accountName.equals(caller.getAccountName()) || domainId != caller.getDomainId()) {
        throw new PermissionDeniedException("Can't create/list resources for account " + accountName + " in domain " + domainId + ", permission denied");
    } else {
        return caller;
    }

accountid

This parameter is used only if the userid parameter is also informed. When the userid parameter is sent, the validateUser method is executed and the accountid parameter value is used to validate whether the informed user belongs to the informed account. If a user with this ID is found, the project owner is changed to the user's account.

accountid parameter usage
private User validateUser(Long userId, Long accountId, Long domainId) {
    User user = null;
    if (userId != null) {
        user = userDao.findById(userId);
        if (user == null ) {
            throw new InvalidParameterValueException("Invalid user ID provided");
        }
        if (user.getAccountId() != accountId || _accountDao.findById(user.getAccountId()).getDomainId() != domainId) {
            throw new InvalidParameterValueException("User doesn't belong to the specified account or domain");
        }
    }
    return user;
}

Summary

According to the aforementioned code analysis, it is not possible to use the accountname and accountid in the way that you mentioned, as the project's owner always is either the account that matches the informed name, or the informed user's account. Therefore, due to the code behavior, I will solve the suggestion comment. Could we move on with this one? @JoaoJandre @winterhazel

@bernardodemarco bernardodemarco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, tested locally

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Ready

Development

Successfully merging this pull request may close these issues.

8 participants