Package org.globus.workspace.network

Examples of org.globus.workspace.network.AssociationEntry


                        + "' is not currently available";
                logger.error(err);
                throw new ResourceRequestDeniedException(err);
            }

            final AssociationEntry entry = (AssociationEntry) entryAndDns[0];

            final String assignedMAC = entry.getMac();
            if (assignedMAC == null) {
                net.append("ANY");
            } else {
                net.append(assignedMAC);
            }
            net.append(XenUtil.WC_FIELD_SEPARATOR);

            //only handling bridged
            net.append("Bridged");
            net.append(XenUtil.WC_FIELD_SEPARATOR);

            net.append(method);
            net.append(XenUtil.WC_FIELD_SEPARATOR);

            net.append(entry.getIpAddress()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(entry.getGateway()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(entry.getBroadcast()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(entry.getSubnetMask()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(entryAndDns[1]).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(entry.getHostname()).
                append(XenUtil.WC_FIELD_SEPARATOR);

            // cert paths, old implementation
            net.append("null").
                append(XenUtil.WC_FIELD_SEPARATOR).
View Full Code Here


        lines.add("");

        for (Map.Entry<String, Association> assoc : associations.entrySet()) {
            lines.add("# network pool: " + assoc.getKey());
            for (Object entryObject : assoc.getValue().getEntries()) {
                final AssociationEntry entry = (AssociationEntry) entryObject;
                lines.add(String.format("%s %s", entry.getIpAddress(), entry.getMac()));
            }
            lines.add("###############################################");
        }

        logger.debug("Writing IP -> MAC pairs file to "+ file.getAbsolutePath());
View Full Code Here

            final Association assoc = assocPair.getValue();
            if (assoc == null || assoc.getEntries() == null) {
                continue;
            }
            for (Object entryObject : assoc.getEntries()) {
                final AssociationEntry entry = (AssociationEntry) entryObject;
                if (entry.isExplicitMac()) {
                    final AssociationEntry inUseEntry = inUse.get(entry.getMac());
                    if (inUseEntry != null) {
                        final String inUseIp = inUseEntry.getIpAddress();
                        if (inUseIp == null || !inUseIp.equals(entry.getIpAddress())) {
                            logger.error("An explicit MAC in network '"+assocName+
                                    "' collides with an in-use network entry! "+
                                    "Explicit: "+ entry.toString() + "\nIn use: "+
                                    inUseEntry.toString());
                            entry.setMac(null);
                            entry.setExplicitMac(false);
                        }

                    }

                }
                if (entry.isExplicitMac()) {
                    if (!explicit.add(entry.getMac())) {
                        logger.warn("Duplicate explicit MAC? "+ entry.getMac());
                    }
                }
            }
        }

        final List<String> macList =
                new ArrayList<String>();
        macList.addAll(inUse.keySet());
        macList.addAll(explicit);

        for (Association assoc : current.values()) {
            for (Object entryObject : assoc.getEntries()) {
                final AssociationEntry entry = (AssociationEntry) entryObject;
                _setMac(entry, macPrefix, macList, explicit);
            }
        }

        return macList;
View Full Code Here

    private static Map<String, AssociationEntry> getInUseMacMap(Map<String, Association> previous) {
        Map<String, AssociationEntry> inUse = new HashMap<String, AssociationEntry>();
        for (Association assoc : previous.values()) {
            for (Object entryObject : assoc.getEntries()) {
                final AssociationEntry entry = (AssociationEntry) entryObject;
                if (entry.isInUse()) {
                    final String mac = entry.getMac();
                    if (mac == null || mac.length() == 0) {
                        logger.warn("Network association entry is supposedly " +
                                "in use but has no MAC address..? "+ entry.toString());
                    }
                    final AssociationEntry clobbered = inUse.put(mac, entry);
                    if (clobbered != null) {
                        logger.warn("There appear to be duplicate MAC addresses in use: "+
                                clobbered.toString() + "\nand\n"+entry.toString());
                    }
                }
            }
        }
        return inUse;
View Full Code Here

        }
       
        final Object[] entryAndDns = nextAssociationEntry(name,
                                                          associations);

        final AssociationEntry entry;
        if (entryAndDns == null || entryAndDns[0] == null) {
            final String err = "network '" + name
                        + "' is not currently available";
            logger.error(err);
            throw new ResourceRequestDeniedException(err);
        } else {
            entry = (AssociationEntry) entryAndDns[0];
            logger.debug("entry picked = " + entry);
        }

        try {
            db.replaceAssociationEntry(name, entry);
        } catch (WorkspaceDatabaseException e) {
            logger.fatal(e.getMessage(), e);
            throw new ResourceRequestDeniedException(
                    "internal error, db problem");
        }

        if (eventLog) {
            logger.info(Lager.ev(vmid) + "'" + name + "' network " +
                            "entry leased, ip=" + entry.getIpAddress());
        }

        return entryAndDns;
    }
View Full Code Here

            return;
        }

        // evidence for storing the entry list as an IP keyed hashtable...
        final Iterator iter = entries.iterator();
        AssociationEntry entry = null;
        boolean found = false;
        while (!found && iter.hasNext()) {
            entry = (AssociationEntry)iter.next();
            if (entry.getIpAddress().equals(ipAddress.trim())) {
                found = true;
            }
        }

        if (!found) {
            throw new ManageException(Lager.id(trackingID) + " entry was " +
                    "not found in '" + name + "': " + ipAddress);
        }
        entry.setInUse(false);
        db.replaceAssociationEntry(name, entry);

        logger.info(Lager.ev(trackingID) + "'" + name + "' network lease " +
                    "is over, ip=" + entry.getIpAddress());
    }
View Full Code Here

        if (entries == null || entries.isEmpty()) {
            return null; // *** EARLY RETURN ***
        }

        final Iterator iter = assoc.getEntries().iterator();
        AssociationEntry entry = null;
        while (iter.hasNext()) {
            entry = (AssociationEntry)iter.next();
            if (!entry.isInUse()) {
                entry.setInUse(true);
                break;
            }
            entry = null;
        }

View Full Code Here

            logger.info("Network '" + assocName + "': DNS changed from " +
                        oldassoc.getDns() + " to " + assoc.getDns());
        }

        for (Object assocEntry : assocEntries) {
            final AssociationEntry entry = (AssociationEntry) assocEntry;
            final AssociationEntry oldentry =
                    getMatchingIpEntry(entry.getIpAddress(),
                            oldassocEntries);

            if (oldentry == null) {
                continue;
            }

            logDifferences(assocName, entry, oldentry);

            // Any change is OK.
            // We know it has same IP address and that is enough to retire
            // with.  But the in-use flag MUST match the old one.
            entry.setInUse(oldentry.isInUse());

            if (!entry.isExplicitMac()) {
                entry.setMac(oldentry.getMac());
            }

            if (entry.isInUse()) {
                logger.debug("Network '" + assocName + "', ip " +
                        entry.getIpAddress() + " is currently in use.");
View Full Code Here

            throw new IllegalArgumentException("ip is null");
        }

        final Iterator iter = entries.iterator();
        while (iter.hasNext()) {
            final AssociationEntry entry = (AssociationEntry) iter.next();
            if (ip.equals(entry.getIpAddress())) {
                return entry;
            }

        }
        return null;
View Full Code Here

            // the rest
            while ((line = bufrd.readLine()) != null) {
                line = line.trim();
                if (line.length() > 0) {
                    AssociationEntry entry = parseAssoc(line);
                    if (entry != null) {
                        associationList.add(entry);
                    }
                }
                // can have an association with no entries
View Full Code Here

TOP

Related Classes of org.globus.workspace.network.AssociationEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.