Random VM Name

Intro

Something I found to be cute about the docker engine is it's feature to create a random name for your containers, when one is not specified.

I've had some good ones e.g

objective_galileo
distracted_euclid

Occasionally I'd be spinning up the odd VM and have to provide some generic name like dev-sebastien. So instead I thought my own arbitrary name generation could save some time here.

Random names

The idea was to combine <adjective>-<pokemon> and use this as the VM parameter.

Thus defining the following in .create_name.sh

function gen_name()
{
    pokemon=(
        "pidgey"
        "pikachu"
        "cubone"
    )
    adjectives=(
        "hungry"
        "adorable"
        "jittery"
    )

    select_pokemon=${pokemon[$RANDOM % {#pokemon[@]}] }
    select_desc=${adjectives[$RANDOM % {#adjectives[@]}] }

    local result=sebastien-$select_desc-$select_pokemon
    echo "$result"
}

Call this in your .bash_aliases file.

source .create_name.sh

And every time you run gen_name in your command line, you'll get a new "vm" name.

I've coupled this with

create_instance(){
    gcloud compute instances create $(gen_name);
}

Here are some of the names of my machines

sebastien-livid-quagsire
sebastien-lonely-metapod
sebastien-gentle-rattata