use of java.lang.Exception in project coprhd-controller by CoprHD.
the class Main method applyIpinfo.
private static void applyIpinfo(ClusterIpInfo ipinfo, String nodeid, int node_count, boolean bNewIp) throws Exception {
log.info("applying ip info: {}", ipinfo.toString());
String isoFilePath = "/tmp/ovf-env.iso";
File isoFile = new File(isoFilePath);
try {
String tmpstr = PlatformUtils.genOvfenvPropertyKVString(ipinfo, nodeid, node_count);
PlatformUtils.genOvfenvIsoImage(tmpstr, isoFilePath);
String ovfenv_part = PlatformUtils.probeOvfenvPartition();
Path path = Paths.get(isoFilePath);
byte[] data = Files.readAllBytes(path);
FileUtils.writePlainFile(ovfenv_part, data);
log.info("Succeed to apply the ip info : {} to ovfenv partition", ipinfo.toString());
} catch (Exception e) {
log.error("Applying ip info to ovfenv partition failed with exception: {}", e.getMessage());
} finally {
isoFile.delete();
}
if (bNewIp) {
FileUtils.deleteFile(IpReconfigConstants.NEWIP_PATH);
FileUtils.deleteFile(IpReconfigConstants.NEWIP_EXPIRATION);
} else {
IpReconfigUtil.writeNodeStatusFile(IpReconfigConstants.NodeStatus.LOCAL_ROLLBACK.toString());
FileUtils.deleteFile(IpReconfigConstants.OLDIP_PATH);
}
}
use of java.lang.Exception in project java-docs-samples by GoogleCloudPlatform.
the class GaeInfoServlet method fetchMetadata.
// Fetch Metadata
String fetchMetadata(String key) throws IOException {
try {
Request request = new Request.Builder().url(metadata + key).addHeader("Metadata-Flavor", "Google").get().build();
Response response = ok.newCall(request).execute();
return response.body().string();
} catch (Exception e) {
log("fetchMetadata - " + metadata + key + ": ", e);
}
return "";
}
Aggregations