EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.epc.strategy]

COVERAGE SUMMARY FOR SOURCE FILE [EucalyptusPartnerCloudReviseParsedImage.java]

nameclass, %method, %block, %line, %
EucalyptusPartnerCloudReviseParsedImage.java100% (1/1)100% (3/3)49%  (53/109)54%  (13.1/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EucalyptusPartnerCloudReviseParsedImage100% (1/1)100% (3/3)49%  (53/109)54%  (13.1/24)
reviseParsedImage (Image, ImageBuilder, OsFamily, OperatingSystem$Builder): void 100% (1/1)38%  (34/90)39%  (7.1/18)
<static initializer> 100% (1/1)100% (7/7)100% (2/2)
EucalyptusPartnerCloudReviseParsedImage (Map): void 100% (1/1)100% (12/12)100% (4/4)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  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,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.epc.strategy;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.Map;
24import java.util.NoSuchElementException;
25import java.util.regex.Matcher;
26import java.util.regex.Pattern;
27 
28import javax.annotation.Resource;
29import javax.inject.Inject;
30import javax.inject.Named;
31import javax.inject.Singleton;
32 
33import org.jclouds.compute.domain.ImageBuilder;
34import org.jclouds.compute.domain.OperatingSystem;
35import org.jclouds.compute.domain.OsFamily;
36import org.jclouds.compute.reference.ComputeServiceConstants;
37import org.jclouds.compute.util.ComputeServiceUtils;
38import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
39import org.jclouds.logging.Logger;
40 
41/**
42 * @author Adrian Cole
43 */
44@Singleton
45public class EucalyptusPartnerCloudReviseParsedImage implements ReviseParsedImage {
46 
47   // debian-6.0-x86_64/debian.6-0.x86-64.img.manifest.xml
48   public static final Pattern PATTERN = Pattern.compile("^([^-]+)-([^-]+)-.*");
49   public static final Pattern WINDOWS = Pattern.compile("^windows-([^/]+)/.*");
50 
51   private final Map<OsFamily, Map<String, String>> osVersionMap;
52 
53   @Resource
54   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
55   protected Logger logger = Logger.NULL;
56 
57   @Inject
58   public EucalyptusPartnerCloudReviseParsedImage(Map<OsFamily, Map<String, String>> osVersionMap) {
59      this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap");
60   }
61 
62   @Override
63   public void reviseParsedImage(org.jclouds.ec2.domain.Image from, ImageBuilder builder, OsFamily family,
64            OperatingSystem.Builder osBuilder) {
65      try {
66         if (from.getImageLocation().startsWith("windows")) {
67            family = OsFamily.WINDOWS;
68            osBuilder.family(family);
69            Matcher matcher = WINDOWS.matcher(from.getImageLocation());
70            if (matcher.find()) {
71               osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(1).replace(
72                        '-', ' ').replace('s', 'S'), osVersionMap));
73            }
74         } else {
75            Matcher matcher = PATTERN.matcher(from.getImageLocation());
76            if (matcher.find()) {
77               family = OsFamily.fromValue(matcher.group(1));
78               osBuilder.family(family);
79               osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(2),
80                        osVersionMap));
81            }
82         }
83      } catch (IllegalArgumentException e) {
84         logger.debug("<< didn't match os(%s)", from.getImageLocation());
85      } catch (NoSuchElementException e) {
86         logger.debug("<< didn't match at all(%s)", from.getImageLocation());
87      }
88   }
89}

[all classes][org.jclouds.epc.strategy]
EMMA 2.0.5312 (C) Vladimir Roubtsov