Skip to content

Commit 6b46552

Browse files
committed
chore: Quick bootstrap script to deploy/destroy DO project
1 parent 87389ef commit 6b46552

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

pilot/provision/bootstrap.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright (c) 2024, Frappe and contributors
2+
# For license information, please see license.txt
3+
4+
import frappe
5+
6+
PROVIDER = "do"
7+
DO_ACCESS_TOKEN = ""
8+
CIDR = "10.10.0.0/24"
9+
REGION = "blr1"
10+
TITLE = "Bangalore"
11+
NAME = "do-bangalore-blr1"
12+
13+
14+
def create():
15+
if frappe.db.exists("Region", NAME):
16+
region = frappe.get_doc("Region", NAME)
17+
else:
18+
region = frappe.new_doc(
19+
"Region",
20+
**{
21+
"name": NAME,
22+
"access_token": DO_ACCESS_TOKEN,
23+
"cloud_provider": PROVIDER,
24+
"region_slug": REGION,
25+
"title": TITLE,
26+
"vpc_cidr_block": CIDR,
27+
},
28+
).insert()
29+
30+
region.provision()
31+
32+
33+
def destroy():
34+
if frappe.db.exists("Region", NAME):
35+
region = frappe.get_doc("Region", NAME)
36+
region.destroy()
37+
38+
39+
def clear():
40+
doctypes = ["Provision Declaration", "Provision Plan", "Provision State", "Provision Action"]
41+
for doctype in doctypes:
42+
frappe.db.delete(doctype)

0 commit comments

Comments
 (0)