EMMA Coverage Report (generated Fri Aug 26 14:14:05 EDT 2011)
[all classes][org.jclouds.cloudsigma.compute.functions]

COVERAGE SUMMARY FOR SOURCE FILE [PreinstalledDiskToImage.java]

nameclass, %method, %block, %line, %
PreinstalledDiskToImage.java0%   (0/1)0%   (0/2)0%   (0/97)0%   (0/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PreinstalledDiskToImage0%   (0/1)0%   (0/2)0%   (0/97)0%   (0/11)
PreinstalledDiskToImage (Supplier, Function): void 0%   (0/1)0%   (0/9)0%   (0/4)
apply (DriveInfo): Image 0%   (0/1)0%   (0/88)0%   (0/7)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19package org.jclouds.cloudsigma.compute.functions;
20 
21import javax.inject.Inject;
22import javax.inject.Singleton;
23 
24import org.jclouds.cloudsigma.domain.DriveInfo;
25import org.jclouds.compute.domain.Image;
26import org.jclouds.compute.domain.ImageBuilder;
27import org.jclouds.compute.domain.OperatingSystem;
28import org.jclouds.compute.domain.OsFamilyVersion64Bit;
29import org.jclouds.compute.domain.OperatingSystem.Builder;
30import org.jclouds.domain.Credentials;
31import org.jclouds.domain.Location;
32 
33import com.google.common.base.Function;
34import com.google.common.base.Supplier;
35import com.google.common.collect.ImmutableMap;
36 
37/**
38 * @author Adrian Cole
39 */
40@Singleton
41public class PreinstalledDiskToImage implements Function<DriveInfo, Image> {
42   private final Supplier<Location> locationSupplier;
43   private final Function<String, OsFamilyVersion64Bit> imageParser;
44 
45   @Inject
46   public PreinstalledDiskToImage(Supplier<Location> locationSupplier,
47            Function<String, OsFamilyVersion64Bit> imageParser) {
48      this.locationSupplier = locationSupplier;
49      this.imageParser = imageParser;
50   }
51 
52   @Override
53   public Image apply(DriveInfo drive) {
54      if (drive.getName() == null)
55         return null;
56      String description = drive.getDescription() != null ? drive.getDescription() : drive.getName();
57      Builder builder = OperatingSystem.builder();
58      OsFamilyVersion64Bit parsed = imageParser.apply(drive.getName());
59      builder.name(drive.getName()).description(description).is64Bit(parsed.is64Bit).version(parsed.version).family(
60               parsed.family);
61      return new ImageBuilder().ids(drive.getUuid()).adminPassword("cloudsigma").userMetadata(
62               ImmutableMap.<String, String> of("size", drive.getSize() / 1024 / 1024 / 1024 + "")).defaultCredentials(
63               new Credentials("cloudsigma", "cloudsigma")).location(locationSupplier.get()).name(drive.getName())
64               .description(description).operatingSystem(builder.build()).version("").build();
65   }
66}

[all classes][org.jclouds.cloudsigma.compute.functions]
EMMA 2.0.5312 (C) Vladimir Roubtsov