{"id":286,"date":"2025-01-17T10:00:26","date_gmt":"2025-01-17T09:00:26","guid":{"rendered":"https:\/\/blog.openshift.one\/?p=286"},"modified":"2025-01-17T10:51:26","modified_gmt":"2025-01-17T09:51:26","slug":"one-liner-of-the-day","status":"publish","type":"post","link":"https:\/\/blog.openshift.one\/index.php\/2025\/01\/17\/one-liner-of-the-day\/","title":{"rendered":"One-liner of the day"},"content":{"rendered":"\n<p>The purpose of this post is to collect in one place set of one-liners that I&#8217;ve been using in my day to day work.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Get a list of VMs across the whole cluster with guest-agent status\n\n<pre class=\"wp-block-code has-background-color has-foreground-background-color has-text-color has-background\"><code># oc get vms -A -o json | jq -r '&#91;\"Name\", \"Namespace\", \"Agent\"], (.items&#91;] | select(.status.conditions&#91;] | select(.type == \"AgentConnected\")) | &#91;.metadata.name, .metadata.namespace, .status.ready]) | @tsv' | column -t\nName                       Namespace  Agent\nfedora-emerald-hornet-13   demo       true\nfedora-harlequin-dingo-62  demo       true<\/code><\/pre>\n<\/li>\n\n\n\n<li>Using curl to access Redfish interface, insert Agent ISO hosted on locally available webserver of all servers matching &#8220;rhocp-controller&#8221; name.\n<pre class=\"wp-block-code has-background-color has-foreground-background-color has-text-color has-background\"><code># curl -sk https:\/\/192.168.232.1:8000\/redfish\/v1\/Systems\/ | jq -r '.Members&#91;].\"@odata.id\"' | while read SYSTEM; do curl -sk https:\/\/192.168.232.1:8000${SYSTEM} | jq -r 'select(.Name | match(\"rhocp-controller\"))| .Id' | while read ID; do curl -k -d '{\"Image\":\"http:\/\/192.168.232.1\/agent.x86_64.iso\", \"Inserted\": true}' -H \"Content-Type: application\/json\" -X POST https:\/\/192.168.232.1:8000\/redfish\/v1\/Managers\/${ID}\/VirtualMedia\/Cd\/Actions\/VirtualMedia.InsertMedia ; done ; done<\/code><\/pre>\n<\/li>\n\n\n\n<li>Using curl to access Redfish interface, reset all servers matching &#8220;rhocp-controller&#8221; name.\n<pre class=\"wp-block-code has-background-color has-foreground-background-color has-text-color has-background\"><code># curl -sk https:\/\/192.168.232.1:8000\/redfish\/v1\/Systems\/ | jq -r '.Members&#91;].\"@odata.id\"' | while read SYSTEM; do curl -sk https:\/\/192.168.232.1:8000${SYSTEM} | jq -r 'select(.Name | match(\"rhocp-controller\"))| .Id' | while read ID; do curl -k -d '{\"Action\": \"Reset\", \"ResetType\": \"On\"}' -X POST -H \"Content-Type: application\/json\" https:\/\/192.168.232.1:8000\/redfish\/v1\/Systems\/${ID}\/Actions\/ComputerSystem.Reset ; done; done<\/code><\/pre>\n<\/li>\n\n\n\n<li>Using curl to access Redfish interface, get a list of all managed systems by that single Redfish instance.\n<pre class=\"wp-block-code has-background-color has-foreground-background-color has-text-color has-background\"><code># curl -sk https:\/\/192.168.232.1:8000\/redfish\/v1\/Systems\/ | jq -r '.Members&#91;].\"@odata.id\"' | while read SYSTEM; do curl -sk https:\/\/192.168.232.1:8000${SYSTEM} | jq -r 'select(.Name | match(\"rhocp-\")) | &#91;.Id, .Name, .PowerState, .Manufacturer] | @tsv'; done | column -t\n513183c9-a472-46ab-97a6-c9e808ccf776  rhocp-controller-2  On   Sushy  Emulator\n7e54fb65-921e-46f4-a1ee-9f3f04a2141a  rhocp-bastion       On   Sushy  Emulator\n96e1afcb-fddf-42a1-a15f-385b4e811355  rhocp-controller-1  On   Sushy  Emulator\nd833bbd6-c0fd-4cb7-843c-ad6a9f0f32ac  rhocp-controller-0  On   Sushy  Emulator\n80db3a4f-930c-4f5f-b4d0-cf18356fe9a5  rhocp-compute-0     Off  Sushy  Emulator<\/code><\/pre>\n<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The purpose of this post is to collect in one place set of one-liners that I&#8217;ve been using in my day to day work.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.openshift.one\/index.php\/wp-json\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.openshift.one\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.openshift.one\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.openshift.one\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.openshift.one\/index.php\/wp-json\/wp\/v2\/comments?post=286"}],"version-history":[{"count":15,"href":"https:\/\/blog.openshift.one\/index.php\/wp-json\/wp\/v2\/posts\/286\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/blog.openshift.one\/index.php\/wp-json\/wp\/v2\/posts\/286\/revisions\/310"}],"wp:attachment":[{"href":"https:\/\/blog.openshift.one\/index.php\/wp-json\/wp\/v2\/media?parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.openshift.one\/index.php\/wp-json\/wp\/v2\/categories?post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.openshift.one\/index.php\/wp-json\/wp\/v2\/tags?post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}