mirror of https://github.com/apache/jclouds.git
added default operating system types to savvis
This commit is contained in:
parent
f2e6c72e5a
commit
5ae1ba44d2
|
@ -28,6 +28,7 @@ import java.util.Set;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.cim.OSType;
|
||||||
import org.jclouds.collect.Memoized;
|
import org.jclouds.collect.Memoized;
|
||||||
import org.jclouds.compute.domain.CIMOperatingSystem;
|
import org.jclouds.compute.domain.CIMOperatingSystem;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
@ -76,7 +77,7 @@ public class VCloudExpressVAppToNodeMetadata implements Function<VCloudExpressVA
|
||||||
builder.name(from.getName());
|
builder.name(from.getName());
|
||||||
builder.location(findLocationForResourceInVDC.apply(from.getVDC()));
|
builder.location(findLocationForResourceInVDC.apply(from.getVDC()));
|
||||||
builder.group(parseGroupFromName(from.getName()));
|
builder.group(parseGroupFromName(from.getName()));
|
||||||
builder.operatingSystem(from.getOsType() != null ? new CIMOperatingSystem(CIMOperatingSystem.OSType
|
builder.operatingSystem(from.getOsType() != null ? new CIMOperatingSystem(OSType
|
||||||
.fromValue(from.getOsType()), null, null, from.getOperatingSystemDescription()) : null);
|
.fromValue(from.getOsType()), null, null, from.getOperatingSystemDescription()) : null);
|
||||||
builder.hardware(hardwareForVCloudExpressVApp.apply(from));
|
builder.hardware(hardwareForVCloudExpressVApp.apply(from));
|
||||||
builder.state(vAppStatusToNodeState.get(from.getStatus()));
|
builder.state(vAppStatusToNodeState.get(from.getStatus()));
|
||||||
|
|
|
@ -0,0 +1,243 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.cim;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operating system based on DMTF CIM model.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
* @see <a
|
||||||
|
* href="http://dmtf.org/sites/default/files/cim/cim_schema_v2280/cim_schema_2.28.0Final-Doc.zip"
|
||||||
|
* />
|
||||||
|
*/
|
||||||
|
public enum OSType {
|
||||||
|
/**
|
||||||
|
* Other
|
||||||
|
*/
|
||||||
|
OTHER(1, "Other", OsFamily.UNRECOGNIZED, false),
|
||||||
|
/**
|
||||||
|
* MACOS
|
||||||
|
*/
|
||||||
|
MACOS(2, "MACOS", OsFamily.DARWIN, false),
|
||||||
|
/**
|
||||||
|
* Solaris
|
||||||
|
*/
|
||||||
|
SOLARIS(29, "Solaris", OsFamily.SOLARIS, false),
|
||||||
|
/**
|
||||||
|
* LINUX
|
||||||
|
*/
|
||||||
|
LINUX(36, "LINUX", OsFamily.LINUX, false),
|
||||||
|
/**
|
||||||
|
* FreeBSD
|
||||||
|
*/
|
||||||
|
FREEBSD(42, "FreeBSD", OsFamily.FREEBSD, false),
|
||||||
|
/**
|
||||||
|
* NetBSD
|
||||||
|
*/
|
||||||
|
NETBSD(43, "NetBSD", OsFamily.NETBSD, false),
|
||||||
|
/**
|
||||||
|
* OpenBSD
|
||||||
|
*/
|
||||||
|
OPENBSD(65, "OpenBSD", OsFamily.OPENBSD, false),
|
||||||
|
/**
|
||||||
|
* Not Applicable
|
||||||
|
*/
|
||||||
|
NOT_APPLICABLE(66, "Not Applicable", OsFamily.UNRECOGNIZED, false),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows Server 2003
|
||||||
|
*/
|
||||||
|
WINDOWS_SERVER_2003(69, "Microsoft Windows Server 2003", OsFamily.WINDOWS, false),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows Server 2003 64-Bit
|
||||||
|
*/
|
||||||
|
WINDOWS_SERVER_2003_64(70, "Microsoft Windows Server 2003 64-Bit", OsFamily.WINDOWS, true),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows Server 2008
|
||||||
|
*/
|
||||||
|
WINDOWS_SERVER_2008(76, "Microsoft Windows Server 2008", OsFamily.WINDOWS, false),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows Server 2008 64-Bit
|
||||||
|
*/
|
||||||
|
WINDOWS_SERVER_2008_64(77, "Microsoft Windows Server 2008 64-Bit", OsFamily.WINDOWS, true),
|
||||||
|
/**
|
||||||
|
* FreeBSD 64-Bit
|
||||||
|
*/
|
||||||
|
FREEBSD_64(78, "FreeBSD 64-Bit", OsFamily.FREEBSD, true),
|
||||||
|
/**
|
||||||
|
* RedHat Enterprise Linux
|
||||||
|
*/
|
||||||
|
RHEL(79, "RedHat Enterprise Linux", OsFamily.RHEL, false),
|
||||||
|
/**
|
||||||
|
* RedHat Enterprise Linux 64-Bit
|
||||||
|
*/
|
||||||
|
RHEL_64(80, "RedHat Enterprise Linux 64-Bit", OsFamily.RHEL, true),
|
||||||
|
/**
|
||||||
|
* Solaris 64-Bit
|
||||||
|
*/
|
||||||
|
SOLARIS_64(81, "Solaris 64-Bit", OsFamily.SOLARIS, true),
|
||||||
|
/**
|
||||||
|
* SUSE
|
||||||
|
*/
|
||||||
|
SUSE(82, "SUSE", OsFamily.SUSE, false),
|
||||||
|
/**
|
||||||
|
* SUSE 64-Bit
|
||||||
|
*/
|
||||||
|
SUSE_64(83, "SUSE 64-Bit", OsFamily.SUSE, true),
|
||||||
|
/**
|
||||||
|
* SLES
|
||||||
|
*/
|
||||||
|
SLES(84, "SLES", OsFamily.SUSE, false),
|
||||||
|
/**
|
||||||
|
* SLES 64-Bit
|
||||||
|
*/
|
||||||
|
SLES_64(85, "SLES 64-Bit", OsFamily.SUSE, true),
|
||||||
|
/**
|
||||||
|
* Novell OES
|
||||||
|
*/
|
||||||
|
NOVELL_OES(86, "Novell OES", OsFamily.SUSE, true),
|
||||||
|
/**
|
||||||
|
* Mandriva
|
||||||
|
*/
|
||||||
|
MANDRIVA(89, "Mandriva", OsFamily.MANDRIVA, false),
|
||||||
|
/**
|
||||||
|
* Mandriva 64-Bit
|
||||||
|
*/
|
||||||
|
MANDRIVA_64(90, "Mandriva 64-Bit", OsFamily.MANDRIVA, true),
|
||||||
|
/**
|
||||||
|
* TurboLinux
|
||||||
|
*/
|
||||||
|
TURBOLINUX(91, "TurboLinux", OsFamily.TURBOLINUX, false),
|
||||||
|
/**
|
||||||
|
* TurboLinux 64-Bit
|
||||||
|
*/
|
||||||
|
TURBOLINUX_64(92, "TurboLinux 64-Bit", OsFamily.TURBOLINUX, true),
|
||||||
|
/**
|
||||||
|
* Ubuntu
|
||||||
|
*/
|
||||||
|
UBUNTU(93, "Ubuntu", OsFamily.UBUNTU, false),
|
||||||
|
/**
|
||||||
|
* Ubuntu 64-Bit
|
||||||
|
*/
|
||||||
|
UBUNTU_64(94, "Ubuntu 64-Bit", OsFamily.UBUNTU, true),
|
||||||
|
/**
|
||||||
|
* Debian
|
||||||
|
*/
|
||||||
|
DEBIAN(95, "Debian", OsFamily.DEBIAN, false),
|
||||||
|
/**
|
||||||
|
* Debian 64-Bit
|
||||||
|
*/
|
||||||
|
DEBIAN_64(96, "Debian 64-Bit", OsFamily.DEBIAN, false),
|
||||||
|
/**
|
||||||
|
* Linux 2.4.x
|
||||||
|
*/
|
||||||
|
LINUX_2_4(97, "Linux 2.4.x", OsFamily.LINUX, false),
|
||||||
|
/**
|
||||||
|
* Linux 2.4.x 64-Bi
|
||||||
|
*/
|
||||||
|
LINUX_2_4_64(98, "Linux 2.4.x 64-Bit", OsFamily.LINUX, true),
|
||||||
|
/**
|
||||||
|
* Linux 2.6.x
|
||||||
|
*/
|
||||||
|
LINUX_2_6(99, "Linux 2.6.x", OsFamily.LINUX, false),
|
||||||
|
/**
|
||||||
|
* Linux 2.6.x 64-Bit
|
||||||
|
*/
|
||||||
|
LINUX_2_6_64(100, "Linux 2.6.x 64-Bit", OsFamily.LINUX, true),
|
||||||
|
/**
|
||||||
|
* Linux 64-Bit
|
||||||
|
*/
|
||||||
|
LINUX_64(101, "Linux 64-Bit", OsFamily.LINUX, true),
|
||||||
|
/**
|
||||||
|
* Other 64-Bit
|
||||||
|
*/
|
||||||
|
OTHER_64(102, "Other 64-Bit", OsFamily.UNRECOGNIZED, true),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows Server 2008 R2
|
||||||
|
*/
|
||||||
|
WINDOWS_SERVER_2008_R2(103, "Microsoft Windows Server 2008 R2", OsFamily.WINDOWS, true),
|
||||||
|
/**
|
||||||
|
* VMware ESXi
|
||||||
|
*/
|
||||||
|
ESXI(104, "VMware ESXi", OsFamily.ESX, true),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows 7
|
||||||
|
*/
|
||||||
|
WINDOWS_7(105, "Microsoft Windows 7", OsFamily.WINDOWS, false),
|
||||||
|
/**
|
||||||
|
* CentOS 32-bit
|
||||||
|
*/
|
||||||
|
CENTOS(106, "CentOS 32-bit", OsFamily.CENTOS, false),
|
||||||
|
/**
|
||||||
|
* CentOS 64-bit
|
||||||
|
*/
|
||||||
|
CENTOS_64(107, "CentOS 64-bit", OsFamily.CENTOS, true),
|
||||||
|
/**
|
||||||
|
* Oracle Enterprise Linux 32-bit
|
||||||
|
*/
|
||||||
|
ORACLE_ENTERPRISE_LINUX(108, "Oracle Enterprise Linux 32-bit", OsFamily.OEL, false),
|
||||||
|
/**
|
||||||
|
* Oracle Enterprise Linux 64-bit
|
||||||
|
*/
|
||||||
|
ORACLE_ENTERPRISE_LINUX_64(109, "Oracle Enterprise Linux 64-bit", OsFamily.OEL, true),
|
||||||
|
/**
|
||||||
|
* eComStation 32-bitx
|
||||||
|
*/
|
||||||
|
ECOMSTATION_32(109, "eComStation 32-bitx", OsFamily.UNRECOGNIZED, false), UNRECOGNIZED(Integer.MAX_VALUE,
|
||||||
|
"UNRECOGNIZED", null, true);
|
||||||
|
private final int code;
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OsFamily getFamily() {
|
||||||
|
return family;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean is64Bit() {
|
||||||
|
return is64Bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
private final OsFamily family;
|
||||||
|
private final boolean is64Bit;
|
||||||
|
|
||||||
|
OSType(int code, String value, OsFamily family, boolean is64Bit) {
|
||||||
|
this.code = code;
|
||||||
|
this.value = value;
|
||||||
|
this.family = family;
|
||||||
|
this.is64Bit = is64Bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OSType fromValue(int code) {
|
||||||
|
for (OSType type : values()) {
|
||||||
|
if (type.code == code)
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
return UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
package org.jclouds.compute.domain;
|
package org.jclouds.compute.domain;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.jclouds.cim.OSType;
|
||||||
import org.jclouds.ovf.OvfEnvelope;
|
import org.jclouds.ovf.OvfEnvelope;
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
|
@ -31,228 +34,99 @@ import com.google.common.annotations.Beta;
|
||||||
*/
|
*/
|
||||||
@Beta
|
@Beta
|
||||||
public class CIMOperatingSystem extends OperatingSystem {
|
public class CIMOperatingSystem extends OperatingSystem {
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends OperatingSystem.Builder {
|
||||||
|
private OSType osType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CIMOperatingSystem#getOsType
|
||||||
|
*/
|
||||||
|
public Builder osType(@Nullable OSType osType) {
|
||||||
|
this.osType = osType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CIMOperatingSystem build() {
|
||||||
|
return new CIMOperatingSystem(family, name, version, arch, description, is64Bit, osType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromCIMOperatingSystem(CIMOperatingSystem in) {
|
||||||
|
return fromOperatingSystem(in).osType(in.getOsType());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder arch(String arch) {
|
||||||
|
return Builder.class.cast(super.arch(arch));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder description(String description) {
|
||||||
|
return Builder.class.cast(super.description(description));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder family(OsFamily family) {
|
||||||
|
return Builder.class.cast(super.family(family));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder fromOperatingSystem(OperatingSystem in) {
|
||||||
|
return Builder.class.cast(super.fromOperatingSystem(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder is64Bit(boolean is64Bit) {
|
||||||
|
return Builder.class.cast(super.is64Bit(is64Bit));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
return Builder.class.cast(super.name(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder version(String version) {
|
||||||
|
return Builder.class.cast(super.version(version));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static CIMOperatingSystem toComputeOs(org.jclouds.ovf.OperatingSystemSection os) {
|
public static CIMOperatingSystem toComputeOs(org.jclouds.ovf.OperatingSystemSection os) {
|
||||||
return new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(os.getId()), "", null, os.getDescription());
|
return new CIMOperatingSystem(OSType.fromValue(os.getId()), "", null, os.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CIMOperatingSystem toComputeOs(OvfEnvelope ovf) {
|
public static CIMOperatingSystem toComputeOs(OvfEnvelope ovf) {
|
||||||
return toComputeOs(ovf.getVirtualSystem().getOperatingSystem());
|
return toComputeOs(ovf.getVirtualSystem().getOperatingSystem());
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum OSType {
|
|
||||||
/**
|
|
||||||
* Other
|
|
||||||
*/
|
|
||||||
OTHER(1, "Other", OsFamily.UNRECOGNIZED, false),
|
|
||||||
/**
|
|
||||||
* MACOS
|
|
||||||
*/
|
|
||||||
MACOS(2, "MACOS", OsFamily.DARWIN, false),
|
|
||||||
/**
|
|
||||||
* Solaris
|
|
||||||
*/
|
|
||||||
SOLARIS(29, "Solaris", OsFamily.SOLARIS, false),
|
|
||||||
/**
|
|
||||||
* LINUX
|
|
||||||
*/
|
|
||||||
LINUX(36, "LINUX", OsFamily.LINUX, false),
|
|
||||||
/**
|
|
||||||
* FreeBSD
|
|
||||||
*/
|
|
||||||
FREEBSD(42, "FreeBSD", OsFamily.FREEBSD, false),
|
|
||||||
/**
|
|
||||||
* NetBSD
|
|
||||||
*/
|
|
||||||
NETBSD(43, "NetBSD", OsFamily.NETBSD, false),
|
|
||||||
/**
|
|
||||||
* OpenBSD
|
|
||||||
*/
|
|
||||||
OPENBSD(65, "OpenBSD", OsFamily.OPENBSD, false),
|
|
||||||
/**
|
|
||||||
* Not Applicable
|
|
||||||
*/
|
|
||||||
NOT_APPLICABLE(66, "Not Applicable", OsFamily.UNRECOGNIZED, false),
|
|
||||||
/**
|
|
||||||
* Microsoft Windows Server 2003
|
|
||||||
*/
|
|
||||||
WINDOWS_SERVER_2003(69, "Microsoft Windows Server 2003", OsFamily.WINDOWS, false),
|
|
||||||
/**
|
|
||||||
* Microsoft Windows Server 2003 64-Bit
|
|
||||||
*/
|
|
||||||
WINDOWS_SERVER_2003_64(70, "Microsoft Windows Server 2003 64-Bit", OsFamily.WINDOWS, true),
|
|
||||||
/**
|
|
||||||
* Microsoft Windows Server 2008
|
|
||||||
*/
|
|
||||||
WINDOWS_SERVER_2008(76, "Microsoft Windows Server 2008", OsFamily.WINDOWS, false),
|
|
||||||
/**
|
|
||||||
* Microsoft Windows Server 2008 64-Bit
|
|
||||||
*/
|
|
||||||
WINDOWS_SERVER_2008_64(77, "Microsoft Windows Server 2008 64-Bit", OsFamily.WINDOWS, true),
|
|
||||||
/**
|
|
||||||
* FreeBSD 64-Bit
|
|
||||||
*/
|
|
||||||
FREEBSD_64(78, "FreeBSD 64-Bit", OsFamily.FREEBSD, true),
|
|
||||||
/**
|
|
||||||
* RedHat Enterprise Linux
|
|
||||||
*/
|
|
||||||
RHEL(79, "RedHat Enterprise Linux", OsFamily.RHEL, false),
|
|
||||||
/**
|
|
||||||
* RedHat Enterprise Linux 64-Bit
|
|
||||||
*/
|
|
||||||
RHEL_64(80, "RedHat Enterprise Linux 64-Bit", OsFamily.RHEL, true),
|
|
||||||
/**
|
|
||||||
* Solaris 64-Bit
|
|
||||||
*/
|
|
||||||
SOLARIS_64(81, "Solaris 64-Bit", OsFamily.SOLARIS, true),
|
|
||||||
/**
|
|
||||||
* SUSE
|
|
||||||
*/
|
|
||||||
SUSE(82, "SUSE", OsFamily.SUSE, false),
|
|
||||||
/**
|
|
||||||
* SUSE 64-Bit
|
|
||||||
*/
|
|
||||||
SUSE_64(83, "SUSE 64-Bit", OsFamily.SUSE, true),
|
|
||||||
/**
|
|
||||||
* SLES
|
|
||||||
*/
|
|
||||||
SLES(84, "SLES", OsFamily.SUSE, false),
|
|
||||||
/**
|
|
||||||
* SLES 64-Bit
|
|
||||||
*/
|
|
||||||
SLES_64(85, "SLES 64-Bit", OsFamily.SUSE, true),
|
|
||||||
/**
|
|
||||||
* Novell OES
|
|
||||||
*/
|
|
||||||
NOVELL_OES(86, "Novell OES", OsFamily.SUSE, true),
|
|
||||||
/**
|
|
||||||
* Mandriva
|
|
||||||
*/
|
|
||||||
MANDRIVA(89, "Mandriva", OsFamily.MANDRIVA, false),
|
|
||||||
/**
|
|
||||||
* Mandriva 64-Bit
|
|
||||||
*/
|
|
||||||
MANDRIVA_64(90, "Mandriva 64-Bit", OsFamily.MANDRIVA, true),
|
|
||||||
/**
|
|
||||||
* TurboLinux
|
|
||||||
*/
|
|
||||||
TURBOLINUX(91, "TurboLinux", OsFamily.TURBOLINUX, false),
|
|
||||||
/**
|
|
||||||
* TurboLinux 64-Bit
|
|
||||||
*/
|
|
||||||
TURBOLINUX_64(92, "TurboLinux 64-Bit", OsFamily.TURBOLINUX, true),
|
|
||||||
/**
|
|
||||||
* Ubuntu
|
|
||||||
*/
|
|
||||||
UBUNTU(93, "Ubuntu", OsFamily.UBUNTU, false),
|
|
||||||
/**
|
|
||||||
* Ubuntu 64-Bit
|
|
||||||
*/
|
|
||||||
UBUNTU_64(94, "Ubuntu 64-Bit", OsFamily.UBUNTU, true),
|
|
||||||
/**
|
|
||||||
* Debian
|
|
||||||
*/
|
|
||||||
DEBIAN(95, "Debian", OsFamily.DEBIAN, false),
|
|
||||||
/**
|
|
||||||
* Debian 64-Bit
|
|
||||||
*/
|
|
||||||
DEBIAN_64(96, "Debian 64-Bit", OsFamily.DEBIAN, false),
|
|
||||||
/**
|
|
||||||
* Linux 2.4.x
|
|
||||||
*/
|
|
||||||
LINUX_2_4(97, "Linux 2.4.x", OsFamily.LINUX, false),
|
|
||||||
/**
|
|
||||||
* Linux 2.4.x 64-Bi
|
|
||||||
*/
|
|
||||||
LINUX_2_4_64(98, "Linux 2.4.x 64-Bit", OsFamily.LINUX, true),
|
|
||||||
/**
|
|
||||||
* Linux 2.6.x
|
|
||||||
*/
|
|
||||||
LINUX_2_6(99, "Linux 2.6.x", OsFamily.LINUX, false),
|
|
||||||
/**
|
|
||||||
* Linux 2.6.x 64-Bit
|
|
||||||
*/
|
|
||||||
LINUX_2_6_64(100, "Linux 2.6.x 64-Bit", OsFamily.LINUX, true),
|
|
||||||
/**
|
|
||||||
* Linux 64-Bit
|
|
||||||
*/
|
|
||||||
LINUX_64(101, "Linux 64-Bit", OsFamily.LINUX, true),
|
|
||||||
/**
|
|
||||||
* Other 64-Bit
|
|
||||||
*/
|
|
||||||
OTHER_64(102, "Other 64-Bit", OsFamily.UNRECOGNIZED, true),
|
|
||||||
/**
|
|
||||||
* Microsoft Windows Server 2008 R2
|
|
||||||
*/
|
|
||||||
WINDOWS_SERVER_2008_R2(103, "Microsoft Windows Server 2008 R2", OsFamily.WINDOWS, true),
|
|
||||||
/**
|
|
||||||
* VMware ESXi
|
|
||||||
*/
|
|
||||||
ESXI(104, "VMware ESXi", OsFamily.ESX, true),
|
|
||||||
/**
|
|
||||||
* Microsoft Windows 7
|
|
||||||
*/
|
|
||||||
WINDOWS_7(105, "Microsoft Windows 7", OsFamily.WINDOWS, false),
|
|
||||||
/**
|
|
||||||
* CentOS 32-bit
|
|
||||||
*/
|
|
||||||
CENTOS(106, "CentOS 32-bit", OsFamily.CENTOS, false),
|
|
||||||
/**
|
|
||||||
* CentOS 64-bit
|
|
||||||
*/
|
|
||||||
CENTOS_64(107, "CentOS 64-bit", OsFamily.CENTOS, true),
|
|
||||||
/**
|
|
||||||
* Oracle Enterprise Linux 32-bit
|
|
||||||
*/
|
|
||||||
ORACLE_ENTERPRISE_LINUX(108, "Oracle Enterprise Linux 32-bit", OsFamily.OEL, false),
|
|
||||||
/**
|
|
||||||
* Oracle Enterprise Linux 64-bit
|
|
||||||
*/
|
|
||||||
ORACLE_ENTERPRISE_LINUX_64(109, "Oracle Enterprise Linux 64-bit", OsFamily.OEL, true),
|
|
||||||
/**
|
|
||||||
* eComStation 32-bitx
|
|
||||||
*/
|
|
||||||
ECOMSTATION_32(109, "eComStation 32-bitx", OsFamily.UNRECOGNIZED, false), UNRECOGNIZED(Integer.MAX_VALUE,
|
|
||||||
"UNRECOGNIZED", null, true);
|
|
||||||
private final int code;
|
|
||||||
|
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OsFamily getFamily() {
|
|
||||||
return family;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean is64Bit() {
|
|
||||||
return is64Bit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final String value;
|
|
||||||
private final OsFamily family;
|
|
||||||
private final boolean is64Bit;
|
|
||||||
|
|
||||||
OSType(int code, String value, OsFamily family, boolean is64Bit) {
|
|
||||||
this.code = code;
|
|
||||||
this.value = value;
|
|
||||||
this.family = family;
|
|
||||||
this.is64Bit = is64Bit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OSType fromValue(int code) {
|
|
||||||
for (OSType type : values()) {
|
|
||||||
if (type.code == code)
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
return UNRECOGNIZED;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private OSType osType;
|
private OSType osType;
|
||||||
|
|
||||||
protected CIMOperatingSystem() {
|
protected CIMOperatingSystem() {
|
||||||
|
@ -260,8 +134,14 @@ public class CIMOperatingSystem extends OperatingSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CIMOperatingSystem(OSType osType, String version, String arch, String description) {
|
public CIMOperatingSystem(OSType osType, String version, String arch, String description) {
|
||||||
super(osType.getFamily(), osType.getValue(), version, arch, description, osType.is64Bit());
|
this(osType.getFamily(), osType.getValue(), version, arch, description, osType.is64Bit(), osType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CIMOperatingSystem(@Nullable OsFamily family, @Nullable String name, @Nullable String version,
|
||||||
|
@Nullable String arch, String description, boolean is64Bit, OSType osType) {
|
||||||
|
super(family, name, version, arch, description, is64Bit);
|
||||||
this.osType = osType;
|
this.osType = osType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,7 +178,7 @@ public class CIMOperatingSystem extends OperatingSystem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[osType=" + osType + ", version=" + getVersion() + ", arch=" + getArch() + ", description="
|
return String.format("[osType=%s, arch=%s, description=%s, family=%s, is64Bit=%s, name=%s, version=%s]", osType,
|
||||||
+ getDescription() + "]";
|
arch, description, family, is64Bit, name, version);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -32,16 +32,69 @@ import com.google.common.annotations.Beta;
|
||||||
*/
|
*/
|
||||||
@Beta
|
@Beta
|
||||||
public class OperatingSystem {
|
public class OperatingSystem {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
protected OsFamily family;
|
||||||
|
protected String name;
|
||||||
|
protected String arch;
|
||||||
|
protected String version;
|
||||||
|
protected String description;
|
||||||
|
protected boolean is64Bit;
|
||||||
|
|
||||||
|
public Builder family(@Nullable OsFamily family) {
|
||||||
|
this.family = family;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder name(@Nullable String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder arch(@Nullable String arch) {
|
||||||
|
this.arch = arch;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder version(@Nullable String version) {
|
||||||
|
this.version = version;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = checkNotNull(description, "description");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder is64Bit(boolean is64Bit) {
|
||||||
|
this.is64Bit = is64Bit;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperatingSystem build() {
|
||||||
|
return new OperatingSystem(family, name, version, arch, description, is64Bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromOperatingSystem(OperatingSystem in) {
|
||||||
|
return family(in.getFamily()).name(in.getName()).version(in.getVersion()).arch(in.getArch()).description(
|
||||||
|
in.getDescription()).is64Bit(in.is64Bit());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private OsFamily family;
|
protected OsFamily family;
|
||||||
@Nullable
|
@Nullable
|
||||||
private String name;
|
protected String name;
|
||||||
@Nullable
|
@Nullable
|
||||||
private String arch;
|
protected String arch;
|
||||||
@Nullable
|
@Nullable
|
||||||
private String version;
|
protected String version;
|
||||||
private String description;
|
protected String description;
|
||||||
private boolean is64Bit;
|
protected boolean is64Bit;
|
||||||
|
|
||||||
// for serialization/deserialization
|
// for serialization/deserialization
|
||||||
protected OperatingSystem() {
|
protected OperatingSystem() {
|
||||||
|
@ -61,9 +114,9 @@ public class OperatingSystem {
|
||||||
/**
|
/**
|
||||||
* Type of the operating system
|
* Type of the operating system
|
||||||
* <p/>
|
* <p/>
|
||||||
* generally, this is used to compare the means by which you use an operating
|
* generally, this is used to compare the means by which you use an operating system. For
|
||||||
* system. For example, to determine compatibility of a particular
|
* example, to determine compatibility of a particular bootstrapping or package installation
|
||||||
* bootstrapping or package installation approach.
|
* approach.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public OsFamily getFamily() {
|
public OsFamily getFamily() {
|
||||||
|
@ -73,10 +126,9 @@ public class OperatingSystem {
|
||||||
/**
|
/**
|
||||||
* name of the operating system; ex. {@code Red Hat Enterprise Linux}
|
* name of the operating system; ex. {@code Red Hat Enterprise Linux}
|
||||||
*
|
*
|
||||||
* <h2>note</h2> While this looks similar to, and may in some cases be the
|
* <h2>note</h2> While this looks similar to, and may in some cases be the same as the java
|
||||||
* same as the java system property {@code os.name} it isn't guaranteed to
|
* system property {@code os.name} it isn't guaranteed to match a particular value. For example,
|
||||||
* match a particular value. For example, this value could be derived from
|
* this value could be derived from data parsed for a cloud api or the OVF CIM OSType enum value;
|
||||||
* data parsed for a cloud api or the OVF CIM OSType enum value;
|
|
||||||
*
|
*
|
||||||
* @return operating system name or null if it couldn't be determined.
|
* @return operating system name or null if it couldn't be determined.
|
||||||
*/
|
*/
|
||||||
|
@ -88,17 +140,15 @@ public class OperatingSystem {
|
||||||
/**
|
/**
|
||||||
* architecture of the operating system; ex. {@code x86_64}
|
* architecture of the operating system; ex. {@code x86_64}
|
||||||
* <p/>
|
* <p/>
|
||||||
* generally, this is used to decide whether an operating system will run
|
* generally, this is used to decide whether an operating system will run certain binaries, for
|
||||||
* certain binaries, for example, a 64bit JDK.
|
* example, a 64bit JDK.
|
||||||
*
|
*
|
||||||
* <h2>note</h2>
|
* <h2>note</h2>
|
||||||
* While this looks similar to, and may in some cases be the same as the java
|
* While this looks similar to, and may in some cases be the same as the java system property
|
||||||
* system property {@code os.arch} it isn't guaranteed to match a particular
|
* {@code os.arch} it isn't guaranteed to match a particular value. For example, this value could
|
||||||
* value. For example, this value could be derived from data parsed for a
|
* be derived from data parsed for a cloud api or the OVF CIM OSType enum value;
|
||||||
* cloud api or the OVF CIM OSType enum value;
|
|
||||||
*
|
*
|
||||||
* @return operating system architecture or null if it couldn't be
|
* @return operating system architecture or null if it couldn't be determined.
|
||||||
* determined.
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getArch() {
|
public String getArch() {
|
||||||
|
@ -108,14 +158,12 @@ public class OperatingSystem {
|
||||||
/**
|
/**
|
||||||
* version of the operating system; ex. {@code 10.0.4}
|
* version of the operating system; ex. {@code 10.0.4}
|
||||||
* <p/>
|
* <p/>
|
||||||
* generally, this is used to compare versions of the same operating system
|
* generally, this is used to compare versions of the same operating system name. It should be
|
||||||
* name. It should be meaningful when sorted against, although this isn't
|
* meaningful when sorted against, although this isn't necessary.
|
||||||
* necessary.
|
|
||||||
* <h2>note</h2>
|
* <h2>note</h2>
|
||||||
* While this looks similar to, and may in some cases be the same as the java
|
* While this looks similar to, and may in some cases be the same as the java system property
|
||||||
* system property {@code os.version} it isn't guaranteed to match a
|
* {@code os.version} it isn't guaranteed to match a particular value. For example, this value
|
||||||
* particular value. For example, this value could be derived from data
|
* could be derived from data parsed for a cloud api or the OVF CIM OSType enum value;
|
||||||
* parsed for a cloud api or the OVF CIM OSType enum value;
|
|
||||||
*
|
*
|
||||||
* @return operating system version or null if it couldn't be determined.
|
* @return operating system version or null if it couldn't be determined.
|
||||||
*/
|
*/
|
||||||
|
@ -125,12 +173,11 @@ public class OperatingSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* description of the operating system; ex. {@code CentOS 32-bit},{@code
|
* description of the operating system; ex. {@code CentOS 32-bit},{@code Other Linux (32-bit)}
|
||||||
* Other Linux (32-bit)}
|
|
||||||
* <p/>
|
* <p/>
|
||||||
* This is the only required field in the operating system object. In some
|
* This is the only required field in the operating system object. In some implementations, it is
|
||||||
* implementations, it is this data that is used to parse the value of the
|
* this data that is used to parse the value of the {@link #name}, {@link #version}, and
|
||||||
* {@link #name}, {@link #version}, and {@link #arch} fields.
|
* {@link #arch} fields.
|
||||||
*
|
*
|
||||||
* @return operating system description
|
* @return operating system description
|
||||||
*/
|
*/
|
||||||
|
@ -198,6 +245,10 @@ public class OperatingSystem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return builder().fromOperatingSystem(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[name=" + name + ", family=" + family + ", version=" + version + ", arch=" + arch + ", is64Bit="
|
return "[name=" + name + ", family=" + family + ", version=" + version + ", arch=" + arch + ", is64Bit="
|
||||||
|
|
|
@ -19,62 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.compute.domain;
|
package org.jclouds.compute.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @see OperatingSystem.Builder
|
||||||
*/
|
*/
|
||||||
public class OperatingSystemBuilder {
|
@Deprecated
|
||||||
@Nullable
|
public class OperatingSystemBuilder extends OperatingSystem.Builder {
|
||||||
private OsFamily family;
|
|
||||||
@Nullable
|
|
||||||
private String name;
|
|
||||||
@Nullable
|
|
||||||
private String arch;
|
|
||||||
@Nullable
|
|
||||||
private String version;
|
|
||||||
private String description;
|
|
||||||
private boolean is64Bit;
|
|
||||||
|
|
||||||
public OperatingSystemBuilder family(@Nullable OsFamily family) {
|
|
||||||
this.family = family;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperatingSystemBuilder name(@Nullable String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperatingSystemBuilder arch(@Nullable String arch) {
|
|
||||||
this.arch = arch;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperatingSystemBuilder version(@Nullable String version) {
|
|
||||||
this.version = version;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperatingSystemBuilder description(String description) {
|
|
||||||
this.description = checkNotNull(description, "description");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperatingSystemBuilder is64Bit(boolean is64Bit) {
|
|
||||||
this.is64Bit = is64Bit;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperatingSystem build() {
|
|
||||||
return new OperatingSystem(family, name, version, arch, description, is64Bit);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OperatingSystem fromOperatingSystem(OperatingSystem in) {
|
|
||||||
return new OperatingSystem(in.getFamily(), in.getName(), in.getVersion(), in.getArch(), in.getDescription(),
|
|
||||||
in.is64Bit());
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -21,14 +21,59 @@ package org.jclouds.ovf;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.jclouds.cim.OSType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An OperatingSystemSection specifies the operating system installed on a virtual machine.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
public class OperatingSystemSection {
|
public class OperatingSystemSection {
|
||||||
|
|
||||||
@Nullable
|
public static Builder builder() {
|
||||||
protected final Integer id;
|
return new Builder();
|
||||||
@Nullable
|
}
|
||||||
protected final String info;
|
|
||||||
|
|
||||||
@Nullable
|
public static class Builder {
|
||||||
|
protected Integer id;
|
||||||
|
protected String info;
|
||||||
|
protected String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see OperatingSystemSection#getID
|
||||||
|
*/
|
||||||
|
public Builder id(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see OperatingSystemSection#getInfo
|
||||||
|
*/
|
||||||
|
public Builder info(String info) {
|
||||||
|
this.info = info;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see OperatingSystemSection#getDescription
|
||||||
|
*/
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperatingSystemSection build() {
|
||||||
|
return new OperatingSystemSection(id, info, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromOperatingSystemSection(OperatingSystemSection in) {
|
||||||
|
return id(in.getId()).info(in.getInfo()).description(in.getDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final Integer id;
|
||||||
|
protected final String info;
|
||||||
protected final String description;
|
protected final String description;
|
||||||
|
|
||||||
public OperatingSystemSection(@Nullable Integer id, @Nullable String info, @Nullable String description) {
|
public OperatingSystemSection(@Nullable Integer id, @Nullable String info, @Nullable String description) {
|
||||||
|
@ -40,6 +85,7 @@ public class OperatingSystemSection {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return ovf id
|
* @return ovf id
|
||||||
|
* @see OSType#getCode()
|
||||||
*/
|
*/
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -98,6 +144,10 @@ public class OperatingSystemSection {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return builder().fromOperatingSystemSection(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + getId() + ", info=" + getInfo() + ", description=" + getDescription() + "]";
|
return "[id=" + getId() + ", info=" + getInfo() + ", description=" + getDescription() + "]";
|
||||||
|
|
|
@ -23,10 +23,10 @@ import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsA
|
||||||
import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsYum;
|
import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsYum;
|
||||||
import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsZypper;
|
import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsZypper;
|
||||||
|
|
||||||
|
import org.jclouds.cim.OSType;
|
||||||
import org.jclouds.compute.domain.CIMOperatingSystem;
|
import org.jclouds.compute.domain.CIMOperatingSystem;
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.CIMOperatingSystem.OSType;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.savvis.vpdc;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.CIMOperatingSystem;
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.savvis.vpdc.domain.Resource;
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
import org.jclouds.savvis.vpdc.features.BrowsingAsyncClient;
|
import org.jclouds.savvis.vpdc.features.BrowsingAsyncClient;
|
||||||
|
@ -51,4 +52,14 @@ public interface VPDCAsyncClient {
|
||||||
@Provides
|
@Provides
|
||||||
@Org
|
@Org
|
||||||
Set<Resource> listOrgs();
|
Set<Resource> listOrgs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* predefined by default in the classpath resource {@code
|
||||||
|
* /savvis-symphonyvpdc/predefined_operatingsystems.json}
|
||||||
|
*
|
||||||
|
* @return the operating systems that are predefined in the provider
|
||||||
|
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/addSingleVM.html" />
|
||||||
|
*/
|
||||||
|
@Provides
|
||||||
|
Set<CIMOperatingSystem> listPredefinedOperatingSystems();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.jclouds.savvis.vpdc;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.CIMOperatingSystem;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.savvis.vpdc.domain.Resource;
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
@ -49,4 +50,13 @@ public interface VPDCClient {
|
||||||
* @return a listing of all orgs that the current user has access to.
|
* @return a listing of all orgs that the current user has access to.
|
||||||
*/
|
*/
|
||||||
Set<Resource> listOrgs();
|
Set<Resource> listOrgs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* predefined by default in the classpath resource {@code
|
||||||
|
* /savvis-symphonyvpdc/predefined_operatingsystems.json}
|
||||||
|
*
|
||||||
|
* @return the operating systems that are predefined in the provider
|
||||||
|
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/addSingleVM.html" />
|
||||||
|
*/
|
||||||
|
Set<CIMOperatingSystem> listPredefinedOperatingSystems();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
import static org.jclouds.savvis.vpdc.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
import static org.jclouds.savvis.vpdc.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -34,10 +35,13 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.CIMOperatingSystem;
|
||||||
import org.jclouds.http.HttpErrorHandler;
|
import org.jclouds.http.HttpErrorHandler;
|
||||||
import org.jclouds.http.annotation.ClientError;
|
import org.jclouds.http.annotation.ClientError;
|
||||||
import org.jclouds.http.annotation.Redirection;
|
import org.jclouds.http.annotation.Redirection;
|
||||||
import org.jclouds.http.annotation.ServerError;
|
import org.jclouds.http.annotation.ServerError;
|
||||||
|
import org.jclouds.json.Json;
|
||||||
|
import org.jclouds.location.Provider;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.rest.AsyncClientFactory;
|
import org.jclouds.rest.AsyncClientFactory;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
|
@ -53,6 +57,7 @@ import org.jclouds.savvis.vpdc.handlers.VPDCErrorHandler;
|
||||||
import org.jclouds.savvis.vpdc.internal.LoginAsyncClient;
|
import org.jclouds.savvis.vpdc.internal.LoginAsyncClient;
|
||||||
import org.jclouds.savvis.vpdc.internal.VCloudToken;
|
import org.jclouds.savvis.vpdc.internal.VCloudToken;
|
||||||
import org.jclouds.savvis.vpdc.predicates.TaskSuccess;
|
import org.jclouds.savvis.vpdc.predicates.TaskSuccess;
|
||||||
|
import org.jclouds.util.Strings2;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
@ -60,6 +65,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -113,6 +119,15 @@ public class VPDCRestClientModule extends RestClientModule<VPDCClient, VPDCAsync
|
||||||
super(VPDCClient.class, VPDCAsyncClient.class, DELEGATE_MAP);
|
super(VPDCClient.class, VPDCAsyncClient.class, DELEGATE_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
protected Set<CIMOperatingSystem> provideOperatingSystems(Json json, @Provider String providerName)
|
||||||
|
throws IOException {
|
||||||
|
return json.fromJson(Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||||
|
"/" + providerName + "/predefined_operatingsystems.json")), new TypeLiteral<Set<CIMOperatingSystem>>() {
|
||||||
|
}.getType());
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||||
|
|
|
@ -0,0 +1,209 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <name@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.domain;
|
||||||
|
|
||||||
|
import org.jclouds.cim.OSType;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Savvis Operating System Specification
|
||||||
|
*
|
||||||
|
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/addSingleVM.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class SavvisOperatingSystemSpecification {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private int savvisId;
|
||||||
|
private int typeId;
|
||||||
|
private String name;
|
||||||
|
private OsFamily family;
|
||||||
|
private String description;
|
||||||
|
private boolean supportedBySavvis;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SavvisOperatingSystemSpecification#getSavvisId
|
||||||
|
*/
|
||||||
|
public Builder savvisId(int savvisId) {
|
||||||
|
this.savvisId = savvisId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SavvisOperatingSystemSpecification#getTypeId
|
||||||
|
*/
|
||||||
|
public Builder typeId(int typeId) {
|
||||||
|
this.typeId = typeId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SavvisOperatingSystemSpecification#getOsFamily
|
||||||
|
*/
|
||||||
|
public Builder family(OsFamily family) {
|
||||||
|
this.family = family;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SavvisOperatingSystemSpecification#getInfo
|
||||||
|
*/
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SavvisOperatingSystemSpecification#getDescription
|
||||||
|
*/
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SavvisOperatingSystemSpecification#isSupportedBySavvis
|
||||||
|
*/
|
||||||
|
public Builder supportedBySavvis(boolean supportedBySavvis) {
|
||||||
|
this.supportedBySavvis = supportedBySavvis;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SavvisOperatingSystemSpecification build() {
|
||||||
|
return new SavvisOperatingSystemSpecification(savvisId, typeId, family, name, description, supportedBySavvis);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromSavvisOperatingSystemSpecification(SavvisOperatingSystemSpecification in) {
|
||||||
|
return savvisId(in.getSavvisId()).typeId(in.getTypeId()).family(in.getFamily()).name(in.getName())
|
||||||
|
.description(in.getDescription()).supportedBySavvis(in.isSupportedBySavvis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int savvisId;
|
||||||
|
private final int typeId;
|
||||||
|
private final OsFamily family;
|
||||||
|
private final String name;
|
||||||
|
private final String description;
|
||||||
|
private final boolean supportedBySavvis;
|
||||||
|
|
||||||
|
public SavvisOperatingSystemSpecification(int savvisId, int typeId, OsFamily family, String name,
|
||||||
|
String description, boolean supportedBySavvis) {
|
||||||
|
this.savvisId = savvisId;
|
||||||
|
this.typeId = typeId;
|
||||||
|
this.family = family;
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.supportedBySavvis = supportedBySavvis;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Internal name used by Savvis
|
||||||
|
*/
|
||||||
|
public int getSavvisId() {
|
||||||
|
return savvisId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return CIM OS Type Id
|
||||||
|
* @see OSType#getCode()
|
||||||
|
*/
|
||||||
|
public int getTypeId() {
|
||||||
|
return typeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the name of the OS
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the operating system family
|
||||||
|
*/
|
||||||
|
public OsFamily getFamily() {
|
||||||
|
return family;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return description
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return whether or not this operating system is supported by Savvis
|
||||||
|
*/
|
||||||
|
public boolean isSupportedBySavvis() {
|
||||||
|
return supportedBySavvis;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
result = prime * result + typeId;
|
||||||
|
result = prime * result + savvisId;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
SavvisOperatingSystemSpecification other = (SavvisOperatingSystemSpecification) obj;
|
||||||
|
if (name == null) {
|
||||||
|
if (other.name != null)
|
||||||
|
return false;
|
||||||
|
} else if (!name.equals(other.name))
|
||||||
|
return false;
|
||||||
|
if (typeId != other.typeId)
|
||||||
|
return false;
|
||||||
|
if (savvisId != other.savvisId)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return builder().fromSavvisOperatingSystemSpecification(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("[description=%s, family=%s, name=%s, typeId=%s, savvisId=%s, supportedBySavvis=%s]",
|
||||||
|
description, family, name, typeId, savvisId, supportedBySavvis);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"family": "WINDOWS",
|
||||||
|
"name": "winLonghorn64Guest",
|
||||||
|
"version": "2008",
|
||||||
|
"description": "Microsoft Windows Server 2008 (Enterprise 64bit)",
|
||||||
|
"is64Bit": true;
|
||||||
|
"osType": "WINDOWS_SERVER_2008_64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"family": "RHEL",
|
||||||
|
"name": "rhel5Guest",
|
||||||
|
"version": "5",
|
||||||
|
"description": "Red Hat Enterprise Linux 5.x 32bit",
|
||||||
|
"is64Bit": false;
|
||||||
|
"osType": "RHEL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"family": "RHEL_64",
|
||||||
|
"name": "rhel5_64Guest",
|
||||||
|
"version": "5",
|
||||||
|
"description": "Red Hat Enterprise Linux 5.x 64bit",
|
||||||
|
"is64Bit": true;
|
||||||
|
"osType": "RHEL_64"
|
||||||
|
}
|
||||||
|
]
|
|
@ -46,11 +46,15 @@ public class VPDCAsyncClientTest extends BaseVPDCAsyncClientTest<VPDCAsyncClient
|
||||||
public void testSync() {
|
public void testSync() {
|
||||||
assert syncClient.getBrowsingClient() != null;
|
assert syncClient.getBrowsingClient() != null;
|
||||||
assertEquals(syncClient.listOrgs().size(), 1);
|
assertEquals(syncClient.listOrgs().size(), 1);
|
||||||
|
assertEquals(syncClient.listPredefinedOperatingSystems().size(), 3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAsync() {
|
public void testAsync() {
|
||||||
assert asyncClient.getBrowsingClient() != null;
|
assert asyncClient.getBrowsingClient() != null;
|
||||||
assertEquals(syncClient.listOrgs().size(), 1);
|
assertEquals(asyncClient.listOrgs().size(), 1);
|
||||||
|
assertEquals(asyncClient.listPredefinedOperatingSystems().size(), 3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue