encode proxy name as base58 to allow full deletion of resources (#907)

This commit is contained in:
bmc-msft
2021-05-21 20:54:17 -04:00
committed by GitHub
parent e7197f1407
commit 6e5f7e4d4c
3 changed files with 13 additions and 2 deletions

View File

@ -14,7 +14,7 @@ from msrestazure.azure_exceptions import CloudError
from onefuzztypes.enums import OS, ErrorCode
from onefuzztypes.models import Authentication, Error
from onefuzztypes.primitives import Extension, Region
from pydantic import BaseModel
from pydantic import BaseModel, validator
from .compute import get_compute_client
from .creds import get_base_resource_group
@ -216,6 +216,15 @@ class VM(BaseModel):
image: str
auth: Authentication
@validator("name", allow_reuse=True)
def check_name(cls, value: Union[UUID, str]) -> Union[UUID, str]:
if isinstance(value, str):
if len(value) > 40:
# Azure truncates resources if the names are longer than 40
# bytes
raise ValueError("VM name too long")
return value
def is_deleted(self) -> bool:
# A VM is considered deleted once all of it's resources including disks,
# NICs, IPs, as well as the VM are deleted