http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java deleted file mode 100644 index 9744bc3..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java +++ /dev/null @@ -1,110 +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.net.URI; -import java.util.Map; -import java.util.Map.Entry; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ClaimType; -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.cloudsigma.domain.DriveMetrics; -import org.jclouds.cloudsigma.domain.DriveStatus; -import org.jclouds.cloudsigma.domain.DriveType; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.Maps; - -@Singleton -public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo> { - - @Resource - protected Logger logger = Logger.NULL; - - @Override - public DriveInfo apply(Map<String, String> from) { - if (from.isEmpty()) - return null; - DriveInfo.Builder builder = new DriveInfo.Builder(); - builder.name(from.get("name")); - if (from.containsKey("use")) - builder.use(Splitter.on(' ').split(from.get("use"))); - if (from.containsKey("status")) - builder.status(DriveStatus.fromValue(from.get("status"))); - builder.metrics(buildMetrics(from)); - builder.user(from.get("user")); - builder.encryptionCipher(from.get("encryption:cipher")); - builder.uuid(from.get("drive")); - if (from.containsKey("claim:type")) - builder.claimType(ClaimType.fromValue(from.get("claim:type"))); - if (from.containsKey("claimed")) - builder.claimed(Splitter.on(' ').split(from.get("claimed"))); - if (from.containsKey("tags")) - builder.tags(Splitter.on(' ').split(from.get("tags"))); - if (from.containsKey("readers")) - builder.readers(Splitter.on(' ').split(from.get("readers"))); - if (from.containsKey("size")) - builder.size(Long.parseLong(from.get("size"))); - Map<String, String> metadata = Maps.newLinkedHashMap(); - for (Entry<String, String> entry : from.entrySet()) { - if (entry.getKey().startsWith("user:")) - metadata.put(entry.getKey().substring(entry.getKey().indexOf(':') + 1), entry.getValue()); - } - if (from.containsKey("use")) - builder.use(Splitter.on(' ').split(from.get("use"))); - if (from.containsKey("bits")) - builder.bits(Integer.parseInt(from.get("bits"))); - if (from.containsKey("url")) - builder.url(URI.create(from.get("url"))); - builder.encryptionKey(from.get("encryption:key")); - builder.description(from.get("description")); - builder.installNotes(from.get("install_notes")); - builder.os(from.get("os")); - if (from.containsKey("drive_type")) - builder.driveType(Splitter.on(',').split(from.get("drive_type"))); - if (from.containsKey("autoexpanding")) - builder.autoexpanding(Boolean.valueOf(from.get("autoexpanding"))); - if (from.containsKey("free")) - builder.free(Boolean.valueOf(from.get("free"))); - if (from.containsKey("type")) - builder.type(DriveType.fromValue(from.get("type"))); - try { - return builder.build(); - } catch (NullPointerException e) { - logger.trace("entry missing data: %s; %s", e.getMessage(), from); - return null; - } - } - - protected DriveMetrics buildMetrics(Map<String, String> from) { - DriveMetrics.Builder metricsBuilder = new DriveMetrics.Builder(); - if (from.containsKey("read:bytes")) - metricsBuilder.readBytes(Long.parseLong(from.get("read:bytes"))); - if (from.containsKey("read:requests")) - metricsBuilder.readRequests(Long.parseLong(from.get("read:requests"))); - if (from.containsKey("write:bytes")) - metricsBuilder.writeBytes(Long.parseLong(from.get("write:bytes"))); - if (from.containsKey("write:requests")) - metricsBuilder.writeRequests(Long.parseLong(from.get("write:requests"))); - return metricsBuilder.build(); - } -}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java deleted file mode 100644 index c5aef9d..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java +++ /dev/null @@ -1,80 +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 org.jclouds.cloudsigma.domain.DriveMetrics; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; - -@Singleton -public class MapToDriveMetrics implements Function<Map<String, String>, Map<String, ? extends DriveMetrics>> { - - public Map<String, ? extends DriveMetrics> apply(Map<String, String> from) { - Builder<String, DriveMetrics> builder = ImmutableMap.builder(); - addIDEDevices(from, builder); - addSCSIDevices(from, builder); - addBlockDevices(from, builder); - return builder.build(); - } - - protected void addBlockDevices(Map<String, String> from, Builder<String, DriveMetrics> 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.put(key, buildMetrics(key, from)); - } - } - - protected void addSCSIDevices(Map<String, String> from, Builder<String, DriveMetrics> 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.put(key, buildMetrics(key, from)); - } - } - - protected void addIDEDevices(Map<String, String> from, Builder<String, DriveMetrics> 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.put(key, buildMetrics(key, from)); - } - } - - protected DriveMetrics buildMetrics(String key, Map<String, String> from) { - DriveMetrics.Builder builder = new DriveMetrics.Builder(); - if (from.containsKey(key + ":read:bytes")) - builder.readBytes(Long.parseLong(from.get(key + ":read:bytes"))); - if (from.containsKey(key + ":read:requests")) - builder.readRequests(Long.parseLong(from.get(key + ":read:requests"))); - if (from.containsKey(key + ":write:bytes")) - builder.writeBytes(Long.parseLong(from.get(key + ":write:bytes"))); - if (from.containsKey(key + ":write:requests")) - builder.writeRequests(Long.parseLong(from.get(key + ":write:requests"))); - return builder.build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToNICs.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToNICs.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToNICs.java deleted file mode 100644 index 76f2461..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToNICs.java +++ /dev/null @@ -1,52 +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 org.jclouds.cloudsigma.domain.Model; -import org.jclouds.cloudsigma.domain.NIC; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableList; - -@Singleton -public class MapToNICs implements Function<Map<String, String>, List<NIC>> { - - @Override - public List<NIC> apply(Map<String, String> from) { - ImmutableList.Builder<NIC> nics = ImmutableList.builder(); - NIC: for (int id : new int[] { 0, 1 }) { - String key = String.format("nic:%d", id); - if (!from.containsKey(key + ":model")) - break NIC; - NIC.Builder nicBuilder = new NIC.Builder(); - nicBuilder.dhcp(from.get(key + ":dhcp")); - nicBuilder.model(Model.fromValue(from.get(key + ":model"))); - nicBuilder.vlan(from.get(key + ":vlan")); - nicBuilder.mac(from.get(key + ":mac")); - if (from.containsKey(key + ":block")) - nicBuilder.block(Splitter.on(' ').split(from.get(key + ":block"))); - nics.add(nicBuilder.build()); - } - return nics.build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToProfileInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToProfileInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToProfileInfo.java deleted file mode 100644 index 50d24e4..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToProfileInfo.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.Map; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ProfileInfo; -import org.jclouds.cloudsigma.domain.ProfileType; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; - -@Singleton -public class MapToProfileInfo implements Function<Map<String, String>, ProfileInfo> { - - @Resource - protected Logger logger = Logger.NULL; - - @Override - public ProfileInfo apply(Map<String, String> from) { - if (from.isEmpty()) - return null; - ProfileInfo.Builder builder = new ProfileInfo.Builder(); - builder.uuid(from.get("uuid")); - builder.email(from.get("email")); - builder.firstName(from.get("first_name")); - builder.lastName(from.get("last_name")); - builder.nickName(from.get("nick_name")); - builder.type(ProfileType.fromValue(from.get("type"))); - try { - return builder.build(); - } catch (NullPointerException e) { - logger.trace("entry missing data: %s; %s", e.getMessage(), from); - return null; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerInfo.java deleted file mode 100644 index 6a493d0..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerInfo.java +++ /dev/null @@ -1,87 +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.Date; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.cloudsigma.domain.ServerMetrics; -import org.jclouds.cloudsigma.domain.ServerStatus; -import org.jclouds.cloudsigma.domain.VNC; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.Maps; - -@Singleton -public class MapToServerInfo implements Function<Map<String, String>, ServerInfo> { - private final Function<Map<String, String>, Map<String, ? extends Device>> mapToDevices; - private final Function<Map<String, String>, ServerMetrics> mapToMetrics; - private final Function<Map<String, String>, List<NIC>> mapToNICs; - - @Inject - public MapToServerInfo(Function<Map<String, String>, Map<String, ? extends Device>> mapToDevices, - Function<Map<String, String>, ServerMetrics> mapToMetrics, Function<Map<String, String>, List<NIC>> mapToNICs) { - this.mapToDevices = mapToDevices; - this.mapToMetrics = mapToMetrics; - this.mapToNICs = mapToNICs; - } - - @Override - public ServerInfo apply(Map<String, String> from) { - if (from.isEmpty()) - return null; - ServerInfo.Builder builder = new ServerInfo.Builder(); - builder.name(from.get("name")); - builder.description(from.get("description")); - builder.persistent(Boolean.parseBoolean(from.get("persistent"))); - if (from.containsKey("use")) - builder.use(Splitter.on(' ').split(from.get("use"))); - if (from.containsKey("status")) - builder.status(ServerStatus.fromValue(from.get("status"))); - if (from.containsKey("smp") && !"auto".equals(from.get("smp"))) - builder.smp(Integer.parseInt(from.get("smp"))); - builder.cpu(Integer.parseInt(from.get("cpu"))); - builder.mem(Integer.parseInt(from.get("mem"))); - builder.user(from.get("user")); - if (from.containsKey("started")) - builder.started(new Date(Long.parseLong(from.get("started")))); - builder.uuid(from.get("server")); - builder.vnc(new VNC(from.get("vnc:ip"), from.get("vnc:password"), from.containsKey("vnc:tls") - && Boolean.valueOf(from.get("vnc:tls")))); - if (from.containsKey("boot")) - builder.bootDeviceIds(Splitter.on(' ').split(from.get("boot"))); - - Map<String, String> metadata = Maps.newLinkedHashMap(); - for (Entry<String, String> entry : from.entrySet()) { - if (entry.getKey().startsWith("user:")) - metadata.put(entry.getKey().substring(entry.getKey().indexOf(':') + 1), entry.getValue()); - } - builder.nics(mapToNICs.apply(from)); - builder.devices(mapToDevices.apply(from)); - builder.metrics(mapToMetrics.apply(from)); - return builder.build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerMetrics.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerMetrics.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerMetrics.java deleted file mode 100644 index 3138b0e..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerMetrics.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.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.DriveMetrics; -import org.jclouds.cloudsigma.domain.ServerMetrics; - -import com.google.common.base.Function; - -@Singleton -public class MapToServerMetrics implements Function<Map<String, String>, ServerMetrics> { - private final Function<Map<String, String>, Map<String, ? extends DriveMetrics>> mapToDriveMetrics; - - @Inject - public MapToServerMetrics(Function<Map<String, String>, Map<String, ? extends DriveMetrics>> mapToDriveMetrics) { - this.mapToDriveMetrics = mapToDriveMetrics; - } - - public ServerMetrics apply(Map<String, String> from) { - ServerMetrics.Builder metricsBuilder = new ServerMetrics.Builder(); - if (from.containsKey("tx:packets")) - metricsBuilder.txPackets(Long.parseLong(from.get("tx:packets"))); - if (from.containsKey("tx")) - metricsBuilder.tx(Long.parseLong(from.get("tx"))); - if (from.containsKey("rx:packets")) - metricsBuilder.rxPackets(Long.parseLong(from.get("rx:packets"))); - if (from.containsKey("rx")) - metricsBuilder.rx(Long.parseLong(from.get("rx"))); - metricsBuilder.driveMetrics(mapToDriveMetrics.apply(from)); - - ServerMetrics metrics = metricsBuilder.build(); - return metrics; - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToStaticIPInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToStaticIPInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToStaticIPInfo.java deleted file mode 100644 index 0a18cfa..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToStaticIPInfo.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.Map; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.StaticIPInfo; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; - -@Singleton -public class MapToStaticIPInfo implements Function<Map<String, String>, StaticIPInfo> { - - @Resource - protected Logger logger = Logger.NULL; - - @Override - public StaticIPInfo apply(Map<String, String> from) { - if (from.isEmpty()) - return null; - StaticIPInfo.Builder builder = new StaticIPInfo.Builder(); - builder.ip(from.get("resource")); - builder.user(from.get("user")); - builder.netmask(from.get("netmask")); - builder.nameservers(Splitter.on(' ').split(from.get("nameserver"))); - builder.gateway(from.get("gateway")); - - try { - return builder.build(); - } catch (NullPointerException e) { - logger.trace("entry missing data: %s; %s", e.getMessage(), from); - return null; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToVLANInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToVLANInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToVLANInfo.java deleted file mode 100644 index 6b404e3..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToVLANInfo.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 java.util.Map; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.VLANInfo; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; - -@Singleton -public class MapToVLANInfo implements Function<Map<String, String>, VLANInfo> { - - @Resource - protected Logger logger = Logger.NULL; - - @Override - public VLANInfo apply(Map<String, String> from) { - if (from.isEmpty()) - return null; - VLANInfo.Builder builder = new VLANInfo.Builder(); - builder.uuid(from.get("resource")); - builder.name(from.get("name")); - builder.user(from.get("user")); - try { - return builder.build(); - } catch (NullPointerException e) { - logger.trace("entry missing data: %s; %s", e.getMessage(), from); - return null; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ReturnPayload.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ReturnPayload.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ReturnPayload.java deleted file mode 100644 index 922599d..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ReturnPayload.java +++ /dev/null @@ -1,32 +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 javax.inject.Singleton; - -import org.jclouds.http.HttpResponse; -import org.jclouds.io.Payload; - -import com.google.common.base.Function; - -@Singleton -public class ReturnPayload implements Function<HttpResponse, Payload> { - - public Payload apply(HttpResponse from) { - return from.getPayload(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ServerToMap.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ServerToMap.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ServerToMap.java deleted file mode 100644 index c529db3..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ServerToMap.java +++ /dev/null @@ -1,74 +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 java.util.Map.Entry; - -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.Server; - -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableMap; - -@Singleton -public class ServerToMap implements Function<Server, Map<String, String>> { - @Override - public Map<String, String> apply(Server from) { - checkNotNull(from, "server"); - ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); - builder.put("name", from.getName()); - builder.put("cpu", from.getCpu() + ""); - if (from.getSmp() != null) - builder.put("smp", from.getSmp() + ""); - else - builder.put("smp", "auto"); - builder.put("mem", from.getMem() + ""); - builder.put("persistent", from.isPersistent() + ""); - if (!from.getBootDeviceIds().isEmpty()) - builder.put("boot", Joiner.on(' ').join(from.getBootDeviceIds())); - for (Entry<String, ? extends Device> entry : from.getDevices().entrySet()) { - builder.put(entry.getKey(), entry.getValue().getDriveUuid()); - builder.put(entry.getKey() + ":media", entry.getValue().getMediaType().toString()); - } - int nicId = 0; - for (NIC nic : from.getNics()) { - builder.put("nic:" + nicId + ":model", nic.getModel().toString()); - if (nic.getDhcp() != null) - builder.put("nic:" + nicId + ":dhcp", nic.getDhcp()); - if (nic.getVlan() != null) - builder.put("nic:" + nicId + ":vlan", nic.getVlan()); - if (nic.getMac() != null) - builder.put("nic:" + nicId + ":mac", nic.getMac()); - nicId++; - } - builder.put("vnc:ip", from.getVnc().getIp() == null ? "auto" : from.getVnc().getIp()); - if (from.getVnc().getPassword() != null) - builder.put("vnc:password", from.getVnc().getPassword()); - if (from.getVnc().isTls()) - builder.put("vnc:tls", "on"); - if (!from.getUse().isEmpty()) - builder.put("use", Joiner.on(' ').join(from.getUse())); - return builder.build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java deleted file mode 100644 index f90584c..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java +++ /dev/null @@ -1,45 +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.collect.Sets.newTreeSet; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; - -@Singleton -public class SplitNewlines implements Function<HttpResponse, Set<String>> { - private final ReturnStringIf2xx returnStringIf200; - - @Inject - protected SplitNewlines(ReturnStringIf2xx returnStringIf200) { - this.returnStringIf200 = returnStringIf200; - } - - @Override - public Set<String> apply(HttpResponse response) { - return newTreeSet(Splitter.on('\n').omitEmptyStrings().split(returnStringIf200.apply(response))); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlinesAndReturnSecondField.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlinesAndReturnSecondField.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlinesAndReturnSecondField.java deleted file mode 100644 index cf118cc..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlinesAndReturnSecondField.java +++ /dev/null @@ -1,60 +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.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.base.Predicates; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -@Singleton -public class SplitNewlinesAndReturnSecondField extends SplitNewlines { - - @Inject - SplitNewlinesAndReturnSecondField(ReturnStringIf2xx returnStringIf200) { - super(returnStringIf200); - } - - @Override - public Set<String> apply(HttpResponse response) { - return ImmutableSet.copyOf(Iterables.filter( - Iterables.transform(super.apply(response), new Function<String, String>() { - - @Override - public String apply(String arg0) { - if (arg0 == null) - return null; - Iterable<String> parts = Splitter.on(' ').split(arg0); - if (Iterables.size(parts) == 2) - return Iterables.get(parts, 1); - else if (Iterables.size(parts) == 1) - return Iterables.get(parts, 0); - return null; - } - - }), Predicates.notNull())); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java deleted file mode 100644 index 56d9aa3..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java +++ /dev/null @@ -1,102 +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.handlers; - -import java.io.IOException; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.logging.Logger; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.util.Closeables2; -import org.jclouds.util.Strings2; - -import com.google.common.base.Throwables; - -/** - * This will parse and set an appropriate exception on the command object. - * - * <p/> - * Errors are returned with an appropriate HTTP status code, an X-Elastic- Error header specifying - * the error type, and a text description in the HTTP body. - */ -@Singleton -public class CloudSigmaErrorHandler implements HttpErrorHandler { - @Resource - protected Logger logger = Logger.NULL; - - public void handleError(HttpCommand command, HttpResponse response) { - // it is important to always read fully and close streams - String message = parseMessage(response); - Exception exception = message != null ? new HttpResponseException(command, response, message) - : new HttpResponseException(command, response); - try { - message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), - response.getStatusLine()); - switch (response.getStatusCode()) { - case 400: - if ((command.getCurrentRequest().getEndpoint().getPath().endsWith("/info")) - || (message != null && message.indexOf("could not be found") != -1)) - exception = new ResourceNotFoundException(message, exception); - else if (message != null && message.indexOf("currently in use") != -1) - exception = new IllegalStateException(message, exception); - else - exception = new IllegalArgumentException(message, exception); - break; - case 401: - exception = new AuthorizationException(message, exception); - break; - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - exception = new ResourceNotFoundException(message, exception); - } - break; - case 405: - exception = new IllegalArgumentException(message, exception); - break; - case 409: - exception = new IllegalStateException(message, exception); - break; - } - } finally { - Closeables2.closeQuietly(response.getPayload()); - command.setException(exception); - } - } - - public String parseMessage(HttpResponse response) { - if (response.getPayload() == null) - return null; - try { - return Strings2.toStringAndClose(response.getPayload().openStream()); - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - response.getPayload().getInput().close(); - } catch (IOException e) { - Throwables.propagate(e); - } - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java deleted file mode 100644 index b984d0a..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java +++ /dev/null @@ -1,136 +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.options; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.jclouds.cloudsigma.domain.AffinityType; - -import com.google.common.base.Joiner; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -/** - * Contains options supported for clone drive operations. <h2> - * Usage</h2> The recommended way to instantiate a CloneDriveOptions object is to statically import - * CloneDriveOptions.Builder.* and invoke a static creation method followed by an instance mutator - * (if needed): - * <p/> - * <code> - * import static org.jclouds.cloudsigma.options.CloneDriveOptions.Builder.*; - * - * - * Payload payload = client.cloneDrive("drive-uuid","newName", size(2*1024*1024l)); - * <code> - */ -public class CloneDriveOptions { - private static final String SSD_AFFINITY_TAG = "affinity:ssd"; - private final Map<String, String> options = Maps.newLinkedHashMap(); - - /** - * adjust to new size in bytes - */ - public CloneDriveOptions size(long size) { - checkArgument(size >= 0, "size must be >= 0"); - options.put("size", size + ""); - return this; - } - - public CloneDriveOptions tags(String... tags) { - // Affinity is conveyed using regular tags; make sure to preserve any already-set affinity tag. - String currentTagsString = options.remove("tags"); - Set<String> currentTags = (currentTagsString == null) ? new HashSet<String>() : - Sets.newLinkedHashSet(Splitter.on(' ').split(currentTagsString)); - - Set<String> newTags = Sets.newLinkedHashSet(); - for (String tag : tags) - newTags.add(tag); - - if (currentTags.contains(SSD_AFFINITY_TAG)) - newTags.add(SSD_AFFINITY_TAG); - - options.put("tags", Joiner.on(' ').join(newTags)); - return this; - } - - /** - * Specifies whether the new drive has 'HDD' affinity (the default) or 'SSD' (for solid-state drives). - * Affinity is conveyed via a special value among the drive's tags. - */ - public CloneDriveOptions affinity(AffinityType affinity) { - // Affinity is conveyed using regular tags; make sure to avoid multiple affinity tags in the options. - String currentTagsString = options.remove("tags"); - Set<String> tags = (currentTagsString == null) ? new LinkedHashSet<String>() : - Sets.newLinkedHashSet(Splitter.on(' ').split(currentTagsString)); - - switch (affinity) { - // SSD affinity is conveyed as a special tag: "affinity:ssd". - case SSD: - tags.add(SSD_AFFINITY_TAG); - break; - - // HDD affinity (the default) is conveyed by the *absence* of the "affinity:ssd" tag. - case HDD: - tags.remove(SSD_AFFINITY_TAG); - break; - } - - if (!tags.isEmpty()) - options.put("tags", Joiner.on(' ').join(tags)); - - return this; - } - - public static class Builder { - - /** - * @see CloneDriveOptions#size - */ - public static CloneDriveOptions size(long size) { - CloneDriveOptions options = new CloneDriveOptions(); - return options.size(size); - } - - /** - * @see CloneDriveOptions#tags - */ - public static CloneDriveOptions tags(String... tags) { - CloneDriveOptions options = new CloneDriveOptions(); - return options.tags(tags); - } - - /** - * @see CloneDriveOptions#affinity - */ - public static CloneDriveOptions affinity(AffinityType affinity) { - CloneDriveOptions options = new CloneDriveOptions(); - return options.affinity(affinity); - } - - } - - public Map<String, String> getOptions() { - return ImmutableMap.copyOf(options); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java deleted file mode 100644 index ce1b95b..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java +++ /dev/null @@ -1,56 +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.predicates; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.CloudSigmaApi; -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; - -@Singleton -public class DriveClaimed implements Predicate<DriveInfo> { - - private final CloudSigmaApi client; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public DriveClaimed(CloudSigmaApi client) { - this.client = client; - } - - public boolean apply(DriveInfo drive) { - logger.trace("looking for claims on drive %s", checkNotNull(drive, "drive")); - drive = refresh(drive); - if (drive == null) - return false; - logger.trace("%s: looking for drive claims: currently: %s", drive.getUuid(), drive.getClaimed()); - return !drive.getClaimed().isEmpty(); - } - - private DriveInfo refresh(DriveInfo drive) { - return client.getDriveInfo(drive.getUuid()); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/reference/CloudSigmaConstants.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/reference/CloudSigmaConstants.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/reference/CloudSigmaConstants.java deleted file mode 100644 index e05cc42..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/reference/CloudSigmaConstants.java +++ /dev/null @@ -1,29 +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.reference; - -public final class CloudSigmaConstants { - - /** - * default VNC password used on new machines - */ - public static final String PROPERTY_VNC_PASSWORD = "jclouds.cloudsigma.vnc-password"; - - private CloudSigmaConstants() { - throw new AssertionError("intentionally unimplemented"); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java deleted file mode 100644 index d4fa25a..0000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java +++ /dev/null @@ -1,79 +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.util; - -import org.jclouds.cloudsigma.domain.IDEDevice; -import org.jclouds.cloudsigma.domain.Model; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.domain.VNC; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -public class Servers { - /** - * Helper to create a small persistent server - * - * @param name - * what to name the server - * @param driveUuuid - * id of the boot drive - * @param vncPassword - * password for vnc - * @return a builder for a persistent 1Ghz 512m server with DHCP enabled network. - */ - public static Server.Builder small(String name, String driveUuuid, String vncPassword) { - return smallWithStaticIP(name, driveUuuid, vncPassword, "auto"); - } - - /** - * Helper to create a small persistent server - * - * @param name - * what to name the server - * @param driveUuuid - * id of the boot drive - * @param vncPassword - * password for vnc - * @param ip - * static IP - * @return a builder for a persistent 1Ghz 512m server with DHCP enabled network. - */ - public static Server.Builder smallWithStaticIP(String name, String driveUuuid, String vncPassword, String ip) { - return new Server.Builder().name(name).cpu(1000).mem(512).persistent(true) - .devices(ImmutableMap.of("ide:0:0", new IDEDevice.Builder(0, 0).uuid(driveUuuid).build())) - .bootDeviceIds(ImmutableSet.of("ide:0:0")) - .nics(ImmutableSet.of(new NIC.Builder().model(Model.E1000).dhcp(ip).build())) - .vnc(new VNC(null, vncPassword, false)); - } - - /** - * Takes the input server and changes its primary ip to a new address. To make this happen, - * you'll need to invoke {@link org.jclouds.cloudsigma.CloudSigmaApi#setServerConfiguration} - * - * @param in - * server to change - * @param ip - * new ip address - * @return server with its primary nic set to the new address. - */ - public static Server changeIP(Server in, String ip) { - return Server.Builder.fromServer(in).nics(ImmutableSet.of(new NIC.Builder().model(Model.E1000).dhcp(ip).build())) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index 768b102..0000000 --- a/apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.cloudsigma.CloudSigmaApiMetadata \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds/blob/f7aea987/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java ---------------------------------------------------------------------- diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java deleted file mode 100644 index adfb1c5..0000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java +++ /dev/null @@ -1,28 +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; - -import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "CloudSigmaApiMetadataTest") -public class CloudSigmaApiMetadataTest extends BaseComputeServiceApiMetadataTest { - - public CloudSigmaApiMetadataTest() { - super(new CloudSigmaApiMetadata()); - } -}
