You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/11/18 18:53:26 UTC
[07/17] jclouds git commit: JCLOUDS-692 Remove the CloudSigma v1
provider.
http://git-wip-us.apache.org/repos/asf/jclouds/blob/d07cf7fa/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 e05a921..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLines.java
+++ /dev/null
@@ -1,55 +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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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/d07cf7fa/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 40ffb0c..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java
+++ /dev/null
@@ -1,99 +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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/d07cf7fa/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 24a471d..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java
+++ /dev/null
@@ -1,114 +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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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.size() == 0)
- 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.valueOf(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.valueOf(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.valueOf(from.get("read:bytes")));
- if (from.containsKey("read:requests"))
- metricsBuilder.readRequests(Long.valueOf(from.get("read:requests")));
- if (from.containsKey("write:bytes"))
- metricsBuilder.writeBytes(Long.valueOf(from.get("write:bytes")));
- if (from.containsKey("write:requests"))
- metricsBuilder.writeRequests(Long.valueOf(from.get("write:requests")));
- return metricsBuilder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/d07cf7fa/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 260d697..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java
+++ /dev/null
@@ -1,84 +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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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.valueOf(from.get(key + ":read:bytes")));
- if (from.containsKey(key + ":read:requests"))
- builder.readRequests(Long.valueOf(from.get(key + ":read:requests")));
- if (from.containsKey(key + ":write:bytes"))
- builder.writeBytes(Long.valueOf(from.get(key + ":write:bytes")));
- if (from.containsKey(key + ":write:requests"))
- builder.writeRequests(Long.valueOf(from.get(key + ":write:requests")));
- return builder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/d07cf7fa/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 d8c3a84..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToNICs.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.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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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/d07cf7fa/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 f19ac70..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToProfileInfo.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.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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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.size() == 0)
- return null;
- if (from.size() == 0)
- 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/d07cf7fa/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 533b3ce..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerInfo.java
+++ /dev/null
@@ -1,91 +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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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.size() == 0)
- 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.valueOf(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.valueOf(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/d07cf7fa/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 9cac5fb..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerMetrics.java
+++ /dev/null
@@ -1,57 +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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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.valueOf(from.get("tx:packets")));
- if (from.containsKey("tx"))
- metricsBuilder.tx(Long.valueOf(from.get("tx")));
- if (from.containsKey("rx:packets"))
- metricsBuilder.rxPackets(Long.valueOf(from.get("rx:packets")));
- if (from.containsKey("rx"))
- metricsBuilder.rx(Long.valueOf(from.get("rx")));
- metricsBuilder.driveMetrics(mapToDriveMetrics.apply(from));
-
- ServerMetrics metrics = metricsBuilder.build();
- return metrics;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/d07cf7fa/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 ea4a139..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToStaticIPInfo.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.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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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.size() == 0)
- return null;
- if (from.size() == 0)
- 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/d07cf7fa/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 6adc666..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToVLANInfo.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.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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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.size() == 0)
- return null;
- if (from.size() == 0)
- 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/d07cf7fa/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 e353279..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ReturnPayload.java
+++ /dev/null
@@ -1,35 +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;
-
-/**
- * @author Adrian Cole
- */
-@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/d07cf7fa/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 38daffa..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ServerToMap.java
+++ /dev/null
@@ -1,78 +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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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().size() != 0)
- 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().size() != 0)
- builder.put("use", Joiner.on(' ').join(from.getUse()));
- return builder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/d07cf7fa/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 10d0ac3..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java
+++ /dev/null
@@ -1,49 +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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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/d07cf7fa/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 36d504c..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlinesAndReturnSecondField.java
+++ /dev/null
@@ -1,64 +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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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/d07cf7fa/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 73bdb17..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java
+++ /dev/null
@@ -1,105 +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.
- *
- * @author Adrian Cole
- *
- */
-@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.toString(response.getPayload());
- } 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/d07cf7fa/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 3d7c4cd..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java
+++ /dev/null
@@ -1,139 +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>
- *
- * @author Adrian Cole
- *
- */
-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/d07cf7fa/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 210c2ef..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.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.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;
-
-/**
- *
- * @author Adrian Cole
- */
-@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().size() > 0;
- }
-
- private DriveInfo refresh(DriveInfo drive) {
- return client.getDriveInfo(drive.getUuid());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/d07cf7fa/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 535c361..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/reference/CloudSigmaConstants.java
+++ /dev/null
@@ -1,30 +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;
-
-/**
- *
- * @author Adrian Cole
- */
-public class CloudSigmaConstants {
-
- /**
- * default VNC password used on new machines
- */
- public static final String PROPERTY_VNC_PASSWORD = "jclouds.cloudsigma.vnc-password";
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/d07cf7fa/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 768f515..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java
+++ /dev/null
@@ -1,83 +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;
-
-/**
- *
- * @author Adrian Cole
- */
-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/d07cf7fa/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/d07cf7fa/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 2f47264..0000000
--- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.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;
-
-import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "CloudSigmaApiMetadataTest")
-public class CloudSigmaApiMetadataTest extends BaseComputeServiceApiMetadataTest {
-
- public CloudSigmaApiMetadataTest() {
- super(new CloudSigmaApiMetadata());
- }
-}