Skip to content

Commit

Permalink
get zones from datacenters
Browse files Browse the repository at this point in the history
  • Loading branch information
daroczig committed Dec 27, 2023
1 parent f2d5104 commit 30fbdfe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions sc_crawler/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from .location import Location

from collections import ChainMap
from importlib import import_module
from types import ModuleType
from typing import Dict, List, Literal, Optional, ForwardRef
Expand Down Expand Up @@ -54,9 +55,6 @@ def __init__(self, **kwargs):
raise NotImplementedError("Unsupported vendor")
pass

def get_instance_types(self):
return self._methods.get_instance_types()

def get_datacenters(self, identifiers: [str] = None):
"""Get datacenters of the vendor.
Expand All @@ -74,6 +72,18 @@ def get_datacenters(self, identifiers: [str] = None):
]
return datacenters

def get_zones(self):
"""Get zones of the vendor."""
# make sure datacenters filled in
self._methods.get_datacenters(self)
# unlist
self._zones = dict(
ChainMap(*[datacenter._zones for datacenter in self._datacenters])
)

def get_instance_types(self):
return self._methods.get_instance_types() # TODO


class Datacenter(BaseModel):
identifier: str
Expand Down
2 changes: 1 addition & 1 deletion sc_crawler/vendors/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def get_datacenters(vendor, *args, **kwargs):
]

# make it easier to access by region name
#datacenters = {datacenter.identifier: datacenter for datacenter in datacenters}
# datacenters = {datacenter.identifier: datacenter for datacenter in datacenters}

# add zones
for datacenter in datacenters:
Expand Down

0 comments on commit 30fbdfe

Please sign in to comment.