Example #1
0
 public static void updateAddressingMode() {
   int allocatedCount = Addresses.clearUnusedSystemAddresses();
   LOG.debug("Found " + allocatedCount + " addresses allocated to eucalyptus");
   if (Addresses.doDynamicAddressing()) {
     return;
   } else {
     Addresses.getInstance().doStaticAddressing(allocatedCount);
   }
 }
Example #2
0
 public static synchronized List<Address> allocateAddresses(String cluster, int count)
     throws NotEnoughResourcesAvailable {
   boolean doDynamic = true;
   AddressUtil.updateAddressingMode();
   doDynamic = Addresses.doDynamicAddressing();
   List<Address> addressList = null;
   if (doDynamic) {
     addressList = Addresses.getInstance().getDynamicSystemAddresses(cluster, count);
   } else {
     addressList = Addresses.getInstance().getStaticSystemAddresses(count);
   }
   return addressList;
 }
Example #3
0
 public static void releaseAddress(String s) {
   try {
     Address addr = Addresses.getInstance().lookup(s);
     AddressUtil.releaseAddress(addr);
   } catch (NoSuchElementException e) {
     LOG.debug(e, e);
   }
 }
Example #4
0
 public static boolean initialize(String cluster, List<Pair> ccList) {
   if (AddressUtil.tryInit(cluster)) {
     try {
       List<Address> addrList = getStoredAddresses(cluster);
       List<String> ccListAddrs =
           Lists.transform(
               ccList,
               new Function<Pair, String>() {
                 @Override
                 public String apply(Pair p) {
                   return p.getLeft();
                 }
               });
       for (Address addr : addrList) {
         if (ccListAddrs.contains(addr.getName())) {
           Pair current = checkHasCurrentState(addr.getName(), ccList);
           if (current != null) {
             try {
               VmInstance vm = VmInstances.getInstance().lookupByInstanceIp(current.getRight());
               addr.setAssigned(vm.getInstanceId(), current.getRight());
             } catch (Exception e) {
               addr.doUnassign();
             }
           }
           addr.init();
           ccList.remove(current);
         } else {
           try {
             addr.release();
             Addresses.getInstance().deregister(addr.getName());
           } catch (Throwable e) {
             LOG.debug(e);
           }
         }
       }
       for (Pair current : ccList) {
         Address addr = AddressUtil.lookupOrCreate(cluster, current);
         try {
           VmInstance vm = VmInstances.getInstance().lookupByInstanceIp(current.getRight());
           addr.allocate(Component.eucalyptus.name());
           addr.setAssigned(vm.getInstanceId(), current.getRight());
         } catch (Exception e) {
           addr.doUnassign();
         }
         addr.init();
       }
     } catch (Throwable e) {
       clusterInit.get(cluster).set(false);
     }
     return true;
   } else {
     return false;
   }
 }
Example #5
0
 public static Address lookupOrCreate(String cluster, Pair p) {
   Address address;
   try {
     try {
       address = Addresses.getInstance().lookup(p.getLeft());
     } catch (NoSuchElementException e1) {
       address = Addresses.getInstance().lookupDisabled(p.getLeft());
     }
   } catch (NoSuchElementException e) {
     LOG.debug(e);
     address = new Address(p.getLeft(), cluster);
     try {
       VmInstance vm = VmInstances.getInstance().lookupByInstanceIp(p.getRight());
       address.allocate(Component.eucalyptus.name());
       address.setAssigned(vm.getInstanceId(), p.getRight());
     } catch (Exception e1) {
       // TODO: dispatch unassign for unknown address.
     }
     address.init();
   }
   return address;
 }
Example #6
0
 public static void dispatchAssignAddress(String addr, VmInstance vm) {
   Address address = Addresses.getInstance().lookup(addr);
   AddressUtil.dispatchAssignAddress(address, vm);
 }