Obtain vm_id from multiple line items
- Remove empty string from VM_IDs string - If more than one is present, check all of them are the same If same return, the unique value Else return none, as we don't handle this case
This commit is contained in:
parent
9f13253475
commit
44ffd042a6
1 changed files with 7 additions and 3 deletions
|
@ -390,14 +390,18 @@ class MonthlyHostingBill(AssignPermissionsMixin, models.Model):
|
||||||
if len(self.lines_meta_data_csv) > 0:
|
if len(self.lines_meta_data_csv) > 0:
|
||||||
vm_ids = [vm_id.strip() for vm_id in
|
vm_ids = [vm_id.strip() for vm_id in
|
||||||
self.lines_meta_data_csv.split(",")]
|
self.lines_meta_data_csv.split(",")]
|
||||||
if len(vm_ids) == 1:
|
unique_vm_ids=set(vm_ids)
|
||||||
return vm_ids[0]
|
unique_vm_ids.discard("")
|
||||||
|
if len(unique_vm_ids) == 1:
|
||||||
|
vm_id = unique_vm_ids.pop()
|
||||||
|
logger.debug("Getting invoice for {}".format(vm_id))
|
||||||
|
return vm_id
|
||||||
else:
|
else:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"More than one VM_ID"
|
"More than one VM_ID"
|
||||||
"for MonthlyHostingBill {}".format(self.invoice_id)
|
"for MonthlyHostingBill {}".format(self.invoice_id)
|
||||||
)
|
)
|
||||||
logger.debug("VM_IDS={}".format(','.join(vm_ids)))
|
logger.debug("VM_IDS={}".format(unique_vm_ids))
|
||||||
return return_value
|
return return_value
|
||||||
|
|
||||||
def get_period_start(self):
|
def get_period_start(self):
|
||||||
|
|
Loading…
Reference in a new issue