def test_interface(self): """ ``ManagedRunner`` provides ``IClusterRunner``. """ runner = ManagedRunner( node_addresses=[b'192.0.2.1'], package_source=PackageSource( version=b"", branch=b"", build_server=b"", ), distribution=b'centos-7', dataset_backend=DatasetBackend.zfs, dataset_backend_configuration={}, identity=ClusterIdentity( name=b'cluster', purpose=u'test', prefix=u'test', ), cert_path=FilePath(mkdtemp()), logging_config=None, ) self.assertTrue( verifyObject(IClusterRunner, runner) )
def postOptions(self): if self['distribution'] is None: raise UsageError("Distribution required.") if self['config-file'] is not None: config_file = FilePath(self['config-file']) self['config'] = yaml.safe_load(config_file.getContent()) else: self['config'] = {} provider = self['provider'].lower() provider_config = self['config'].get(provider, {}) package_source = PackageSource( version=self['flocker-version'], branch=self['branch'], build_server=self['build-server'], ) try: get_runner = getattr(self, "_runner_" + provider.upper()) except AttributeError: raise UsageError( "Provider {!r} not supported. Available providers: {}".format( provider, ', '.join( name.lower() for name in self._get_provider_names() ) ) ) else: self.runner = get_runner( package_source=package_source, dataset_backend=self.dataset_backend(), provider_config=provider_config, )
def postOptions(self): if self['distribution'] is None: raise UsageError("Distribution required.") if self['config-file'] is not None: config_file = FilePath(self['config-file']) self['config'] = yaml.safe_load(config_file.getContent()) else: self['config'] = {} if self['flocker-version']: rpm_version = make_rpm_version(self['flocker-version']) os_version = "%s-%s" % (rpm_version.version, rpm_version.release) if os_version.endswith('.dirty'): os_version = os_version[:-len('.dirty')] else: os_version = None self['package_source'] = PackageSource( version=self['flocker-version'], os_version=os_version, branch=self['branch'], build_server=self['build-server'], ) if self['pip']: supported = PIP_DISTRIBUTIONS else: supported = PACKAGED_CLIENT_DISTRIBUTIONS if self['distribution'] not in supported: raise UsageError( "Distribution %r not supported. Available distributions: %s" % (self['distribution'], ', '.join(supported)))
def postOptions(self): if self['distribution'] is None: raise UsageError("Distribution required.") self['package_source'] = PackageSource( version=self['flocker-version'], branch=self['branch'], build_server=self['build-server'], )
def postOptions(self): if self['distribution'] is None: raise UsageError("Distribution required.") if self['config-file'] is not None: config_file = FilePath(self['config-file']) self['config'] = yaml.safe_load(config_file.getContent()) else: self['config'] = {} if self['flocker-version']: os_version = "%s-%s" % make_rpm_version(self['flocker-version']) if os_version.endswith('.dirty'): os_version = os_version[:-len('.dirty')] else: os_version = None package_source = PackageSource( version=self['flocker-version'], os_version=os_version, branch=self['branch'], build_server=self['build-server'], ) if self['provider'] not in PROVIDERS: raise UsageError( "Provider %r not supported. Available providers: %s" % (self['provider'], ', '.join(PROVIDERS))) if self['provider'] in CLOUD_PROVIDERS: # Configuration must include credentials etc for cloud providers. try: provider_config = self['config'][self['provider']] except KeyError: raise UsageError("Configuration file must include a " "{!r} config stanza.".format( self['provider'])) provisioner = CLOUD_PROVIDERS[self['provider']](**provider_config) self.runner = LibcloudRunner( config=self['config'], top_level=self.top_level, distribution=self['distribution'], package_source=package_source, provisioner=provisioner, variants=self['variants'], ) else: self.runner = VagrantRunner( config=self['config'], top_level=self.top_level, distribution=self['distribution'], package_source=package_source, variants=self['variants'], )
def test_interface(self): """ ``ManagedRunner`` provides ``IClusterRunner``. """ runner = ManagedRunner( node_addresses=[b'192.0.2.1'], package_source=PackageSource( version=b"", branch=b"", build_server=b"", ), distribution=b'centos-7', dataset_backend=DatasetBackend.zfs, dataset_backend_configuration={}, ) self.assertTrue(verifyObject(IClusterRunner, runner))
def get_steps_pkg(distribution, package_source=PackageSource()): """ Get commands to run for testing client package installation. :param bytes distribution: The distribution the node is running. :param PackageSource package_source: The source from which to install the package. :return: An ``Effect`` to pass to a ``Dispatcher`` that supports ``Sequence``, ``Run``, ``Sudo``, ``Comment``, and ``Put``. """ if distribution not in PACKAGED_CLIENT_DISTRIBUTIONS: raise UsageError( "Distribution %r not supported. Available distributions: %s" % (distribution, ', '.join(PACKAGED_CLIENT_DISTRIBUTIONS))) package_manager = DOCKER_IMAGES[distribution].package_manager steps = [ ensure_minimal_setup(package_manager), task_cli_pkg_install(distribution, package_source), ] return steps
def postOptions(self): if self['distribution'] is None: raise UsageError("Distribution required.") if self['config-file'] is not None: config_file = FilePath(self['config-file']) self['config'] = yaml.safe_load(config_file.getContent()) else: self['config'] = {} if self['provider'] not in PROVIDERS: raise UsageError( "Provider %r not supported. Available providers: %s" % (self['provider'], ', '.join(PROVIDERS.keys()))) if self['flocker-version']: os_version = "%s-%s" % make_rpm_version(self['flocker-version']) if os_version.endswith('.dirty'): os_version = os_version[:-len('.dirty')] else: os_version = None package_source = PackageSource( version=self['flocker-version'], os_version=os_version, branch=self['branch'], build_server=self['build-server'], ) provider_factory = PROVIDERS[self['provider']] self.runner = provider_factory( top_level=self.top_level, config=self['config'], distribution=self['distribution'], package_source=package_source, variants=self['variants'], )
def postOptions(self): if self['distribution'] is None: raise UsageError("Distribution required.") if self['config-file'] is not None: config_file = FilePath(self['config-file']) self['config'] = yaml.safe_load(config_file.getContent()) else: self['config'] = {} self['package_source'] = PackageSource( version=self['flocker-version'], branch=self['branch'], build_server=self['build-server'], ) if self['pip']: supported = PIP_DISTRIBUTIONS else: supported = PACKAGED_CLIENT_DISTRIBUTIONS if self['distribution'] not in supported: raise UsageError( "Distribution %r not supported. Available distributions: %s" % (self['distribution'], ', '.join(supported)))