Skip to content

Commit

Permalink
Merge pull request #23 from threefoldtech/development-v3-runmodes
Browse files Browse the repository at this point in the history
config: add run modes as config dictionnary
  • Loading branch information
maxux authored Mar 9, 2023
2 parents 3885ccb + 0957989 commit ca84bbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
15 changes: 4 additions & 11 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@
app = Flask(__name__, static_url_path='/static')
app.url_map.strict_slashes = False

runmodes = {
"prod": "production (v3)",
"test": "testing (v3)",
"dev": "development (v3)",
"qa": "qa-network (v3)",
}

#
# Database
#
Expand Down Expand Up @@ -67,7 +60,7 @@ def ipxe_script(release, farmer, extra="", source=None):

kernel = os.path.join(config['kernel-path'], source)

if release not in runmodes.keys():
if release not in config['runmodes'].keys():
abort(401)

if not os.path.exists(kernel):
Expand All @@ -86,7 +79,7 @@ def ipxe_script(release, farmer, extra="", source=None):


settings = {
"release": runmodes[release],
"release": config['runmodes'][release],
"farmerid": farmer,
"parameters": extra,
"kernel": kernel_secure,
Expand All @@ -102,7 +95,7 @@ def ipxe_quick_script(release, farmer, extra=""):
source = 'zero-os-development-zos-v2-generic.efi'
kernel = os.path.join(config['kernel-path'], source)

if release not in runmodes.keys():
if release not in config['runmodes'].keys():
abort(401)

if not os.path.exists(kernel):
Expand All @@ -118,7 +111,7 @@ def ipxe_quick_script(release, farmer, extra=""):
cmdline += " " + extra

settings = {
"release": runmodes[release],
"release": config['runmodes'][release],
"parameters": extra,
"kernel": kernel,
"cmdline": cmdline,
Expand Down
9 changes: 9 additions & 0 deletions config.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ config = {

# sqlite3 database used for provisioning
'bootstrap-db': 'db/bootstrap.sqlite3',

# allowed run-modes and their pretty name
'runmodes': {
"prod": "production (v3)",
"test": "testing (v3)",
"dev": "development (v3)",
"qa": "qa-network (v3)",
},

}

0 comments on commit ca84bbc

Please sign in to comment.