Support get/set/delete variables in Python client/CLI

Bug #1659110 reported by Sulochan Acharya
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Craton's Python Client
Fix Released
Critical
Thomas Maddox

Bug Description

CLI and client support for get/set/delete of resource vars

Functionality should be supported both for the Python client:

host = craton.hosts.get(item_id=8)
host.variables.update(x='foo', y={'a': 47, 'b': True}, z='baz')

As well as for the CLI:

craton region-vars-get 1
craton cell-vars-get 3 x=true y=47 z=foo/bar w=3.14159
cat <<EOF | craton host-vars-set 13
{
    "glance_default_store": "not-so-swift",
    "neutron_l2_population": false,
    "make_stuff_up": true,
    "some/namespaced/variable": {"a": 1, "b": 2}
}
EOF
craton host-vars-get --format=json 13 | jq -C
craton cell-vars-delete 13 make_stuff_up
craton cell-vars-set 13 x= y=42 # deletes x

etc.

The following resources should be supported: projects, regions, cells, hosts, network devices.

The general subcommand convention will be <resources>-vars-get,
<resources>-vars-set, and <resource>-vars-delete.

Code will be implemented to minimize the overhead of doing
this for additional resources in the future, such as cloud, user,
workflow, etc.

It would be more ergonomic if the CLI supported referencing a
resource, like a host, by an identifying name, not just an ID, but
any such work will be done in a separate bug.

Changed in python-cratonclient:
importance: Undecided → High
assignee: nobody → Sulochan Acharya (sulochan-acharya)
Jim Baker (jimbaker)
Changed in python-cratonclient:
assignee: Sulochan Acharya (sulochan-acharya) → Jim Baker (jimbaker)
Revision history for this message
Jim Baker (jimbaker) wrote :

To minimize task scheduling, also support projects; so depends on https://review.openstack.org/#/c/427777/

description: updated
Changed in python-cratonclient:
milestone: none → v0.1.0
importance: High → Critical
status: New → In Progress
summary: - Variables should be available from cli
+ Variables should be available from Python client/CLI
summary: - Variables should be available from Python client/CLI
+ Support get/set/delete variables in Python client/CLI
Revision history for this message
Thomas Maddox (thomas-maddox) wrote :

16:26 jimbaker: thomasem, btw, i was thinking for vars, we should support this format for nested https://github.com/jkbrzt/httpie#non-string-json-fieldsjson:

We agreed it'd be nice to be able to support inline JSON in the *-vars-set commands via syntax like ":=", similar to HTTPie.

Changed in python-cratonclient:
assignee: Jim Baker (jimbaker) → Thomas Maddox (thomas-maddox)
Revision history for this message
Thomas Maddox (thomas-maddox) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-cratonclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/441627

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/442026

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/442027

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-cratonclient (master)

Reviewed: https://review.openstack.org/427032
Committed: https://git.openstack.org/cgit/openstack/python-cratonclient/commit/?id=05b4f117bbf9544d34a5ea7836d9da811d07eb8f
Submitter: Jenkins
Branch: master

commit 05b4f117bbf9544d34a5ea7836d9da811d07eb8f
Author: Thomas Maddox <email address hidden>
Date: Fri Mar 3 17:19:29 2017 +0000

    CLI and client support for get/set/delete of resource vars

    Functionality is supported both for the Python client:

    host = craton.hosts.get(item_id=8)
    host.variables.update(x='foo', y={'a': 47, 'b': True}, z='baz')
    host.variables.delete("foo", "bar", "baz")

    As well as for the CLI:

    craton host-vars-get 1
    craton host-vars-set 3 x=true y=47 z=foo/bar w=3.14159
    cat <<EOF | craton host-vars-set 13
    {
        "glance_default_store": "not-so-swift",
        "neutron_l2_population": false,
        "make_stuff_up": true,
        "some/namespaced/variable": {"a": 1, "b": 2}
    }
    EOF
    craton --format json host-vars-get 13 | jq -C
    craton host-vars-delete 13 make_stuff_up
    craton host-vars-set 13 x= y=42 # deletes x

    This patch implements the basis for supporting this
    in other resources as well, however we only address
    hosts here as an initial implementation. We will
    fast-follow with support in other resources.

    Partial-Bug: 1659110
    Change-Id: Id30188937518d7103d6f943cf1d038b039dc30cc

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/441627
Committed: https://git.openstack.org/cgit/openstack/python-cratonclient/commit/?id=c0cdd3950f266581b341fd8e7f24e5b3f5a2372a
Submitter: Jenkins
Branch: master

commit c0cdd3950f266581b341fd8e7f24e5b3f5a2372a
Author: Thomas Maddox <email address hidden>
Date: Sat Mar 4 18:45:36 2017 +0000

    Add variables support for remaining resources

    This patch implements the variables support
    for the remaining resources that use variables

    Change-Id: I8d5515742db2d62ff1dea38c10018cc9579a82f4
    Partial-Bug: 1659110

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/442026
Committed: https://git.openstack.org/cgit/openstack/python-cratonclient/commit/?id=0ad237ed60997676d3b6b765dbef8936c9d80bd3
Submitter: Jenkins
Branch: master

commit 0ad237ed60997676d3b6b765dbef8936c9d80bd3
Author: Thomas Maddox <email address hidden>
Date: Mon Mar 6 16:31:52 2017 +0000

    DRY out Variables shell tests

    This patch pulls out the common setup bits for
    Variables shell tests.

    Change-Id: I8012f51b06a40d0c8d8b0aaeff407881789da9b2
    Partial-Bug: 1659110

Changed in python-cratonclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/442027
Committed: https://git.openstack.org/cgit/openstack/python-cratonclient/commit/?id=e1f554595ed5958360fbb6e533da85de7660d658
Submitter: Jenkins
Branch: master

commit e1f554595ed5958360fbb6e533da85de7660d658
Author: Thomas Maddox <email address hidden>
Date: Mon Mar 6 16:37:52 2017 +0000

    Adds remaining shell tests for variables

    This patch includes the shell integration tests
    for remaining Resources' variables implementation

    Change-Id: I44dc2c3463715321f70bb48514a70906d0c864ec
    Closes-Bug: 1659110

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.