def _xml_ele_to_obj(cls, element): flavor_dict = element.attrib # XML data types differ from JSON, so we normalize here if 'vcpus' in flavor_dict: flavor_dict['vcpus'] = (flavor_dict.get('vcpus') and int(flavor_dict.get('vcpus'))) if 'disk' in flavor_dict: flavor_dict['disk'] = (flavor_dict.get('disk') and int(flavor_dict.get('disk'))) if 'rxtx_factor' in flavor_dict: flavor_dict['rxtx_factor'] = \ (flavor_dict.get('rxtx_factor') and float(flavor_dict.get('rxtx_factor'))) if 'ram' in flavor_dict: flavor_dict['ram'] = (flavor_dict.get('ram') and int(flavor_dict.get('ram'))) if 'swap' in flavor_dict: flavor_dict['swap'] = (flavor_dict.get('swap') and int(flavor_dict.get('swap'))) if 'ephemeral' in flavor_dict: flavor_dict['ephemeral'] = (flavor_dict.get('ephemeral') and int(flavor_dict.get('ephemeral'))) links = Links._xml_ele_to_obj(element) specs = element.find('extra_specs') extra_specs = (FlavorExtraSpecs._xml_ele_to_obj(specs) if specs is not None else None) flavor = Flavor(id=flavor_dict.get('id'), name=flavor_dict.get('name'), ram=flavor_dict.get('ram'), disk=flavor_dict.get('disk'), vcpus=flavor_dict.get('vcpus'), swap=flavor_dict.get('swap'), rxtx_factor=flavor_dict.get('rxtx_factor'), links=links, ephemeral_disk=flavor_dict.get('ephemeral'), extra_specs=extra_specs) return flavor
def _xml_ele_to_obj(cls, element): flavor_dict = element.attrib # XML data types differ from JSON, so we normalize here if 'vcpus' in flavor_dict: flavor_dict['vcpus'] = (flavor_dict.get('vcpus') and int(flavor_dict.get('vcpus'))) if 'disk' in flavor_dict: flavor_dict['disk'] = (flavor_dict.get('disk') and int(flavor_dict.get('disk'))) if 'rxtx_factor' in flavor_dict: flavor_dict['rxtx_factor'] = \ (flavor_dict.get('rxtx_factor') and float(flavor_dict.get('rxtx_factor'))) if 'ram' in flavor_dict: flavor_dict['ram'] = (flavor_dict.get('ram') and int(flavor_dict.get('ram'))) if 'swap' in flavor_dict: flavor_dict['swap'] = (flavor_dict.get('swap') and int(flavor_dict.get('swap'))) if 'ephemeral' in flavor_dict: flavor_dict['ephemeral'] = (flavor_dict.get('ephemeral') and int(flavor_dict.get('ephemeral'))) links = Links._xml_ele_to_obj(element) specs = element.find('extra_specs') extra_specs = (FlavorExtraSpecs._xml_ele_to_obj(specs) if specs is not None else None) flavor = Flavor( id=flavor_dict.get('id'), name=flavor_dict.get('name'), ram=flavor_dict.get('ram'), disk=flavor_dict.get('disk'), vcpus=flavor_dict.get('vcpus'), swap=flavor_dict.get('swap'), rxtx_factor=flavor_dict.get('rxtx_factor'), links=links, ephemeral_disk=flavor_dict.get('ephemeral'), extra_specs=extra_specs) return flavor