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;
}
Aggregations