Use absolute paths

This commit is contained in:
PCoder 2020-12-10 08:56:34 +05:30
parent 785091e4ff
commit 01d8cc1b9b

View file

@ -28,8 +28,9 @@ class Command(BaseCommand):
specs = {'cpu': 1, 'memory': 1, 'disk_size': 10} specs = {'cpu': 1, 'memory': 1, 'disk_size': 10}
manager = OpenNebulaManager(email=user_email, password=cu.password) manager = OpenNebulaManager(email=user_email, password=cu.password)
pub_keys = [settings.TEST_MANAGE_SSH_KEY_PUBKEY] pub_keys = [settings.TEST_MANAGE_SSH_KEY_PUBKEY]
if not os.path.exists("outputs"): PROJECT_PATH = os.path.abspath(os.path.dirname(__name__))
os.mkdir("outputs") if not os.path.exists("%s/outputs" % PROJECT_PATH):
os.mkdir("%s/outputs" % PROJECT_PATH)
for vm_template in VMTemplate.objects.all(): for vm_template in VMTemplate.objects.all():
vm_name = 'test-%s' % vm_template.name vm_name = 'test-%s' % vm_template.name
vm_id = manager.create_vm( vm_id = manager.create_vm(
@ -54,7 +55,9 @@ class Command(BaseCommand):
date_str = datetime.datetime.strftime( date_str = datetime.datetime.strftime(
datetime.datetime.now(), '%Y%m%d%H%M%S' datetime.datetime.now(), '%Y%m%d%H%M%S'
) )
with open("output/check_vm_templates_%s.txt" % date_str, 'w', with open("%s/outputs/check_vm_templates_%s.txt" %
(PROJECT_PATH, date_str),
'w',
encoding='utf-8') as f: encoding='utf-8') as f:
f.write(json.dumps(result_dict)) f.write(json.dumps(result_dict))
else: else: