diff --git a/mc_openapi/__main__.py b/mc_openapi/__main__.py index 1bfaad2db8f2e7509f1d72f49a70cdf0b2a09e45..4d3ee38f3bff491c7e22204dba811f486db3e3b6 100644 --- a/mc_openapi/__main__.py +++ b/mc_openapi/__main__.py @@ -10,6 +10,7 @@ from doml_synthesis.types import State from mc_openapi.app_config import app from mc_openapi.doml_mc import DOMLVersion +from mc_openapi.doml_mc.csp_compatibility.cspcomp import check_csp_compatibility from mc_openapi.doml_mc.domlr_parser.exceptions import RequirementException from mc_openapi.doml_mc.domlr_parser.parser import (DOMLRTransformer, Parser, SynthesisDOMLRTransformer) @@ -75,9 +76,10 @@ else: # Check CSP Compatibility if args.csp: - from mc_openapi.doml_mc.csp_compatibility import CSPCompatibilityValidator - cspc = CSPCompatibilityValidator - cspc.check(dmc.intermediate_model, doml_ver) + # from mc_openapi.doml_mc.csp_compatibility import CSPCompatibilityValidator + # cspc = CSPCompatibilityValidator + # cspc.check(dmc.intermediate_model, doml_ver) + check_csp_compatibility(dmc.intermediate_model, doml_ver) exit(0) # Store of Requirements and unique string constants diff --git a/mc_openapi/doml_mc/csp_compatibility/cspcomp.py b/mc_openapi/doml_mc/csp_compatibility/cspcomp.py new file mode 100644 index 0000000000000000000000000000000000000000..690f7db410f9724c461db6c9c6aec9f4b67fde73 --- /dev/null +++ b/mc_openapi/doml_mc/csp_compatibility/cspcomp.py @@ -0,0 +1,107 @@ +from itertools import groupby +import re +import requests +from mc_openapi.doml_mc.imc import IntermediateModelChecker +from mc_openapi.doml_mc.intermediate_model.metamodel import DOMLVersion + + +IEC_API = 'https://iec.ci.piacere.digital.tecnalia.dev/services/iecbackend/api/root-services/catalogue' + +def check_csp_compatibility(model: IntermediateModelChecker, doml_version: DOMLVersion): + if doml_version != DOMLVersion.V2_2 and doml_version != DOMLVersion.V2_2_1: + print("Unsupported DOML version!") + + all_json = requests.get(IEC_API).json() + + all_json = [ + { + 'name': x['serviceName'], + 'class': x['serviceClass']['serviceClassName'], + 'props': x['serviceAttributeValues'] + } + for x in all_json + ] + + def filterByClass(name: str): + return [vm for vm in all_json if vm['class'] == name] + + def groupByProvider(elems: list): + def flatten_properties(el): + for p in el['props']: + el[p['serviceAttributeType']['name'].lower()] = p['serviceAttributeValue'] or None + el.pop('props', None) + return el + + elems = [flatten_properties(elem) for elem in elems] + + return { k: list(v) for k, v in groupby(sorted(elems, key=lambda elem: elem['provider']), lambda elem: elem['provider'])} + + + # Catalog IEC Elements + iec_vms = groupByProvider(filterByClass('Virtual Machine')) + iec_stos = groupByProvider(filterByClass('Storage')) + iec_dbs = groupByProvider(filterByClass('Database')) + + # DOML IM Elements + im_elems = model.values() + + compnodes = [cn for cn in im_elems if re.match(r"infrastructure_(ComputingNode|Container|PhysicalComputingNode|VirtualMachine)", cn.class_)] + locations = [lc for lc in im_elems if lc.class_ == 'infrastructure_Location'] + + # print(compnodes) + # print(locations) + + # for each provider + # check if the available elements have all the properties of doml elements + # if not, mark provider as unsupported and report the unsupported element and its value + + for provider, avail_vms in iec_vms.items(): + print(f'==={provider}===') + for cn in compnodes: + # attributes are list|None! + name = cn.attributes.get('commons_DOMLElement::name') + cpu_count = cn.attributes.get('infrastructure_ComputingNode::cpu_count') + memory_mb = cn.attributes.get('infrastructure_ComputingNode::memory_mb') + location = cn.associations.get('infrastructure_ComputingNode::location') + region = None + zone = None + if location: + location = model[list(location)[0]] + region = location.attributes.get('infrastructure_Location::region') + zone = location.attributes.get('infrastructure_Location::zone') + # not in IEC + # arch = cn.attributes.get('infrastructure_ComputingNode::architecture') + # os = cn.attributes.get('infrastructure_ComputingNode::os') + + print(f'---{name[0]}---') + + valid_configs = avail_vms + + if cpu_count: + valid_configs = [ + avm for avm in valid_configs + if (int(avm['virtual cpu cores']) == cpu_count[0] if cpu_count else False) + ] + + if memory_mb: + valid_configs = [ + avm for avm in valid_configs + if (float(avm['memory']) * 1000 == float(memory_mb[0]) if memory_mb else False) + ] + + if region: + valid_configs = [ + avm for avm in valid_configs + if (avm['region'] == region[0] if region else False) + ] + + if zone: + valid_configs = [ + avm for avm in valid_configs + if (avm['zone'] == zone[0] if zone else False) + ] + + # print(valid_configs) + + + diff --git a/mc_openapi/notebooks/csp_compatibility.ipynb b/mc_openapi/notebooks/csp_compatibility.ipynb index de1e63dc5f41bcc5097fa7ef29f3c32840b8c97d..7ff29d6570a90c67a3f22f42597bb601b038c597 100644 --- a/mc_openapi/notebooks/csp_compatibility.ipynb +++ b/mc_openapi/notebooks/csp_compatibility.ipynb @@ -2,24 +2,569 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", - "import requests" + "import requests\n", + "from pprint import pprint\n", + "from itertools import groupby" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[{'name': 'C1_Spain', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'SPEU', 'Provider': 'ARSY', 'Virtual CPU Cores': '1', 'Frequency per Core': '1500', 'Memory': '1', 'Instance Storage': '40', 'Optimized for': None, 'Public IP': None, 'Underpinning Technology': 'VmWare', 'Availability': '99.5', 'Response time: Virtual Machine Performance': '5', 'Legal Level/Accreditations': None, 'Cost/Currency': '15'}, {'name': 'C1_USA', 'class': 'Virtual Machine', 'Region': '00NA', 'Zone': 'USNA', 'Provider': 'ARSY', 'Virtual CPU Cores': '1', 'Frequency per Core': '1500', 'Memory': '1', 'Instance Storage': '40', 'Optimized for': None, 'Public IP': None, 'Underpinning Technology': 'VmWare', 'Availability': '99.5', 'Response time: Virtual Machine Performance': '5', 'Legal Level/Accreditations': None, 'Cost/Currency': '15'}, {'name': 'C2_Europe', 'class': 'Virtual Machine', 'Frequency per Core': '1500', 'Memory': '4', 'Instance Storage': '60', 'Optimized for': None, 'Public IP': None, 'Underpinning Technology': 'VmWare', 'Availability': '99.6', 'Response time: Virtual Machine Performance': '3', 'Legal Level/Accreditations': None, 'Cost/Currency': '40', 'Region': '00EU', 'Zone': 'DEEU', 'Provider': 'ARSY', 'Virtual CPU Cores': '2'}, {'name': 'C2_UnitedKingdom', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'UKEU', 'Provider': 'ARSY', 'Virtual CPU Cores': '2', 'Frequency per Core': '1500', 'Memory': '4', 'Instance Storage': '60', 'Optimized for': None, 'Public IP': None, 'Underpinning Technology': 'VmWare', 'Availability': '99.6', 'Response time: Virtual Machine Performance': '3', 'Legal Level/Accreditations': None, 'Cost/Currency': '40'}, {'name': 'C4_Europe', 'class': 'Virtual Machine', 'Public IP': 'IPV4', 'Underpinning Technology': 'VmWare', 'Availability': '99.8', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '80', 'Region': '00EU', 'Zone': None, 'Provider': 'ARSY', 'Virtual CPU Cores': '4', 'Frequency per Core': '1500', 'Memory': '8', 'Instance Storage': '100', 'Optimized for': None}, {'name': 'C4_USA', 'class': 'Virtual Machine', 'Region': '00NA', 'Zone': 'USNA', 'Provider': 'ARSY', 'Virtual CPU Cores': '4', 'Frequency per Core': '1500', 'Memory': '8', 'Instance Storage': '100', 'Optimized for': None, 'Public IP': None, 'Underpinning Technology': 'VmWare', 'Availability': '99.8', 'Response time: Virtual Machine Performance': '3', 'Legal Level/Accreditations': None, 'Cost/Currency': '80'}, {'name': 'C8_Germany', 'class': 'Virtual Machine', 'Legal Level/Accreditations': None, 'Cost/Currency': '150', 'Region': '00EU', 'Zone': 'DEEU', 'Provider': 'ARSY', 'Virtual CPU Cores': '8', 'Frequency per Core': '1500', 'Memory': '16', 'Instance Storage': '200', 'Optimized for': None, 'Public IP': 'IPV4', 'Underpinning Technology': 'VmWare', 'Availability': '99.9', 'Response time: Virtual Machine Performance': '2'}, {'name': 'C8_Spain', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'SPEU', 'Provider': 'ARSY', 'Virtual CPU Cores': '8', 'Frequency per Core': '1500', 'Memory': '16', 'Instance Storage': '200', 'Optimized for': None, 'Public IP': 'IPV4', 'Underpinning Technology': 'VmWare', 'Availability': '99.8', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '150'}, {'name': 't2.nano', 'class': 'Virtual Machine', 'Frequency per Core': '1500', 'Memory': '0.5', 'Instance Storage': '40', 'Optimized for': 'GEPU', 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '98', 'Response time: Virtual Machine Performance': '3', 'Legal Level/Accreditations': None, 'Cost/Currency': '4.53', 'Region': '00EU', 'Zone': 'IEEU', 'Provider': 'AMAZ', 'Virtual CPU Cores': '1'}, {'name': 't2.medium', 'class': 'Virtual Machine', 'Region': '00NA', 'Zone': 'USNA', 'Provider': 'AMAZ', 'Virtual CPU Cores': '2', 'Frequency per Core': '1500', 'Memory': '4', 'Instance Storage': '60', 'Optimized for': 'GEPU', 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '98.2', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '39.75'}, {'name': 'm5.large', 'class': 'Virtual Machine', 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '98.5', 'Response time: Virtual Machine Performance': '1', 'Legal Level/Accreditations': None, 'Cost/Currency': '77', 'Region': '00NA', 'Zone': 'CANA', 'Provider': 'ARSY', 'Virtual CPU Cores': '2', 'Frequency per Core': '1500', 'Memory': '8', 'Instance Storage': '100', 'Optimized for': 'GEPU'}, {'name': 'm4.4xlarge', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'SPEU', 'Provider': 'AMAZ', 'Virtual CPU Cores': '16', 'Frequency per Core': '1500', 'Memory': '64', 'Instance Storage': '120', 'Optimized for': 'GEPU', 'Public IP': None, 'Underpinning Technology': None, 'Availability': '99.8', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '640'}, {'name': 'm5.2xlarge', 'class': 'Virtual Machine', 'Legal Level/Accreditations': None, 'Cost/Currency': '323', 'Region': '00NA', 'Zone': 'USNA', 'Provider': 'AMAZ', 'Virtual CPU Cores': '8', 'Frequency per Core': '1500', 'Memory': '32', 'Instance Storage': '100', 'Optimized for': 'GEPU', 'Public IP': None, 'Underpinning Technology': None, 'Availability': '99.2', 'Response time: Virtual Machine Performance': '3'}, {'name': 'c5.2xlarge', 'class': 'Virtual Machine', 'Region': '00NA', 'Zone': 'CANA', 'Provider': 'AMAZ', 'Virtual CPU Cores': '8', 'Frequency per Core': '1500', 'Memory': '16', 'Instance Storage': '80', 'Optimized for': 'COOP', 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '99.4', 'Response time: Virtual Machine Performance': '5', 'Legal Level/Accreditations': None, 'Cost/Currency': '268'}, {'name': 'c4.8xlarge', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'IEEU', 'Provider': 'AMAZ', 'Virtual CPU Cores': '36', 'Frequency per Core': '1500', 'Memory': '60', 'Instance Storage': '200', 'Optimized for': 'COOP', 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '99.8', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '1304'}, {'name': 'g3.8xlarge', 'class': 'Virtual Machine', 'Provider': 'AMAZ', 'Virtual CPU Cores': '32', 'Frequency per Core': '1500', 'Memory': '244', 'Instance Storage': '220', 'Optimized for': 'GPUI', 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '99.8', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '2209', 'Region': '00NA', 'Zone': 'USNA'}, {'name': 'p2.8xlarge', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'UKEU', 'Provider': 'AMAZ', 'Virtual CPU Cores': '32', 'Frequency per Core': '1500', 'Memory': '488', 'Instance Storage': '250', 'Optimized for': 'GPUI', 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '99.9', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '5600'}, {'name': 'r4.xlarge', 'class': 'Virtual Machine', 'Instance Storage': '70', 'Optimized for': 'MEOP', 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '98.5', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '214', 'Region': '00NA', 'Zone': 'USNA', 'Provider': 'AMAZ', 'Virtual CPU Cores': '4', 'Frequency per Core': '1500', 'Memory': '30.5'}, {'name': 'x1e.4xlarge', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'DEEU', 'Provider': 'AMAZ', 'Virtual CPU Cores': '16', 'Frequency per Core': '1500', 'Memory': '488', 'Instance Storage': '80', 'Optimized for': 'MEOP', 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '99', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '3376'}, {'name': 'A2v2', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'IEEU', 'Provider': 'AZUR', 'Virtual CPU Cores': '2', 'Frequency per Core': '1500', 'Memory': '4', 'Instance Storage': '20', 'Optimized for': None, 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '95', 'Response time: Virtual Machine Performance': '5', 'Legal Level/Accreditations': None, 'Cost/Currency': '93.60'}, {'name': 'A2v2_USA', 'class': 'Virtual Machine', 'Region': '00NA', 'Zone': 'USNA', 'Provider': 'AZUR', 'Virtual CPU Cores': '2', 'Frequency per Core': '1500', 'Memory': '4', 'Instance Storage': '20', 'Optimized for': None, 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '95', 'Response time: Virtual Machine Performance': '5', 'Legal Level/Accreditations': None, 'Cost/Currency': '67'}, {'name': 'B8_USA', 'class': 'Virtual Machine', 'Frequency per Core': '1500', 'Memory': '32', 'Instance Storage': '64', 'Optimized for': None, 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '98', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '242', 'Region': '00NA', 'Zone': None, 'Provider': 'AZUR', 'Virtual CPU Cores': '8'}, {'name': 'B8_Germany', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'DEEU', 'Provider': 'AZUR', 'Virtual CPU Cores': '8', 'Frequency per Core': '1500', 'Memory': '32', 'Instance Storage': '64', 'Optimized for': None, 'Public IP': None, 'Underpinning Technology': None, 'Availability': '98', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '170'}, {'name': 'A3_France', 'class': 'Virtual Machine', 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '96', 'Response time: Virtual Machine Performance': '3', 'Legal Level/Accreditations': None, 'Cost/Currency': '193', 'Region': '00EU', 'Zone': 'FREU', 'Provider': 'AZUR', 'Virtual CPU Cores': '4', 'Frequency per Core': '1500', 'Memory': '7', 'Instance Storage': '120', 'Optimized for': None}, {'name': 'DS13v2', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': None, 'Provider': 'AZUR', 'Virtual CPU Cores': '8', 'Frequency per Core': '1500', 'Memory': '56', 'Instance Storage': '112', 'Optimized for': None, 'Public IP': None, 'Underpinning Technology': None, 'Availability': '98', 'Response time: Virtual Machine Performance': '3', 'Legal Level/Accreditations': None, 'Cost/Currency': '541'}, {'name': 'n1-standard-16', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'DEEU', 'Provider': 'GOOG', 'Virtual CPU Cores': '16', 'Frequency per Core': '1500', 'Memory': '60', 'Instance Storage': '300', 'Optimized for': None, 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '96', 'Response time: Virtual Machine Performance': '4', 'Legal Level/Accreditations': None, 'Cost/Currency': '500'}, {'name': 'n1-highmem-16', 'class': 'Virtual Machine', 'Virtual CPU Cores': '16', 'Frequency per Core': '1500', 'Memory': '104', 'Instance Storage': '300', 'Optimized for': 'MEOP', 'Public IP': None, 'Underpinning Technology': None, 'Availability': '98', 'Response time: Virtual Machine Performance': '4', 'Legal Level/Accreditations': None, 'Cost/Currency': '552', 'Region': '00NA', 'Zone': 'USNA', 'Provider': 'GOOG'}, {'name': 'VM_1_CS', 'class': 'Virtual Machine', 'Memory': '4', 'Instance Storage': '256', 'Optimized for': None, 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '98', 'Response time: Virtual Machine Performance': '100', 'Legal Level/Accreditations': None, 'Cost/Currency': '186', 'Region': '00EU', 'Zone': 'ZUEU', 'Provider': 'CLSI', 'Virtual CPU Cores': '2', 'Frequency per Core': '5200'}, {'name': 'm1.medium', 'class': 'Virtual Machine', 'Region': '00NA', 'Zone': 'USNA', 'Provider': 'AMAZ', 'Virtual CPU Cores': '1', 'Frequency per Core': None, 'Memory': '3.7', 'Instance Storage': '410', 'Optimized for': None, 'Public IP': 'IPV4', 'Underpinning Technology': None, 'Availability': '98', 'Response time: Virtual Machine Performance': '100', 'Legal Level/Accreditations': None, 'Cost/Currency': '200'}, {'name': 'm1.tiny', 'class': 'Virtual Machine', 'Underpinning Technology': None, 'Availability': '98', 'Response time: Virtual Machine Performance': '10', 'Legal Level/Accreditations': None, 'Cost/Currency': '10', 'Region': '00EU', 'Zone': 'SPEU', 'Provider': 'OPEN', 'Virtual CPU Cores': '1', 'Frequency per Core': '1500', 'Memory': '512', 'Instance Storage': '1', 'Optimized for': None, 'Public IP': 'IPV4'}, {'name': 'm1.small', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'SPEU', 'Provider': 'OPEN', 'Virtual CPU Cores': '1', 'Frequency per Core': '1500', 'Memory': '2', 'Instance Storage': '20', 'Optimized for': None, 'Public IP': None, 'Underpinning Technology': None, 'Availability': '99', 'Response time: Virtual Machine Performance': '5', 'Legal Level/Accreditations': None, 'Cost/Currency': '20'}, {'name': 'm1.medium', 'class': 'Virtual Machine', 'Cost/Currency': '40', 'Region': '00EU', 'Zone': 'SPEU', 'Provider': 'OPEN', 'Virtual CPU Cores': '2', 'Frequency per Core': '1500', 'Memory': '4', 'Instance Storage': '40', 'Optimized for': None, 'Public IP': None, 'Underpinning Technology': None, 'Availability': '99.5', 'Response time: Virtual Machine Performance': '4', 'Legal Level/Accreditations': None}, {'name': 'm1.large', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'SPEU', 'Provider': 'OPEN', 'Virtual CPU Cores': '4', 'Frequency per Core': '1500', 'Memory': '8', 'Instance Storage': '80', 'Optimized for': None, 'Public IP': None, 'Underpinning Technology': None, 'Availability': '99.6', 'Response time: Virtual Machine Performance': '3', 'Legal Level/Accreditations': None, 'Cost/Currency': '80'}, {'name': 'm1.xlarge', 'class': 'Virtual Machine', 'Region': '00EU', 'Zone': 'SPEU', 'Provider': 'OPEN', 'Virtual CPU Cores': '8', 'Frequency per Core': '1500', 'Memory': '16', 'Instance Storage': '160', 'Optimized for': None, 'Public IP': None, 'Underpinning Technology': None, 'Availability': '99.8', 'Response time: Virtual Machine Performance': '2', 'Legal Level/Accreditations': None, 'Cost/Currency': '160'}]\n" + "{'AMAZ': [{'availability': '98',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '4.53',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '40',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '0.5',\n", + " 'name': 't2.nano',\n", + " 'optimized for': 'GEPU',\n", + " 'provider': 'AMAZ',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '3',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '1',\n", + " 'zone': 'IEEU'},\n", + " {'availability': '98.2',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '39.75',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '60',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '4',\n", + " 'name': 't2.medium',\n", + " 'optimized for': 'GEPU',\n", + " 'provider': 'AMAZ',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '2',\n", + " 'zone': 'USNA'},\n", + " {'availability': '99.8',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '640',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '120',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '64',\n", + " 'name': 'm4.4xlarge',\n", + " 'optimized for': 'GEPU',\n", + " 'provider': 'AMAZ',\n", + " 'public ip': None,\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '16',\n", + " 'zone': 'SPEU'},\n", + " {'availability': '99.2',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '323',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '100',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '32',\n", + " 'name': 'm5.2xlarge',\n", + " 'optimized for': 'GEPU',\n", + " 'provider': 'AMAZ',\n", + " 'public ip': None,\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '3',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '8',\n", + " 'zone': 'USNA'},\n", + " {'availability': '99.4',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '268',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '80',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '16',\n", + " 'name': 'c5.2xlarge',\n", + " 'optimized for': 'COOP',\n", + " 'provider': 'AMAZ',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '5',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '8',\n", + " 'zone': 'CANA'},\n", + " {'availability': '99.8',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '1304',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '200',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '60',\n", + " 'name': 'c4.8xlarge',\n", + " 'optimized for': 'COOP',\n", + " 'provider': 'AMAZ',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '36',\n", + " 'zone': 'IEEU'},\n", + " {'availability': '99.8',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '2209',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '220',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '244',\n", + " 'name': 'g3.8xlarge',\n", + " 'optimized for': 'GPUI',\n", + " 'provider': 'AMAZ',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '32',\n", + " 'zone': 'USNA'},\n", + " {'availability': '99.9',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '5600',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '250',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '488',\n", + " 'name': 'p2.8xlarge',\n", + " 'optimized for': 'GPUI',\n", + " 'provider': 'AMAZ',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '32',\n", + " 'zone': 'UKEU'},\n", + " {'availability': '98.5',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '214',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '70',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '30.5',\n", + " 'name': 'r4.xlarge',\n", + " 'optimized for': 'MEOP',\n", + " 'provider': 'AMAZ',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '4',\n", + " 'zone': 'USNA'},\n", + " {'availability': '99',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '3376',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '80',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '488',\n", + " 'name': 'x1e.4xlarge',\n", + " 'optimized for': 'MEOP',\n", + " 'provider': 'AMAZ',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '16',\n", + " 'zone': 'DEEU'},\n", + " {'availability': '98',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '200',\n", + " 'frequency per core': None,\n", + " 'instance storage': '410',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '3.7',\n", + " 'name': 'm1.medium',\n", + " 'optimized for': None,\n", + " 'provider': 'AMAZ',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '100',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '1',\n", + " 'zone': 'USNA'}],\n", + " 'ARSY': [{'availability': '99.5',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '15',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '40',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '1',\n", + " 'name': 'C1_Spain',\n", + " 'optimized for': None,\n", + " 'provider': 'ARSY',\n", + " 'public ip': None,\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '5',\n", + " 'underpinning technology': 'VmWare',\n", + " 'virtual cpu cores': '1',\n", + " 'zone': 'SPEU'},\n", + " {'availability': '99.5',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '15',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '40',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '1',\n", + " 'name': 'C1_USA',\n", + " 'optimized for': None,\n", + " 'provider': 'ARSY',\n", + " 'public ip': None,\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '5',\n", + " 'underpinning technology': 'VmWare',\n", + " 'virtual cpu cores': '1',\n", + " 'zone': 'USNA'},\n", + " {'availability': '99.6',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '40',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '60',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '4',\n", + " 'name': 'C2_Europe',\n", + " 'optimized for': None,\n", + " 'provider': 'ARSY',\n", + " 'public ip': None,\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '3',\n", + " 'underpinning technology': 'VmWare',\n", + " 'virtual cpu cores': '2',\n", + " 'zone': 'DEEU'},\n", + " {'availability': '99.6',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '40',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '60',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '4',\n", + " 'name': 'C2_UnitedKingdom',\n", + " 'optimized for': None,\n", + " 'provider': 'ARSY',\n", + " 'public ip': None,\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '3',\n", + " 'underpinning technology': 'VmWare',\n", + " 'virtual cpu cores': '2',\n", + " 'zone': 'UKEU'},\n", + " {'availability': '99.8',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '80',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '100',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '8',\n", + " 'name': 'C4_Europe',\n", + " 'optimized for': None,\n", + " 'provider': 'ARSY',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': 'VmWare',\n", + " 'virtual cpu cores': '4',\n", + " 'zone': None},\n", + " {'availability': '99.8',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '80',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '100',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '8',\n", + " 'name': 'C4_USA',\n", + " 'optimized for': None,\n", + " 'provider': 'ARSY',\n", + " 'public ip': None,\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '3',\n", + " 'underpinning technology': 'VmWare',\n", + " 'virtual cpu cores': '4',\n", + " 'zone': 'USNA'},\n", + " {'availability': '99.9',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '150',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '200',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '16',\n", + " 'name': 'C8_Germany',\n", + " 'optimized for': None,\n", + " 'provider': 'ARSY',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': 'VmWare',\n", + " 'virtual cpu cores': '8',\n", + " 'zone': 'DEEU'},\n", + " {'availability': '99.8',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '150',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '200',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '16',\n", + " 'name': 'C8_Spain',\n", + " 'optimized for': None,\n", + " 'provider': 'ARSY',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': 'VmWare',\n", + " 'virtual cpu cores': '8',\n", + " 'zone': 'SPEU'},\n", + " {'availability': '98.5',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '77',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '100',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '8',\n", + " 'name': 'm5.large',\n", + " 'optimized for': 'GEPU',\n", + " 'provider': 'ARSY',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '1',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '2',\n", + " 'zone': 'CANA'}],\n", + " 'AZUR': [{'availability': '95',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '93.60',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '20',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '4',\n", + " 'name': 'A2v2',\n", + " 'optimized for': None,\n", + " 'provider': 'AZUR',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '5',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '2',\n", + " 'zone': 'IEEU'},\n", + " {'availability': '95',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '67',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '20',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '4',\n", + " 'name': 'A2v2_USA',\n", + " 'optimized for': None,\n", + " 'provider': 'AZUR',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '5',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '2',\n", + " 'zone': 'USNA'},\n", + " {'availability': '98',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '242',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '64',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '32',\n", + " 'name': 'B8_USA',\n", + " 'optimized for': None,\n", + " 'provider': 'AZUR',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '8',\n", + " 'zone': None},\n", + " {'availability': '98',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '170',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '64',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '32',\n", + " 'name': 'B8_Germany',\n", + " 'optimized for': None,\n", + " 'provider': 'AZUR',\n", + " 'public ip': None,\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '8',\n", + " 'zone': 'DEEU'},\n", + " {'availability': '96',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '193',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '120',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '7',\n", + " 'name': 'A3_France',\n", + " 'optimized for': None,\n", + " 'provider': 'AZUR',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '3',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '4',\n", + " 'zone': 'FREU'},\n", + " {'availability': '98',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '541',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '112',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '56',\n", + " 'name': 'DS13v2',\n", + " 'optimized for': None,\n", + " 'provider': 'AZUR',\n", + " 'public ip': None,\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '3',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '8',\n", + " 'zone': None}],\n", + " 'CLSI': [{'availability': '98',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '186',\n", + " 'frequency per core': '5200',\n", + " 'instance storage': '256',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '4',\n", + " 'name': 'VM_1_CS',\n", + " 'optimized for': None,\n", + " 'provider': 'CLSI',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '100',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '2',\n", + " 'zone': 'ZUEU'}],\n", + " 'GOOG': [{'availability': '96',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '500',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '300',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '60',\n", + " 'name': 'n1-standard-16',\n", + " 'optimized for': None,\n", + " 'provider': 'GOOG',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '4',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '16',\n", + " 'zone': 'DEEU'},\n", + " {'availability': '98',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '552',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '300',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '104',\n", + " 'name': 'n1-highmem-16',\n", + " 'optimized for': 'MEOP',\n", + " 'provider': 'GOOG',\n", + " 'public ip': None,\n", + " 'region': '00NA',\n", + " 'response time: virtual machine performance': '4',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '16',\n", + " 'zone': 'USNA'}],\n", + " 'OPEN': [{'availability': '98',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '10',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '1',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '512',\n", + " 'name': 'm1.tiny',\n", + " 'optimized for': None,\n", + " 'provider': 'OPEN',\n", + " 'public ip': 'IPV4',\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '10',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '1',\n", + " 'zone': 'SPEU'},\n", + " {'availability': '99',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '20',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '20',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '2',\n", + " 'name': 'm1.small',\n", + " 'optimized for': None,\n", + " 'provider': 'OPEN',\n", + " 'public ip': None,\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '5',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '1',\n", + " 'zone': 'SPEU'},\n", + " {'availability': '99.5',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '40',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '40',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '4',\n", + " 'name': 'm1.medium',\n", + " 'optimized for': None,\n", + " 'provider': 'OPEN',\n", + " 'public ip': None,\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '4',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '2',\n", + " 'zone': 'SPEU'},\n", + " {'availability': '99.6',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '80',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '80',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '8',\n", + " 'name': 'm1.large',\n", + " 'optimized for': None,\n", + " 'provider': 'OPEN',\n", + " 'public ip': None,\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '3',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '4',\n", + " 'zone': 'SPEU'},\n", + " {'availability': '99.8',\n", + " 'class': 'Virtual Machine',\n", + " 'cost/currency': '160',\n", + " 'frequency per core': '1500',\n", + " 'instance storage': '160',\n", + " 'legal level/accreditations': None,\n", + " 'memory': '16',\n", + " 'name': 'm1.xlarge',\n", + " 'optimized for': None,\n", + " 'provider': 'OPEN',\n", + " 'public ip': None,\n", + " 'region': '00EU',\n", + " 'response time: virtual machine performance': '2',\n", + " 'underpinning technology': None,\n", + " 'virtual cpu cores': '8',\n", + " 'zone': 'SPEU'}]}\n" ] } ], @@ -42,13 +587,15 @@ "\n", "def flatten_properties(el):\n", " for p in el['props']:\n", - " el[p['serviceAttributeType']['name']] = p['serviceAttributeValue'] or None\n", + " el[p['serviceAttributeType']['name'].lower()] = p['serviceAttributeValue'] or None\n", " el.pop('props', None)\n", " return el\n", "\n", "vms = [flatten_properties(vm) for vm in vms]\n", "\n", - "print(vms)" + "vms ={ k: list(v) for k, v in groupby(sorted(vms, key=lambda vm: vm['provider']), lambda vm: vm['provider'])}\n", + "\n", + "pprint(vms)" ] } ], @@ -68,7 +615,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.2" }, "orig_nbformat": 4 },