@@ -500,7 +500,7 @@ def create_or_update(self):
500500 errorcode = None
501501 message = None
502502 err_str = str (err )
503- regex_string = re .search (r' status_code:\s*(\d+)' , err_str )
503+ regex_string = re .search (r" status_code:\s*(\d+)" , err_str )
504504 if regex_string :
505505 status_code = int (regex_string .group (1 ))
506506 regex_string = re .search (r"'errorcode':\s*(\d+)" , err_str )
@@ -510,9 +510,9 @@ def create_or_update(self):
510510 if regex_string :
511511 message = regex_string .group (1 )
512512 if not (
513- status_code == 599 and
514- errorcode == 1065 and
515- message == "Internal error while adding HSM key."
513+ status_code == 599
514+ and errorcode == 1065
515+ and message == "Internal error while adding HSM key."
516516 ):
517517 self .return_failure (err )
518518
@@ -580,15 +580,43 @@ def create_or_update(self):
580580 "INFO: Resource %s:%s exists and is different. Will be REMOVED and ADDED."
581581 % (self .resource_name , self .resource_id )
582582 )
583- if self .resource_name == "systemfile" :
584- # If the systemfile is present, we will delete it and add it again
585- self .delete ()
586- ok , err = create_resource (
587- self .client , self .resource_name , self .resource_module_params
588- )
589- if not ok :
590- self .return_failure (err )
591-
583+ # If the systemfile is present, we will delete it and add it again
584+ self .delete ()
585+ ok , err = create_resource (
586+ self .client , self .resource_name , self .resource_module_params
587+ )
588+ if not ok :
589+ self .return_failure (err )
590+ elif self .resource_name == "location" :
591+ # TODO: primary composite key needs to be added.
592+ # location resource has composite primary key. 1.ipfrom 2.ipto
593+ ok , err = create_resource (
594+ self .client , self .resource_name , self .resource_module_params
595+ )
596+ if not ok :
597+ self .return_failure (err )
598+ # elif self.resource_name == "bfdinterface":
599+ # # bfgInterface does not have primary key. Hence, we will check if the name is same and decide update or create
600+ # if self.resource_module_params.get("name", "") == self.existing_resource.get("name", ""):
601+ # log(
602+ # "INFO: Resource %s:%s exists and is different. Will be UPDATED."
603+ # % (self.resource_name, self.resource_id)
604+ # )
605+ # ok, err = update_resource(
606+ # self.client, self.resource_name, self.resource_module_params
607+ # )
608+ # if not ok:
609+ # self.return_failure(err)
610+ # else:
611+ # log(
612+ # "INFO: Resource %s:%s doesn't exist. Will be CREATED."
613+ # % (self.resource_name, self.resource_id)
614+ # )
615+ # ok, err = create_resource(
616+ # self.client, self.resource_name, self.resource_module_params
617+ # )
618+ # if not ok:
619+ # self.return_failure(err)
592620 elif self .resource_name .endswith ("_binding" ):
593621 # Generally bindings are not updated. They are removed and added again.
594622 log (
@@ -707,7 +735,7 @@ def delete(self):
707735 errorcode = None
708736 message = None
709737 err_str = str (err )
710- regex_string = re .search (r' status_code:\s*(\d+)' , err_str )
738+ regex_string = re .search (r" status_code:\s*(\d+)" , err_str )
711739 if regex_string :
712740 status_code = int (regex_string .group (1 ))
713741 regex_string = re .search (r"'errorcode':\s*(\d+)" , err_str )
@@ -717,9 +745,9 @@ def delete(self):
717745 if regex_string :
718746 message = regex_string .group (1 )
719747 if not (
720- status_code == 599 and
721- errorcode == 1065 and
722- message == "Internal error while adding HSM key."
748+ status_code == 599
749+ and errorcode == 1065
750+ and message == "Internal error while adding HSM key."
723751 ):
724752 self .return_failure (err )
725753 else :
0 commit comments