Example #1
0
    def __init__(self, key, secret=None, secure=False, host=None, port=None,
                 api_version=None, **kwargs):
        """
        Creates a new instance of a StratusLabNodeDriver from the
        given parameters.  All of the parameters are ignored except
        for the ones defined below.

        The configuration is read from the named configuration file
        (or file-like object).  The 'locations' in the API correspond
        to the named sections within the configuration file.

        :param key: ignored by this driver
        :param secret: ignored by this driver
        :param secure: passed to superclass; True required CA certs
        :param host: ignored by this driver (use locations instead)
        :param port: ignored by this driver (use locations instead)
        :param api_version: ignored by this driver
        :param kwargs: additional keyword arguments

        :keyword stratuslab_user_config (str or file): File name or
        file-like object from which to read the user's StratusLab
        configuration.  Sections in the configuration file correspond
        to 'locations' within this API.

        :keyword stratuslab_default_location (str): The id (name) of
        the section within the user configuration file to use as the
        default location.

        :returns: StratusLabNodeDriver

        """
        super(StratusLabNodeDriver, self).__init__(key,
                                                   secret=secret,
                                                   secure=secure,
                                                   host=host,
                                                   port=port,
                                                   api_version=api_version,
                                                   **kwargs)

        self.name = "StratusLab Node Provider"
        self.website = 'http://stratuslab.eu/'
        self.type = "stratuslab"

        # only ssh-based authentication is supported by StratusLab
        self.features['create_node'] = ['ssh_key']

        user_config_file = kwargs.get('stratuslab_user_config',
                                      StratusLabUtil.defaultConfigFileUser)
        default_section = kwargs.get('stratuslab_default_location', None)

        self.user_configurator = UserConfigurator(configFile=user_config_file)

        self.default_location, self.locations = \
            self._get_config_locations(default_section)

        self.sizes = self._get_config_sizes()