diff --git a/concho/config.py b/concho/config.py index aaebc98..87bf6b1 100644 --- a/concho/config.py +++ b/concho/config.py @@ -363,7 +363,7 @@ class Config(): def get_price(self): price = self.configurator.chassis.price - + print(self.cpu.uid, self.configurator.chassis.price, self.configurator.get_item_price(self.cpu.uid), self.ram_price) price += self.num_servers * self.num_cpu_per_server * self.configurator.get_item_price(self.cpu.uid) + self.ram_price assert price > 0.0 return price diff --git a/concho/hpe.py b/concho/hpe.py index c80872f..6a44f28 100644 --- a/concho/hpe.py +++ b/concho/hpe.py @@ -32,6 +32,12 @@ def parse_cpu_label(label: str) -> str: assert False, 'unhandled label : %s' % label +def hpe_product_get_attr(hpe_product_node: dict, attr_name: str) -> str: + for attr_node in hpe_product_node['attributes']: + if attr_node['id'] == attr_name: + return attr_node['value'] + + class HpeCatalogParser(): def __init__(self, hpe_catalog: dict): @@ -40,9 +46,16 @@ class HpeCatalogParser(): def get_base_price(self): base_price = 0.0 for component_db in self.hpe_catalog: + print('component %s' % component_db['id']) for item_node in component_db['products']: if item_node['selected']: - base_price += float(item_node['price']) + quantity = 1 + # quantity_as_str = item_node['selectedQuantity'] + quantity_as_str = hpe_product_get_attr(item_node, 'selectedQty') + if quantity_as_str: + quantity = int(quantity_as_str) + print('HpeCatalogParser.get_base_price : adding %d * %f (%s)' % (quantity, item_node['price'], item_node['desc'])) + base_price += float(item_node['price']) * quantity return base_price def parse_proc_change_options(self): @@ -365,6 +378,7 @@ class HpeConfiguratorParser(): one_cpu_price = configurator.get_item_price(configurator.base_config.cpu.uid) ram_price = configurator.base_config.ram_price + print('HpeConfiguratorParser.parse : chassis_id=%s cpu.uid = %s, base_price=%f, ram_price=%f' % (chassis_id, configurator.base_config.cpu.uid, base_price, ram_price)) configurator.chassis.price = base_price - configurator.base_config.num_cpus * one_cpu_price - ram_price