Search in sources :

Example 6 with Project

use of net.juniper.contrail.api.types.Project 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

IOException (java.io.IOException)6 Project (net.juniper.contrail.api.types.Project)6 CloudException (com.cloud.exception.CloudException)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 ApiConnector (net.juniper.contrail.api.ApiConnector)3 Domain (com.cloud.domain.Domain)2 InternalErrorException (com.cloud.exception.InternalErrorException)2 NetworkIpam (net.juniper.contrail.api.types.NetworkIpam)2 SubnetType (net.juniper.contrail.api.types.SubnetType)2 VirtualMachine (net.juniper.contrail.api.types.VirtualMachine)2 VirtualNetwork (net.juniper.contrail.api.types.VirtualNetwork)2 VnSubnetsType (net.juniper.contrail.api.types.VnSubnetsType)2 BaseCmd (org.apache.cloudstack.api.BaseCmd)2 VlanVO (com.cloud.dc.VlanVO)1 VlanDao (com.cloud.dc.dao.VlanDao)1 DomainVO (com.cloud.domain.DomainVO)1 Network (com.cloud.network.Network)1 ProjectVO (com.cloud.projects.ProjectVO)1 Account (com.cloud.user.Account)1 UserVm (com.cloud.uservm.UserVm)1