[ale] Node.js Satellite 5 API client library

James Sumners james.sumners at gmail.com
Fri Feb 19 15:22:19 EST 2016


On Fri, Feb 19, 2016 at 3:07 PM, Chuck Payne <terrorpup at gmail.com> wrote:

> James,
>
> Thanks, I am working on getting ansible and spacewalk to work
> together. This is nice.
>

Yeah, it's really easy to do some hefty tasks:

```
'use strict';

const fs = require('fs');
const ty = require('then-yield');
const SatClient = require('sat5-xmlrpc');
const client = new SatClient({host: 'rhn.example.com'});

const outputDir = '/tmp';

function* doit() {
  try {
    const key = yield client.auth.login('user', 'supersecret');

    const prodGroup = yield client.systemgroup.getDetails(key, 'PROD');
    const prodSystems = yield client.systemgroup.listSystemsMinimal(key,
prodGroup.name);

    const advisories = {};

    for (let system of prodSystems) {
      const file = `${outputDir}/${system.name}`;
      fs.appendFileSync(file, '# Errata Needed\n\n');
      const erratas = yield client.system.getRelevantErrata(key, system.id);
      for (let errata of erratas) {
        let details;
        if (advisories.hasOwnProperty(errata.advisory_name)) {
          details = advisories[errata.advisory_name];
        } else {
          details = yield client.errata.getDetails(key,
errata.advisory_name);
          advisories[errata.advisory_name] = details;
        }

        let str = '';
        str += `+ ${errata.advisory_name}\n`;
        str += `  + type: ${details.type}\n`;
        str += `  + issued: ${details.issue_date}\n`;
        str += `  + sysnopsis: ${details.synopsis}\n`;
        fs.appendFile(file, str);
      }
    }
  } catch (e) {
    console.error(e);
  }
}

ty.spawn(doit);
```


-- 
James Sumners
http://james.sumners.info/ (technical profile)
http://jrfom.com/ (personal site)
http://haplo.bandcamp.com/ (band page)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20160219/8f0030b9/attachment.html>


More information about the Ale mailing list