forked from cpanel/elevate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from cpanel/RE-745_path_fix
Re 745 path fix
- Loading branch information
Showing
27 changed files
with
951 additions
and
58 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
OWNER=cpanel | ||
REPO=elevate-actions | ||
COMMIT=dcba4f168b5aa17dc46fe04e8ba00691580765ba | ||
CHECK_NAME="Dave Check" | ||
|
||
gh api \ | ||
--method POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
/repos/${OWNER}/${REPO}/check-runs \ | ||
-f "name=${CHECK_NAME}" \ | ||
-f "head_sha=${COMMIT}" \ | ||
-f "status=in_progress" \ | ||
-f "external_id=42" \ | ||
-f "started_at=2018-05-04T01:14:52Z" \ | ||
-f "output[title]=The Report of all reports" \ | ||
-f "output[summary]=Things went boomski" \ | ||
-f "output[text]=May want to run another check, there, boss." |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env bash | ||
|
||
export OS_AUTH_TYPE=v3applicationcredential | ||
export OS_AUTH_URL=https://keystone.hou-01.cloud.prod.cpanel.net:5000/v3 | ||
export OS_IDENTITY_API_VERSION=3 | ||
export OS_REGION_NAME="RegionOne" | ||
export OS_INTERFACE=public | ||
export OS_APPLICATION_CREDENTIAL_ID=${{ secrets.OS_APPLICATION_CREDENTIAL_ID }} | ||
export OS_APPLICATION_CREDENTIAL_SECRET=${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }} | ||
|
||
# two hours ago | ||
HAMMER_TIME=$(date -d '-2 hour' --utc +"%Y-%m-%dT%H:%M:%SZ") | ||
|
||
get_elevatebcl_instances () { | ||
LIST=$(openstack server list -f json --no-name-lookup | jq -r .[].ID) | ||
rm id_created_name.txt > /dev/null 2>&1 | ||
while IFS= read -r VM; do | ||
openstack server show -f json "$VM" | jq -r '.id + "," + .created + "," + .name' | grep packer >> id_created_name.txt | ||
done <<< "$LIST" | ||
} | ||
|
||
remove_stale_instances () { | ||
echo "HAMMERTIME: $HAMMER_TIME" | ||
while IFS="," read -r ID CREATED_DATE NAME | ||
do | ||
if [[ $CREATED_DATE < $HAMMER_TIME ]]; | ||
then | ||
echo "deleting: $ID,$CREATED_DATE,$NAME" | ||
openstack server delete "$ID" | ||
fi | ||
done < <(cat id_created_name.txt) | ||
} | ||
|
||
get_keys () { | ||
LIST=$(openstack keypair list -f json | jq -r .[].Name) | ||
rm keyid_created_name.txt > /dev/null 2>&1 | ||
while IFS= read -r KEYPAIR; do | ||
openstack keypair show -f json "$KEYPAIR" | jq -r '.id + "," + .created_at + "," + .name' | grep deletethis >> keyid_created_name.txt | ||
done <<< "$LIST" | ||
} | ||
|
||
remove_stale_keys () { | ||
echo "HAMMERTIME: $HAMMER_TIME" | ||
while IFS="," read -r ID CREATED_DATE NAME | ||
do | ||
if [[ $CREATED_DATE < $HAMMER_TIME ]]; | ||
then | ||
echo "deleting: $ID,$CREATED_DATE,$NAME" | ||
openstack keypair delete "$ID" | ||
fi | ||
done < <(cat keyid_created_name.txt) | ||
} | ||
|
||
get_volumes () { | ||
rm volume_ids.txt > /dev/null 2>&1 | ||
openstack volume list | grep packer | grep available | awk '{print $2}' >> volume_ids.txt | ||
} | ||
|
||
remove_volumes () { | ||
while IFS= read -r ID; do | ||
openstack volume delete "$ID" || true | ||
done < <(cat volume_ids.txt) | ||
} | ||
|
||
# prune VMs | ||
get_packer_instances | ||
remove_stale_instances | ||
# prune keys | ||
get_keys | ||
remove_stale_keys | ||
# prune volumes | ||
get_volumes | ||
remove_volumes |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Openstack Pruner | ||
run-name: Openstack Pruner | ||
on: | ||
schedule: | ||
- cron: '*/5 * * * *' | ||
jobs: | ||
run-pruner: | ||
runs-on: [self-hosted] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run Openstack Pruner | ||
run: ./.github/workflows/openstack/prune_openstack |
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
Oops, something went wrong.