Search in sources :

Example 1 with CreateVlanIpRangeCmd

use of org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd in project cloudstack by apache.

the class ManagementServerMock method createPublicVlanIpRange.

private void createPublicVlanIpRange() {
    CreateVlanIpRangeCmd cmd = new CreateVlanIpRangeCmd();
    BaseCmd proxy = ComponentContext.inject(cmd);
    Long public_net_id = null;
    List<NetworkVO> nets = _networksDao.listByZoneAndTrafficType(_zone.getId(), TrafficType.Public);
    if (nets != null && !nets.isEmpty()) {
        NetworkVO public_net = nets.get(0);
        public_net_id = public_net.getId();
    } else {
        s_logger.debug("no public network found in the zone: " + _zone.getId());
    }
    Account system = _accountMgr.getSystemAccount();
    setParameter(cmd, "accountName", BaseCmd.CommandType.STRING, system.getAccountName());
    setParameter(cmd, "domainId", BaseCmd.CommandType.LONG, Domain.ROOT_DOMAIN);
    setParameter(cmd, "startIp", BaseCmd.CommandType.STRING, "10.84.60.200");
    setParameter(cmd, "endIp", BaseCmd.CommandType.STRING, "10.84.60.250");
    setParameter(cmd, ApiConstants.GATEWAY, BaseCmd.CommandType.STRING, "10.84.60.254");
    setParameter(cmd, ApiConstants.NETMASK, BaseCmd.CommandType.STRING, "255.255.255.0");
    setParameter(cmd, "networkID", BaseCmd.CommandType.LONG, public_net_id);
    setParameter(cmd, "zoneId", BaseCmd.CommandType.LONG, _zone.getId());
    setParameter(cmd, "vlan", BaseCmd.CommandType.STRING, "untagged");
    s_logger.debug("createPublicVlanIpRange execute : zone id: " + _zone.getId() + ", public net id: " + public_net_id);
    try {
        _configService.createVlanAndPublicIpRange(cmd);
    } catch (Exception e) {
        s_logger.debug("createPublicVlanIpRange: " + e);
    }
}
Also used : Account(com.cloud.user.Account) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) CreateVlanIpRangeCmd(org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd) BaseCmd(org.apache.cloudstack.api.BaseCmd) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException)

Aggregations

AgentUnavailableException (com.cloud.exception.AgentUnavailableException)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)1 NetworkVO (com.cloud.network.dao.NetworkVO)1 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)1 Account (com.cloud.user.Account)1 BaseCmd (org.apache.cloudstack.api.BaseCmd)1 CreateVlanIpRangeCmd (org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd)1