Examples of HypervisorMetadata


Examples of com.abiquo.hypervisor.plugin.annotation.HypervisorMetadata

                "The plugin {} has invalid format. {} annotation is missing. Ignoring this plugin",
                new Object[] {plugin.getClass().getName(), HypervisorMetadata.class.getName()});
            return Optional.absent();
        }

        HypervisorMetadata metadata = optionalMetadata.get();
        final List<DiskFormatType> diskFormatTypes = Arrays.asList(DiskFormatType.values());
        List<DiskFormatType> compatibleTypes = Arrays.asList(metadata.compatibleDiskFormatTypes());

        // Hypervisor type must be informed
        if (isNullOrEmpty(metadata.type()))
        {
            LOG.error("The type of the plugin {} is null or empty. Ignoring this plugin",
                new Object[] {plugin.getClass().getName()});
            return Optional.absent();
        }

        // Hypervisor friendly name must be informed
        if (isNullOrEmpty(metadata.friendlyName()))
        {
            LOG.error("The friendly name of the plugin {} is null or empty. Ignoring this plugin",
                new Object[] {metadata.type()});
            return Optional.absent();
        }

        // All compatible types must be in DiskFormatType otherwise we don't load this plugin
        boolean allContained = Iterables.any(compatibleTypes, new Predicate<DiskFormatType>()
        {
            @Override
            public boolean apply(final DiskFormatType input)
            {
                return diskFormatTypes.contains(input);
            }
        });

        if (!allContained)
        {
            LOG.error(
                "The plugin {} has invalid configuration compatibles disk format type is not a known disk format types (is not in DiskFormatTypes). Ignoring this plugin",
                metadata.type());
            return Optional.absent();
        }

        // Base format must be in compatible formats otherwise we don't load this plugin
        if (!compatibleTypes.contains(metadata.baseDiskFormatType()))
        {
            LOG.error(
                "The plugin {} has invalid configuration base disk format type is not in compatible disk format types. {} is not in compatibleDiskFormatTypes. Ignoring this plugin",
                new Object[] {metadata.type(), metadata.baseDiskFormatType()});
            return Optional.absent();
        }

        // Validate specific plugin configuration
        try
        {
            plugin.validateConfiguration();
        }
        catch (IllegalStateException e)
        {
            LOG.error("The plugin {} has invalid configuration: {}", new Object[] {metadata.type(),
            e.getMessage()});
            return Optional.absent();
        }

        try
        {
            Class<IHypervisorConnection> connectionClass =
                resolveIHypervisorConnection(plugin.getClass());

            LoadedPlugin loadedPlugin = new LoadedPlugin(connectionClass, plugin);
            loadedPlugin.unsupportedOperations = copyOf(getUnsupportedOperations(plugin));
            loadedPlugin.constraints = copyOf(loadConstraints(plugin));

            LOG.info("Loaded plugin for hypervisor type {}", metadata.type());
            return Optional.of(loadedPlugin);
        }
        catch (Exception e)
        {
            LOG.error("Unable to load plugin for hypervisor type {}", metadata.type(), e);
        }

        return Optional.absent();
    }
View Full Code Here

Examples of com.abiquo.hypervisor.plugin.annotation.HypervisorMetadata

                "The plugin {} has invalid format. {} annotation is missing. Ignoring this plugin",
                new Object[] {plugin.getClass().getName(), HypervisorMetadata.class.getName()});
            return Optional.absent();
        }

        HypervisorMetadata metadata = optionalMetadata.get();
        final List<DiskFormatType> diskFormatTypes = Arrays.asList(DiskFormatType.values());

        List<DiskFormatType> compatibleTypes = Arrays.asList(metadata.compatibleDiskFormatTypes());

        // Computable type must be informed
        if (metadata.type().length == 0)
        {
            LOG.error("The type of the plugin {} is null or empty. Ignoring this plugin",
                new Object[] {plugin.getClass().getName()});
            return Optional.absent();
        }

        // Computable friendly name must be informed
        if (metadata.friendlyName().length == 0)
        {
            LOG.error("The friendly name of the plugin {} is null or empty. Ignoring this plugin",
                new Object[] {metadata.type()});
            return Optional.absent();
        }

        // All compatible types must be in DiskFormatType otherwise we don't load this plugin
        boolean allContained = Iterables.any(compatibleTypes, new Predicate<DiskFormatType>()
        {
            @Override
            public boolean apply(final DiskFormatType input)
            {
                return diskFormatTypes.contains(input);
            }
        });

        if (!allContained)
        {
            LOG.error(
                "The plugin {} has invalid configuration compatibles disk format type is not a known disk format types (is not in DiskFormatTypes). Ignoring this plugin",
                metadata.type());
            return Optional.absent();
        }

        // Base format must be in compatible formats otherwise we don't load this plugin
        if (!compatibleTypes.contains(metadata.baseDiskFormatType()))
        {
            LOG.error(
                "The plugin {} has invalid configuration base disk format type is not in compatible disk format types. {} is not in compatibleDiskFormatTypes. Ignoring this plugin",
                new Object[] {metadata.type(), metadata.baseDiskFormatType()});
            return Optional.absent();
        }

        if (!areCompatibleInterfaces(plugin))
        {
            LOG.error(
                "loadPlugin: plugin {} implements both {} and {} which is an imcompatible combination",
                new Object[] {plugin.getClass(), IHypervisor.class.getName(),
                ICloudProvider.class.getName()});
            return Optional.absent();
        }

        // Validate specific plugin configuration
        try
        {
            plugin.validateConfiguration();
        }
        catch (IllegalStateException e)
        {
            LOG.error("The plugin {} has invalid configuration: {}", new Object[] {metadata.type(),
            e.getMessage()});
            return Optional.absent();
        }

        // Validate at least one region is retrieved
        if (isCloudProvider(plugin))
        {
            for (String type : metadata.type())
            {
                List<Region> regionNames =
                    ((ICloudProvider< ? extends IConnection>) plugin).getRegions(type);
                if (regionNames == null || regionNames.isEmpty())
                {
                    LOG.error(
                        "The plugin {} extends from ICloudProvider but does not return any region",
                        metadata.type());
                    return Optional.absent();
                }
            }
        }

        try
        {
            Class<IConnection> connectionClass = resolveIConnectionData(plugin.getClass());

            Builder<String, LoadedPlugin> builder = ImmutableMap.<String, LoadedPlugin> builder();
            for (String pluginType : metadata.type())
            {
                LoadedPlugin loadedPlugin = new LoadedPlugin(pluginType, connectionClass, plugin);
                builder.put(pluginType, loadedPlugin);
                LOG.debug("Loaded plugin for type {}", pluginType);
            }
            return Optional.of(builder.build());
        }
        catch (Exception e)
        {
            LOG.error("Unable to load plugin for type {}", metadata.type(), e);
        }

        return Optional.absent();
    }
