Ejemplo n.º 1
0
def get(args):
    product = Product(name=args.name)
    product_rendered = [product.render()]

    release_groups_rendered = []

    for release in product.releases():
        release_groups_rendered.append(release.render())

    cdn_repos_rendered = []
    for product_version in product_rendered[0]['product_versions']:
        for variant in product_version['variants']:
            for cdn_repo in Variant(name=variant['name']).cdn_repos():
                cdn_repos = [repo['name'] for repo in cdn_repos_rendered]
                if cdn_repo.name not in cdn_repos:
                    cdn_repos_rendered.append(cdn_repo.render())

    output = {
        'products': product_rendered,
        'release_groups': release_groups_rendered,
        'cdn_repos': sorted(cdn_repos_rendered, key=lambda x: x['name'])
    }

    yaml.dump(output, stdout, sort_keys=False)
Ejemplo n.º 2
0
def product(monkeypatch, mock_get):
    monkeypatch.delattr('requests.sessions.Session.request')
    monkeypatch.setattr(ErrataConnector, '_auth', None)
    monkeypatch.setattr(requests, 'get', mock_get)
    return Product('RHCEPH')
Ejemplo n.º 3
0
    def create(klass,
               name,
               product,
               product_versions,
               type,
               program_manager,
               default_brew_tag,
               blocker_flags,
               ship_date=None):
        """
        Create a new release in the ET.

        See https://bugzilla.redhat.com/1401608 for background.

        Note this method enforces certain conventions:
        * Always disables PDC for a release
        * Always creates the releases as "enabled"
        * Always allows multiple advisories per package
        * Description is always the combination of the product's own
          description (for example "Red Hat Ceph Storage") with the number
          from the latter part of the release's name. So a new "rhceph-3.0"
          release will have a description "Red Hat Ceph Storage 3.0".

        :param name: short name for this release, eg "rhceph-3.0"
        :param product: short name, eg. "RHCEPH".
        :param product_versions: list of names, eg. ["RHEL-7-CEPH-3"]
        :param type: "Zstream" or "QuarterlyUpdate"
        :param program_manager: for example "anharris" (Drew Harris, Ceph PgM)
        :param default_brew_tag: for example "ceph-3.0-rhel-7-candidate"
        :param blocker_flags: for example, "ceph-3.0"
        :param ship_date: date formatted as strftime("%Y-%b-%d"). For example,
                          "2017-Nov-17". If ommitted, the ship_date will
                          be set to today's date. (This can always be updated
                          later to match the ship date value in Product
                          Pages.)
        """
        product = Product(product)

        (_, number) = name.split('-', 1)
        description = '%s %s' % (product.description, number)

        program_manager = User(program_manager)

        product_version_ids = set([])
        for pv_name in product_versions:
            pv = ProductVersion(pv_name)
            product_version_ids.add(pv.id)

        if ship_date is None:
            today = date.today()
            ship_date = today.strftime("%Y-%b-%d")

        et = ErrataConnector()
        url = et._url + '/release/create'
        payload = {
            'type': type,
            'release[allow_blocker]': 0,
            'release[allow_exception]': 0,
            'release[allow_pkg_dupes]': 1,
            'release[allow_shadow]': 0,
            'release[blocker_flags]': blocker_flags,
            'release[default_brew_tag]': default_brew_tag,
            'release[description]': description,
            'release[enable_batching]': 0,
            'release[enabled]': 1,
            'release[is_deferred]': 0,
            'release[is_pdc]': 0,
            'release[name]': name,
            'release[product_id]': product.id,
            'release[product_version_ids][]': product_version_ids,
            'release[program_manager_id]': program_manager.id,
            'release[ship_date]': ship_date,
            'release[type]': type,
        }
        result = et._post(url, data=payload)
        if (sys.version_info > (3, 0)):
            body = result.text
        else:
            # Found during live testing:
            # UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1'
            # in position 44306: ordinal not in range(128)
            # Not sure why there was a non-ascii character in the ET's HTTP
            # response, but this fixes it.
            body = result.text.encode('utf-8')
        if result.status_code != 200:
            # help with debugging:
            print(body)
        result.raise_for_status()
        # We can get a 200 HTTP status_code here even when the POST failed to
        # create the release in the ET database. (This happens, for example, if
        # there are no Approved Components defined in Bugzilla for the release
        # flag, and the ET hits Bugzilla's XMLRPC::FaultException.)
        if 'field_errors' in body:
            print(body)
            raise ReleaseCreationError('see field_errors <div>')
        return klass(name=name)
Ejemplo n.º 4
0
def get(args):
    p = Product(name=args.name)
    print('Name: %s' % p.name)
    print('Description: %s' % p.description)
    print('Supports PDC: %s' % p.supports_pdc)
    print('URL: %s' % p.url)
Ejemplo n.º 5
0
def get(args):
    p = Product(name=args.name)
    print('Name: %s' % p.name)
    print('Description: %s' % p.description)
    print('URL: %s' % p.url)