Add/delete projects

master
root 4 years ago
parent bc02e54306
commit ee32ec10d3

@ -1,2 +1,27 @@
# eqx # eqx
## Token
export PACKET_TOKEN=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Or
cat $HOME/.packet-cli.json
{
"token": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
## Dependencies
apt install jq
git clone https://github.com/packethost/packet-cli
mkdir -p ~/bin
wget -O ~/bin/packet https://github.com/packethost/packet-cli/releases/download/0.1.1/packet-linux-amd64
chmod +x ~/bin/packet

@ -0,0 +1,17 @@
#!/bin/bash
# eqx-cluster-create
#
# Create a cluster of bare metal on Equinix
#
# Usage:
# eqx-cluster-create
# Example:
# eqx-cluster-create
#
set -x
#
EQXRANDHOST=`dd bs=12 count=1 if=/dev/random 2>/dev/null | base64 | tr [:upper:] [:lower:] | tr -dc [:alpha:]`

@ -0,0 +1,39 @@
#!/bin/bash
# Usage:
# eqx-create-org [name]
# Example:
# eqx-create-org fooorg
# eqx-create-org fooorg --description "barrog" --website "http://127.0.0.1"
set -x
packet \
organization \
create \
--name "$@"
exit
Example:
packet organization create -n [name]
Usage:
packet organization create [flags]
Flags:
-d, --description string Description of the organization
-h, --help help for create
-l, --logo string Logo URL]
-n, --name string Name of the organization
-t, --twitter string Twitter URL of the organization
-w, --website string Website URL of the organization
Global Flags:
--config string Path to JSON or YAML configuration file
--exclude strings Comma seperated Href references to collapse in results, may be dotted three levels deep
--include strings Comma seperated Href references to expand in results, may be dotted three levels deep
-j, --json JSON output
--search string Search keyword for use in 'get' actions. Search is not supported by all resources.
-y, --yaml YAML output

@ -0,0 +1,57 @@
#!/bin/bash
# eqx-create-project
# Create an Equinix Project.
# If no name is given, a random string is chosen
#
# Usage:
# eqx-create-project [name]
# Example:
# eqx-create-project
# eqx-create-project fooproject
EQXRAND=`dd bs=12 count=1 if=/dev/random 2>/dev/null | base64 | tr [:upper:] [:lower:] | tr -dc [:alpha:]`
EQXPROJECT="$1"
if [[ $1 == "" ]]
then EQXPROJECT=$EQXRAND
fi
packet \
project \
create \
--name \
$EQXPROJECT \
2>/dev/null | \
grep -v -e "^+" -e "CREATED" | \
cut -f 4 -d " "
exit
2021/01/23 14:45:25 [DEBUG] POST https://api.equinix.com/metal/v1/projects
+--------------------------------------+--------------+----------------------+
| ID | NAME | CREATED |
+--------------------------------------+--------------+----------------------+
| 7ac35d0b-17be-4e76-a15a-cc68a3f3d81b | udmlbdyxsouf | 2021-01-23T21:45:26Z |
+--------------------------------------+--------------+----------------------+
packet project create --name [project_name]
Usage:
packet project create [flags]
Flags:
-h, --help help for create
-n, --name string Name of the project
-o, --organization-id string UUID of the organization
-m, --payment-method-id string UUID of the payment method
Global Flags:
--config string Path to JSON or YAML configuration file
--exclude strings Comma seperated Href references to collapse in results, may be dotted three levels deep
--include strings Comma seperated Href references to expand in results, may be dotted three levels deep
-j, --json JSON output
--search string Search keyword for use in 'get' actions. Search is not supported by all resources.
-y, --yaml YAML output

@ -0,0 +1,32 @@
#!/bin/bash
# eqx-delete-project
# Delete an Equinix Project.
#
# Usage:
# eqx-delete-project [name]
# Example:
# eqx-delete-project fooproject
#set -x
EQXPROJECT="$1"
if [[ $1 == "" ]]
then \
echo -e "Need project name, such as:\n"
eqx-get-project-names
echo
exit
fi
EQXPROJECTID=`eqx-get-project-uuid $EQXPROJECT`
packet \
project \
delete \
--id \
$EQXPROJECTID \
2>/dev/null
exit

@ -0,0 +1,33 @@
#!/bin/bash
# eqx-delete-project
# Delete an Equinix Project.
#
# Usage:
# eqx-delete-project [name]
# Example:
# eqx-delete-project fooproject
#set -x
EQXPROJECT="$1"
if [[ $1 == "" ]]
then \
echo -e "Need project name, such as:\n"
eqx-get-project-names
echo
exit
fi
EQXPROJECTID=`eqx-get-project-uuid $EQXPROJECT`
packet \
project \
delete \
--force \
--id \
$EQXPROJECTID \
2>/dev/null
exit

@ -0,0 +1,4 @@
#!/bin/bash
eqx-get-projects | jq --raw-output '.[] | {name}' | grep name | cut -f 2 -d ":" | sed -e 's/ //g' -e 's/"//g'

@ -0,0 +1,31 @@
#!/bin/bash
# eqx-get-project-uuid
#
# XXX not real stable way to do this...
#
# Get project UUID from a name
#
# Usage:
# eqx-get-project-uuid [name]
# Example:
# eqx-get-project-uuid fooproject
EQXPROJECT="$1"
if [[ $1 == "" ]]
then \
echo -e "Need project name, such as:\n"
eqx-get-project-names
echo
exit
fi
# XXX this...
packet \
project \
get \
--project $EQXPROJECT \
2>/dev/null | \
grep -w " $EQXPROJECT " | \
cut -f 2 -d " "

@ -0,0 +1,3 @@
{
"token": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
Loading…
Cancel
Save