@@ -142,6 +142,7 @@ def setup_and_spinup(
142142 override_base : bool = False ,
143143 vcpus : int = 12 ,
144144 memory : int = 32768 ,
145+ no_depot : bool = False ,
145146 ):
146147 """
147148 Setup and spin up a VM from a kernel workspace name.
@@ -152,6 +153,7 @@ def setup_and_spinup(
152153 override_base: If True, destroy and recreate the VM but override the base image as well
153154 vcpus: Number of virtual CPUs
154155 memory: Memory in MiB
156+ no_depot: If True, skip depot client installation and channel setup
155157
156158 Returns:
157159 VmInstance: The running VM instance
@@ -163,7 +165,7 @@ def setup_and_spinup(
163165 vm .destroy ()
164166
165167 vm .setup (override_base = override_base )
166- vm_instance = vm .spin_up (config = config , vcpus = vcpus , memory = memory )
168+ vm_instance = vm .spin_up (config = config , vcpus = vcpus , memory = memory , no_depot = no_depot )
167169
168170 return vm_instance
169171
@@ -186,7 +188,7 @@ def _download_source_image(self, override_base: bool = False):
186188 logging .info (f"Downloading image from { self ._get_vm_url ()} " )
187189 wget .download (self ._get_vm_url (), out = str (self .qcow2_source_path ))
188190
189- def _setup_cloud_init (self , config : Config ):
191+ def _setup_cloud_init (self , config : Config , no_depot : bool = False ):
190192 yaml = YAML ()
191193 yaml .preserve_quotes = True
192194 yaml .width = 4096
@@ -231,26 +233,29 @@ def _setup_cloud_init(self, config: Config):
231233 )
232234 data ["runcmd" ].append ("dnf clean all" )
233235
234- # Depot: always install the client, but only login+enable if credentials are present
235- data ["runcmd" ].append ("dnf install -y https://depot.ciq.com/public/files/depot-client/depot/depot.x86_64.rpm" )
236- depot_user = os .environ .get ("DEPOT_USER" )
237- depot_token = os .environ .get ("DEPOT_TOKEN" )
238- if depot_user and depot_token and self .depot_channels :
239- data ["runcmd" ].append (f"depot login -u { depot_user } -t { depot_token } " )
240- for channel in self .depot_channels :
241- data ["runcmd" ].append (f"depot enable { channel } -y" )
236+ # Depot: install the client and login+enable if credentials are present
237+ if not no_depot :
238+ data ["runcmd" ].append (
239+ "dnf install -y https://depot.ciq.com/public/files/depot-client/depot/depot.x86_64.rpm"
240+ )
241+ depot_user = os .environ .get ("DEPOT_USER" )
242+ depot_token = os .environ .get ("DEPOT_TOKEN" )
243+ if depot_user and depot_token and self .depot_channels :
244+ data ["runcmd" ].append (f"depot login -u { depot_user } -t { depot_token } " )
245+ for channel in self .depot_channels :
246+ data ["runcmd" ].append (f"depot enable { channel } -y" )
242247
243248 # Install packages needed later
244249 data ["runcmd" ].append ([str (config .base_path / Path ("kernel-src-tree-tools" ) / Path ("kernel_install_dep.sh" ))])
245250 # Write this to image cloud_init
246251 with open (self .cloud_init_path , "w" ) as f :
247252 yaml .dump (data , f )
248253
249- def _create_image (self , config : Config , vcpus : int = 12 , memory : int = 32768 ):
254+ def _create_image (self , config : Config , vcpus : int = 12 , memory : int = 32768 , no_depot : bool = False ):
250255 # Make sure the dir exists
251256 self .qcow2_path .parent .mkdir (parents = True , exist_ok = True )
252257
253- self ._setup_cloud_init (config = config )
258+ self ._setup_cloud_init (config = config , no_depot = no_depot )
254259 # Copy qcow2 image to work dir
255260 self .qcow2_source_path .copy (self .qcow2_path )
256261
@@ -282,11 +287,11 @@ def _resize_disk(self):
282287 def setup (self , override_base : bool = False ):
283288 self ._download_source_image (override_base = override_base )
284289
285- def spin_up (self , config : Config , vcpus : int = 12 , memory : int = 32768 ) -> VmInstance :
290+ def spin_up (self , config : Config , vcpus : int = 12 , memory : int = 32768 , no_depot : bool = False ) -> VmInstance :
286291 if not VirtHelper .exists (vm_name = self .name ):
287292 logging .info (f"VM { self .name } does not exist, creating from scratch..." )
288293
289- self ._create_image (config = config , vcpus = vcpus , memory = memory )
294+ self ._create_image (config = config , vcpus = vcpus , memory = memory , no_depot = no_depot )
290295 return VmInstance (name = self .name , kernel_workspace = self .kernel_workspace )
291296
292297 logging .info (f"Vm { self .name } already exists" )
0 commit comments