nacx commented on this pull request.
> +
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ private final PlanToHardware planToHardware;
+ private final OperatingSystemToImage operatingSystemToImage;
+ private final FacilityToLocation facilityToLocation;
+ private final Function<Device.State, NodeMetadata.Status> toPortableStatus;
+ private final GroupNamingConvention groupNamingConvention;
+
+ @Inject
+ DeviceToNodeMetadata(PlanToHardware planToHardware, OperatingSystemToImage
operatingSystemToImage, FacilityToLocation facilityToLocation,
+ Function<Device.State, NodeMetadata.Status>
toPortableStatus,
+ GroupNamingConvention.Factory groupNamingConvention) {
+ this.planToHardware = checkNotNull(planToHardware, "planToHardware
cannot be null");
No need for null checks in the injection constructors.
> +
+ private final JustProvider justProvider;
+
+ // allow us to lazy discover the provider of a resource
+ @Inject
+ FacilityToLocation(JustProvider justProvider) {
+ this.justProvider = justProvider;
+ }
+
+ @Override
+ public Location apply(final Facility facility) {
+ final LocationBuilder builder = new LocationBuilder();
+ builder.id(facility.code());
+ builder.description(facility.name());
+ builder.parent(getOnlyElement(justProvider.get()));
+ builder.scope(LocationScope.REGION);
Can the ISO-3166 code be inferred in a consistent way, for example from the
`state` field?
> +public class PlanToHardware implements Function<Plan, Hardware> {
+
+ @Override
+ public Hardware apply(Plan plan) {
+ HardwareBuilder builder = new HardwareBuilder()
+ .ids(plan.slug())
+ .name(plan.name())
+ .hypervisor("none")
+ .processors(getProcessors(plan))
+ .ram(getMemory(plan))
+ .volumes(getVolumes(plan));
+ return builder.build();
+ }
+
+ private Integer getMemory(Plan plan) {
+ if (plan.specs() == null || plan.specs().drives() == null) return -1;
Better return 0 ?
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/346#pullrequestreview-18362581