Fixing offline deployment a bit

This commit is contained in:
Anton Hvornum 2019-11-29 13:21:39 +01:00
parent d89bacdf9f
commit a83b21ec01
1 changed files with 28 additions and 20 deletions

View File

@ -696,13 +696,8 @@ def get_application_instructions(target):
return instructions return instructions
def get_instructions(target, *positionals, **kwargs): def get_local_instructions(target):
instructions = oDict() instructions = oDict()
try:
instructions = grab_url_data('{}/{}.json'.format(args['profiles-path'], target)).decode('UTF-8')
print('[N] Found net-deploy instructions called: {}'.format(target))
except urllib.error.HTTPError:
print('[N] Could not find remote instructions. Trying local instructions under ./deployments')
local_path = './deployments' if os.path.isfile('./archinstall.py') else './archinstall/deployments' # Dangerous assumption local_path = './deployments' if os.path.isfile('./archinstall.py') else './archinstall/deployments' # Dangerous assumption
if os.path.isfile(f'{local_path}/{target}.json'): if os.path.isfile(f'{local_path}/{target}.json'):
with open(f'{local_path}/{target}.json', 'r') as fh: with open(f'{local_path}/{target}.json', 'r') as fh:
@ -713,6 +708,19 @@ def get_instructions(target, *positionals, **kwargs):
print('[N] No instructions found called: {}'.format(target)) print('[N] No instructions found called: {}'.format(target))
return instructions return instructions
def get_instructions(target, *positionals, **kwargs):
instructions = oDict()
if get_default_gateway_linux():
try:
instructions = grab_url_data('{}/{}.json'.format(args['profiles-path'], target)).decode('UTF-8')
print('[N] Found net-deploy instructions called: {}'.format(target))
except urllib.error.HTTPError:
print('[N] Could not find remote instructions. Trying local instructions under ./deployments')
isntructions = get_local_instructions(target, *positionals)
else:
isntructions = get_local_instructions(target, *positionals)
if type(instructions) in (dict, oDict):
try: try:
instructions = json.loads(instructions, object_pairs_hook=oDict) instructions = json.loads(instructions, object_pairs_hook=oDict)
except: except: