@@ -142,7 +142,7 @@ def get_or_create_model(self, manufacturer_id):
142142 model_id = self .get_model (self .model )
143143 return model_id
144144
145- def post_hardware (self , serial_number , model_id , status_id = 2 , company_id = 1 ):
145+ def post_hardware (self , serial_number , model_id , status_id , company_id ):
146146 endpoint = 'hardware'
147147 payload = {
148148 'serial' : serial_number ,
@@ -180,7 +180,7 @@ def get_hardware(self, serial_number):
180180 print ("No hardware found in database, perhaps create a new one?" )
181181 return None
182182
183- def patch_hardware (self , hardware_id , serial_number , model_id , status_id = 2 , company_id = 1 ):
183+ def patch_hardware (self , hardware_id , serial_number , model_id , status_id , company_id ):
184184 endpoint = f'hardware/{ hardware_id } ?deleted=false'
185185 payload = {
186186 'serial' : serial_number ,
@@ -207,17 +207,17 @@ def patch_hardware(self, hardware_id, serial_number, model_id, status_id=2, comp
207207 print (f"Failed to update hardware: { response .get ('messages' )} " )
208208 return False
209209
210- def get_or_create_hardware (self , model_id , update_hardware ):
210+ def get_or_create_hardware (self , model_id , update_hardware , status_id = 2 , company_id = 1 ):
211211 hardware_id = self .get_hardware (self .serial_number )
212212 if hardware_id is None :
213213 print ("Creating new hardware" )
214214 update_hardware = False
215- success = self .post_hardware (self .serial_number , model_id )
215+ success = self .post_hardware (self .serial_number , model_id , status_id , company_id )
216216 if success :
217217 hardware_id = self .get_hardware (self .serial_number )
218218 if update_hardware :
219219 print ("Patching hardware" )
220- self .patch_hardware (hardware_id , self .serial_number , model_id )
220+ self .patch_hardware (hardware_id , self .serial_number , model_id , status_id , company_id )
221221 return hardware_id
222222
223223# Resolve pyinstaller's stoopid windows executable path issue
@@ -297,8 +297,10 @@ def main():
297297 print ("Model fetched: " , model_id )
298298
299299 # Get the hardware, if it exists, update it properly.
300+ snipeit_status_id = config ['GENERAL' ]['snipeit_status_id' ]
301+ snipeit_company_id = config ['GENERAL' ]['snipeit_company_id' ]
300302 update_hardware = True
301- hardware_id = it_client .get_or_create_hardware (model_id , update_hardware )
303+ hardware_id = it_client .get_or_create_hardware (model_id , update_hardware , snipeit_status_id , snipeit_company_id )
302304 if hardware_id is None :
303305 return print ("Failed to fetch hardware" )
304306 print ("Hardware fetched: " , hardware_id )
0 commit comments