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

[merged] status: Support --json option #315

Closed
wants to merge 1 commit into from

Conversation

cgwalters
Copy link
Member

It's really simple to reflect the DBus API into JSON, which tools like
Ansible or jq from the command line or whatever can parse to find
interesting things like the current version.

Closes: #301

It's really simple to reflect the DBus API into JSON, which tools like
Ansible or `jq` from the command line or whatever can parse to find
interesting things like the current version.

Closes: coreos#301
@cgwalters
Copy link
Member Author

Things like:

https://github.com/projectatomic/atomic-host-tests/blob/master/tests/upgrade-interrupt/main.yaml#L65

will need to be ported to see if --json exists, if it does, use it, if not fall back.

@miabbott
Copy link
Member

miabbott commented Jun 9, 2016

Thanks for pointing that out. Happy to see machine readable output for scripting purposes. 😄

@miabbott
Copy link
Member

I tested this and saw that some of the field names in the JSON are different from the normal status:

[root@92e55a4fd2da /]# /usr/bin/rpm-ostree status --json | python -m json.tool
[
    {
        "checksum": "4bf265cf86242caa56e86808b1d802034086644aaf75c11b4ef9dbb19d10a5a6",
        "id": "rhel-atomic-host-4bf265cf86242caa56e86808b1d802034086644aaf75c11b4ef9dbb19d10a5a6.0",
        "origin": "rhel-atomic-host-ostree:rhel-atomic-host/7/x86_64/standard",
        "osname": "rhel-atomic-host",
        "serial": 0,
        "timestamp": 1465236727,
        "version": "7.2.5"
    }
]
[root@92e55a4fd2da /]# /usr/bin/rpm-ostree status                             
* rhel-atomic-host-ostree:rhel-atomic-host/7/x86_64/standard
       Version: 7.2.5 (2016-06-06 18:12:07)
        Commit: 4bf265cf86242caa56e86808b1d802034086644aaf75c11b4ef9dbb19d10a5a6
        OSName: rhel-atomic-host
  GPGSignature: (unsigned)

Would it be possible to have the names of the fields be the same in both cases?

@cgwalters
Copy link
Member Author

I know it would be nice if they matched...but we can't change the DBus API since Cockpit uses it (plus various internal consumers).

Trying to align them just for --json would require another reverse mapping table and make this patch much bigger and harder to maintain long term.

We can easily change some of the status nouns like using Checksum: instead of Commit: but...I dunno we don't have a lot of consistency here =/

@miabbott
Copy link
Member

I'm in favor of easier maintenance, so the explanation suits me fine.

@jlebon
Copy link
Member

jlebon commented Jun 13, 2016

Awesome, quite surprising how easy it is.
@rh-atomic-bot r+ 55a81e3

@rh-atomic-bot
Copy link

⌛ Testing commit 55a81e3 with merge b7d1b82...

@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: jlebon
Pushing b7d1b82 to master...

@rh-atomic-bot rh-atomic-bot changed the title status: Support --json option [merged] status: Support --json option Jun 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants