mirror of https://github.com/apache/jclouds.git
added server model to elastichosts
This commit is contained in:
parent
b41eedf882
commit
ea3b75874e
|
@ -0,0 +1,73 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.elastichosts.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class BlockDevice extends Device {
|
||||||
|
|
||||||
|
private final char index;
|
||||||
|
|
||||||
|
public BlockDevice(String driveUuid, MediaType mediaType, char index) {
|
||||||
|
super(driveUuid, mediaType);
|
||||||
|
checkArgument(index >= 0 && index < 8, "index must be between 0 and 7");
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + index;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
BlockDevice other = (BlockDevice) obj;
|
||||||
|
if (index != other.index)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return String.format("block:%d", index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + getId() + ", driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -112,7 +112,7 @@ public class CreateDriveRequest extends BaseDrive {
|
||||||
public CreateDriveRequest(String name, long size, @Nullable ClaimType claimType, Iterable<String> readers,
|
public CreateDriveRequest(String name, long size, @Nullable ClaimType claimType, Iterable<String> readers,
|
||||||
Iterable<String> tags, Map<String, String> userMetadata, @Nullable String encryptionCipher,
|
Iterable<String> tags, Map<String, String> userMetadata, @Nullable String encryptionCipher,
|
||||||
Iterable<String> avoid) {
|
Iterable<String> avoid) {
|
||||||
super(name, size, claimType, readers, tags, userMetadata);
|
super(null, name, size, claimType, readers, tags, userMetadata);
|
||||||
this.encryptionCipher = encryptionCipher;
|
this.encryptionCipher = encryptionCipher;
|
||||||
this.avoid = ImmutableSet.copyOf(checkNotNull(avoid, "avoid"));
|
this.avoid = ImmutableSet.copyOf(checkNotNull(avoid, "avoid"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.elastichosts.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public abstract class Device {
|
||||||
|
protected final String driveUuid;
|
||||||
|
protected final MediaType mediaType;
|
||||||
|
|
||||||
|
public Device(String driveUuid, MediaType mediaType) {
|
||||||
|
this.driveUuid = checkNotNull(driveUuid, "driveUuid");
|
||||||
|
this.mediaType = checkNotNull(mediaType, "mediaType");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id generated based on the device bus, unit, and/or index numbers;
|
||||||
|
*/
|
||||||
|
public abstract String getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Drive UUID to connect as specified device.
|
||||||
|
*/
|
||||||
|
public String getDriveUuid() {
|
||||||
|
return driveUuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return set to 'cdrom' to simulate a cdrom, set to 'disk' or leave unset to simulate a hard
|
||||||
|
* disk.
|
||||||
|
*/
|
||||||
|
public MediaType getMediaType() {
|
||||||
|
return mediaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((driveUuid == null) ? 0 : driveUuid.hashCode());
|
||||||
|
result = prime * result + ((mediaType == null) ? 0 : mediaType.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Device other = (Device) obj;
|
||||||
|
if (driveUuid == null) {
|
||||||
|
if (other.driveUuid != null)
|
||||||
|
return false;
|
||||||
|
} else if (!driveUuid.equals(other.driveUuid))
|
||||||
|
return false;
|
||||||
|
if (mediaType != other.mediaType)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -82,12 +82,12 @@ public class DriveData extends BaseDrive {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DriveData build() {
|
public DriveData build() {
|
||||||
return new DriveData(name, size, claimType, readers, tags, userMetadata);
|
return new DriveData(uuid, name, size, claimType, readers, tags, userMetadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DriveData(String name, long size, @Nullable ClaimType claimType, Iterable<String> readers,
|
public DriveData(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType, Iterable<String> readers,
|
||||||
Iterable<String> tags, Map<String, String> userMetadata) {
|
Iterable<String> tags, Map<String, String> userMetadata) {
|
||||||
super(name, size, claimType, readers, tags, userMetadata);
|
super(uuid, name, size, claimType, readers, tags, userMetadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -44,7 +44,6 @@ public class DriveInfo extends BaseDrive {
|
||||||
private Set<String> claimed = ImmutableSet.of();
|
private Set<String> claimed = ImmutableSet.of();
|
||||||
private String encryptionCipher;
|
private String encryptionCipher;
|
||||||
private String description;
|
private String description;
|
||||||
private String uuid;
|
|
||||||
private Set<String> driveType = ImmutableSet.of();
|
private Set<String> driveType = ImmutableSet.of();
|
||||||
private String encryptionKey;
|
private String encryptionKey;
|
||||||
private Boolean free;
|
private Boolean free;
|
||||||
|
@ -89,11 +88,6 @@ public class DriveInfo extends BaseDrive {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder uuid(String uuid) {
|
|
||||||
this.uuid = uuid;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder driveType(Iterable<String> driveType) {
|
public Builder driveType(Iterable<String> driveType) {
|
||||||
this.driveType = ImmutableSet.copyOf(checkNotNull(driveType, "driveType"));
|
this.driveType = ImmutableSet.copyOf(checkNotNull(driveType, "driveType"));
|
||||||
return this;
|
return this;
|
||||||
|
@ -172,14 +166,6 @@ public class DriveInfo extends BaseDrive {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Builder name(String name) {
|
|
||||||
return Builder.class.cast(super.name(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -196,6 +182,22 @@ public class DriveInfo extends BaseDrive {
|
||||||
return Builder.class.cast(super.size(size));
|
return Builder.class.cast(super.size(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder uuid(String uuid) {
|
||||||
|
return Builder.class.cast(super.uuid(uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
return Builder.class.cast(super.name(name));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -233,8 +235,6 @@ public class DriveInfo extends BaseDrive {
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String description;
|
private final String description;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String uuid;
|
|
||||||
@Nullable
|
|
||||||
private final Set<String> driveType;
|
private final Set<String> driveType;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String encryptionCipher;
|
private final String encryptionCipher;
|
||||||
|
@ -264,18 +264,17 @@ public class DriveInfo extends BaseDrive {
|
||||||
private final Long writeRequests;
|
private final Long writeRequests;
|
||||||
|
|
||||||
public DriveInfo(DriveStatus status, String user, Boolean autoexpanding, Integer bits, Iterable<String> claimed,
|
public DriveInfo(DriveStatus status, String user, Boolean autoexpanding, Integer bits, Iterable<String> claimed,
|
||||||
ClaimType claimType, String description, String drive, Iterable<String> driveType, String encryptionCipher,
|
ClaimType claimType, String description, String uuid, Iterable<String> driveType, String encryptionCipher,
|
||||||
String encryptionKey, Boolean free, String imaging, String installNotes, String name, String os,
|
String encryptionKey, Boolean free, String imaging, String installNotes, String name, String os,
|
||||||
Iterable<String> readers, Long readBytes, Long readRequests, Long size, Iterable<String> tags, DriveType type,
|
Iterable<String> readers, Long readBytes, Long readRequests, Long size, Iterable<String> tags, DriveType type,
|
||||||
URI url, Iterable<String> use, Map<String, String> userMetadata, Long writeBytes, Long writeRequests) {
|
URI url, Iterable<String> use, Map<String, String> userMetadata, Long writeBytes, Long writeRequests) {
|
||||||
super(name, size, claimType, readers, tags, userMetadata);
|
super(uuid, name, size, claimType, readers, tags, userMetadata);
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.autoexpanding = autoexpanding;
|
this.autoexpanding = autoexpanding;
|
||||||
this.bits = bits;
|
this.bits = bits;
|
||||||
this.claimed = ImmutableSet.copyOf(claimed);
|
this.claimed = ImmutableSet.copyOf(claimed);
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.uuid = drive;
|
|
||||||
this.driveType = ImmutableSet.copyOf(driveType);
|
this.driveType = ImmutableSet.copyOf(driveType);
|
||||||
this.encryptionCipher = encryptionCipher;
|
this.encryptionCipher = encryptionCipher;
|
||||||
this.encryptionKey = encryptionKey;
|
this.encryptionKey = encryptionKey;
|
||||||
|
@ -326,19 +325,11 @@ public class DriveInfo extends BaseDrive {
|
||||||
return claimed;
|
return claimed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO undocumented
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return uuid of the drive.
|
|
||||||
*/
|
|
||||||
public String getUuid() {
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
public Set<String> getDriveType() {
|
public Set<String> getDriveType() {
|
||||||
return driveType;
|
return driveType;
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.elastichosts.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class IDEDevice extends Device {
|
||||||
|
|
||||||
|
private final char bus;
|
||||||
|
private final char unit;
|
||||||
|
|
||||||
|
public IDEDevice(String driveUuid, MediaType mediaType, char bus, char unit) {
|
||||||
|
super(driveUuid, mediaType);
|
||||||
|
checkArgument(bus == 0 || bus == 1, "bus must be 0 or 1");
|
||||||
|
checkArgument(unit == 0 || unit == 1, "unit must be 0 or 1");
|
||||||
|
this.bus = bus;
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + bus;
|
||||||
|
result = prime * result + unit;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
IDEDevice other = (IDEDevice) obj;
|
||||||
|
if (bus != other.bus)
|
||||||
|
return false;
|
||||||
|
if (unit != other.unit)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return String.format("ide:%d:%d", bus, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getBus() {
|
||||||
|
return bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + getId() + ", driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,199 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.elastichosts.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class Item {
|
||||||
|
public static class Builder {
|
||||||
|
protected String uuid;
|
||||||
|
protected String name;
|
||||||
|
protected Set<String> tags = ImmutableSet.of();
|
||||||
|
protected Map<String, String> userMetadata = ImmutableMap.of();
|
||||||
|
|
||||||
|
public Builder uuid(String uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder tags(Iterable<String> tags) {
|
||||||
|
this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder userMetadata(Map<String, String> userMetadata) {
|
||||||
|
this.userMetadata = ImmutableMap.copyOf(checkNotNull(userMetadata, "userMetadata"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item build() {
|
||||||
|
return new Item(uuid, name, tags, userMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
result = prime * result + ((tags == null) ? 0 : tags.hashCode());
|
||||||
|
result = prime * result + ((userMetadata == null) ? 0 : userMetadata.hashCode());
|
||||||
|
result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Builder other = (Builder) obj;
|
||||||
|
if (name == null) {
|
||||||
|
if (other.name != null)
|
||||||
|
return false;
|
||||||
|
} else if (!name.equals(other.name))
|
||||||
|
return false;
|
||||||
|
if (tags == null) {
|
||||||
|
if (other.tags != null)
|
||||||
|
return false;
|
||||||
|
} else if (!tags.equals(other.tags))
|
||||||
|
return false;
|
||||||
|
if (userMetadata == null) {
|
||||||
|
if (other.userMetadata != null)
|
||||||
|
return false;
|
||||||
|
} else if (!userMetadata.equals(other.userMetadata))
|
||||||
|
return false;
|
||||||
|
if (uuid == null) {
|
||||||
|
if (other.uuid != null)
|
||||||
|
return false;
|
||||||
|
} else if (!uuid.equals(other.uuid))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
protected final String uuid;
|
||||||
|
protected final String name;
|
||||||
|
protected final Set<String> tags;
|
||||||
|
protected final Map<String, String> userMetadata;
|
||||||
|
|
||||||
|
public Item(@Nullable String uuid, String name, Iterable<String> tags, Map<String, String> userMetadata) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.name = checkNotNull(name, "name");
|
||||||
|
this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags"));
|
||||||
|
this.userMetadata = ImmutableMap.copyOf(checkNotNull(userMetadata, "userMetadata"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return uuid of the item.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return name of the item
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return list of tags
|
||||||
|
*/
|
||||||
|
public Set<String> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return user-defined KEY VALUE pairs
|
||||||
|
*/
|
||||||
|
public Map<String, String> getUserMetadata() {
|
||||||
|
return userMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
result = prime * result + ((tags == null) ? 0 : tags.hashCode());
|
||||||
|
result = prime * result + ((userMetadata == null) ? 0 : userMetadata.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Item other = (Item) obj;
|
||||||
|
if (name == null) {
|
||||||
|
if (other.name != null)
|
||||||
|
return false;
|
||||||
|
} else if (!name.equals(other.name))
|
||||||
|
return false;
|
||||||
|
if (tags == null) {
|
||||||
|
if (other.tags != null)
|
||||||
|
return false;
|
||||||
|
} else if (!tags.equals(other.tags))
|
||||||
|
return false;
|
||||||
|
if (userMetadata == null) {
|
||||||
|
if (other.userMetadata != null)
|
||||||
|
return false;
|
||||||
|
} else if (!userMetadata.equals(other.userMetadata))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[uuid=" + uuid + ", name=" + name + ", tags=" + tags + ", userMetadata=" + userMetadata + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.elastichosts.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media type - set to 'cdrom' to simulate a cdrom, set to 'disk' or leave unset to simulate a hard
|
||||||
|
* disk.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public enum MediaType {
|
||||||
|
DISK, CDROM, UNRECOGNIZED;
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return name().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return value();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MediaType fromValue(String type) {
|
||||||
|
try {
|
||||||
|
return valueOf(checkNotNull(type, "type").toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.elastichosts.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public enum Model {
|
||||||
|
E1000, RTl8139, VIRTIO, UNRECOGNIZED;
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return name().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return value();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Model fromValue(String model) {
|
||||||
|
try {
|
||||||
|
return valueOf(checkNotNull(model, "model").toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,122 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.elastichosts.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class NIC {
|
||||||
|
private final String dhcp;
|
||||||
|
private final Model model;
|
||||||
|
private final String vlan;
|
||||||
|
private final String mac;
|
||||||
|
|
||||||
|
public NIC(@Nullable String dhcp, Model model, @Nullable String vlan, @Nullable String mac) {
|
||||||
|
this.dhcp = dhcp;
|
||||||
|
this.model = checkNotNull(model, "model");
|
||||||
|
this.vlan = vlan;
|
||||||
|
this.mac = mac;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The IP address offered by DHCP to network interface 0. If unset, no address is
|
||||||
|
* offered. Set to 'auto' to allocate a temporary IP at boot.
|
||||||
|
*/
|
||||||
|
public String getDhcp() {
|
||||||
|
return dhcp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Create network interface with given type (use 'e1000' as default value; 'rtl8139' or
|
||||||
|
* 'virtio' are also available).
|
||||||
|
*/
|
||||||
|
public Model getModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The VLAN to which the network interface is attached.
|
||||||
|
*/
|
||||||
|
public String getVlan() {
|
||||||
|
return vlan;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The MAC address of the network interface. If unset, a randomly generated address is
|
||||||
|
* used. If set, should be unique on the VLAN.
|
||||||
|
*/
|
||||||
|
public String getMac() {
|
||||||
|
return mac;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((dhcp == null) ? 0 : dhcp.hashCode());
|
||||||
|
result = prime * result + ((mac == null) ? 0 : mac.hashCode());
|
||||||
|
result = prime * result + ((model == null) ? 0 : model.hashCode());
|
||||||
|
result = prime * result + ((vlan == null) ? 0 : vlan.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
NIC other = (NIC) obj;
|
||||||
|
if (dhcp == null) {
|
||||||
|
if (other.dhcp != null)
|
||||||
|
return false;
|
||||||
|
} else if (!dhcp.equals(other.dhcp))
|
||||||
|
return false;
|
||||||
|
if (mac == null) {
|
||||||
|
if (other.mac != null)
|
||||||
|
return false;
|
||||||
|
} else if (!mac.equals(other.mac))
|
||||||
|
return false;
|
||||||
|
if (model != other.model)
|
||||||
|
return false;
|
||||||
|
if (vlan == null) {
|
||||||
|
if (other.vlan != null)
|
||||||
|
return false;
|
||||||
|
} else if (!vlan.equals(other.vlan))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[dhcp=" + dhcp + ", model=" + model + ", vlan=" + vlan + ", mac=" + mac + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.elastichosts.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class SCSIDevice extends Device {
|
||||||
|
|
||||||
|
private final char bus = 0;
|
||||||
|
private final char unit;
|
||||||
|
|
||||||
|
public SCSIDevice(String driveUuid, MediaType mediaType, char unit) {
|
||||||
|
super(driveUuid, mediaType);
|
||||||
|
checkArgument(unit >= 0 && unit < 8, "unit must be between 0 and 7");
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + bus;
|
||||||
|
result = prime * result + unit;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
SCSIDevice other = (SCSIDevice) obj;
|
||||||
|
if (bus != other.bus)
|
||||||
|
return false;
|
||||||
|
if (unit != other.unit)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getBus() {
|
||||||
|
return bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return String.format("scsi:%d:%d", bus, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + getId() + ", driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,337 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.elastichosts.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class Server extends Item {
|
||||||
|
//
|
||||||
|
// user UUID
|
||||||
|
// status active|stopped
|
||||||
|
// cpu CPU
|
||||||
|
// smp SMP
|
||||||
|
// mem MEM
|
||||||
|
// bootDeviceIds UUID
|
||||||
|
// description DESCRIPTION
|
||||||
|
// ide:0:0 UUID
|
||||||
|
// ide:0:1 UUID
|
||||||
|
// ide:1:0 UUID
|
||||||
|
// ide:1:1 UUID
|
||||||
|
// nic:0:model NIC_0_MODEL
|
||||||
|
// nic:0:dhcp NIC_0_DHCP
|
||||||
|
// nic:1:model NIC_1_MODEL
|
||||||
|
// nic:1:vlan NIC_1_VLAN
|
||||||
|
// vnc:ip VNC_IP
|
||||||
|
// vnc:password VNC_PASS
|
||||||
|
|
||||||
|
public static class Builder extends Item.Builder {
|
||||||
|
protected int cpu;
|
||||||
|
protected Integer smp;
|
||||||
|
protected int mem;
|
||||||
|
protected boolean persistent;
|
||||||
|
protected Set<? extends Device> devices = ImmutableSet.of();
|
||||||
|
protected Set<String> bootDeviceIds = ImmutableSet.of();
|
||||||
|
protected List<NIC> nics = ImmutableList.of();
|
||||||
|
protected String user;
|
||||||
|
protected VNC vnc;
|
||||||
|
// TODO undocumented
|
||||||
|
protected String description;
|
||||||
|
|
||||||
|
public Builder cpu(int cpu) {
|
||||||
|
this.cpu = cpu;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder smp(Integer smp) {
|
||||||
|
this.smp = smp;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder mem(int mem) {
|
||||||
|
this.mem = mem;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder persistent(boolean persistent) {
|
||||||
|
this.persistent = persistent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder devices(Iterable<? extends Device> devices) {
|
||||||
|
this.devices = ImmutableSet.copyOf(checkNotNull(devices, "devices"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder bootDeviceIds(Iterable<String> bootDeviceIds) {
|
||||||
|
this.bootDeviceIds = ImmutableSet.copyOf(checkNotNull(bootDeviceIds, "bootDeviceIds"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder nics(Iterable<NIC> nics) {
|
||||||
|
this.nics = ImmutableList.copyOf(checkNotNull(nics, "nics"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder user(String user) {
|
||||||
|
this.user = user;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder vnc(VNC vnc) {
|
||||||
|
this.vnc = vnc;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder uuid(String uuid) {
|
||||||
|
return Builder.class.cast(super.uuid(uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
return Builder.class.cast(super.name(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder tags(Iterable<String> tags) {
|
||||||
|
return Builder.class.cast(super.tags(tags));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder userMetadata(Map<String, String> userMetadata) {
|
||||||
|
return Builder.class.cast(super.userMetadata(userMetadata));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Server build() {
|
||||||
|
return new Server(uuid, name, cpu, smp, mem, persistent, devices, tags, bootDeviceIds, userMetadata, nics,
|
||||||
|
user, vnc, description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final int cpu;
|
||||||
|
protected final Integer smp;
|
||||||
|
protected final int mem;
|
||||||
|
protected final boolean persistent;
|
||||||
|
protected final Set<? extends Device> devices;
|
||||||
|
protected final Set<String> bootDeviceIds;
|
||||||
|
@Nullable
|
||||||
|
protected final String user;
|
||||||
|
protected final List<NIC> nics;
|
||||||
|
protected final VNC vnc;
|
||||||
|
@Nullable
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
public Server(@Nullable String uuid, String name, int cpu, @Nullable Integer smp, int mem, boolean persistent,
|
||||||
|
Iterable<? extends Device> devices, Iterable<String> bootDeviceIds, Iterable<String> tags,
|
||||||
|
Map<String, String> userMetadata, Iterable<NIC> nics, @Nullable String user, VNC vnc, String description) {
|
||||||
|
super(uuid, name, tags, userMetadata);
|
||||||
|
this.cpu = cpu;
|
||||||
|
this.smp = smp;
|
||||||
|
this.mem = mem;
|
||||||
|
this.persistent = persistent;
|
||||||
|
this.devices = ImmutableSet.copyOf(checkNotNull(devices, "devices"));
|
||||||
|
this.bootDeviceIds = ImmutableSet.copyOf(checkNotNull(bootDeviceIds, "bootDeviceIds"));
|
||||||
|
this.nics = ImmutableList.copyOf(checkNotNull(nics, "nics"));
|
||||||
|
this.user = user;
|
||||||
|
this.vnc = checkNotNull(vnc, "vnc");
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return CPU quota in core MHz.
|
||||||
|
*/
|
||||||
|
public int getCpu() {
|
||||||
|
return cpu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return number of virtual processors or null if calculated based on cpu.
|
||||||
|
*/
|
||||||
|
public Integer getSmp() {
|
||||||
|
return smp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return virtual memory size in MB.
|
||||||
|
*/
|
||||||
|
public int getMem() {
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return 'true' means that server will revert to a 'stopped' status on server stop or shutdown,
|
||||||
|
* rather than being destroyed automatically.
|
||||||
|
*/
|
||||||
|
public boolean isPersistent() {
|
||||||
|
return persistent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return set of devices present
|
||||||
|
*/
|
||||||
|
public Set<? extends Device> getDevices() {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return ids of the devices to boot, e.g. ide:0:0 or ide:1:0
|
||||||
|
* @see Device#getId()
|
||||||
|
*/
|
||||||
|
public Set<String> getBootDeviceIds() {
|
||||||
|
return bootDeviceIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<NIC> getNics() {
|
||||||
|
return nics;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO undocumented
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return owner of the server.
|
||||||
|
*/
|
||||||
|
public String getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VNC getVnc() {
|
||||||
|
return vnc;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO undocumented
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + ((bootDeviceIds == null) ? 0 : bootDeviceIds.hashCode());
|
||||||
|
result = prime * result + cpu;
|
||||||
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
|
result = prime * result + ((devices == null) ? 0 : devices.hashCode());
|
||||||
|
result = prime * result + mem;
|
||||||
|
result = prime * result + ((nics == null) ? 0 : nics.hashCode());
|
||||||
|
result = prime * result + (persistent ? 1231 : 1237);
|
||||||
|
result = prime * result + ((smp == null) ? 0 : smp.hashCode());
|
||||||
|
result = prime * result + ((user == null) ? 0 : user.hashCode());
|
||||||
|
result = prime * result + ((vnc == null) ? 0 : vnc.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (!super.equals(obj))
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Server other = (Server) obj;
|
||||||
|
if (bootDeviceIds == null) {
|
||||||
|
if (other.bootDeviceIds != null)
|
||||||
|
return false;
|
||||||
|
} else if (!bootDeviceIds.equals(other.bootDeviceIds))
|
||||||
|
return false;
|
||||||
|
if (cpu != other.cpu)
|
||||||
|
return false;
|
||||||
|
if (description == null) {
|
||||||
|
if (other.description != null)
|
||||||
|
return false;
|
||||||
|
} else if (!description.equals(other.description))
|
||||||
|
return false;
|
||||||
|
if (devices == null) {
|
||||||
|
if (other.devices != null)
|
||||||
|
return false;
|
||||||
|
} else if (!devices.equals(other.devices))
|
||||||
|
return false;
|
||||||
|
if (mem != other.mem)
|
||||||
|
return false;
|
||||||
|
if (nics == null) {
|
||||||
|
if (other.nics != null)
|
||||||
|
return false;
|
||||||
|
} else if (!nics.equals(other.nics))
|
||||||
|
return false;
|
||||||
|
if (persistent != other.persistent)
|
||||||
|
return false;
|
||||||
|
if (smp == null) {
|
||||||
|
if (other.smp != null)
|
||||||
|
return false;
|
||||||
|
} else if (!smp.equals(other.smp))
|
||||||
|
return false;
|
||||||
|
if (user == null) {
|
||||||
|
if (other.user != null)
|
||||||
|
return false;
|
||||||
|
} else if (!user.equals(other.user))
|
||||||
|
return false;
|
||||||
|
if (vnc == null) {
|
||||||
|
if (other.vnc != null)
|
||||||
|
return false;
|
||||||
|
} else if (!vnc.equals(other.vnc))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[uuid=" + uuid + ", name=" + name + ", tags=" + tags + ", userMetadata=" + userMetadata + ", cpu=" + cpu
|
||||||
|
+ ", smp=" + smp + ", mem=" + mem + ", persistent=" + persistent + ", devices=" + devices
|
||||||
|
+ ", bootDeviceIds=" + bootDeviceIds + ", user=" + user + ", nics=" + nics + ", vnc=" + vnc
|
||||||
|
+ ", description=" + description + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.elastichosts.domain;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class VNC {
|
||||||
|
@Nullable
|
||||||
|
private final String ip;
|
||||||
|
@Nullable
|
||||||
|
private final String password;
|
||||||
|
private final boolean tls;
|
||||||
|
|
||||||
|
public VNC(String ip, String password, boolean tls) {
|
||||||
|
this.ip = ip;
|
||||||
|
this.password = password;
|
||||||
|
this.tls = tls;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return IP address for overlay VNC access on port 5900. Set to 'auto', to reuse nic:0:dhcp if
|
||||||
|
* available, or otherwise allocate a temporary IP at boot.
|
||||||
|
*/
|
||||||
|
public String getIp() {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Password for VNC access. If unset, VNC is disabled.
|
||||||
|
*/
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Set to 'on' to require VeNCrypt-style TLS auth in addition to the password. If this is
|
||||||
|
* unset, only unencrypted VNC is available.
|
||||||
|
*/
|
||||||
|
public boolean isTls() {
|
||||||
|
return tls;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((ip == null) ? 0 : ip.hashCode());
|
||||||
|
result = prime * result + ((password == null) ? 0 : password.hashCode());
|
||||||
|
result = prime * result + (tls ? 1231 : 1237);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
VNC other = (VNC) obj;
|
||||||
|
if (ip == null) {
|
||||||
|
if (other.ip != null)
|
||||||
|
return false;
|
||||||
|
} else if (!ip.equals(other.ip))
|
||||||
|
return false;
|
||||||
|
if (password == null) {
|
||||||
|
if (other.password != null)
|
||||||
|
return false;
|
||||||
|
} else if (!password.equals(other.password))
|
||||||
|
return false;
|
||||||
|
if (tls != other.tls)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[ip=" + ip + ", password=" + password + ", tls=" + tls + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,33 +27,25 @@ import java.util.Set;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.elastichosts.domain.ClaimType;
|
import org.jclouds.elastichosts.domain.ClaimType;
|
||||||
|
import org.jclouds.elastichosts.domain.Item;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.internal.util.ImmutableMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class BaseDrive {
|
public class BaseDrive extends Item {
|
||||||
public static class Builder {
|
public static class Builder extends Item.Builder {
|
||||||
protected String name;
|
|
||||||
protected long size;
|
protected long size;
|
||||||
protected ClaimType claimType = ClaimType.EXCLUSIVE;
|
protected ClaimType claimType = ClaimType.EXCLUSIVE;
|
||||||
protected Set<String> readers = ImmutableSet.of();
|
protected Set<String> readers = ImmutableSet.of();
|
||||||
protected Set<String> tags = ImmutableSet.of();
|
|
||||||
protected Map<String, String> userMetadata = ImmutableMap.of();
|
|
||||||
|
|
||||||
public Builder claimType(ClaimType claimType) {
|
public Builder claimType(ClaimType claimType) {
|
||||||
this.claimType = claimType;
|
this.claimType = claimType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder readers(Iterable<String> readers) {
|
public Builder readers(Iterable<String> readers) {
|
||||||
this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers"));
|
this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers"));
|
||||||
return this;
|
return this;
|
||||||
|
@ -64,36 +56,84 @@ public class BaseDrive {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder tags(Iterable<String> tags) {
|
/**
|
||||||
this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags"));
|
* {@inheritDoc}
|
||||||
return this;
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder uuid(String uuid) {
|
||||||
|
return Builder.class.cast(super.uuid(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
return Builder.class.cast(super.name(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder tags(Iterable<String> tags) {
|
||||||
|
return Builder.class.cast(super.tags(tags));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public Builder userMetadata(Map<String, String> userMetadata) {
|
public Builder userMetadata(Map<String, String> userMetadata) {
|
||||||
this.userMetadata = ImmutableMap.copyOf(checkNotNull(userMetadata, "userMetadata"));
|
return Builder.class.cast(super.userMetadata(userMetadata));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseDrive build() {
|
public BaseDrive build() {
|
||||||
return new BaseDrive(name, size, claimType, readers, tags, userMetadata);
|
return new BaseDrive(uuid, name, size, claimType, readers, tags, userMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + ((claimType == null) ? 0 : claimType.hashCode());
|
||||||
|
result = prime * result + ((readers == null) ? 0 : readers.hashCode());
|
||||||
|
result = prime * result + (int) (size ^ (size >>> 32));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (!super.equals(obj))
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Builder other = (Builder) obj;
|
||||||
|
if (claimType != other.claimType)
|
||||||
|
return false;
|
||||||
|
if (readers == null) {
|
||||||
|
if (other.readers != null)
|
||||||
|
return false;
|
||||||
|
} else if (!readers.equals(other.readers))
|
||||||
|
return false;
|
||||||
|
if (size != other.size)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final String name;
|
|
||||||
protected final long size;
|
protected final long size;
|
||||||
protected final ClaimType claimType;
|
protected final ClaimType claimType;
|
||||||
protected final Set<String> readers;
|
protected final Set<String> readers;
|
||||||
protected final Set<String> tags;
|
|
||||||
protected final Map<String, String> userMetadata;
|
|
||||||
|
|
||||||
public BaseDrive(String name, long size, @Nullable ClaimType claimType, Iterable<String> readers,
|
public BaseDrive(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType,
|
||||||
Iterable<String> tags, Map<String, String> userMetadata) {
|
Iterable<String> readers, Iterable<String> tags, Map<String, String> userMetadata) {
|
||||||
this.name = checkNotNull(name, "name");
|
super(uuid, name, tags, userMetadata);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.claimType = checkNotNull(claimType, "set claimType to exclusive, not null");
|
this.claimType = checkNotNull(claimType, "set claimType to exclusive, not null");
|
||||||
this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers"));
|
this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers"));
|
||||||
this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags"));
|
|
||||||
this.userMetadata = ImmutableMap.copyOf(checkNotNull(userMetadata, "userMetadata"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,14 +146,6 @@ public class BaseDrive {
|
||||||
return claimType;
|
return claimType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return Drive name
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return list of users allowed to read from a drive or 'ffffffff-ffff-ffff-ffff-ffffffffffff'
|
* @return list of users allowed to read from a drive or 'ffffffff-ffff-ffff-ffff-ffffffffffff'
|
||||||
|
@ -131,22 +163,6 @@ public class BaseDrive {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return list of tags
|
|
||||||
*/
|
|
||||||
public Set<String> getTags() {
|
|
||||||
return tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return user-defined KEY VALUE pairs
|
|
||||||
*/
|
|
||||||
public Map<String, String> getUserMetadata() {
|
|
||||||
return userMetadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
|
@ -198,8 +214,8 @@ public class BaseDrive {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[name=" + name + ", size=" + size + ", claimType=" + claimType + ", readers=" + readers + ", tags="
|
return "[uuid=" + uuid + ", name=" + name + ", tags=" + tags + ", userMetadata=" + userMetadata + ", size="
|
||||||
+ tags + ", userMetadata=" + userMetadata + "]";
|
+ size + ", claimType=" + claimType + ", readers=" + readers + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,6 +21,7 @@ package org.jclouds.elastichosts.functions;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.elastichosts.domain.DriveInfo;
|
import org.jclouds.elastichosts.domain.DriveInfo;
|
||||||
|
@ -35,7 +36,12 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class KeyValuesDelimitedByBlankLinesToDriveInfo implements Function<HttpResponse, DriveInfo> {
|
public class KeyValuesDelimitedByBlankLinesToDriveInfo implements Function<HttpResponse, DriveInfo> {
|
||||||
ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet setParser;
|
private final ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet setParser;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public KeyValuesDelimitedByBlankLinesToDriveInfo(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet setParser) {
|
||||||
|
this.setParser = setParser;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DriveInfo apply(HttpResponse response) {
|
public DriveInfo apply(HttpResponse response) {
|
||||||
|
|
|
@ -157,10 +157,10 @@ public class ElasticHostsClientLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info = client.createDrive(new CreateDriveRequest.Builder().name(prefix).size(1024 * 1024l).build());
|
info = client.createDrive(new CreateDriveRequest.Builder().name(prefix).size(4 * 1024 * 1024l).build());
|
||||||
assertNotNull(info.getUuid());
|
assertNotNull(info.getUuid());
|
||||||
assertEquals(info.getName(), prefix);
|
assertEquals(info.getName(), prefix);
|
||||||
assertEquals(info.getSize(), 1024 * 1024l);
|
assertEquals(info.getSize(), 4 * 1024 * 1024l);
|
||||||
assertEquals(info, client.getDriveInfo(info.getUuid()));
|
assertEquals(info, client.getDriveInfo(info.getUuid()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ public class ElasticHostsClientLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info2 = client.createDrive(new CreateDriveRequest.Builder().name(prefix + "2").size(1024 * 1024l).build());
|
info2 = client.createDrive(new CreateDriveRequest.Builder().name(prefix + "2").size(4 * 1024 * 1024l).build());
|
||||||
client.imageDrive(info.getUuid(), info2.getUuid());
|
client.imageDrive(info.getUuid(), info2.getUuid());
|
||||||
|
|
||||||
// TODO block until complete
|
// TODO block until complete
|
||||||
|
|
Loading…
Reference in New Issue