Java Code Examples for org.jclouds.compute.domain.NodeMetadata#getOperatingSystem()

The following examples show how to use org.jclouds.compute.domain.NodeMetadata#getOperatingSystem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JcloudsIaas.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
protected InstanceMetadata createInstanceMetadata(NodeMetadata nodeMetadata) {
    InstanceMetadata instanceMetadata = new InstanceMetadata();
    instanceMetadata.setHostname(nodeMetadata.getHostname());
    instanceMetadata.setImageId(nodeMetadata.getImageId());
    instanceMetadata.setLoginPort(nodeMetadata.getLoginPort());
    if (nodeMetadata.getHardware() != null) {
        instanceMetadata.setHypervisor(nodeMetadata.getHardware().getHypervisor());
        instanceMetadata.setRam(String.valueOf(nodeMetadata.getHardware().getRam()));
    }
    if (nodeMetadata.getOperatingSystem() != null) {
        instanceMetadata.setOperatingSystemName(nodeMetadata.getOperatingSystem().getName());
        instanceMetadata.setOperatingSystemVersion(nodeMetadata.getOperatingSystem().getVersion());
        instanceMetadata.setOperatingSystem64bit(nodeMetadata.getOperatingSystem().is64Bit());
    }
    return instanceMetadata;
}
 
Example 2
Source File: JcloudsLocation.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
/**
 * Whether the given VM is Windows.
 *
 * @see #isWindows(Image, ConfigBag)
 */
public boolean isWindows(NodeMetadata node, ConfigBag config) {
    OsFamily override = config.get(OS_FAMILY_OVERRIDE);
    if (override != null) return override == OsFamily.WINDOWS;

    OsFamily confFamily = config.get(OS_FAMILY);
    OperatingSystem os = (node != null) ? node.getOperatingSystem() : null;
    return (os != null && os.getFamily() != OsFamily.UNRECOGNIZED)
            ? (OsFamily.WINDOWS == os.getFamily())
            : (OsFamily.WINDOWS == confFamily);
}
 
Example 3
Source File: CloudDistributedTLCJob.java    From tlaplus with MIT License 4 votes vote down vote up
public WrapperNodeMetadata(final NodeMetadata m, final LoginCredentials credentials) {
	super(m.getProviderId(), m.getName(), m.getId(), m.getLocation(), m.getUri(), m.getUserMetadata(),
			m.getTags(), m.getGroup(), m.getHardware(), m.getImageId(), m.getOperatingSystem(), m.getStatus(),
			m.getBackendStatus(), m.getLoginPort(), m.getPublicAddresses(), m.getPrivateAddresses(),
			credentials, m.getHostname());
}
 
Example 4
Source File: MachinePoolPredicates.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
/** True iff the node matches the criteria specified in this template. 
 * <p>
 * NB: This only checks some of the most common fields, 
 * plus a hashcode (in strict mode).  
 * In strict mode you're practically guaranteed to match only machines created by this template.
 * (Add a tag(uid) and you _will_ be guaranteed, strict mode or not.)
 * <p> 
 * Outside strict mode, some things (OS and hypervisor) can fall through the gaps.  
 * But if that is a problem we can easily add them in.
 * <p>
 * (Caveat: If explicit Hardware, Image, and/or Template were specified in the template,
 * then the hash code probably will not detect it.)   
 **/
public static boolean matches(ReusableMachineTemplate template, NodeMetadata m) {
    try {
        // tags and user metadata

        if (! m.getTags().containsAll( template.getTags(false) )) return false;

        if (! isSubMapOf(template.getUserMetadata(false), m.getUserMetadata())) return false;


        // common hardware parameters

        if (template.getMinRam()!=null && m.getHardware().getRam() < template.getMinRam()) return false;

        if (template.getMinCores()!=null) {
            double numCores = 0;
            for (Processor p: m.getHardware().getProcessors()) numCores += p.getCores();
            if (numCores+0.001 < template.getMinCores()) return false;
        }

        if (template.getIs64bit()!=null) {
            if (m.getOperatingSystem().is64Bit() != template.getIs64bit()) return false;
        }

        if (template.getOsFamily()!=null) {
            if (m.getOperatingSystem() == null || 
                    !template.getOsFamily().equals(m.getOperatingSystem().getFamily())) return false;
        }
        if (template.getOsNameMatchesRegex()!=null) {
            if (m.getOperatingSystem() == null || m.getOperatingSystem().getName()==null ||
                    !m.getOperatingSystem().getName().matches(template.getOsNameMatchesRegex())) return false;
        }

        if (template.getLocationId()!=null) {
            if (!isLocationContainedIn(m.getLocation(), template.getLocationId())) return false;
        }

        // TODO other TemplateBuilder fields and TemplateOptions

        return true;
        
    } catch (Exception e) {
        log.warn("Error (rethrowing) trying to match "+m+" against "+template+": "+e, e);
        throw Throwables.propagate(e);
    }
}