@@ -103,7 +103,10 @@ def _configure(self, data: Dict[str, Any]) -> ConfigureStatus:
103103 Returns:
104104 The job ID to track its status alongside the initial status.
105105 """
106- log .debug ("Received the following data to create/modify: %s" % json .dumps (data , indent = 2 ))
106+ if log .isEnabledFor (logging .DEBUG ):
107+ log .debug (
108+ "Received the following data to create/modify: %s" , json .dumps (data , indent = 2 )
109+ )
107110 resp = self .session .post (path = "configure" , json = data )
108111 self ._raise_for_status (response = resp )
109112 rsp_data = resp .json ()
@@ -121,17 +124,19 @@ def _query_job_details(self, job_id: str) -> ConfigureStatus:
121124 Returns:
122125 The updated job status.
123126 """
124- log .debug (f "Query job details for \" { job_id } \" " )
127+ log .debug ("Query job details for \" %s \" " , job_id )
125128 resp = self .session .get (path = f"configure/{ job_id } /status" )
126129
127130 # We don't want to fail if there's a server error thus we make a fake
128131 # response for it so the query job details will be retried.
129132 if resp .status_code >= 500 :
130133 log .warning (
131134 (
132- f"Got HTTP { resp .status_code } from server when querying job { job_id } status."
133- " Considering the job_status as \" pending\" ."
134- )
135+ "Got HTTP %s from server when querying job %s status."
136+ " Considering the job_status as \" pending\" ." ,
137+ ),
138+ resp .status_code ,
139+ job_id ,
135140 )
136141 return ConfigureStatus .from_json (
137142 {
@@ -177,7 +182,7 @@ def _wait_for_job_completion(self, job_id: str) -> ConfigureStatus:
177182 error_message = f"Job { job_id } failed: \n { job_details .errors } "
178183 self ._raise_error (InvalidStateError , error_message )
179184 elif job_details .job_result == "succeeded" :
180- log .debug (f "Job { job_id } succeeded" )
185+ log .debug ("Job %s succeeded" , job_id )
181186 return job_details
182187
183188 def configure (self , resource : AzureResource ) -> ConfigureStatus :
@@ -194,7 +199,8 @@ def configure(self, resource: AzureResource) -> ConfigureStatus:
194199 "$schema" : self .CONFIGURE_SCHEMA .format (AZURE_API_VERSION = self .AZURE_API_VERSION ),
195200 "resources" : [resource .to_json ()],
196201 }
197- log .debug ("Data to configure: %s" , json .dumps (data , indent = 2 ))
202+ if log .isEnabledFor (logging .DEBUG ):
203+ log .debug ("Data to configure: %s" , json .dumps (data , indent = 2 ))
198204 res = self ._configure (data = data )
199205 return self ._wait_for_job_completion (job_id = res .job_id )
200206
@@ -601,16 +607,18 @@ def publish(self, metadata: AzurePublishingMetadata) -> None:
601607 plan_name = metadata .destination .split ("/" )[- 1 ]
602608 product , plan = self .get_product_plan_by_name (product_name , plan_name )
603609 log .info (
604- "Preparing to associate the image \" %s\" with the plan \" %s\" from product \" %s\" "
605- % (metadata .image_path , plan_name , product_name )
610+ "Preparing to associate the image \" %s\" with the plan \" %s\" from product \" %s\" " ,
611+ metadata .image_path ,
612+ plan_name ,
613+ product_name ,
606614 )
607615
608616 # 2. Retrieve the VM Technical configuration for the given plan
609- log .info ("Retrieving the technical config for \" %s\" ." % metadata .destination )
617+ log .info ("Retrieving the technical config for \" %s\" ." , metadata .destination )
610618 tech_config = self .get_plan_tech_config (product , plan )
611619
612620 # 3. Prepare the Disk Version
613- log .info ("Creating the VMImageResource with SAS for image: \" %s\" " % metadata .image_path )
621+ log .info ("Creating the VMImageResource with SAS for image: \" %s\" " , metadata .image_path )
614622 sas = OSDiskURI (uri = metadata .image_path )
615623 source = VMImageSource (source_type = "sasUri" , os_disk = sas .to_json (), data_disks = [])
616624
@@ -640,8 +648,10 @@ def publish(self, metadata: AzurePublishingMetadata) -> None:
640648 # Check the images of the selected DiskVersion if it exists
641649 if disk_version :
642650 log .info (
643- "DiskVersion \" %s\" exists in \" %s\" for the image \" %s\" ."
644- % (disk_version .version_number , metadata .destination , metadata .image_path )
651+ "DiskVersion \" %s\" exists in \" %s\" for the image \" %s\" ." ,
652+ disk_version .version_number ,
653+ metadata .destination ,
654+ metadata .image_path ,
645655 )
646656 disk_version = set_new_sas_disk_version (disk_version , metadata , source )
647657
@@ -651,20 +661,21 @@ def publish(self, metadata: AzurePublishingMetadata) -> None:
651661 tech_config .disk_versions .append (disk_version )
652662 else :
653663 log .info (
654- "The destination \" %s\" already contains the SAS URI: \" %s\" ."
655- % (metadata .destination , metadata .image_path )
664+ "The destination \" %s\" already contains the SAS URI: \" %s\" ." ,
665+ metadata .destination ,
666+ metadata .image_path ,
656667 )
657668
658669 # 4. With the updated disk_version we should adjust the SKUs and submit the changes
659670 if disk_version :
660- log .info ("Updating SKUs for \" %s\" ." % metadata .destination )
671+ log .info ("Updating SKUs for \" %s\" ." , metadata .destination )
661672 tech_config .skus = update_skus (
662673 disk_versions = tech_config .disk_versions ,
663674 generation = metadata .generation ,
664675 plan_name = plan_name ,
665676 old_skus = tech_config .skus ,
666677 )
667- log .info ("Updating the technical configuration for \" %s\" ." % metadata .destination )
678+ log .info ("Updating the technical configuration for \" %s\" ." , metadata .destination )
668679 self .configure (resource = tech_config )
669680
670681 # 5. Proceed to publishing if it was requested.
0 commit comments