Skip to content

Commit

Permalink
Merge pull request #665 from deNBI/refactor/metadata_write_token
Browse files Browse the repository at this point in the history
refactor(Metadata):renamed metadata server token to metadata_write_to…
  • Loading branch information
vktrrdk authored Jan 6, 2025
2 parents f5443e1 + 78fff05 commit c18fd67
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions simple_vm_client/metadata_connector/metadata_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ def load_config_yml(self, config_file: str) -> None:

def load_env_config(self):
required_keys = [
"METADATA_SERVER_TOKEN",
"METADATA_WRITE_TOKEN",
]
missing_keys = [key for key in required_keys if key not in os.environ]
if missing_keys:
missing_keys_str = ", ".join(missing_keys)
logger.error(
f"MetadataServer missing keys {missing_keys_str} not provided in env!"
)
self.METADATA_SERVER_TOKEN = os.environ.get("METADATA_SERVER_TOKEN")
self.METADATA_WRITE_TOKEN = os.environ.get("METADATA_WRITE_TOKEN")
logger.info("Metadata Environment loaded")

def remove_metadata(self, ip: str):
Expand All @@ -74,8 +74,8 @@ def remove_metadata(self, ip: str):
remove_metadata_url,
timeout=(30, 30),
headers={
"X-Auth-Token": self.METADATA_SERVER_TOKEN,
}
"X-Auth-Token": self.METADATA_WRITE_TOKEN,
},
)
response.raise_for_status()
logger.info(f"Metadata removed successfully for {ip}")
Expand All @@ -102,9 +102,9 @@ def set_metadata(self, ip: str, metadata: VirtualMachineServerMetadata):
data=serialized_data,
timeout=(30, 30),
headers={
"X-Auth-Token": self.METADATA_SERVER_TOKEN,
"X-Auth-Token": self.METADATA_WRITE_TOKEN,
"Content-Type": "application/json",
}
},
)
response.raise_for_status()
logger.info(f"Metadata set successfully for {ip}")
Expand All @@ -121,10 +121,7 @@ def is_metadata_server_available(self):
health_url = urljoin(self.METADATA_BASE_URL, "health")

try:
response = requests.get(
health_url,
timeout=(30, 30)
)
response = requests.get(health_url, timeout=(30, 30))
response.raise_for_status()
logger.info(f"Metadata Health Check --- {response.json()}")
return True
Expand Down

0 comments on commit c18fd67

Please sign in to comment.