View Full Code Here

Examples of com.abiquo.hypervisor.plugin.annotation.HypervisorMetadata

                "The plugin {} has invalid format. {} annotation is missing. Ignoring this plugin",
                new Object[] {plugin.getClass().getName(), HypervisorMetadata.class.getName()});
            return Optional.absent();
        }

        HypervisorMetadata metadata = optionalMetadata.get();
        final List<DiskFormatType> diskFormatTypes = Arrays.asList(DiskFormatType.values());

        List<DiskFormatType> compatibleTypes = Arrays.asList(metadata.compatibleDiskFormatTypes());

        // Computable type must be informed
        if (metadata.type().length == 0)
        {
            LOG.error("The type of the plugin {} is null or empty. Ignoring this plugin",
                new Object[] {plugin.getClass().getName()});
            return Optional.absent();
        }

        // Computable friendly name must be informed
        if (metadata.friendlyName().length == 0)
        {
            LOG.error("The friendly name of the plugin {} is null or empty. Ignoring this plugin",
                new Object[] {metadata.type()});
            return Optional.absent();
        }

        // All compatible types must be in DiskFormatType otherwise we don't load this plugin
        boolean allContained = Iterables.any(compatibleTypes, new Predicate<DiskFormatType>()
        {
            @Override
            public boolean apply(final DiskFormatType input)
            {
                return diskFormatTypes.contains(input);
            }
        });

        if (!allContained)
        {
            LOG.error(
                "The plugin {} has invalid configuration compatibles disk format type is not a known disk format types (is not in DiskFormatTypes). Ignoring this plugin",
                metadata.type());
            return Optional.absent();
        }

        // Base format must be in compatible formats otherwise we don't load this plugin
        if (!compatibleTypes.contains(metadata.baseDiskFormatType()))
        {
            LOG.error(
                "The plugin {} has invalid configuration base disk format type is not in compatible disk format types. {} is not in compatibleDiskFormatTypes. Ignoring this plugin",
                new Object[] {metadata.type(), metadata.baseDiskFormatType()});
            return Optional.absent();
        }

        if (!areCompatibleInterfaces(plugin))
        {
            LOG.error(
                "loadPlugin: plugin {} implements both {} and {} which is an imcompatible combination",
                new Object[] {plugin.getClass(), IHypervisor.class.getName(),
                ICloudProvider.class.getName()});
            return Optional.absent();
        }

        // Validate specific plugin configuration
        try
        {
            plugin.validateConfiguration();
        }
        catch (IllegalStateException e)
        {
            LOG.error("The plugin {} has invalid configuration: {}", new Object[] {metadata.type(),
            e.getMessage()});
            return Optional.absent();
        }

        // Validate at least one region is retrieved
        if (isCloudProvider(plugin))
        {
            for (String type : metadata.type())
            {
                List<Region> regionNames =
                    ((ICloudProvider< ? extends IConnection>) plugin).getRegions(type);
                if (regionNames == null || regionNames.isEmpty())
                {
                    LOG.error(
                        "The plugin {} extends from ICloudProvider but does not return any region",
                        metadata.type());
                    return Optional.absent();
                }
            }
        }

        try
        {
            Class<IConnection> connectionClass = resolveIConnectionData(plugin.getClass());

            Builder<String, LoadedPlugin> builder = ImmutableMap.<String, LoadedPlugin> builder();
            for (String pluginType : metadata.type())
            {
                LoadedPlugin loadedPlugin = new LoadedPlugin(pluginType, connectionClass, plugin);
                builder.put(pluginType, loadedPlugin);
                LOG.debug("Loaded plugin for type {}", pluginType);
            }
            return Optional.of(builder.build());
        }
        catch (Exception e)
        {
            LOG.error("Unable to load plugin for type {}", metadata.type(), e);
        }

        return Optional.absent();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.