コード例 #1
0
  @Override
  public List<CiscoAsa1000vDeviceVO> listCiscoAsa1000vResources(ListCiscoAsa1000vResourcesCmd cmd) {
    Long physicalNetworkId = cmd.getPhysicalNetworkId();
    Long ciscoAsa1000vResourceId = cmd.getCiscoAsa1000vResourceId();
    List<CiscoAsa1000vDeviceVO> responseList = new ArrayList<CiscoAsa1000vDeviceVO>();

    if (physicalNetworkId == null && ciscoAsa1000vResourceId == null) {
      throw new InvalidParameterValueException(
          "Either physical network Id or Asa 1000v device Id must be specified");
    }

    if (ciscoAsa1000vResourceId != null) {
      CiscoAsa1000vDeviceVO ciscoAsa1000vResource =
          _ciscoAsa1000vDao.findById(ciscoAsa1000vResourceId);
      if (ciscoAsa1000vResource == null) {
        throw new InvalidParameterValueException(
            "Could not find Cisco Asa 1000v device with id: " + ciscoAsa1000vResourceId);
      }
      responseList.add(ciscoAsa1000vResource);
    } else {
      PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
      if (physicalNetwork == null) {
        throw new InvalidParameterValueException(
            "Could not find a physical network with id: " + physicalNetworkId);
      }
      responseList = _ciscoAsa1000vDao.listByPhysicalNetwork(physicalNetworkId);
    }

    return responseList;
  }
コード例 #2
0
  @Override
  public boolean deleteCiscoAsa1000vResource(DeleteCiscoAsa1000vResourceCmd cmd) {
    Long asaResourceId = cmd.getCiscoAsa1000vResourceId();
    CiscoAsa1000vDeviceVO asaResource = _ciscoAsa1000vDao.findById(asaResourceId);
    if (asaResource == null) {
      throw new InvalidParameterValueException(
          "Could not find a Cisco ASA 1000v appliance with id " + asaResourceId);
    }

    NetworkAsa1000vMapVO networkAsaMap =
        _networkAsa1000vMapDao.findByAsa1000vId(asaResource.getId());
    if (networkAsaMap != null) {
      throw new CloudRuntimeException(
          "Cisco ASA 1000v appliance with id "
              + asaResourceId
              + " cannot be deleted as it is associated with guest network");
    }

    _ciscoAsa1000vDao.remove(asaResourceId);

    return true;
  }