npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sazze/ops-cli

v1.0.6

Published

C4 Operations Command Line Interface

Downloads

1

Readme

ops-cli

C4 Operations Command Line Interface

Official command line interface to sazze-c4/ops

Install

npm install -g @sazze/ops-cli

Usage

ops --help

Config

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 against
  • OPTIONS: (optional) options to pass to the search
    • -ma: (optional) match the pattern against specific attributes (can be specified multiple times) (default: fqdn, chefRole, and mac)
    • -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 chefRole

Resposne:

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_STRING
  • FILTER_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 for
  • OPTIONS: (optional) options to pass to show
    • --raw: (optional) show raw JSON host 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.com

Response:

fqdn:     host1.example.com
chefRole: my-chef-role
ip:       192.168.1.1
mac:      AA:BB:CC:DD:EE:FF
  1. show multiple hosts
ops host filter example.com | ops host show

Response:

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:FF

Clone

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: the FQDN for the new host
  • --mac MAC_ADDR: (optional) the mac address to use for the new host. MAC_ADDR should be of the format AA: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) the FQDN or ID of 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 --pretty

Response:

{
  "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) the FQDN of the host to map. This option can be specified more than once. (default: read host FQDN's from STDIN)
  • --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.com
  1. Map hosts returned from a filter
ops host filter example.com | ops host map --byHost
  1. Map all hosts
ops host filter | ops host map --byHost

Create

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 create

Examples:

  1. Create host from file
cat host1.example.com.json | ops host create
  1. Create host from clone
ops clone host1.example.com | ops host create

Remove

ops host rm FQDN

Provision

ops host provision FQDN

Deprovision

ops host deprovision FQDN

Create Bridge

Add an interface on a host to a bridge (create the bridge if it doesn't exist).

ops host mkBr FQDN BRIDGE INTERFACE
  • FQDN: the FQDN of the host
  • BRIDGE: 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 bond0

Remove Bridge

ops host rmBr FQDN BRIDGE

Address Commands

List

ops addr list

Show

ops addr show

Assign

ops addr assign

Unassign

ops addr unassign

License

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.