try {
EC2Address ec2Address = new EC2Address();
// this gets our networkId
// CloudStackAccount caller = getCurrentAccount();
CloudStackZone zone = findZone();
CloudStackNetwork net = findNetwork(zone);
// CloudStackIpAddress resp = getApi().associateIpAddress(null, null, null, "0036952d-48df-4422-9fd0-94b0885e18cb");
CloudStackIpAddress resp = getApi().associateIpAddress(zone.getId(), null, null, net.getId());
ec2Address.setAssociatedInstanceId(resp.getId());
if (resp.getIpAddress() == null) {
List<CloudStackIpAddress> addrList = getApi().listPublicIpAddresses(null, null, null, null, null, null, null, null, null);
if (addrList != null && addrList.size() > 0) {
for (CloudStackIpAddress addr: addrList) {