http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileType.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileType.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileType.java deleted file mode 100644 index 383a691..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileType.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -public enum ProfileType { - REGULAR, UNRECOGNIZED; - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static ProfileType fromValue(String type) { - try { - return valueOf(checkNotNull(type, "type").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/SCSIDevice.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/SCSIDevice.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/SCSIDevice.java deleted file mode 100644 index 932a722..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/SCSIDevice.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkArgument; - -public class SCSIDevice extends Device { - public static class Builder extends Device.Builder { - private final int unit; - - public Builder(int unit) { - this.unit = unit; - } - - @Override - public Device build() { - return new SCSIDevice(uuid, mediaType, unit); - } - - } - - private static final int bus = 0; - private final int unit; - - public SCSIDevice(String driveUuid, MediaType mediaType, int 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 (unit != other.unit) - return false; - return true; - } - - public int getBus() { - return bus; - } - - public int 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 + "]"; - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Server.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Server.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Server.java deleted file mode 100644 index ea92d1d..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Server.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -public class Server extends Item { - - public static class Builder extends Item.Builder { - protected int cpu; - protected Integer smp; - protected int mem; - protected boolean persistent; - protected Map<String, ? extends Device> devices = ImmutableMap.of(); - protected Set<String> bootDeviceIds = ImmutableSet.of(); - protected List<NIC> nics = ImmutableList.of(); - protected VNC vnc; - // TODO cloudsigma specific - 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(Map<String, ? extends Device> devices) { - this.devices = ImmutableMap.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 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 use(Iterable<String> use) { - return Builder.class.cast(super.use(use)); - } - - public Server build() { - return new Server(uuid, name, cpu, smp, mem, persistent, devices, bootDeviceIds, use, nics, vnc, description); - } - - public static Builder fromServer(Server in) { - return new Builder().uuid(in.getUuid()).name(in.getName()).cpu(in.getCpu()).mem(in.getMem()) - .persistent(in.isPersistent()).description(in.getDescription()).devices(in.getDevices()) - .bootDeviceIds(in.getBootDeviceIds()).use(in.getUse()).nics(in.getNics()).vnc(in.getVnc()); - } - } - - protected final int cpu; - protected final Integer smp; - protected final int mem; - protected final boolean persistent; - @Nullable - protected final Map<String, Device> devices; - protected final Set<String> bootDeviceIds; - 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, - Map<String, ? extends Device> devices, Iterable<String> bootDeviceIds, Iterable<String> use, - Iterable<NIC> nics, VNC vnc, String description) { - super(uuid, name, use); - this.cpu = cpu; - this.smp = smp; - this.mem = mem; - this.persistent = persistent; - this.devices = ImmutableMap.copyOf(checkNotNull(devices, "devices")); - this.bootDeviceIds = ImmutableSet.copyOf(checkNotNull(bootDeviceIds, "bootDeviceIds")); - this.nics = ImmutableList.copyOf(checkNotNull(nics, "nics")); - 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 devices present, mapped by id - */ - public Map<String, 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; - } - - 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 + ((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 (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 + ", use=" + use + ", cpu=" + cpu + ", smp=" + smp + ", mem=" + mem - + ", persistent=" + persistent + ", devices=" + devices + ", bootDeviceIds=" + bootDeviceIds + ", nics=" - + nics + ", vnc=" + vnc + ", description=" + description + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerInfo.java deleted file mode 100644 index 0763bd7..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerInfo.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.domain; - -import java.util.Date; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; - -public class ServerInfo extends Server { - - public static class Builder extends Server.Builder { - protected ServerStatus status; - protected Date started; - protected String user; - protected ServerMetrics metrics; - - public Builder status(ServerStatus status) { - this.status = status; - return this; - } - - public Builder started(Date started) { - this.started = started; - return this; - } - - public Builder user(String user) { - this.user = user; - return this; - } - - public Builder metrics(ServerMetrics metrics) { - this.metrics = metrics; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Builder cpu(int cpu) { - return Builder.class.cast(super.cpu(cpu)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder smp(Integer smp) { - return Builder.class.cast(super.smp(smp)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder mem(int mem) { - return Builder.class.cast(super.mem(mem)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder persistent(boolean persistent) { - return Builder.class.cast(super.persistent(persistent)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder devices(Map<String, ? extends Device> devices) { - return Builder.class.cast(super.devices(devices)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder bootDeviceIds(Iterable<String> bootDeviceIds) { - return Builder.class.cast(super.bootDeviceIds(bootDeviceIds)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder nics(Iterable<NIC> nics) { - return Builder.class.cast(super.nics(nics)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder vnc(VNC vnc) { - return Builder.class.cast(super.vnc(vnc)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder description(String description) { - return Builder.class.cast(super.description(description)); - } - - /** - * {@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 use(Iterable<String> use) { - return Builder.class.cast(super.use(use)); - } - - public ServerInfo build() { - return new ServerInfo(uuid, name, cpu, smp, mem, persistent, devices, bootDeviceIds, use, nics, vnc, - description, status, started, user, metrics); - } - } - - protected final ServerStatus status; - @Nullable - protected final Date started; - @Nullable - protected final String user; - protected final ServerMetrics metrics; - - public ServerInfo(String uuid, String name, int cpu, Integer smp, int mem, boolean persistent, - Map<String, ? extends Device> devices, Iterable<String> bootDeviceIds, Iterable<String> use, - Iterable<NIC> nics, VNC vnc, String description, ServerStatus status, Date started, String user, - @Nullable ServerMetrics metrics) { - super(uuid, name, cpu, smp, mem, persistent, devices, bootDeviceIds, use, nics, vnc, description); - this.status = status; - this.started = started; - this.user = user; - this.metrics = metrics; - } - - /** - * - * @return active | stopped | paused | dumped | dead - */ - public ServerStatus getStatus() { - return status; - } - - // TODO undocumented - public Date getStarted() { - return started; - } - - /** - * - * @return metrics, if the server is running, or null - */ - @Nullable - public ServerMetrics getMetrics() { - return metrics; - } - - // TODO undocumented - /** - * - * @return owner of the server. - */ - public String getUser() { - return user; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((metrics == null) ? 0 : metrics.hashCode()); - result = prime * result + ((started == null) ? 0 : started.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((user == null) ? 0 : user.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; - ServerInfo other = (ServerInfo) obj; - if (metrics == null) { - if (other.metrics != null) - return false; - } else if (!metrics.equals(other.metrics)) - return false; - if (started == null) { - if (other.started != null) - return false; - } else if (!started.equals(other.started)) - return false; - if (status != other.status) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - return true; - } - - @Override - public String toString() { - return "[cpu=" + cpu + ", smp=" + smp + ", mem=" + mem + ", persistent=" + persistent + ", devices=" + devices - + ", bootDeviceIds=" + bootDeviceIds + ", nics=" + nics + ", vnc=" + vnc + ", uuid=" + uuid + ", name=" - + name + ", use=" + use + ", status=" + status + ", started=" + started + ", user=" + user + ", metrics=" - + metrics + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerMetrics.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerMetrics.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerMetrics.java deleted file mode 100644 index 7c39b8d..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerMetrics.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import com.google.common.collect.ImmutableMap; - -public class ServerMetrics { - - public static class Builder { - protected long txPackets; - protected long tx; - protected long rxPackets; - protected long rx; - protected Map<String, DriveMetrics> driveMetrics = ImmutableMap.<String, DriveMetrics> of(); - - public Builder txPackets(long txPackets) { - this.txPackets = txPackets; - return this; - } - - public Builder tx(long tx) { - this.tx = tx; - return this; - } - - public Builder rxPackets(long rxPackets) { - this.rxPackets = rxPackets; - return this; - } - - public Builder rx(long rx) { - this.rx = rx; - return this; - } - - public Builder driveMetrics(Map<String, ? extends DriveMetrics> driveMetrics) { - this.driveMetrics = ImmutableMap.copyOf(checkNotNull(driveMetrics, "driveMetrics")); - return this; - } - - public ServerMetrics build() { - return new ServerMetrics(tx, txPackets, rx, rxPackets, driveMetrics); - } - } - - protected final long txPackets; - protected final long tx; - protected final long rxPackets; - protected final long rx; - protected final Map<String, DriveMetrics> driveMetrics; - - public ServerMetrics(long tx, long txPackets, long rx, long rxPackets, Map<String, DriveMetrics> driveMetrics) { - this.txPackets = txPackets; - this.tx = tx; - this.rxPackets = rxPackets; - this.rx = rx; - this.driveMetrics = ImmutableMap.copyOf(checkNotNull(driveMetrics, "driveMetrics")); - } - - // TODO undocumented - public long getTxPackets() { - return txPackets; - } - - // TODO undocumented - public long getTx() { - return tx; - } - - // TODO undocumented - public long getRxPackets() { - return rxPackets; - } - - // TODO undocumented - public long getRx() { - return rx; - } - - /** - * - * @return metrics keyed on device id ex. {@code ide:0:0} - */ - public Map<String, DriveMetrics> getDriveMetrics() { - return driveMetrics; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((driveMetrics == null) ? 0 : driveMetrics.hashCode()); - result = prime * result + (int) (rx ^ (rx >>> 32)); - result = prime * result + (int) (rxPackets ^ (rxPackets >>> 32)); - result = prime * result + (int) (tx ^ (tx >>> 32)); - result = prime * result + (int) (txPackets ^ (txPackets >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ServerMetrics other = (ServerMetrics) obj; - if (driveMetrics == null) { - if (other.driveMetrics != null) - return false; - } else if (!driveMetrics.equals(other.driveMetrics)) - return false; - if (rx != other.rx) - return false; - if (rxPackets != other.rxPackets) - return false; - if (tx != other.tx) - return false; - if (txPackets != other.txPackets) - return false; - return true; - } - - @Override - public String toString() { - return "[ txPackets=" + txPackets + ", tx=" + tx + ", rxPackets=" + rxPackets + ", rx=" + rx + ", driveMetrics=" - + driveMetrics + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerStatus.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerStatus.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerStatus.java deleted file mode 100644 index 19c164a..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerStatus.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -public enum ServerStatus { - ACTIVE, STOPPED, PAUSED, DUMPED, DEAD, UNRECOGNIZED; - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static ServerStatus fromValue(String status) { - try { - return valueOf(checkNotNull(status, "status").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/StaticIPInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/StaticIPInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/StaticIPInfo.java deleted file mode 100644 index fdef081..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/StaticIPInfo.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ImmutableSet; - -public class StaticIPInfo { - public static class Builder { - protected String ip; - protected String user; - protected String netmask; - protected Set<String> nameservers = ImmutableSet.of(); - protected String gateway; - - public Builder ip(String ip) { - this.ip = ip; - return this; - } - - public Builder user(String user) { - this.user = user; - return this; - } - - public Builder nameservers(Iterable<String> nameservers) { - this.nameservers = ImmutableSet.copyOf(checkNotNull(nameservers, "nameservers")); - return this; - } - - public Builder gateway(String gateway) { - this.gateway = gateway; - return this; - } - - public Builder netmask(String netmask) { - this.netmask = netmask; - return this; - } - - public StaticIPInfo build() { - return new StaticIPInfo(ip, user, netmask, nameservers, gateway); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); - result = prime * result + ((nameservers == null) ? 0 : nameservers.hashCode()); - result = prime * result + ((netmask == null) ? 0 : netmask.hashCode()); - result = prime * result + ((user == null) ? 0 : user.hashCode()); - result = prime * result + ((ip == null) ? 0 : ip.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 (gateway == null) { - if (other.gateway != null) - return false; - } else if (!gateway.equals(other.gateway)) - return false; - if (nameservers == null) { - if (other.nameservers != null) - return false; - } else if (!nameservers.equals(other.nameservers)) - return false; - if (netmask == null) { - if (other.netmask != null) - return false; - } else if (!netmask.equals(other.netmask)) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - if (ip == null) { - if (other.ip != null) - return false; - } else if (!ip.equals(other.ip)) - return false; - return true; - } - } - - protected final String ip; - protected final String user; - protected final String netmask; - protected final Set<String> nameservers; - protected final String gateway; - - public StaticIPInfo(String ip, String user, String netmask, Iterable<String> nameservers, String gateway) { - this.ip = checkNotNull(ip, "ip"); - this.user = checkNotNull(user, "user"); - this.netmask = checkNotNull(netmask, "netmask"); - this.nameservers = ImmutableSet.copyOf(checkNotNull(nameservers, "nameservers")); - this.gateway = checkNotNull(gateway, "gateway"); - } - - /** - * - * @return ip of the ip. - */ - @Nullable - public String getAddress() { - return ip; - } - - /** - * - * @return user owning the ip - */ - public String getUser() { - return user; - } - - /** - * - * @return netmask of the ip - */ - public String getNetmask() { - return netmask; - } - - /** - * - * @return nameservers of the ip - */ - public Set<String> getNameservers() { - return nameservers; - } - - /** - * - * @return gateway of the ip - */ - public String getGateway() { - return gateway; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); - result = prime * result + ((nameservers == null) ? 0 : nameservers.hashCode()); - result = prime * result + ((netmask == null) ? 0 : netmask.hashCode()); - result = prime * result + ((user == null) ? 0 : user.hashCode()); - result = prime * result + ((ip == null) ? 0 : ip.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; - StaticIPInfo other = (StaticIPInfo) obj; - if (gateway == null) { - if (other.gateway != null) - return false; - } else if (!gateway.equals(other.gateway)) - return false; - if (nameservers == null) { - if (other.nameservers != null) - return false; - } else if (!nameservers.equals(other.nameservers)) - return false; - if (netmask == null) { - if (other.netmask != null) - return false; - } else if (!netmask.equals(other.netmask)) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - if (ip == null) { - if (other.ip != null) - return false; - } else if (!ip.equals(other.ip)) - return false; - return true; - } - - @Override - public String toString() { - return "[ip=" + ip + ", user=" + user + ", netmask=" + netmask + ", nameservers=" - + nameservers + ", gateway=" + gateway + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VLANInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VLANInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VLANInfo.java deleted file mode 100644 index 87635e2..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VLANInfo.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.javax.annotation.Nullable; - -public class VLANInfo { - public static class Builder { - protected String uuid; - protected String name; - protected String user; - - public Builder uuid(String uuid) { - this.uuid = uuid; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder user(String user) { - this.user = user; - return this; - } - - public VLANInfo build() { - return new VLANInfo(uuid, name, user); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((user == null) ? 0 : user.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 (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - 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 String user; - - public VLANInfo(String uuid, String name, String user) { - this.uuid = checkNotNull(uuid, "uuid"); - this.name = checkNotNull(name, "name"); - this.user = checkNotNull(user, "user"); - } - - /** - * - * @return uuid of the vlan. - */ - @Nullable - public String getUuid() { - return uuid; - } - - /** - * - * @return name of the vlan - */ - public String getName() { - return name; - } - - /** - * - * @return user owning the vlan - */ - public String getUser() { - return user; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((user == null) ? 0 : user.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; - VLANInfo other = (VLANInfo) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - - return true; - } - - @Override - public String toString() { - return "[uuid=" + uuid + ", name=" + name + ", user=" + user + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VNC.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VNC.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VNC.java deleted file mode 100644 index f28a553..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VNC.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.domain; - -import org.jclouds.javax.annotation.Nullable; - -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 + "]"; - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java deleted file mode 100644 index 4fe8876..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ClaimType; -import org.jclouds.cloudsigma.domain.Drive; - -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableMap; - -@Singleton -public class BaseDriveToMap implements Function<Drive, Map<String, String>> { - @Override - public Map<String, String> apply(Drive from) { - checkNotNull(from, "drive"); - ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); - builder.put("name", from.getName()); - builder.put("size", from.getSize() + ""); - if (from.getClaimType() != ClaimType.EXCLUSIVE) - builder.put("claim:type", from.getClaimType().toString()); - if (from.getTags().size() != 0) - builder.put("tags", Joiner.on(' ').join(from.getTags())); - if (from.getReaders().size() != 0) - builder.put("readers", Joiner.on(' ').join(from.getReaders())); - if (from.getUse().size() != 0) - builder.put("use", Joiner.on(' ').join(from.getUse())); - return builder.build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/DriveDataToMap.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/DriveDataToMap.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/DriveDataToMap.java deleted file mode 100644 index 469f888..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/DriveDataToMap.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Predicates.not; -import static com.google.common.collect.Maps.filterKeys; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.DriveData; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; - -@Singleton -public class DriveDataToMap implements Function<DriveData, Map<String, String>> { - private final BaseDriveToMap baseDriveToMap; - - @Inject - public DriveDataToMap(BaseDriveToMap baseDriveToMap) { - this.baseDriveToMap = baseDriveToMap; - } - - @Override - public Map<String, String> apply(DriveData from) { - return renameKey(baseDriveToMap.apply(from), "use", "use"); - } - - /** - * If the supplied map contains the key {@code k1}, its value will be assigned to the key {@code - * k2}. Note that this doesn't modify the input map. - * - * @param <V> - * type of value the map holds - * @param in - * the map you wish to make a copy of - * @param k1 - * old key - * @param k2 - * new key - * @return copy of the map with the value of the key re-routed, or the original, if it {@code k1} - * wasn't present. - */ - @VisibleForTesting - static <V> Map<String, V> renameKey(Map<String, V> in, String k1, String k2) { - if (checkNotNull(in, "input map").containsKey(checkNotNull(k1, "old key"))) { - Builder<String, V> builder = ImmutableMap.builder(); - builder.putAll(filterKeys(in, not(equalTo(k1)))); - V tags = in.get(k1); - builder.put(checkNotNull(k2, "new key"), tags); - in = builder.build(); - } - return in; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfo.java deleted file mode 100644 index 5753a52..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfo.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -@Singleton -public class KeyValuesDelimitedByBlankLinesToDriveInfo implements Function<HttpResponse, DriveInfo> { - private final ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet setParser; - - @Inject - public KeyValuesDelimitedByBlankLinesToDriveInfo(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet setParser) { - this.setParser = setParser; - } - - @Override - public DriveInfo apply(HttpResponse response) { - Set<DriveInfo> drives = setParser.apply(response); - if (drives.size() == 0) - return null; - return Iterables.get(drives, 0); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfo.java deleted file mode 100644 index 9e1e61b..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfo.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ProfileInfo; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -@Singleton -public class KeyValuesDelimitedByBlankLinesToProfileInfo implements Function<HttpResponse, ProfileInfo> { - private final ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet setParser; - - @Inject - public KeyValuesDelimitedByBlankLinesToProfileInfo(ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet setParser) { - this.setParser = setParser; - } - - @Override - public ProfileInfo apply(HttpResponse response) { - Set<ProfileInfo> drives = setParser.apply(response); - if (drives.size() == 0) - return null; - return Iterables.get(drives, 0); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfo.java deleted file mode 100644 index e22a420..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfo.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -@Singleton -public class KeyValuesDelimitedByBlankLinesToServerInfo implements Function<HttpResponse, ServerInfo> { - private final ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet setParser; - - @Inject - public KeyValuesDelimitedByBlankLinesToServerInfo(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet setParser) { - this.setParser = setParser; - } - - @Override - public ServerInfo apply(HttpResponse response) { - Set<ServerInfo> drives = setParser.apply(response); - if (drives.size() == 0) - return null; - return Iterables.get(drives, 0); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToStaticIPInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToStaticIPInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToStaticIPInfo.java deleted file mode 100644 index b02f16b..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToStaticIPInfo.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.StaticIPInfo; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -@Singleton -public class KeyValuesDelimitedByBlankLinesToStaticIPInfo implements Function<HttpResponse, StaticIPInfo> { - private final ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet setParser; - - @Inject - public KeyValuesDelimitedByBlankLinesToStaticIPInfo(ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet setParser) { - this.setParser = setParser; - } - - @Override - public StaticIPInfo apply(HttpResponse response) { - Set<StaticIPInfo> drives = setParser.apply(response); - if (drives.size() == 0) - return null; - return Iterables.get(drives, 0); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfo.java deleted file mode 100644 index fba64be..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfo.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.VLANInfo; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -@Singleton -public class KeyValuesDelimitedByBlankLinesToVLANInfo implements Function<HttpResponse, VLANInfo> { - private final ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet setParser; - - @Inject - public KeyValuesDelimitedByBlankLinesToVLANInfo(ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet setParser) { - this.setParser = setParser; - } - - @Override - public VLANInfo apply(HttpResponse response) { - Set<VLANInfo> drives = setParser.apply(response); - if (drives.size() == 0) - return null; - return Iterables.get(drives, 0); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.java deleted file mode 100644 index 1292d66..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet implements Function<HttpResponse, Set<DriveInfo>> { - private final ReturnStringIf2xx returnStringIf200; - private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; - private final MapToDriveInfo mapToDrive; - - @Inject - ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet(ReturnStringIf2xx returnStringIf200, - ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToDriveInfo mapToDrive) { - this.returnStringIf200 = returnStringIf200; - this.mapConverter = mapConverter; - this.mapToDrive = mapToDrive; - } - - @Override - public Set<DriveInfo> apply(HttpResponse response) { - String text = returnStringIf200.apply(response); - if (text == null || text.trim().equals("")) - return ImmutableSet.<DriveInfo> of(); - return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToDrive)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMaps.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMaps.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMaps.java deleted file mode 100644 index 0ded8ac..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMaps.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.List; -import java.util.Map; - -import javax.inject.Singleton; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToListOfMaps implements Function<String, List<Map<String, String>>> { - - @Override - public List<Map<String, String>> apply(String from) { - List<Map<String, String>> maps = Lists.newArrayList(); - for (String listOfKeyValues : Splitter.on("\n\n").split(from)) { - if (!"".equals(listOfKeyValues)) { - Map<String, String> map = Maps.newLinkedHashMap(); - for (String keyValueLine : Splitter.on('\n').split(listOfKeyValues)) { - if (!"".equals(keyValueLine)) { - int firstIndex = keyValueLine.indexOf(' '); - if (firstIndex != -1) { - String key = keyValueLine.substring(0, firstIndex); - String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n"); - map.put(key, value); - } - } - } - if (map.size() != 0) - maps.add(map); - } - } - return maps; - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet.java deleted file mode 100644 index 00bc07d..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ProfileInfo; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet implements Function<HttpResponse, Set<ProfileInfo>> { - private final ReturnStringIf2xx returnStringIf200; - private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; - private final MapToProfileInfo mapToProfile; - - @Inject - ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet(ReturnStringIf2xx returnStringIf200, - ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToProfileInfo mapToProfile) { - this.returnStringIf200 = returnStringIf200; - this.mapConverter = mapConverter; - this.mapToProfile = mapToProfile; - } - - @Override - public Set<ProfileInfo> apply(HttpResponse response) { - String text = returnStringIf200.apply(response); - if (text == null || text.trim().equals("")) - return ImmutableSet.<ProfileInfo> of(); - return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToProfile)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.java deleted file mode 100644 index f1eec32..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - - -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet implements Function<HttpResponse, Set<ServerInfo>> { - private final ReturnStringIf2xx returnStringIf200; - private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; - private final MapToServerInfo mapToServer; - - @Inject - ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet(ReturnStringIf2xx returnStringIf200, - ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToServerInfo mapToServer) { - this.returnStringIf200 = returnStringIf200; - this.mapConverter = mapConverter; - this.mapToServer = mapToServer; - } - - @Override - public Set<ServerInfo> apply(HttpResponse response) { - String text = returnStringIf200.apply(response); - if (text == null || text.trim().equals("")) - return ImmutableSet.<ServerInfo> of(); - return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToServer)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.java deleted file mode 100644 index 669164a..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.StaticIPInfo; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet implements Function<HttpResponse, Set<StaticIPInfo>> { - private final ReturnStringIf2xx returnStringIf200; - private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; - private final MapToStaticIPInfo mapToProfile; - - @Inject - ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet(ReturnStringIf2xx returnStringIf200, - ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToStaticIPInfo mapToProfile) { - this.returnStringIf200 = returnStringIf200; - this.mapConverter = mapConverter; - this.mapToProfile = mapToProfile; - } - - @Override - public Set<StaticIPInfo> apply(HttpResponse response) { - String text = returnStringIf200.apply(response); - if (text == null || text.trim().equals("")) - return ImmutableSet.<StaticIPInfo> of(); - return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToProfile)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.java deleted file mode 100644 index 3413279..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.VLANInfo; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet implements Function<HttpResponse, Set<VLANInfo>> { - private final ReturnStringIf2xx returnStringIf200; - private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; - private final MapToVLANInfo mapToProfile; - - @Inject - ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet(ReturnStringIf2xx returnStringIf200, - ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToVLANInfo mapToProfile) { - this.returnStringIf200 = returnStringIf200; - this.mapConverter = mapConverter; - this.mapToProfile = mapToProfile; - } - - @Override - public Set<VLANInfo> apply(HttpResponse response) { - String text = returnStringIf200.apply(response); - if (text == null || text.trim().equals("")) - return ImmutableSet.<VLANInfo> of(); - return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToProfile)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLines.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLines.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLines.java deleted file mode 100644 index f9da173..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLines.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Map; - -import javax.inject.Singleton; - -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; - -@Singleton -public class ListOfMapsToListOfKeyValuesDelimitedByBlankLines implements - Function<Iterable<Map<String, String>>, String> { - - @Override - public String apply(Iterable<Map<String, String>> from) { - return Joiner.on("\n\n").join(Iterables.transform(from, new Function<Map<String, String>, String>() { - - @Override - public String apply(Map<String, String> from) { - return Joiner.on('\n').withKeyValueSeparator(" ") - .join(Maps.transformValues(from, new Function<String, String>() { - - @Override - public String apply(String from) { - return from.replace("\n", "\\n"); - } - - })); - } - - })); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ba04fa04/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java deleted file mode 100644 index b25a3f0..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.cloudsigma.functions; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.BlockDevice; -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.IDEDevice; -import org.jclouds.cloudsigma.domain.MediaType; -import org.jclouds.cloudsigma.domain.SCSIDevice; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.common.collect.Maps; - -@Singleton -public class MapToDevices implements Function<Map<String, String>, Map<String, ? extends Device>> { - @Singleton - public static class DeviceToId implements Function<Device, String> { - @Override - public String apply(Device input) { - return input.getId(); - } - } - - private final Function<Device, String> deviceToId; - - @Inject - public MapToDevices(Function<Device, String> deviceToId) { - this.deviceToId = deviceToId; - } - - public Map<String, ? extends Device> apply(Map<String, String> from) { - Builder<Device> devices = ImmutableSet.builder(); - addIDEDevices(from, devices); - addSCSIDevices(from, devices); - addBlockDevices(from, devices); - - return Maps.uniqueIndex(devices.build(), deviceToId); - } - - protected void addBlockDevices(Map<String, String> from, Builder<Device> devices) { - BLOCK: for (int index : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { - String key = String.format("block:0:%d", index); - if (!from.containsKey(key)) - break BLOCK; - devices.add(populateBuilder(new BlockDevice.Builder(index), key, from).build()); - } - } - - protected void addSCSIDevices(Map<String, String> from, Builder<Device> devices) { - SCSI: for (int unit : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { - String key = String.format("scsi:0:%d", unit); - if (!from.containsKey(key)) - break SCSI; - devices.add(populateBuilder(new SCSIDevice.Builder(unit), key, from).build()); - } - } - - protected void addIDEDevices(Map<String, String> from, Builder<Device> devices) { - IDE: for (int bus : new int[] { 0, 1 }) - for (int unit : new int[] { 0, 1 }) { - String key = String.format("ide:%d:%d", bus, unit); - if (!from.containsKey(key)) - break IDE; - devices.add(populateBuilder(new IDEDevice.Builder(bus, unit), key, from).build()); - } - } - - protected Device.Builder populateBuilder(Device.Builder deviceBuilder, String key, Map<String, String> from) { - deviceBuilder.uuid(from.get(key)); - if (from.containsKey(key + ":media")) - deviceBuilder.mediaType(MediaType.fromValue(from.get(key + ":media"))); - return deviceBuilder; - } -}
