use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class AttachVolumeCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("Volume Id: " + getId() + " VmId: " + getVirtualMachineId());
Volume result = _userVmService.attachVolumeToVM(this);
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to attach volume");
}
}
use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class AuthorizeSecurityGroupIngressCmd method execute.
@Override
public void execute() {
if (cidrList != null) {
for (String cidr : cidrList) {
if (!NetUtils.isValidCIDR(cidr)) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, cidr + " is an Invalid CIDR ");
}
}
}
List<? extends SecurityRule> ingressRules = _securityGroupService.authorizeSecurityGroupIngress(this);
if (ingressRules != null && !ingressRules.isEmpty()) {
SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponseFromSecurityGroupRule(ingressRules);
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to authorize security group ingress rule(s)");
}
}
use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class AddSecondaryStorageCmd method execute.
@Override
public void execute() {
try {
List<? extends Host> result = _resourceService.discoverHosts(this);
HostResponse hostResponse = null;
if (result != null && result.size() > 0) {
for (Host host : result) {
// There should only be one secondary storage host per add
hostResponse = _responseGenerator.createHostResponse(host);
hostResponse.setResponseName(getCommandName());
hostResponse.setObjectName("secondarystorage");
this.setResponseObject(hostResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add secondary storage");
}
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}
use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class AddTrafficTypeCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("TrafficType Id: " + getEntityId());
PhysicalNetworkTrafficType result = _networkService.getPhysicalNetworkTrafficType(getEntityId());
if (result != null) {
TrafficTypeResponse response = _responseGenerator.createTrafficTypeResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add traffic type to physical network");
}
}
use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class AddVpnUserCmd method create.
@Override
public void create() {
Account owner = _accountService.getAccount(getEntityOwnerId());
VpnUser vpnUser = _ravService.addVpnUser(owner.getId(), userName, password);
if (vpnUser == null) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
}
setEntityId(vpnUser.getId());
}
Aggregations