...
 
Commits (3)
......@@ -23,6 +23,7 @@ class ITLoad:
vram: int
vdisk: int
vc_tag: Optional[str] = None
already_gone: bool = False
Schema: ClassVar[Type[Schema]] = Schema # for mypy
......@@ -65,6 +66,7 @@ class ITLoadSourceMock(ITLoadSource):
class ITLoadSourceFile(ITLoadSource):
def __init__(self, path):
self._path = path
self._it_loads = None
@dataclass
class ITLoadFromFile:
......@@ -79,9 +81,12 @@ class ITLoadSourceFile(ITLoadSource):
vdisk=self.disk)
async def get_it_loads(self):
with open(self._path) as itl_file:
raw_json = json.load(itl_file)
return [self.ITLoadFromFile.Schema().load(item).to_itl() for item in raw_json]
if not self._it_loads:
with open(self._path) as itl_file:
raw_json = json.load(itl_file)
self._it_loads = [self.ITLoadFromFile.Schema().load(item).to_itl() for item in raw_json]
return self._it_loads
......
......@@ -392,6 +392,7 @@ class EOPlanSourceHttp(EOPlanSource):
]
whole_plans = [EOPlan(None, shifting_plan, None) for shifting_plan in shifting_plans_for_relocation]
# return [whole_plans[0]]
return whole_plans
except Exception:
log.exception("Exception while querying eo plan notification")
......
......@@ -228,6 +228,7 @@ class ITLBClientDaemon:
log.info("Start handling relocate plan")
eo_plan = eo_plan_impl.eo_plan
available_it_loads = await self._db_api_client.get_it_loads()
available_it_loads = [itl for itl in available_it_loads if not itl.already_gone]
ips_to_offer = []
needed_watts = eo_plan.relocate.power_watts
remaining_needed_watts = needed_watts
......@@ -287,6 +288,10 @@ class ITLBClientDaemon:
migration_request = await self._to_migration_request(eo_plan.relocate.move_from_date, eo_plan.relocate.end,
[ips.itl for ips in ips_to_offer])
# Mark ITLs as migrated, so no longer there
for ips in ips_to_offer:
ips.itl.already_gone = True
eo_plan_impl.all_it_loads = itl_powers_sla
eo_plan_impl.migration_request = [ProposedMigrationRequestItem(req, status='submitted')
for req in migration_request]
......