Created
September 1, 2017 20:05
-
-
Save ldelossa/9d30aaa846dcf71a8c45bbfb176e22c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GCE vimeo-logs shortcuts | |
# Images shortcuts | |
logs-lim() { gcloud --project vimeo-logs compute images list } | |
logs-rmim() { if [ $# -eq 0 ]; then echo "Deletes an image: [image-name]"; else | |
gcloud --project vimeo-logs compute images delete $1; fi } | |
# Instances shortcuts | |
logs-li() { gcloud --project vimeo-logs compute instances list } | |
logs-di() { if [ $# -eq 0 ]; then echo "Describes an instance: [instance-name]"; else gcloud --project vimeo-logs compute instances describe $1; fi } | |
logs-ci() { if [ $# -eq 0 ]; then echo "Creates an instance: [instance-name] [image] [machine-type]"; else | |
gcloud --project vimeo-logs compute instances create $1 --image=$2 --machine-type $3 --network=vimeo-logs --subnet=us-east1-b; fi } | |
logs-rmi() { if [ $# -eq 0 ]; then echo "Deletes an instance: [instance-name]"; else | |
gcloud --project vimeo-logs compute instances delete $1; fi } | |
logs-lt() { if [ $# -eq 0 ]; then echo "Lists tags for instance: [instance-name]"; else | |
gcloud --project vimeo-logs compute instances describe $1 --format=json | jq '.tags'; fi} | |
logs-at() { if [ $# -eq 0 ]; then echo "Adds tag to instance: [instance-name] [tag]"; else | |
gcloud --project vimeo-logs compute instances add-tags $1 --tags=$2; fi } | |
logs-rmt() { if [ $# -eq 0 ]; then echo "Removes tag from instance: [instance-name] [tag]"; else | |
gcloud --project vimeo-logs compute instances remove-tags $1 --tags=$2; fi } | |
# Instance templates shortcuts | |
logs-lit() { gcloud --project vimeo-logs compute instance-templates list } | |
logs-dit() { if [ $# -eq 0 ]; then echo "Describes an instance template: [name]"; else | |
gcloud --project vimeo-logs compute instance-templates describe $1; fi } | |
logs-cit() { if [ $# -eq 0 ]; then echo "Creates an instance template: [name] [machine-type] [subnet] [tags] [image]"; else | |
gcloud --project vimeo-logs compute instance-templates create $1 --machine-type=$2 --subnet=$3 --tags="$4" --image=$5 --network=vimeo-logs; fi } | |
logs-rmit() { if [ $# -eq 0 ]; then echo "Removes an instance template: [name]"; else | |
gcloud --project vimeo-logs compute instance-templates delete $1; fi } | |
# General instance group shortcuts | |
logs-dig() { if [ $# -eq 0 ]; then echo "Describes an instance group: [instance-group-name]"; else | |
gcloud --project vimeo-logs compute instance-groups describe $1; fi } | |
# Managed instance group shortcuts | |
logs-lmig() { gcloud --project vimeo-logs compute instance-groups list --only-managed } | |
logs-dmig() { if [ $# -eq 0 ]; then echo "Describes a managed instance group: [instance-group-name]"; else | |
gcloud --project vimeo-logs compute instance-groups managed describe $1; fi } | |
logs-limig() { if [ $# -eq 0 ]; then echo "List instances in managed instance group: [name]"; else | |
gcloud --project vimeo-logs compute instance-groups managed list-instances $1; fi } | |
logs-cmig() { if [ $# -eq 0 ]; then echo "Creates a managed instance group: [name] [size] [instance-template]"; else | |
gcloud --project vimeo-logs compute instance-groups managed create $1 --size=$2 --template=$3; fi } | |
logs-rmmig() { if [ $# -eq 0 ]; then echo "Removes a managed instance group: [name]"; else | |
gcloud --project vimeo-logs compute instance-groups managed delete $1; fi } | |
logs-aimig() { if [ $# -eq 0 ]; then echo "Abandons an instance from a managed instange group: [managed-instance-group] [instance-name]"; else | |
gcloud --project vimeo-logs compute instance-groups managed abandon-instance $1 --instances=$2; | |
gcloud --project vimeo-logs compute instance-groups managed wait-until-stable $1; fi } | |
logs-rcimig() { if [ $# -eq 0 ]; then echo "Recreate instances in managed instance group: [managed-instance-group] [instance-name]"; else | |
gcloud --project vimeo-logs compute instance-groups managed recreate-instance $1 --instances=$2; | |
gcloud --project vimeo-logs compute instance-groups managed wait-until-stable $1; fi } | |
logs-rsmig() { if [ $# -eq 0 ]; then echo "Resizes a managed instance group: [name] [size]"; else | |
diff1=$(logs-limig $1); | |
gcloud --project vimeo-logs compute instance-groups managed resize $1 --size=$2; | |
echo "\n" | |
gcloud --project vimeo-logs compute instance-groups managed wait-until-stable $1; | |
diff2=$(logs-limig $1); | |
echo "\n" | |
diff -y <(echo $diff1) <(echo $diff2); fi } | |
logs-stmig() { if [ $# -eq 0 ]; then echo "Sets template for managed instance group: [managed-instance-group] [instance-template]"; else | |
gcloud --project vimeo-logs compute instance-groups managed set-instance-template $1 --template=$2; fi } | |
logs-stablemig() { if [ $# -eq 0 ]; then echo "Blocks until instance group is stable: [name]"; else | |
gcloud --project vimeo-logs compute instance-groups managed wait-until-stable $1; fi } | |
# Misc Shortcuts | |
logs-sn() { if [ $# -eq 0 ]; then echo "Shows instance network config: [instance-name]"; else | |
gcloud --project vimeo-logs compute instances describe $1 --format=json | jq '.networkInterfaces'; fi } | |
logs-ssh() { if [ $# -eq 0 ]; then echo "SSH's into instance: [instance-name]"; else | |
gcloud --project vimeo-logs compute ssh louis@$1 --ssh-key-file=~/.ssh/vimeo_louis_id_rsa; fi } | |
logs-sshcmd() { if [ $# -eq 0 ]; then echo "SSH's into instance: [instance-name]"; else | |
gcloud --project vimeo-logs compute ssh louis@$1 --ssh-key-file=~/.ssh/vimeo_louis_id_rsa --command="$2"; fi } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment