self.http_code = http_code
super(Exception, self).__init__(message)
+
class NBIBadArgumentsException(Exception):
"""
Bad argument values exception
self.bad_args = bad_args
def __str__(self):
- return "{}, Bad arguments: {}".format(
- self.message, self.bad_args
- )
+ return "{}, Bad arguments: {}".format(self.message, self.bad_args)
+
def deep_get(target_dict, key_list):
"""
return target_dict
-def detect_descriptor_usage(
- descriptor: dict, db_collection: str, db: object
-) -> bool:
+def detect_descriptor_usage(descriptor: dict, db_collection: str, db: object) -> bool:
"""Detect the descriptor usage state.
Args:
}
if db_collection not in search_dict:
- raise NBIBadArgumentsException("db_collection should be equal to vnfds or nsds", "db_collection")
+ raise NBIBadArgumentsException(
+ "db_collection should be equal to vnfds or nsds", "db_collection"
+ )
record_list = db.get_list(
search_dict[db_collection][0],
return True
except (DbException, KeyError, NBIBadArgumentsException) as error:
- raise EngineException(f"Error occured while detecting the descriptor usage: {error}")
+ raise EngineException(
+ f"Error occured while detecting the descriptor usage: {error}"
+ )
def update_descriptor_usage_state(
"_admin.usageState": "IN_USE",
}
- db.set_one(db_collection, {"_id": descriptor["_id"]}, update_dict=descriptor_update)
+ db.set_one(
+ db_collection, {"_id": descriptor["_id"]}, update_dict=descriptor_update
+ )
except (DbException, KeyError, NBIBadArgumentsException) as error:
- raise EngineException(f"Error occured while updating the descriptor usage state: {error}")
+ raise EngineException(
+ f"Error occured while updating the descriptor usage state: {error}"
+ )
def get_iterable(input_var):