Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFE] Possibility to set batch name while creating errata #177

Open
dhodovsk opened this issue Jul 30, 2019 · 2 comments
Open

[RFE] Possibility to set batch name while creating errata #177

dhodovsk opened this issue Jul 30, 2019 · 2 comments

Comments

@dhodovsk
Copy link

It happened to us a few times, that the batch was incorrectly assigned when we created errata automatically.

We got a request from PgM to set the batch for errata to a specific value when it is created (we have the name in the form of a string). Would it be possible to add the functionality into erratum.commit method?

@ktdreyer
Copy link
Member

I'm not familiar with batching, but I know OpenStack uses it a lot (eg. @yazug )

Could you please share how you want to change the code?

@dhodovsk
Copy link
Author

This is how we use it now: There is some private attribute accessing.

    def batch_is_active(self):
        e = ErrataConnector()
        batch_data = e._get(f"/api/v1/batches?filter[name]={self.batch_name}")["data"]
        if len(batch_data) == 0:
            msg = f"Batch {self.batch_name} not found."
            self.logger.error(msg)
            self._logs.append(msg)
            return False
        self.batch_id = batch_data[0]["id"]
        return batch_data[0]["attributes"]["is_active"]

    def update_batch(self):
        if not self.batch_id:
            return True

        if self.new_errata.batch_id == self.batch_id:
            self.logger.info(f"Errata has correct batch {self.batch_name}")
            return True

        url = f"/api/v1/erratum/{self.new_errata.errata_id}/change_batch"
        data = {"batch_name": self.batch_name}
        r = self.new_errata._post(url, data=data)
        if not r.ok:
            msg = f"Failed to update batch for errata {self.new_errata.errata_id}. {r.text}"
            self.logger.error(msg)
            self._logs.append(msg)
        else:
            msg = f"Updated batch to {self.batch_name}"
            self.logger.info(msg)
        return r.ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants