-
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.
chore: Quick bootstrap script to deploy/destroy DO project
- Loading branch information
1 parent
87389ef
commit 6b46552
Showing
1 changed file
with
42 additions
and
0 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,42 @@ | ||
# Copyright (c) 2024, Frappe and contributors | ||
# For license information, please see license.txt | ||
|
||
import frappe | ||
|
||
PROVIDER = "do" | ||
DO_ACCESS_TOKEN = "" | ||
CIDR = "10.10.0.0/24" | ||
REGION = "blr1" | ||
TITLE = "Bangalore" | ||
NAME = "do-bangalore-blr1" | ||
|
||
|
||
def create(): | ||
if frappe.db.exists("Region", NAME): | ||
region = frappe.get_doc("Region", NAME) | ||
else: | ||
region = frappe.new_doc( | ||
"Region", | ||
**{ | ||
"name": NAME, | ||
"access_token": DO_ACCESS_TOKEN, | ||
"cloud_provider": PROVIDER, | ||
"region_slug": REGION, | ||
"title": TITLE, | ||
"vpc_cidr_block": CIDR, | ||
}, | ||
).insert() | ||
|
||
region.provision() | ||
|
||
|
||
def destroy(): | ||
if frappe.db.exists("Region", NAME): | ||
region = frappe.get_doc("Region", NAME) | ||
region.destroy() | ||
|
||
|
||
def clear(): | ||
doctypes = ["Provision Declaration", "Provision Plan", "Provision State", "Provision Action"] | ||
for doctype in doctypes: | ||
frappe.db.delete(doctype) |