@sazze/ops-cli v1.0.6
ops-cli
C4 Operations Command Line Interface
Official command line interface to sazze-c4/ops
Install
npm install -g @sazze/ops-cliUsage
ops --helpConfig
Configuration can be specified in a JSON file named .ops.conf located in the user's home directory.
Host Commands
Search (* Coming Soon)
Find hosts that match a perl RegExp pattern.
Usage:
ops host search PATTERN [OPTIONS]PATTERN: the perl RegExp to match againstOPTIONS: (optional) options to pass to the search-ma: (optional) match the pattern against specific attributes (can be specified multiple times) (default:fqdn,chefRole, andmac)-ra: (optional) the attribute to return if a match is found (default:fqdn)
All matches are written to STDOUT with 1 match per line.
Examples:
1) Only match against a host's chefRole attribute
ops search host "developer" -am chefRoleResposne:
dev-craig.c1.cs1.sazze.com
dev-ajaso.c1.cs1.sazze.com
...Filter
Like search, but uses the old c3.ops.sazze.com filter style (nothing fancy allowed here, just a "string contains" check). Filters against fqdn, chefRole, and mac attributes.
Usage:
ops host filter FILTER_STRINGFILTER_STRING: the string to filter hosts with
Examples:
1) Find hosts containing "envoy"
ops host filter "envoy"Response:
mc-envoy-main1.c1.cs1.sazze.com
mc-envoy-main2.c1.cs1.sazze.com
ipmi-mc-envoy-main1.c1.cs1.sazze.com
ipmi-mc-envoy-main2.c1.cs1.sazze.com
...Show
Get information about a host
Usage:
ops host show FQDN [OPTIONS]FQDN: the FQDN of the host to get information forOPTIONS: (optional) options to pass to show--raw: (optional) show rawJSONhost object--pretty: (optional) pretty print the raw JSON output
--tree: (optional) show host info in a tree format--all: (optional) expand all host attributes--macs: (optional) expand host mac addresses--disks: (optional) expand host disks--raids: (optional) expand host raids--interfaces: (optional) expand host interfaces--bridges: (optional) expand host bridges--bonds: (optional) expand host bonds--guests: (optional) expand host guests--kvmHost: (optional) expand host kvm host--ipmiHost: (optional) expand host ipmi host
Can get info for multiple hosts by writing hostname(s) to STDIN (1 per line)
Examples:
1) show host host1.example.com
ops host show host1.example.comResponse:
fqdn: host1.example.com
chefRole: my-chef-role
ip: 192.168.1.1
mac: AA:BB:CC:DD:EE:FF2) show multiple hosts
ops host filter example.com | ops host showResponse:
fqdn: host1.example.com
chefRole: my-chef-role
ip: 192.168.1.1
mac: AA:BB:CC:DD:EE:FE
fqdn: host2.example.com
chefRole: my-chef-role
ip: 192.168.1.2
mac: AA:BB:CC:DD:EE:FFClone
Clone an existing host. Outputs the json representation of the host.
Most common use case is to pipe the output of ops host clone to ops host create
Can also direct the output to a file for editing prior to consumption by ops host create
Usage:
ops host clone DONOR_FQDN --cloneName FQDN [--mac MAC_ADDR] [--noInterfaces] [--zone ZONE] [--pool POOL] [--vmHostId FQDN|ID] [--chefRole ROLE] [--pretty]DONOR_FQDN: the FQDN of the host to clone--cloneName FQDN: theFQDNfor the new host--mac MAC_ADDR: (optional) the mac address to use for the new host.MAC_ADDRshould be of the formatAA:BB:CC:DD:EE:FF. This option may be specified more than once. Mac addresses will be applied to interfaces in the order received.--noInterfaces: (optional) do not clone the network interfaces--zone ZONE: (optional) the name of the zone for the new host (default: the donor host's zone)--pool POOL: (optional) the name of the pool for the new host (default: the donor host's pool)--vmHostId FQDN|ID: (optional) theFQDNorIDof the host that will host the new virtual machine. (default: the donor host's vmHostId). This options is ignored if the donor host is not a virtual machine.--chefRole ROLE: (optional) the chef role for the new host (default: the donor host's chef role)--pretty: (optional) pretty print the JSON output (useful for writing to a file for future editing)
Examples:
1) Clone a host
ops host clone host1.example.com --cloneName host2.example.com --prettyResponse:
{
"fqdn": "host2.example.com",
"name": "host2",
"cpu": 4,
"ram": 4096,
"type": 2,
"active": 1,
"disks": [
{
"size": 34816,
"order": 0,
"partitions": [
{
"mount": "/boot",
"fsType": "ext4",
"size": 200,
"primary": 1,
"order": 0
},
{
"mount": "swap",
"fsType": "swap",
"size": 2048,
"primary": 0,
"order": 0
},
{
"mount": "/",
"fsType": "ext4",
"size": 0,
"primary": 0,
"order": 0
}
]
}
],
"vmHost": 0,
"chefRole": "chef-role",
"domain": {
"domain": "example.com"
},
"pool": {
"poolId": 1,
"name": "example pool",
"zoneId": 1
},
"zone": {
"zoneId": 1,
"name": "example zone",
"domain": "example.com",
"chefServer": "chef.example.com"
},
"raid": [],
"netInterfaces": [
{
"name": "eth0"
}
],
"netInterfaceBonds": [],
"vmHostId": 1234,
"vmDiskPrefixes": []
}Map
Create a map of where hosts are located.
Accepts host names on the command line or from STDIN and maps them to their locations.
Usage:
ops host map [FQDN] [--byHost | --byZone]FQDN: (optional) theFQDNof the host to map. This option can be specified more than once. (default: read hostFQDN's fromSTDIN)--byHost: (optional) organize hosts by virtual machine host--byZone: (optional) organize hosts by zone
Examples:
1) Map a couple of known hosts
ops host map host1.example.com host2.example.com2) Map hosts returned from a filter
ops host filter example.com | ops host map --byHost3) Map all hosts
ops host filter | ops host map --byHostCreate
Create a host from a json object read from STDIN.
Most common use case is to pipe the output of ops host clone to ops host create
Usage:
ops host createExamples:
1) Create host from file
cat host1.example.com.json | ops host create2) Create host from clone
ops clone host1.example.com | ops host createRemove
ops host rm FQDNProvision
ops host provision FQDNDeprovision
ops host deprovision FQDNCreate Bridge
Add an interface on a host to a bridge (create the bridge if it doesn't exist).
ops host mkBr FQDN BRIDGE INTERFACEFQDN: theFQDNof the hostBRIDGE: the name of the bridge to add the interface to (i.e.br0)INTERFACE: the name of the interface to add to the bridge
Examples:
ops host mkBr host1.example.com br0 bond0Remove Bridge
ops host rmBr FQDN BRIDGEAddress Commands
List
ops addr listShow
ops addr showAssign
ops addr assignUnassign
ops addr unassignLicense
ISC License (ISC)
Copyright (c) 2016, Sazze, Inc.
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.