@@ -1067,22 +1067,16 @@ def get_insert_operations(group_ids, flt=None, project=None, compute=compute):
1067
1067
1068
1068
1069
1069
def machine_type_sockets (template ):
1070
- pattern = re .compile ("^(?P<family>[^-]+)-(?P<type>[^-]+)-(?P<core>[^-]+)$ " )
1070
+ pattern = re .compile ("^(?P<family>[^-]+)" )
1071
1071
m = pattern .match (template .machineType )
1072
1072
if not m :
1073
1073
raise Exception (f"template { template } does not match expected regex" )
1074
1074
family = m .group ("family" )
1075
- try :
1076
- core_count = int (m .group ("core" ))
1077
- except ValueError :
1078
- log .warning (
1079
- f"core count in machine type { template .machineType } is not an integer. Default to 1 socket."
1080
- )
1081
- return 1
1075
+ guestCpus : int = int (template .machine_info .guestCpus )
1082
1076
socket_count = dict .get (
1083
1077
{
1084
1078
"h3" : 2 ,
1085
- "c2d" : 2 if core_count > 56 else 1 ,
1079
+ "c2d" : 2 if guestCpus > 56 else 1 ,
1086
1080
},
1087
1081
family ,
1088
1082
1 , # assume 1 socket for all other families
@@ -1092,11 +1086,11 @@ def machine_type_sockets(template):
1092
1086
1093
1087
def isSmt (template ):
1094
1088
machineType : str = template .machineType
1089
+ guestCpus : int = int (template .machine_info .guestCpus )
1095
1090
1096
- pattern = re .compile ("^(?P<family>[^-]+)-(?P<type>[^-]+)-(?P<core>[^-]+)$ " )
1091
+ pattern = re .compile ("^(?P<family>[^-]+)" )
1097
1092
matches = pattern .match (machineType )
1098
1093
machineTypeFamily : str = matches ["family" ]
1099
- machineTypeCore : int = int (matches ["core" ])
1100
1094
1101
1095
# https://cloud.google.com/compute/docs/cpu-platforms
1102
1096
noSmtFamily = [
@@ -1106,7 +1100,7 @@ def isSmt(template):
1106
1100
]
1107
1101
if machineTypeFamily in noSmtFamily :
1108
1102
return False
1109
- elif machineTypeCore == 1 :
1103
+ elif guestCpus == 1 :
1110
1104
return False
1111
1105
return True
1112
1106
0 commit comments