def parse_instance(instance_type, product_attributes): i = scrape.Instance() i.instance_type = instance_type pieces = instance_type.split('.') if len(pieces) == 1: # Dedicated host that is not u-*.metal, skipping # May be a good idea to all dedicated hosts in the future return i.family = product_attributes.get('instanceFamily') if '32-bit' in product_attributes.get('processorArchitecture'): i.arch.append('i386') i.vCPU = locale.atoi(product_attributes.get('vcpu')) # Memory is given in form of "1,952 GiB", let's parse it i.memory = locale.atof(product_attributes.get('memory').split(' ')[0]) i.network_performance = product_attributes.get('networkPerformance') if product_attributes.get('currentGeneration') == 'Yes': i.generation = 'current' else: i.generation = 'previous' gpu = product_attributes.get('gpu') if gpu is not None: i.GPU = locale.atoi(gpu) try: ecu = product_attributes.get('ecu') if ecu == 'Variable': i.ECU = 'variable' else: i.ECU = locale.atof(ecu) except: pass i.physical_processor = product_attributes.get('physicalProcessor') # CPU features processor_features = product_attributes.get('processorFeatures') if processor_features is not None: if "Intel AVX512" in processor_features: i.intel_avx512 = True if "Intel AVX2" in processor_features: i.intel_avx2 = True if "Intel AVX" in processor_features: i.intel_avx = True if "Intel Turbo" in processor_features: i.intel_turbo = True i.clock_speed_ghz = product_attributes.get('clockSpeed') enhanced_networking = product_attributes.get('enhancedNetworkingSupported') if enhanced_networking is not None and enhanced_networking == 'Yes': i.enhanced_networking = True return i
def parse_instance(instance_type, product_attributes, api_description): pieces = instance_type.split('.') if len(pieces) == 1: # Dedicated host that is not u-*.metal, skipping # May be a good idea to all dedicated hosts in the future return i = scrape.Instance() i.api_description = api_description i.instance_type = instance_type i.family = product_attributes.get('instanceFamily') i.vCPU = locale.atoi(product_attributes.get('vcpu')) # Memory is given in form of "1,952 GiB", let's parse it i.memory = locale.atof(product_attributes.get('memory').split(' ')[0]) if api_description: i.arch = api_description['ProcessorInfo']['SupportedArchitectures'] i.network_performance = api_description['NetworkInfo'][ 'NetworkPerformance'] else: # Assume x86_64 if there's no DescribeInstanceTypes data. i.arch.append('x86_64') if '32-bit' in product_attributes.get('processorArchitecture'): i.arch.append('i386') i.network_performance = product_attributes.get('networkPerformance') if product_attributes.get('currentGeneration') == 'Yes': i.generation = 'current' else: i.generation = 'previous' gpu = product_attributes.get('gpu') if gpu is not None: i.GPU = locale.atoi(gpu) if api_description: if 'FpgaInfo' in api_description: for fpga in api_description['FpgaInfo']['Fpgas']: i.FPGA += fpga['Count'] netinfo = api_description['NetworkInfo'] if netinfo['EnaSupport'] == 'required': i.ebs_as_nvme = True i.vpc = { 'max_enis': netinfo['MaximumNetworkInterfaces'], 'ips_per_eni': netinfo['Ipv4AddressesPerInterface'] } try: ecu = product_attributes.get('ecu') if ecu == 'Variable': i.ECU = 'variable' else: i.ECU = locale.atof(ecu) except: pass i.physical_processor = product_attributes.get('physicalProcessor') # CPU features processor_features = product_attributes.get('processorFeatures') if processor_features is not None: if "Intel AVX512" in processor_features: i.intel_avx512 = True if "Intel AVX2" in processor_features: i.intel_avx2 = True if "Intel AVX" in processor_features: i.intel_avx = True if "Intel Turbo" in processor_features: i.intel_turbo = True i.clock_speed_ghz = product_attributes.get('clockSpeed') enhanced_networking = product_attributes.get('enhancedNetworkingSupported') if enhanced_networking is not None and enhanced_networking == 'Yes': i.enhanced_networking = True return i
def parse_instance(instance_type, product_attributes, api_description): pieces = instance_type.split(".") if len(pieces) == 1: # Dedicated host that is not u-*.metal, skipping # May be a good idea to all dedicated hosts in the future return i = scrape.Instance() i.api_description = api_description i.instance_type = instance_type i.family = product_attributes.get("instanceFamily") i.vCPU = locale.atoi(product_attributes.get("vcpu")) # Memory is given in form of "1,952 GiB", let's parse it i.memory = locale.atof(product_attributes.get("memory").split(" ")[0]) if api_description: i.arch = api_description["ProcessorInfo"]["SupportedArchitectures"] i.network_performance = api_description["NetworkInfo"]["NetworkPerformance"] else: # Assume x86_64 if there's no DescribeInstanceTypes data. i.arch.append("x86_64") if "32-bit" in product_attributes.get("processorArchitecture"): i.arch.append("i386") i.network_performance = product_attributes.get("networkPerformance") if product_attributes.get("currentGeneration") == "Yes": i.generation = "current" else: i.generation = "previous" gpu = product_attributes.get("gpu") if gpu is not None: i.GPU = locale.atoi(gpu) if api_description: if "FpgaInfo" in api_description: for fpga in api_description["FpgaInfo"]["Fpgas"]: i.FPGA += fpga["Count"] netinfo = api_description["NetworkInfo"] if netinfo["EnaSupport"] == "required": i.ebs_as_nvme = True i.vpc = { "max_enis": netinfo["MaximumNetworkInterfaces"], "ips_per_eni": netinfo["Ipv4AddressesPerInterface"], } try: ecu = product_attributes.get("ecu") if ecu == "Variable": i.ECU = "variable" else: i.ECU = locale.atof(ecu) except: pass i.physical_processor = product_attributes.get("physicalProcessor") # CPU features processor_features = product_attributes.get("processorFeatures") if processor_features is not None: if "Intel AVX512" in processor_features: i.intel_avx512 = True if "Intel AVX2" in processor_features: i.intel_avx2 = True if "Intel AVX" in processor_features: i.intel_avx = True if "Intel Turbo" in processor_features: i.intel_turbo = True i.clock_speed_ghz = product_attributes.get("clockSpeed") enhanced_networking = product_attributes.get("enhancedNetworkingSupported") if enhanced_networking is not None and enhanced_networking == "Yes": i.enhanced_networking = True return i