filtered-azure-image.res 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. cloudbridge.test.test_image_service.CloudImageServiceTestCase
  2. Test output
  3. ..
  4. ----------------------------------------------------------------------
  5. Ran 2 tests in 735.237s
  6. OK
  7. Wrote profile results to run_single.py.lprof
  8. Timer unit: 1e-06 s
  9. Total time: 302.637 s
  10. Function: create at line 863
  11. Line # Hits Time Per Hit % Time Line Contents
  12. ==============================================================
  13. 863 @dispatch(event="provider.compute.instances.create",
  14. 864 priority=BaseInstanceService.STANDARD_EVENT_PRIORITY)
  15. 865 @profile
  16. 866 def create(self, label, image, vm_type, subnet, zone,
  17. 867 key_pair=None, vm_firewalls=None, user_data=None,
  18. 868 launch_config=None, **kwargs):
  19. 869 2 38.0 19.0 0.0 AzureInstance.assert_valid_resource_label(label)
  20. 870 2 6.0 3.0 0.0 instance_name = AzureInstance._generate_name_from_label(label,
  21. 871 2 112.0 56.0 0.0 "cb-ins")
  22. 872
  23. 873 2 6.0 3.0 0.0 image = (image if isinstance(image, AzureMachineImage) else
  24. 874 1 149.0 149.0 0.0 self.provider.compute.images.get(image))
  25. 875 2 4.0 2.0 0.0 if not isinstance(image, AzureMachineImage):
  26. 876 raise Exception("Provided image %s is not a valid azure image"
  27. 877 % image)
  28. 878
  29. 879 instance_size = vm_type.id if \
  30. 880 2 9.0 4.5 0.0 isinstance(vm_type, VMType) else vm_type
  31. 881
  32. 882 2 4.0 2.0 0.0 if not subnet:
  33. 883 # Azure has only a single zone per region; use the current one
  34. 884 zone = self.provider.compute.regions.get(
  35. 885 self.provider.region_name).zones[0]
  36. 886 subnet = self.provider.networking.subnets.get_or_create_default(
  37. 887 zone)
  38. 888 else:
  39. 889 subnet = (self.provider.networking.subnets.get(subnet)
  40. 890 2 8.0 4.0 0.0 if isinstance(subnet, str) else subnet)
  41. 891
  42. 892 2 4.0 2.0 0.0 zone_id = zone.id if isinstance(zone, PlacementZone) else zone
  43. 893
  44. 894 subnet_id, zone_id, vm_firewall_id = \
  45. 895 2 7.0 3.5 0.0 self._resolve_launch_options(instance_name,
  46. 896 2 863326.0 431663.0 0.3 subnet, zone_id, vm_firewalls)
  47. 897
  48. 898 2 5.0 2.5 0.0 storage_profile = self._create_storage_profile(image, launch_config,
  49. 899 2 509.0 254.5 0.0 instance_name, zone_id)
  50. 900
  51. 901 nic_params = {
  52. 902 2 11.0 5.5 0.0 'location': self.provider.region_name,
  53. 903 'ip_configurations': [{
  54. 904 2 3.0 1.5 0.0 'name': instance_name + '_ip_config',
  55. 905 2 2.0 1.0 0.0 'private_ip_allocation_method': 'Dynamic',
  56. 906 'subnet': {
  57. 907 2 4.0 2.0 0.0 'id': subnet_id
  58. 908 }
  59. 909 }]
  60. 910 }
  61. 911
  62. 912 2 3.0 1.5 0.0 if vm_firewall_id:
  63. 913 nic_params['network_security_group'] = {
  64. 914 'id': vm_firewall_id
  65. 915 }
  66. 916 2 16.0 8.0 0.0 nic_info = self.provider.azure_client.create_nic(
  67. 917 2 4.0 2.0 0.0 instance_name + '_nic',
  68. 918 2 63373404.0 31686702.0 20.9 nic_params
  69. 919 )
  70. 920 # #! indicates shell script
  71. 921 ud = '#cloud-config\n' + user_data \
  72. 922 2 6.0 3.0 0.0 if user_data and not user_data.startswith('#!')\
  73. 923 and not user_data.startswith('#cloud-config') else user_data
  74. 924
  75. 925 # Key_pair is mandatory in azure and it should not be None.
  76. 926 2 2.0 1.0 0.0 temp_key_pair = None
  77. 927 2 3.0 1.5 0.0 if key_pair:
  78. 928 key_pair = (key_pair if isinstance(key_pair, AzureKeyPair)
  79. 929 else self.provider.security.key_pairs.get(key_pair))
  80. 930 else:
  81. 931 # Create a temporary keypair if none is provided to keep Azure
  82. 932 # happy, but the private key will be discarded, so it'll be all
  83. 933 # but useless. However, this will allow an instance to be launched
  84. 934 # without specifying a keypair, so users may still be able to login
  85. 935 # if they have a preinstalled keypair/password baked into the image
  86. 936 2 4.0 2.0 0.0 temp_kp_name = "".join(["cb-default-kp-",
  87. 937 2 6.0 3.0 0.0 str(uuid.uuid5(uuid.NAMESPACE_OID,
  88. 938 2 123.0 61.5 0.0 instance_name))[-6:]])
  89. 939 2 39.0 19.5 0.0 key_pair = self.provider.security.key_pairs.create(
  90. 940 2 2467166.0 1233583.0 0.8 name=temp_kp_name)
  91. 941 2 4.0 2.0 0.0 temp_key_pair = key_pair
  92. 942
  93. 943 params = {
  94. 944 2 4.0 2.0 0.0 'location': zone_id or self.provider.region_name,
  95. 945 'os_profile': {
  96. 946 2 12.0 6.0 0.0 'admin_username': self.provider.vm_default_user_name,
  97. 947 2 4.0 2.0 0.0 'computer_name': instance_name,
  98. 948 'linux_configuration': {
  99. 949 2 4.0 2.0 0.0 "disable_password_authentication": True,
  100. 950 "ssh": {
  101. 951 2 3.0 1.5 0.0 "public_keys": [{
  102. 952 "path":
  103. 953 2 4.0 2.0 0.0 "/home/{}/.ssh/authorized_keys".format(
  104. 954 2 8.0 4.0 0.0 self.provider.vm_default_user_name),
  105. 955 2 25.0 12.5 0.0 "key_data": key_pair._key_pair.Key
  106. 956 }]
  107. 957 }
  108. 958 }
  109. 959 },
  110. 960 'hardware_profile': {
  111. 961 2 8.0 4.0 0.0 'vm_size': instance_size
  112. 962 },
  113. 963 'network_profile': {
  114. 964 2 4.0 2.0 0.0 'network_interfaces': [{
  115. 965 2 8.0 4.0 0.0 'id': nic_info.id
  116. 966 }]
  117. 967 },
  118. 968 2 4.0 2.0 0.0 'storage_profile': storage_profile,
  119. 969 2 6.0 3.0 0.0 'tags': {'Label': label}
  120. 970 }
  121. 971
  122. 972 2 6.0 3.0 0.0 for disk_def in storage_profile.get('data_disks', []):
  123. 973 params['tags'] = dict(disk_def.get('tags', {}), **params['tags'])
  124. 974
  125. 975 2 4.0 2.0 0.0 if user_data:
  126. 976 custom_data = base64.b64encode(bytes(ud, 'utf-8'))
  127. 977 params['os_profile']['custom_data'] = str(custom_data, 'utf-8')
  128. 978
  129. 979 2 4.0 2.0 0.0 if not temp_key_pair:
  130. 980 params['tags'].update(Key_Pair=key_pair.id)
  131. 981
  132. 982 2 3.0 1.5 0.0 try:
  133. 983 2 234547650.0 117273825.0 77.5 vm = self.provider.azure_client.create_vm(instance_name, params)
  134. 984 except Exception as e:
  135. 985 # If VM creation fails, attempt to clean up intermediary resources
  136. 986 self.provider.azure_client.delete_nic(nic_info.id)
  137. 987 for disk_def in storage_profile.get('data_disks', []):
  138. 988 if disk_def.get('tags', {}).get('delete_on_terminate'):
  139. 989 disk_id = disk_def.get('managed_disk', {}).get('id')
  140. 990 if disk_id:
  141. 991 vol = self.provider.storage.volumes.get(disk_id)
  142. 992 vol.delete()
  143. 993 raise e
  144. 994 finally:
  145. 995 2 7.0 3.5 0.0 if temp_key_pair:
  146. 996 2 514491.0 257245.5 0.2 temp_key_pair.delete()
  147. 997 2 869810.0 434905.0 0.3 return AzureInstance(self.provider, vm)
  148. Total time: 193.572 s
  149. Function: delete at line 1044
  150. Line # Hits Time Per Hit % Time Line Contents
  151. ==============================================================
  152. 1044 @dispatch(event="provider.compute.instances.delete",
  153. 1045 priority=BaseInstanceService.STANDARD_EVENT_PRIORITY)
  154. 1046 @profile
  155. 1047 def delete(self, instance):
  156. 1048 """
  157. 1049 Permanently terminate this instance.
  158. 1050 After deleting the VM. we are deleting the network interface
  159. 1051 associated to the instance, and also removing OS disk and data disks
  160. 1052 where tag with name 'delete_on_terminate' has value True.
  161. 1053 """
  162. 1054 2 5.0 2.5 0.0 ins = (instance if isinstance(instance, AzureInstance) else
  163. 1055 self.get(instance))
  164. 1056 2 1.0 0.5 0.0 if not instance:
  165. 1057 return
  166. 1058
  167. 1059 # Remove IPs first to avoid a network interface conflict
  168. 1060 # pylint:disable=protected-access
  169. 1061 2 629624.0 314812.0 0.3 for public_ip_id in ins._public_ip_ids:
  170. 1062 ins.remove_floating_ip(public_ip_id)
  171. 1063 2 57140854.0 28570427.0 29.5 self.provider.azure_client.deallocate_vm(ins.id)
  172. 1064 2 52038863.0 26019431.5 26.9 self.provider.azure_client.delete_vm(ins.id)
  173. 1065 # pylint:disable=protected-access
  174. 1066 4 33.0 8.2 0.0 for nic_id in ins._nic_ids:
  175. 1067 2 22277030.0 11138515.0 11.5 self.provider.azure_client.delete_nic(nic_id)
  176. 1068 # pylint:disable=protected-access
  177. 1069 2 14.0 7.0 0.0 for data_disk in ins._vm.storage_profile.data_disks:
  178. 1070 if data_disk.managed_disk:
  179. 1071 # pylint:disable=protected-access
  180. 1072 if ins._vm.tags.get('delete_on_terminate',
  181. 1073 'False') == 'True':
  182. 1074 self.provider.azure_client. \
  183. 1075 delete_disk(data_disk.managed_disk.id)
  184. 1076 # pylint:disable=protected-access
  185. 1077 2 3.0 1.5 0.0 if ins._vm.storage_profile.os_disk.managed_disk:
  186. 1078 2 22.0 11.0 0.0 self.provider.azure_client. \
  187. 1079 2 61486021.0 30743010.5 31.8 delete_disk(ins._vm.storage_profile.os_disk.managed_disk.id)
  188. Total time: 93.7213 s
  189. Function: label at line 629
  190. Line # Hits Time Per Hit % Time Line Contents
  191. ==============================================================
  192. 629 @label.setter
  193. 630 @profile
  194. 631 def label(self, value):
  195. 632 """
  196. 633 Set the image label when it is a private image.
  197. 634 """
  198. 635 11 35.0 3.2 0.0 if not self.is_gallery_image:
  199. 636 11 159.0 14.5 0.0 self.assert_valid_resource_label(value)
  200. 637 3 10.0 3.3 0.0 self._image.tags.update(Label=value or "")
  201. 638 3 21.0 7.0 0.0 self._provider.azure_client. \
  202. 639 3 93721100.0 31240366.7 100.0 update_image_tags(self.id, self._image.tags)
  203. Total time: 2.4564 s
  204. Function: create at line 306
  205. Line # Hits Time Per Hit % Time Line Contents
  206. ==============================================================
  207. 306 @dispatch(event="provider.security.key_pairs.create",
  208. 307 priority=BaseKeyPairService.STANDARD_EVENT_PRIORITY)
  209. 308 @profile
  210. 309 def create(self, name, public_key_material=None):
  211. 310 2 26.0 13.0 0.0 AzureKeyPair.assert_valid_resource_name(name)
  212. 311 2 1818893.0 909446.5 74.0 key_pair = self.get(name)
  213. 312
  214. 313 2 1.0 0.5 0.0 if key_pair:
  215. 314 raise DuplicateResourceException(
  216. 315 'Keypair already exists with name {0}'.format(name))
  217. 316
  218. 317 2 2.0 1.0 0.0 private_key = None
  219. 318 2 1.0 0.5 0.0 if not public_key_material:
  220. 319 2 125367.0 62683.5 5.1 public_key_material, private_key = cb_helpers.generate_key_pair()
  221. 320
  222. 321 entity = {
  223. 322 2 8.0 4.0 0.0 'PartitionKey': AzureKeyPairService.PARTITION_KEY,
  224. 323 2 69.0 34.5 0.0 'RowKey': str(uuid.uuid4()),
  225. 324 2 2.0 1.0 0.0 'Name': name,
  226. 325 2 2.0 1.0 0.0 'Key': public_key_material
  227. 326 }
  228. 327
  229. 328 2 259619.0 129809.5 10.6 self.provider.azure_client.create_public_key(entity)
  230. 329 2 252398.0 126199.0 10.3 key_pair = self.get(name)
  231. 330 2 6.0 3.0 0.0 key_pair.material = private_key
  232. 331 2 1.0 0.5 0.0 return key_pair
  233. Total time: 2.12995 s
  234. Function: get_or_create_default at line 320
  235. Line # Hits Time Per Hit % Time Line Contents
  236. ==============================================================
  237. 320 @profile
  238. 321 def get_or_create_default(self, zone):
  239. 322 # Look for a CB-default subnet
  240. 323 1 2129945.0 2129945.0 100.0 matches = self.find(label=BaseSubnet.CB_DEFAULT_SUBNET_LABEL)
  241. 324 1 1.0 1.0 0.0 if matches:
  242. 325 1 2.0 2.0 0.0 return matches[0]
  243. 326
  244. 327 # No provider-default Subnet exists, try to create it (net + subnets)
  245. 328 network = self.provider.networking.networks.get_or_create_default()
  246. 329 subnet = self.create(BaseSubnet.CB_DEFAULT_SUBNET_LABEL, network,
  247. 330 BaseSubnet.CB_DEFAULT_SUBNET_IPV4RANGE, zone)
  248. 331 return subnet
  249. Total time: 2.07273 s
  250. Function: find at line 1272
  251. Line # Hits Time Per Hit % Time Line Contents
  252. ==============================================================
  253. 1272 @dispatch(event="provider.networking.subnets.find",
  254. 1273 priority=BaseSubnetService.STANDARD_EVENT_PRIORITY)
  255. 1274 @profile
  256. 1275 def find(self, network=None, **kwargs):
  257. 1276 1 1595752.0 1595752.0 77.0 obj_list = self._list_subnets(network)
  258. 1277 1 5.0 5.0 0.0 filters = ['label']
  259. 1278 1 476932.0 476932.0 23.0 matches = cb_helpers.generic_find(filters, kwargs, obj_list)
  260. 1279
  261. 1280 1 5.0 5.0 0.0 return ClientPagedResultList(self.provider,
  262. 1281 1 34.0 34.0 0.0 matches if matches else [])
  263. Total time: 2.05943 s
  264. Function: get at line 259
  265. Line # Hits Time Per Hit % Time Line Contents
  266. ==============================================================
  267. 259 @dispatch(event="provider.security.key_pairs.get",
  268. 260 priority=BaseKeyPairService.STANDARD_EVENT_PRIORITY)
  269. 261 @profile
  270. 262 def get(self, key_pair_id):
  271. 263 4 4.0 1.0 0.0 try:
  272. 264 4 29.0 7.2 0.0 key_pair = self.provider.azure_client.\
  273. 265 4 2059336.0 514834.0 100.0 get_public_key(key_pair_id)
  274. 266
  275. 267 4 8.0 2.0 0.0 if key_pair:
  276. 268 2 47.0 23.5 0.0 return AzureKeyPair(self.provider, key_pair)
  277. 269 2 2.0 1.0 0.0 return None
  278. 270 except AzureException as error:
  279. 271 log.debug("KeyPair %s was not found.", key_pair_id)
  280. 272 log.debug(error)
  281. 273 return None
  282. Total time: 1.54248 s
  283. Function: list at line 705
  284. Line # Hits Time Per Hit % Time Line Contents
  285. ==============================================================
  286. 705 @profile
  287. 706 def list(self, filter_by_owner=True, limit=None, marker=None):
  288. 707 """
  289. 708 List all images.
  290. 709 """
  291. 710 6 1542134.0 257022.3 100.0 azure_images = self.provider.azure_client.list_images()
  292. 711 azure_gallery_refs = self.provider.azure_client.list_gallery_refs() \
  293. 712 6 13.0 2.2 0.0 if not filter_by_owner else []
  294. 713 6 8.0 1.3 0.0 cb_images = [AzureMachineImage(self.provider, img)
  295. 714 6 107.0 17.8 0.0 for img in azure_images + azure_gallery_refs]
  296. 715 6 12.0 2.0 0.0 return ClientPagedResultList(self.provider, cb_images,
  297. 716 6 206.0 34.3 0.0 limit=limit, marker=marker)
  298. Total time: 1.36268 s
  299. Function: refresh at line 1340
  300. Line # Hits Time Per Hit % Time Line Contents
  301. ==============================================================
  302. 1340 @profile
  303. 1341 def refresh(self):
  304. 1342 """
  305. 1343 Refreshes the state of this instance by re-querying the cloud provider
  306. 1344 for its latest state.
  307. 1345 """
  308. 1346 4 13.0 3.2 0.0 try:
  309. 1347 4 1362322.0 340580.5 100.0 self._vm = self._provider.azure_client.get_vm(self.id)
  310. 1348 2 4.0 2.0 0.0 if not self._vm.tags:
  311. 1349 self._vm.tags = {}
  312. 1350 2 10.0 5.0 0.0 self._update_state()
  313. 1351 2 7.0 3.5 0.0 except (CloudError, ValueError) as cloud_error:
  314. 1352 2 316.0 158.0 0.0 log.exception(cloud_error.message)
  315. 1353 # The volume no longer exists and cannot be refreshed.
  316. 1354 # set the state to unknown
  317. 1355 2 10.0 5.0 0.0 self._state = 'unknown'
  318. Total time: 1.26517 s
  319. Function: list at line 1180
  320. Line # Hits Time Per Hit % Time Line Contents
  321. ==============================================================
  322. 1180 @dispatch(event="provider.networking.networks.list",
  323. 1181 priority=BaseNetworkService.STANDARD_EVENT_PRIORITY)
  324. 1182 @profile
  325. 1183 def list(self, limit=None, marker=None):
  326. 1184 1 2.0 2.0 0.0 networks = [AzureNetwork(self.provider, network)
  327. 1185 1 1265074.0 1265074.0 100.0 for network in self.provider.azure_client.list_networks()]
  328. 1186 1 8.0 8.0 0.0 return ClientPagedResultList(self.provider, networks,
  329. 1187 1 88.0 88.0 0.0 limit=limit, marker=marker)
  330. Total time: 1.04684 s
  331. Function: refresh at line 705
  332. Line # Hits Time Per Hit % Time Line Contents
  333. ==============================================================
  334. 705 @profile
  335. 706 def refresh(self):
  336. 707 """
  337. 708 Refreshes the state of this instance by re-querying the cloud provider
  338. 709 for its latest state.
  339. 710 """
  340. 711 4 17.0 4.2 0.0 if not self.is_gallery_image:
  341. 712 4 8.0 2.0 0.0 try:
  342. 713 4 1046459.0 261614.8 100.0 self._image = self._provider.azure_client.get_image(self.id)
  343. 714 2 11.0 5.5 0.0 self._state = self._image.provisioning_state
  344. 715 2 9.0 4.5 0.0 except CloudError as cloud_error:
  345. 716 2 328.0 164.0 0.0 log.exception(cloud_error.message)
  346. 717 # image no longer exists
  347. 718 2 8.0 4.0 0.0 self._state = "unknown"
  348. Total time: 1.02779 s
  349. Function: get at line 1168
  350. Line # Hits Time Per Hit % Time Line Contents
  351. ==============================================================
  352. 1168 @dispatch(event="provider.networking.networks.get",
  353. 1169 priority=BaseNetworkService.STANDARD_EVENT_PRIORITY)
  354. 1170 @profile
  355. 1171 def get(self, network_id):
  356. 1172 4 5.0 1.2 0.0 try:
  357. 1173 4 1027667.0 256916.8 100.0 network = self.provider.azure_client.get_network(network_id)
  358. 1174 4 118.0 29.5 0.0 return AzureNetwork(self.provider, network)
  359. 1175 except (CloudError, InvalidValueException) as cloud_error:
  360. 1176 # Azure raises the cloud error if the resource not available
  361. 1177 log.exception(cloud_error)
  362. 1178 return None
  363. Total time: 0.75888 s
  364. Function: get at line 677
  365. Line # Hits Time Per Hit % Time Line Contents
  366. ==============================================================
  367. 677 @profile
  368. 678 def get(self, image_id):
  369. 679 """
  370. 680 Returns an Image given its id
  371. 681 """
  372. 682 3 3.0 1.0 0.0 try:
  373. 683 3 758580.0 252860.0 100.0 image = self.provider.azure_client.get_image(image_id)
  374. 684 2 45.0 22.5 0.0 return AzureMachineImage(self.provider, image)
  375. 685 1 3.0 3.0 0.0 except (CloudError, InvalidValueException) as cloud_error:
  376. 686 # Azure raises the cloud error if the resource not available
  377. 687 1 248.0 248.0 0.0 log.exception(cloud_error)
  378. 688 1 1.0 1.0 0.0 return None
  379. Total time: 0.503087 s
  380. Function: delete at line 333
  381. Line # Hits Time Per Hit % Time Line Contents
  382. ==============================================================
  383. 333 @dispatch(event="provider.security.key_pairs.delete",
  384. 334 priority=BaseKeyPairService.STANDARD_EVENT_PRIORITY)
  385. 335 @profile
  386. 336 def delete(self, key_pair):
  387. 337 2 4.0 2.0 0.0 key_pair = (key_pair if isinstance(key_pair, AzureKeyPair) else
  388. 338 self.get(key_pair))
  389. 339 2 2.0 1.0 0.0 if key_pair:
  390. 340 # pylint:disable=protected-access
  391. 341 2 503081.0 251540.5 100.0 self.provider.azure_client.delete_public_key(key_pair._key_pair)
  392. Total time: 0.470769 s
  393. Function: find at line 690
  394. Line # Hits Time Per Hit % Time Line Contents
  395. ==============================================================
  396. 690 @profile
  397. 691 def find(self, **kwargs):
  398. 692 3 1.0 0.3 0.0 obj_list = self
  399. 693 3 2.0 0.7 0.0 filters = ['label']
  400. 694 3 470713.0 156904.3 100.0 matches = cb_helpers.generic_find(filters, kwargs, obj_list)
  401. 695
  402. 696 # All kwargs should have been popped at this time.
  403. 697 2 3.0 1.5 0.0 if len(kwargs) > 0:
  404. 698 raise InvalidParamException(
  405. 699 "Unrecognised parameters for search: %s. Supported "
  406. 700 "attributes: %s" % (kwargs, ", ".join(filters)))
  407. 701
  408. 702 2 3.0 1.5 0.0 return ClientPagedResultList(self.provider,
  409. 703 2 47.0 23.5 0.0 matches if matches else [])
  410. Total time: 0.286981 s
  411. Function: get at line 1109
  412. Line # Hits Time Per Hit % Time Line Contents
  413. ==============================================================
  414. 1109 @dispatch(event="provider.compute.regions.get",
  415. 1110 priority=BaseRegionService.STANDARD_EVENT_PRIORITY)
  416. 1111 @profile
  417. 1112 def get(self, region_id):
  418. 1113 2 2.0 1.0 0.0 region = None
  419. 1114 6 286832.0 47805.3 99.9 for azureRegion in self.provider.azure_client.list_locations():
  420. 1115 6 7.0 1.2 0.0 if azureRegion.name == region_id:
  421. 1116 2 67.0 33.5 0.0 region = AzureRegion(self.provider, azureRegion)
  422. 1117 2 73.0 36.5 0.0 break
  423. 1118 2 0.0 0.0 0.0 return region