ebsarr / packet

packet, a CLI tool to manage packet.net services
Other
40 stars 14 forks source link

"updateDeviceCmd" action for baremetal #23

Closed sygibson closed 6 years ago

sygibson commented 6 years ago

Love the tool - simple - fast, easy to use ... thank you !

Looking through the baremetal.go code, it appears there's no way to update an existing baremetal machine. As a user I'd like to be able to modify existing baremetal machines with new values.

For example:

packet baremetal update-device --id --file userdata.txt or packet baremetal update-device --id --hostname fred

ebsarr commented 6 years ago

WIP

ebsarr commented 6 years ago

@sygibson : I pushed an update to a new branch v2.2 to address this request as well as #24 and #25 . Could you help by running some tests? Thanks.

ebsarr commented 6 years ago

@vielmetti :

I implemented the update-device command, with empty strings or false boolean value for the accepted parameters by default . This allows to do packet baremetal update-device --hostname my-host-name without modifying the other parameters. Some test results:

Device info

$ packet baremetal list-device --device-id 78e57da0-be43-4ae1-979b-3494acc8c249

{
    "id": "78e57da0-be43-4ae1-979b-3494acc8c249",
    "href": "/devices/78e57da0-be43-4ae1-979b-3494acc8c249",
    "hostname": "78e57da0.packethost.net",
    "state": "active",
    "created_at": "2018-03-11T04:59:16Z",
    "updated_at": "2018-03-11T05:03:59Z",
    "billing_cycle": "hourly",
    "ip_addresses": []
}

Update hostname

$ packet baremetal update-device --hostname nrt1-ebsarrtest01 --device-id 78e57da0-be43-4ae1-979b-3494acc8c249

{
    "id": "78e57da0-be43-4ae1-979b-3494acc8c249",
    "href": "/devices/78e57da0-be43-4ae1-979b-3494acc8c249",
    "hostname": "nrt1-ebsarrtest01",
    "state": "active",
    "created_at": "2018-03-11T04:59:16Z",
    "updated_at": "2018-03-11T05:14:02Z",
    "billing_cycle": "hourly",
    "ip_addresses": []
}

Update description

$ packet baremetal update-device --description 'Device created to test packet command line v2.2' --device-id 78e57da0-be43-4ae1-979b-3494acc8c249

{
    "id": "78e57da0-be43-4ae1-979b-3494acc8c249",
    "href": "/devices/78e57da0-be43-4ae1-979b-3494acc8c249",
    "hostname": "78e57da0.packethost.net",
    "state": "active",
    "created_at": "2018-03-11T04:59:16Z",
    "updated_at": "2018-03-11T05:17:46.771Z",
    "billing_cycle": "hourly",
    "ip_addresses": []
}

Notice that after the second update, the hostname was reverted back to the one assigned by default when provisioning the device. Is this the expected result, or did I miss something on how to use this API? And by the way, how can I verify the device description? The API does not return any description value, neither could I find it in the portal...

vielmetti commented 6 years ago

Thanks @ebsarr - it looks like when our portal changed that some parts of the UI omitted the device description. We have an internal ticket to track this which I'll update here when it's addressed.

ebsarr commented 6 years ago

@vielmetti : Thanks. I've posted a question to packet CS to follow up on the other question.

ebsarr commented 6 years ago

Issue fixed in latest release.