Ejemplo n.º 1
0
    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'],
            )
Ejemplo n.º 2
0
    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'],
            )
Ejemplo n.º 3
0
    def run(self):
        with open('python-flocker.spec.in', 'r') as source:
            spec = source.read()

        flocker_version = versioneer.get_version()
        version, release = make_rpm_version(flocker_version)
        with open('python-flocker.spec', 'w') as destination:
            destination.write("%%global flocker_version %s\n" %
                              (flocker_version, ))
            destination.write("%%global flocker_version_underscore %s\n" %
                              (flocker_version.replace('-', '_'), ))
            destination.write("%%global supplied_rpm_version %s\n" %
                              (version, ))
            destination.write("%%global supplied_rpm_release %s\n" %
                              (release, ))
            destination.write(spec)
Ejemplo n.º 4
0
    def run(self):
        with open('python-flocker.spec.in', 'r') as source:
            spec = source.read()

        flocker_version = versioneer.get_version()
        version, release = make_rpm_version(flocker_version)
        with open('python-flocker.spec', 'w') as destination:
            destination.write(
                "%%global flocker_version %s\n" % (flocker_version,))
            destination.write(
                "%%global flocker_version_underscore %s\n" % (
                    flocker_version.replace('-', '_'),))
            destination.write(
                "%%global supplied_rpm_version %s\n" % (version,))
            destination.write(
                "%%global supplied_rpm_release %s\n" % (release,))
            destination.write(spec)
Ejemplo n.º 5
0
def build_box(path, name, version, branch, build_server):
    """
    Build a vagrant box.

    :param FilePath path: Directory containing ``Vagrantfile``.
    :param bytes name: Base name of vagrant box. Used to build filename.
    :param bytes version: Version of vagrant box. Used to build filename.
    :param bytes branch: Branch to get flocker RPMs from.
    :param build_server: Base URL of build server to download RPMs from.
    """
    box_path = path.child('%s%s%s.box' %
                          (name, '-' if version else '', version))
    json_path = path.child('%s.json' % (name, ))

    # Destroy the box to begin, so that we are guaranteed
    # a clean build.
    run(['vagrant', 'destroy', '-f'], cwd=path.path)

    # Update the base box to the latest version on vagrant cloud.
    run(['vagrant', 'box', 'update'], cwd=path.path)

    # Generate the enviroment variables used to pass options down to the
    # provisioning scripts via the Vagrantfile
    env = os.environ.copy()
    rpm_version, rpm_release = make_rpm_version(version)
    env.update({
        'FLOCKER_RPM_VERSION': '%s-%s' % (rpm_version, rpm_release),
        'FLOCKER_BUILD_SERVER': build_server,
        # branch is None if it isn't passed, but that isn't a legal
        # environment value.
        'FLOCKER_BRANCH': branch or ''
    })
    # Boot the VM and run the provisioning scripts.
    run(['vagrant', 'up'], cwd=path.path, env=env)

    # Package up running VM.
    run(['vagrant', 'package', '--output', box_path.path], cwd=path.path)

    # And destroy at the end to save space.  If one of the above commands fail,
    # this will be skipped, so the image can still be debugged.
    run(['vagrant', 'destroy', '-f'], cwd=path.path)

    # Generate metadata needed to add box locally.
    metadata = box_metadata(name, version, box_path)
    json_path.setContent(json.dumps(metadata))
Ejemplo n.º 6
0
def build_box(path, name, version, branch, build_server):
    """
    Build a vagrant box.

    :param FilePath path: Directory containing ``Vagrantfile``.
    :param bytes name: Base name of vagrant box. Used to build filename.
    :param bytes version: Version of vagrant box. Used to build filename.
    :param bytes branch: Branch to get flocker RPMs from.
    :param build_server: Base URL of build server to download RPMs from.
    """
    box_path = path.child('%s%s%s.box'
                          % (name, '-' if version else '', version))
    json_path = path.child('%s.json' % (name,))

    # Destroy the box to begin, so that we are guaranteed
    # a clean build.
    run(['vagrant', 'destroy', '-f'], cwd=path.path)

    # Update the base box to the latest version on vagrant cloud.
    run(['vagrant', 'box', 'update'], cwd=path.path)

    # Generate the enviroment variables used to pass options down to the
    # provisioning scripts via the Vagrantfile
    env = os.environ.copy()
    rpm_version, rpm_release = make_rpm_version(version)
    env.update({
        'FLOCKER_RPM_VERSION': '%s-%s' % (rpm_version, rpm_release),
        'FLOCKER_BUILD_SERVER': build_server,
        # branch is None if it isn't passed, but that isn't a legal
        # environment value.
        'FLOCKER_BRANCH': branch or ''
        })
    # Boot the VM and run the provisioning scripts.
    run(['vagrant', 'up'], cwd=path.path, env=env)

    # Package up running VM.
    run(['vagrant', 'package', '--output', box_path.path], cwd=path.path)

    # And destroy at the end to save space.  If one of the above commands fail,
    # this will be skipped, so the image can still be debugged.
    run(['vagrant', 'destroy', '-f'], cwd=path.path)

    # Generate metadata needed to add box locally.
    metadata = box_metadata(name, version, box_path)
    json_path.setContent(json.dumps(metadata))
Ejemplo n.º 7
0
    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'],
        )
Ejemplo n.º 8
0
    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,
        )