mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-15 03:18:07 +00:00
add instance_id generated at install time (#245)
This commit is contained in:
@ -92,6 +92,7 @@ FUNC_TOOLS_ERROR = (
|
||||
|
||||
logger = logging.getLogger("deploy")
|
||||
|
||||
|
||||
def gen_guid():
|
||||
return str(uuid.uuid4())
|
||||
|
||||
@ -464,6 +465,29 @@ class Client:
|
||||
% json.dumps(result.as_dict(), indent=4, sort_keys=True),
|
||||
)
|
||||
|
||||
def add_instance_id(self):
|
||||
logger.info("setting instance_id log export")
|
||||
|
||||
container_name = "base-config"
|
||||
blob_name = "instance_id"
|
||||
account_name = self.results["deploy"]["func-name"]["value"]
|
||||
key = self.results["deploy"]["func-key"]["value"]
|
||||
account_url = "https://%s.blob.core.windows.net" % account_name
|
||||
client = BlobServiceClient(account_url, credential=key)
|
||||
if container_name not in [x["name"] for x in client.list_containers()]:
|
||||
client.create_container(container_name)
|
||||
|
||||
blob_client = client.get_blob_client(container_name, blob_name)
|
||||
if blob_client.exists():
|
||||
logger.debug("instance_id already exists")
|
||||
instance_id = uuid.UUID(blob_client.download_blob().readall())
|
||||
else:
|
||||
logger.debug("creating new instance_id")
|
||||
instance_id = uuid.uuid4()
|
||||
blob_client.upload_blob(str(instance_id))
|
||||
|
||||
logger.info("instance_id: %s", instance_id)
|
||||
|
||||
def add_log_export(self):
|
||||
if not self.export_appinsights:
|
||||
logger.info("not exporting appinsights")
|
||||
@ -683,6 +707,7 @@ def main():
|
||||
("queues", Client.create_queues),
|
||||
("eventgrid", Client.create_eventgrid),
|
||||
("tools", Client.upload_tools),
|
||||
("add_instance_id", Client.add_instance_id),
|
||||
("instance-specific-setup", Client.upload_instance_setup),
|
||||
("third-party", Client.upload_third_party),
|
||||
("api", Client.deploy_app),
|
||||
|
Reference in New Issue
Block a user