Search in sources :

Example 1 with CreateNetworkCmd

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

the class NetworkProviderTest method createTestNetwork.

private Network createTestNetwork(String name) {
    CreateNetworkCmd cmd = new CreateNetworkCmd();
    ComponentContext.inject(cmd);
    Account system = _accountMgr.getSystemAccount();
    DataCenter zone = _server.getZone();
    ManagementServerMock.setParameter(cmd, "accountName", BaseCmd.CommandType.STRING, system.getAccountName());
    ManagementServerMock.setParameter(cmd, ApiConstants.NAME, BaseCmd.CommandType.STRING, name);
    ManagementServerMock.setParameter(cmd, "displayText", BaseCmd.CommandType.STRING, "test network");
    ManagementServerMock.setParameter(cmd, "networkOfferingId", BaseCmd.CommandType.LONG, _contrailMgr.getRouterOffering().getId());
    ManagementServerMock.setParameter(cmd, "zoneId", BaseCmd.CommandType.LONG, zone.getId());
    ManagementServerMock.setParameter(cmd, ApiConstants.GATEWAY, BaseCmd.CommandType.STRING, "10.0.1.254");
    ManagementServerMock.setParameter(cmd, ApiConstants.NETMASK, BaseCmd.CommandType.STRING, "255.255.255.0");
    // Physical network id can't be specified for Guest traffic type.
    // SetParameter(cmd, "physicalNetworkId", BaseCmd.CommandType.LONG, _znet.getId());
    Network result = null;
    try {
        result = _networkService.createGuestNetwork(cmd);
    } catch (CloudException e) {
        e.printStackTrace();
        return null;
    }
    return result;
}
Also used : Account(com.cloud.user.Account) DataCenter(com.cloud.dc.DataCenter) VirtualNetwork(net.juniper.contrail.api.types.VirtualNetwork) Network(com.cloud.network.Network) CreateNetworkCmd(org.apache.cloudstack.api.command.user.network.CreateNetworkCmd) CloudException(com.cloud.exception.CloudException)

Aggregations

DataCenter (com.cloud.dc.DataCenter)1 CloudException (com.cloud.exception.CloudException)1 Network (com.cloud.network.Network)1 Account (com.cloud.user.Account)1 VirtualNetwork (net.juniper.contrail.api.types.VirtualNetwork)1 CreateNetworkCmd (org.apache.cloudstack.api.command.user.network.CreateNetworkCmd)1