diff options
author | Justin Choquette <jchoquette@iol.unh.edu> | 2023-06-08 12:46:53 -0400 |
---|---|---|
committer | Justin Choquette <jchoquette@iol.unh.edu> | 2023-07-21 13:17:51 -0400 |
commit | a09db9f287a02873c0226759f8ea444bb304cd59 (patch) | |
tree | 59e744e4b998973a808abbae2d21fbdd6201d829 /src/laas_dashboard/model_test.py | |
parent | 8ddc7e820e120f1dde4e901d3cb6f1dd3f281e65 (diff) |
LaaS 3.0 Almost MVP
Change-Id: Ided9a43cf3088bb58a233dc459711c03f43e11b8
Signed-off-by: Justin Choquette <jchoquette@iol.unh.edu>
Diffstat (limited to 'src/laas_dashboard/model_test.py')
-rw-r--r-- | src/laas_dashboard/model_test.py | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/src/laas_dashboard/model_test.py b/src/laas_dashboard/model_test.py deleted file mode 100644 index ba3ef35..0000000 --- a/src/laas_dashboard/model_test.py +++ /dev/null @@ -1,110 +0,0 @@ -############################################################################## -# Copyright (c) 2020 Sawyer Bergeron, Parker Berberian, Sean Smith, and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from resource_inventory.models import ( - ResourceProfile, - ResourceQuery, - Image, - DiskProfile, - CpuProfile, - RamProfile, - InterfaceProfile, -) - - -def rp_has_all_components(): - """ - Check that every ResourceProfile has an InterfaceProfile, - DiskProfile, CpuProfile, and RamProfile. - """ - - result = True - - for rp in ResourceProfile.objects.all(): - ip = InterfaceProfile.objects.filter(host=rp).exists() - dp = DiskProfile.objects.filter(host=rp).exists() - cp = CpuProfile.objects.filter(host=rp).exists() - ram = RamProfile.objects.filter(host=rp).exists() - - if not ip: - print("No InterfaceProfiles for host", rp.name) - result = False - - if not dp: - print("No DiskProfile for host", rp.name) - result = False - - if not cp: - print("No CpuProfile for host", rp.name) - result = False - - if not ram: - print("No RamProfile for host", rp.name) - result = False - - return result - - -def ip_for_all_ifaces(): - """ - Check that every InterfaceProfile for a Resource has - an Interface. - """ - - result = True - - for res in ResourceQuery.filter(): - iface_set = res.get_interfaces() - iface_profile_set = InterfaceProfile.objects.filter(host=res.profile) - - # find out what profiles we have - curr_profiles = [iface.profile for iface in iface_set] - missing_profiles = set(iface_profile_set) - set(curr_profiles) - - if missing_profiles: - print('No interface for profiles', missing_profiles, 'for host', res.name) - result = False - - return result - - -def rp_has_image(): - """ - Make sure every ResourceProfile has an Image. - """ - - result = True - - rp_set = ResourceProfile.objects.all() - image_set = Image.objects.all() - image_profiles = set([image.host_type for image in image_set]) - - for rp in rp_set: - if rp not in image_profiles: - print("ResourceProfile", rp.name, "has no image associated with it.") - result = False - return result - - -def run_test(test): - print('RUNNING TEST', test) - result = test() - if result: - print(test, 'WAS A SUCCESS!') - else: - print(test, 'FAILED') - print('============================================') - - -def run_tests(): - tests = [rp_has_all_components, ip_for_all_ifaces, rp_has_image] - - for test in tests: - run_test(test) |