Search in sources :

Example 1 with CreateProjectCmd

use of org.apache.cloudstack.api.command.user.project.CreateProjectCmd in project cloudstack by apache.

the class NetworkProviderTest method createProject.

public void createProject(String name) {
    BaseCmd cmd = new CreateProjectCmd();
    BaseCmd proxy = ComponentContext.inject(cmd);
    Account system = _accountMgr.getSystemAccount();
    ManagementServerMock.setParameter(proxy, "accountName", BaseCmd.CommandType.STRING, system.getAccountName());
    ManagementServerMock.setParameter(proxy, "domainId", BaseCmd.CommandType.LONG, Domain.ROOT_DOMAIN);
    ManagementServerMock.setParameter(proxy, "name", BaseCmd.CommandType.STRING, name);
    ManagementServerMock.setParameter(proxy, "displayText", BaseCmd.CommandType.STRING, name);
    try {
        ((CreateProjectCmd) proxy).create();
        ((CreateProjectCmd) proxy).execute();
    } catch (Exception e) {
        s_logger.debug("CreateProjectCmd exception: " + e);
        e.printStackTrace();
        fail("create project cmd failed");
    }
    DomainVO domain = _domainDao.findById(Domain.ROOT_DOMAIN);
    try {
        net.juniper.contrail.api.types.Domain vncDomain = (net.juniper.contrail.api.types.Domain) _api.findById(net.juniper.contrail.api.types.Domain.class, domain.getUuid());
        if (_api.findByName(net.juniper.contrail.api.types.Project.class, vncDomain, name) == null) {
            fail("create project failed in vnc");
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Exception while creating a project in vnc");
    }
}
Also used : Account(com.cloud.user.Account) BaseCmd(org.apache.cloudstack.api.BaseCmd) CloudException(com.cloud.exception.CloudException) IOException(java.io.IOException) DomainVO(com.cloud.domain.DomainVO) Project(net.juniper.contrail.api.types.Project) CreateProjectCmd(org.apache.cloudstack.api.command.user.project.CreateProjectCmd) Domain(com.cloud.domain.Domain)

Aggregations

Domain (com.cloud.domain.Domain)1 DomainVO (com.cloud.domain.DomainVO)1 CloudException (com.cloud.exception.CloudException)1 Account (com.cloud.user.Account)1 IOException (java.io.IOException)1 Project (net.juniper.contrail.api.types.Project)1 BaseCmd (org.apache.cloudstack.api.BaseCmd)1 CreateProjectCmd (org.apache.cloudstack.api.command.user.project.CreateProjectCmd)1