use of com.cloud.utils.exception.ExecutionException in project cloudstack by apache.
the class JuniperSrxResource method execute.
private Answer execute(RemoteAccessVpnCfgCommand cmd, int numRetries) {
long accountId = Long.parseLong(cmd.getAccessDetail(NetworkElementCommand.ACCOUNT_ID));
String guestNetworkCidr = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR);
String preSharedKey = cmd.getPresharedKey();
String[] ipRange = cmd.getIpRange().split("-");
try {
openConfiguration();
// Delete existing VPN objects for this account
deleteVpnObjectsForAccount(accountId);
if (cmd.isCreate()) {
// Add IKE policy
manageIkePolicy(SrxCommand.ADD, null, accountId, preSharedKey);
// Add address pool
manageAddressPool(SrxCommand.ADD, null, accountId, guestNetworkCidr, ipRange[0], ipRange[1], _primaryDnsAddress);
}
commitConfiguration();
return new Answer(cmd);
} catch (ExecutionException e) {
s_logger.error(e);
closeConfiguration();
if (numRetries > 0 && refreshSrxConnection()) {
int numRetriesRemaining = numRetries - 1;
s_logger.debug("Retrying RemoteAccessVpnCfgCommand. Number of retries remaining: " + numRetriesRemaining);
return execute(cmd, numRetriesRemaining);
} else {
return new Answer(cmd, e);
}
}
}
use of com.cloud.utils.exception.ExecutionException in project cloudstack by apache.
the class F5BigIpResource method getMembers.
private List<String> getMembers(String virtualServerName) throws ExecutionException {
try {
List<String> members = new ArrayList<String>();
String[] virtualServerNames = genStringArray(virtualServerName);
CommonIPPortDefinition[] membersArray = _loadbalancerApi.get_member(virtualServerNames)[0];
for (CommonIPPortDefinition member : membersArray) {
members.add(member.getAddress() + "-" + member.getPort());
}
return members;
} catch (RemoteException e) {
throw new ExecutionException(e.getMessage());
}
}
use of com.cloud.utils.exception.ExecutionException in project cloudstack by apache.
the class F5BigIpResource method saveConfiguration.
private void saveConfiguration() throws ExecutionException {
try {
_configSyncApi.save_configuration("", SystemConfigSyncSaveMode.SAVE_BASE_LEVEL_CONFIG);
_configSyncApi.save_configuration("", SystemConfigSyncSaveMode.SAVE_HIGH_LEVEL_CONFIG);
s_logger.debug("Successfully saved F5 BigIp configuration.");
} catch (RemoteException e) {
s_logger.error("Failed to save F5 BigIp configuration due to: " + e);
throw new ExecutionException(e.getMessage());
}
}
use of com.cloud.utils.exception.ExecutionException in project cloudstack by apache.
the class F5BigIpResource method getStrippedVirtualServers.
/* getStrippedVirtualServers retuns VirtualServers without user partition information
ex: if VirtualServers is vs-tcp-10.147.44.8-22 then the get_list() will return /Common/vs-tcp-10.147.44.8-22
This method will strip the partition information and only returns a list with VirtualServers (vs-tcp-10.147.44.8-22)*/
private List<String> getStrippedVirtualServers() throws ExecutionException {
try {
List<String> virtualServers = new ArrayList<String>();
String[] virtualServersArray = _virtualServerApi.get_list();
for (String virtualServer : virtualServersArray) {
if (virtualServer.contains("/")) {
virtualServers.add(virtualServer.substring(virtualServer.lastIndexOf("/") + 1));
} else {
virtualServers.add(virtualServer);
}
}
return virtualServers;
} catch (RemoteException e) {
throw new ExecutionException(e.getMessage());
}
}
use of com.cloud.utils.exception.ExecutionException in project cloudstack by apache.
the class F5BigIpResource method execute.
private synchronized Answer execute(IpAssocCommand cmd, int numRetries) {
String[] results = new String[cmd.getIpAddresses().length];
int i = 0;
try {
IpAddressTO[] ips = cmd.getIpAddresses();
for (IpAddressTO ip : ips) {
// is it saver to use Long.valueOf(BroadcastDomain.getValue(ip.getBroadcastUri())) ???
// i.o.w. can this contain vlan:// then change !!!
long guestVlanTag = Long.parseLong(ip.getBroadcastUri());
// It's a hack, using isOneToOneNat field for indicate if it's inline or not
boolean inline = ip.isOneToOneNat();
String vlanSelfIp = inline ? tagAddressWithRouteDomain(ip.getVlanGateway(), guestVlanTag) : ip.getVlanGateway();
String vlanNetmask = ip.getVlanNetmask();
// Delete any existing guest VLAN with this tag, self IP, and netmask
deleteGuestVlan(guestVlanTag, vlanSelfIp, vlanNetmask, inline);
if (ip.isAdd()) {
// Add a new guest VLAN
addGuestVlan(guestVlanTag, vlanSelfIp, vlanNetmask, inline);
}
saveConfiguration();
results[i++] = ip.getPublicIp() + " - success";
}
} catch (ExecutionException e) {
s_logger.error("Failed to execute IPAssocCommand due to " + e);
if (shouldRetry(numRetries)) {
return retry(cmd, numRetries);
} else {
results[i++] = IpAssocAnswer.errorResult;
}
}
return new IpAssocAnswer(cmd, results);
}
Aggregations