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

Vagrant commands should be able to output machine-readable format #1098

Closed
foxx opened this Issue Sep 3, 2012 · 10 comments

Comments

Projects
None yet
5 participants
@foxx

foxx commented Sep 3, 2012

It would be nice if the vagrant commands themselves were scriptable.

For example:

 root@envprov1 [/mnt/ds1/vagrant/projects/pm2] > vagrant status
Current VM states:

prodclone1               not created
slice21                  running

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.

Trying to filter through that requires a not very sane approach, it would be better if you had something like:

 root@envprov1 [/mnt/ds1/vagrant/projects/pm2] > vagrant status -t
prodclone1,not created
slice21,running

I.e. making the output script friendly.

Thoughts?

@foxx

This comment has been minimized.

Show comment
Hide comment
@foxx

foxx Sep 3, 2012

For example, to convert this:

Current VM states:

prodclone1               not created
slice21                  running

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.

Into this:

[('prodclone1', 'not created'), ('slice21', 'running')]

Required the following python code:

        _slices = self._execute("vagrant status")
        _slices = _slices.split("\n\n", 2)
        _slices = _slices[1]
        _slices = _slices.split("\n")
        _slices = map(lambda x: x.split(" ", 1), _slices)
        _slices = map(lambda x: (x[0].strip(), x[1].strip()), _slices)
        print _slices

Although it is scriptable, it's not exactly clean/sane, and any future changes to status command output could break this.

foxx commented Sep 3, 2012

For example, to convert this:

Current VM states:

prodclone1               not created
slice21                  running

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.

Into this:

[('prodclone1', 'not created'), ('slice21', 'running')]

Required the following python code:

        _slices = self._execute("vagrant status")
        _slices = _slices.split("\n\n", 2)
        _slices = _slices[1]
        _slices = _slices.split("\n")
        _slices = map(lambda x: x.split(" ", 1), _slices)
        _slices = map(lambda x: (x[0].strip(), x[1].strip()), _slices)
        print _slices

Although it is scriptable, it's not exactly clean/sane, and any future changes to status command output could break this.

@patcon

This comment has been minimized.

Show comment
Hide comment
@patcon

patcon Sep 8, 2012

Contributor

Good call. json output would be nifty :)

Contributor

patcon commented Sep 8, 2012

Good call. json output would be nifty :)

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Sep 10, 2012

Member

I agree. Marking this as a feature requests, and I changed the subject a little bit.

I think I'd rather output in a format that is easily sliceable with unix tools, so: not JSON. Line-oriented output separated by a delimiter or whitespace would be best so you can grep/awk/sed it.

Member

mitchellh commented Sep 10, 2012

I agree. Marking this as a feature requests, and I changed the subject a little bit.

I think I'd rather output in a format that is easily sliceable with unix tools, so: not JSON. Line-oriented output separated by a delimiter or whitespace would be best so you can grep/awk/sed it.

@foxx

This comment has been minimized.

Show comment
Hide comment
@foxx

foxx Sep 10, 2012

+1 for grep/awk/sed friendly.

foxx commented Sep 10, 2012

+1 for grep/awk/sed friendly.

@patcon

This comment has been minimized.

Show comment
Hide comment
@patcon

patcon Sep 10, 2012

Contributor

👍

Contributor

patcon commented Sep 10, 2012

👍

@michaeltwofish

This comment has been minimized.

Show comment
Hide comment
@michaeltwofish

michaeltwofish Sep 26, 2012

*nix tool friendly status output would be great.

In the meantime, this awk script works for my purposes, relying on only the blank line around the statuses.

vagrant status|awk '/^$/ {stat = !stat;next}; stat == 1 {print}'

michaeltwofish commented Sep 26, 2012

*nix tool friendly status output would be great.

In the meantime, this awk script works for my purposes, relying on only the blank line around the statuses.

vagrant status|awk '/^$/ {stat = !stat;next}; stat == 1 {print}'
@zpatten

This comment has been minimized.

Show comment
Hide comment
@zpatten

zpatten Mar 22, 2013

@mitchellh Do you have an ETA on this? Based on your comments on my Cucumber-Chef project I had expected, at minimum, a basic implementation of this with the "new" vagrant. I have not been able to find this functionality in the latest release of vagrant (i.e. 1.1.2). Am I missing something obvious? Thanks in advance!

zpatten commented Mar 22, 2013

@mitchellh Do you have an ETA on this? Based on your comments on my Cucumber-Chef project I had expected, at minimum, a basic implementation of this with the "new" vagrant. I have not been able to find this functionality in the latest release of vagrant (i.e. 1.1.2). Am I missing something obvious? Thanks in advance!

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Mar 22, 2013

Member

I would've loved to have had it in 1.1, but I had to cut the release at some point, and it was already a pretty huge release. At this point I'm targeting 1.3, but will put it into 1.2 if I find time.

Member

mitchellh commented Mar 22, 2013

I would've loved to have had it in 1.1, but I had to cut the release at some point, and it was already a pretty huge release. At this point I'm targeting 1.3, but will put it into 1.2 if I find time.

@zpatten

This comment has been minimized.

Show comment
Hide comment
@zpatten

zpatten Mar 22, 2013

Awesome; sounds good! I know how it goes, was just curious as to the status of it; as long as it is still on your radar :)

Thanks for the quick response!

zpatten commented Mar 22, 2013

Awesome; sounds good! I know how it goes, was just curious as to the status of it; as long as it is still on your radar :)

Thanks for the quick response!

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Nov 25, 2013

Member

This is done!

Member

mitchellh commented Nov 25, 2013

This is done!

@mitchellh mitchellh closed this Nov 25, 2013

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