Пример #1
0
 public EnumSet<VMDetails> getDetails() throws InvalidParameterValueException {
   EnumSet<VMDetails> dv;
   if (viewDetails == null || viewDetails.size() <= 0) {
     dv = EnumSet.of(VMDetails.all);
   } else {
     try {
       ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
       for (String detail : viewDetails) {
         dc.add(VMDetails.valueOf(detail));
       }
       dv = EnumSet.copyOf(dc);
     } catch (IllegalArgumentException e) {
       throw new InvalidParameterValueException(
           "The details parameter contains a non permitted value. The allowed values are "
               + EnumSet.allOf(VMDetails.class));
     }
   }
   return dv;
 }
Пример #2
0
 @Override
 public void execute() {
   CallContext.current().setEventDetails("Vm Id: " + getVmId() + " Network Id: " + getNetworkId());
   UserVm result = _userVmService.addNicToVirtualMachine(this);
   ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
   dc.add(VMDetails.valueOf("nics"));
   EnumSet<VMDetails> details = EnumSet.copyOf(dc);
   if (result != null) {
     UserVmResponse response =
         _responseGenerator
             .createUserVmResponse(ResponseView.Restricted, "virtualmachine", details, result)
             .get(0);
     response.setResponseName(getCommandName());
     setResponseObject(response);
   } else {
     throw new ServerApiException(
         ApiErrorCode.INTERNAL_ERROR,
         "Failed to add NIC to vm. Refer to server logs for details.");
   }
 }