filtered-gcp-compute.res 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  1. cloudbridge.test.test_compute_service.CloudComputeServiceTestCase
  2. Error during cleanup: CloudBridgeBaseException: <HttpError 404 when requesting https://www.googleapis.com/compute/v1/projects/cloudbridge-dev/zones/us-central1-a/disks/cb-blkattch-b77ddf-aafd60?alt=json returned "The resource 'projects/cloudbridge-dev/zones/us-central1-a/disks/cb-blkattch-b77ddf-aafd60' was not found"> from exception type: <class 'googleapiclient.errors.HttpError'>
  3. Error during cleanup: 'NoneType' object has no attribute '_ip'
  4. Test output
  5. ......
  6. ----------------------------------------------------------------------
  7. Ran 6 tests in 1529.464s
  8. OK
  9. Wrote profile results to run_single.py.lprof
  10. Timer unit: 1e-06 s
  11. Total time: 245.431 s
  12. Function: get at line 642
  13. Line # Hits Time Per Hit % Time Line Contents
  14. ==============================================================
  15. 642 @dispatch(event="provider.compute.instances.get",
  16. 643 priority=BaseInstanceService.STANDARD_EVENT_PRIORITY)
  17. 644 @profile
  18. 645 def get(self, instance_id):
  19. 646 """
  20. 647 Returns an instance given its name. Returns None
  21. 648 if the object does not exist.
  22. 649
  23. 650 A GCP instance is uniquely identified by its selfLink, which is used
  24. 651 as its id.
  25. 652 """
  26. 653 725 245415590.0 338504.3 100.0 instance = self.provider.get_resource('instances', instance_id)
  27. 654 725 14964.0 20.6 0.0 return GCPInstance(self.provider, instance) if instance else None
  28. Total time: 242.841 s
  29. Function: refresh at line 1237
  30. Line # Hits Time Per Hit % Time Line Contents
  31. ==============================================================
  32. 1237 @profile
  33. 1238 def refresh(self):
  34. 1239 """
  35. 1240 Refreshes the state of this instance by re-querying the cloud provider
  36. 1241 for its latest state.
  37. 1242 """
  38. 1243 716 242833071.0 339152.3 100.0 inst = self._provider.compute.instances.get(self.id)
  39. 1244 716 819.0 1.1 0.0 if inst:
  40. 1245 # pylint:disable=protected-access
  41. 1246 711 6944.0 9.8 0.0 self._gcp_instance = inst._gcp_instance
  42. 1247 else:
  43. 1248 # instance no longer exists
  44. 1249 5 18.0 3.6 0.0 self._gcp_instance['status'] = InstanceState.UNKNOWN
  45. Total time: 241.941 s
  46. Function: create at line 490
  47. Line # Hits Time Per Hit % Time Line Contents
  48. ==============================================================
  49. 490 @dispatch(event="provider.compute.instances.create",
  50. 491 priority=BaseInstanceService.STANDARD_EVENT_PRIORITY)
  51. 492 @profile
  52. 493 def create(self, label, image, vm_type, subnet, zone=None,
  53. 494 key_pair=None, vm_firewalls=None, user_data=None,
  54. 495 launch_config=None, **kwargs):
  55. 496 """
  56. 497 Creates a new virtual machine instance.
  57. 498 """
  58. 499 14 184.0 13.1 0.0 GCPInstance.assert_valid_resource_name(label)
  59. 500 4 22.0 5.5 0.0 zone_name = self.provider.default_zone
  60. 501 4 8.0 2.0 0.0 if zone:
  61. 502 4 14.0 3.5 0.0 if not isinstance(zone, GCPPlacementZone):
  62. 503 4 7.0 1.8 0.0 zone = GCPPlacementZone(
  63. 504 4 11.0 2.8 0.0 self.provider,
  64. 505 4 635237.0 158809.2 0.3 self.provider.get_resource('zones', zone))
  65. 506 4 26.0 6.5 0.0 zone_name = zone.name
  66. 507 4 20.0 5.0 0.0 if not isinstance(vm_type, GCPVMType):
  67. 508 4 676873.0 169218.2 0.3 vm_type = self.provider.compute.vm_types.get(vm_type)
  68. 509
  69. 510 4 12.0 3.0 0.0 network_interface = {'accessConfigs': [{'type': 'ONE_TO_ONE_NAT',
  70. 511 4 14.0 3.5 0.0 'name': 'External NAT'}]}
  71. 512 4 13.0 3.2 0.0 if subnet:
  72. 513 4 29.0 7.2 0.0 network_interface['subnetwork'] = subnet.id
  73. 514 else:
  74. 515 network_interface['network'] = 'global/networks/default'
  75. 516
  76. 517 4 11.0 2.8 0.0 num_roots = 0
  77. 518 4 9.0 2.2 0.0 disks = []
  78. 519 4 11.0 2.8 0.0 boot_disk = None
  79. 520 4 14.0 3.5 0.0 if isinstance(launch_config, GCPLaunchConfig):
  80. 521 17 52.0 3.1 0.0 for disk in launch_config.block_devices:
  81. 522 16 48.0 3.0 0.0 if not disk.source:
  82. 523 13 810.0 62.3 0.0 volume_name = 'disk-{0}'.format(uuid.uuid4())
  83. 524 13 43.0 3.3 0.0 volume_size = disk.size if disk.size else 1
  84. 525 13 184.0 14.2 0.0 volume = self.provider.storage.volumes.create(
  85. 526 13 17742244.0 1364788.0 7.3 volume_name, volume_size, zone)
  86. 527 13 16957937.0 1304456.7 7.0 volume.wait_till_ready()
  87. 528 13 38.0 2.9 0.0 source_field = 'source'
  88. 529 13 59.0 4.5 0.0 source_value = volume.id
  89. 530 3 14.0 4.7 0.0 elif isinstance(disk.source, GCPMachineImage):
  90. 531 1 2.0 2.0 0.0 source_field = 'initializeParams'
  91. 532 # Explicitly set diskName; otherwise, instance label will
  92. 533 # be used by default which may collide with existing disks.
  93. 534 source_value = {
  94. 535 1 7.0 7.0 0.0 'sourceImage': disk.source.id,
  95. 536 1 70.0 70.0 0.0 'diskName': 'image-disk-{0}'.format(uuid.uuid4()),
  96. 537 1 5.0 5.0 0.0 'diskSizeGb': disk.size if disk.size else 20}
  97. 538 2 7.0 3.5 0.0 elif isinstance(disk.source, GCPVolume):
  98. 539 1 2.0 2.0 0.0 source_field = 'source'
  99. 540 1 5.0 5.0 0.0 source_value = disk.source.id
  100. 541 1 4.0 4.0 0.0 elif isinstance(disk.source, GCPSnapshot):
  101. 542 1 1637892.0 1637892.0 0.7 volume = disk.source.create_volume(zone, size=disk.size)
  102. 543 1 20995545.0 20995545.0 8.7 volume.wait_till_ready()
  103. 544 1 3.0 3.0 0.0 source_field = 'source'
  104. 545 1 5.0 5.0 0.0 source_value = volume.id
  105. 546 else:
  106. 547 log.warning('Unknown disk source')
  107. 548 continue
  108. 549 16 45.0 2.8 0.0 autoDelete = True
  109. 550 16 53.0 3.3 0.0 if disk.delete_on_terminate is not None:
  110. 551 4 12.0 3.0 0.0 autoDelete = disk.delete_on_terminate
  111. 552 16 57.0 3.6 0.0 num_roots += 1 if disk.is_root else 0
  112. 553 16 45.0 2.8 0.0 if disk.is_root and not boot_disk:
  113. 554 1 3.0 3.0 0.0 boot_disk = {'boot': True,
  114. 555 1 3.0 3.0 0.0 'autoDelete': autoDelete,
  115. 556 1 3.0 3.0 0.0 source_field: source_value}
  116. 557 else:
  117. 558 15 47.0 3.1 0.0 disks.append({'boot': False,
  118. 559 15 39.0 2.6 0.0 'autoDelete': autoDelete,
  119. 560 15 56.0 3.7 0.0 source_field: source_value})
  120. 561
  121. 562 4 11.0 2.8 0.0 if num_roots > 1:
  122. 563 log.warning('The launch config contains %d boot disks. Will '
  123. 564 'use the first one', num_roots)
  124. 565 4 11.0 2.8 0.0 if image:
  125. 566 4 10.0 2.5 0.0 if boot_disk:
  126. 567 1 229.0 229.0 0.0 log.warning('A boot image is given while the launch config '
  127. 568 'contains a boot disk, too. The launch config '
  128. 569 'will be used.')
  129. 570 else:
  130. 571 3 10.0 3.3 0.0 if not isinstance(image, GCPMachineImage):
  131. 572 3 553853.0 184617.7 0.2 image = self.provider.compute.images.get(image)
  132. 573 # Explicitly set diskName; otherwise, instance name will be
  133. 574 # used by default which may conflict with existing disks.
  134. 575 boot_disk = {
  135. 576 3 8.0 2.7 0.0 'boot': True,
  136. 577 3 8.0 2.7 0.0 'autoDelete': True,
  137. 578 'initializeParams': {
  138. 579 3 17.0 5.7 0.0 'sourceImage': image.id,
  139. 580 3 189.0 63.0 0.0 'diskName': 'image-disk-{0}'.format(uuid.uuid4())}}
  140. 581
  141. 582 4 13.0 3.2 0.0 if not boot_disk:
  142. 583 log.warning('No boot disk is given for instance %s.', label)
  143. 584 return None
  144. 585 # The boot disk must be the first disk attached to the instance.
  145. 586 4 17.0 4.2 0.0 disks.insert(0, boot_disk)
  146. 587
  147. 588 config = {
  148. 589 4 230.0 57.5 0.0 'name': GCPInstance._generate_name_from_label(label, 'cb-inst'),
  149. 590 4 32.0 8.0 0.0 'machineType': vm_type.resource_url,
  150. 591 4 11.0 2.8 0.0 'disks': disks,
  151. 592 4 15.0 3.8 0.0 'networkInterfaces': [network_interface]
  152. 593 }
  153. 594
  154. 595 4 12.0 3.0 0.0 if vm_firewalls and isinstance(vm_firewalls, list):
  155. 596 1 3.0 3.0 0.0 vm_firewall_names = []
  156. 597 1 4.0 4.0 0.0 if isinstance(vm_firewalls[0], VMFirewall):
  157. 598 1 10.0 10.0 0.0 vm_firewall_names = [f.name for f in vm_firewalls]
  158. 599 elif isinstance(vm_firewalls[0], str):
  159. 600 vm_firewall_names = vm_firewalls
  160. 601 1 3.0 3.0 0.0 if len(vm_firewall_names) > 0:
  161. 602 1 4.0 4.0 0.0 config['tags'] = {}
  162. 603 1 4.0 4.0 0.0 config['tags']['items'] = vm_firewall_names
  163. 604
  164. 605 4 11.0 2.8 0.0 if user_data:
  165. 606 entry = {'key': 'user-data', 'value': user_data}
  166. 607 config['metadata'] = {'items': [entry]}
  167. 608
  168. 609 4 11.0 2.8 0.0 if key_pair:
  169. 610 1 3.0 3.0 0.0 if not isinstance(key_pair, GCPKeyPair):
  170. 611 key_pair = self._provider.security.key_pairs.get(key_pair)
  171. 612 1 3.0 3.0 0.0 if key_pair:
  172. 613 1 3.0 3.0 0.0 kp = key_pair._key_pair
  173. 614 kp_entry = {
  174. 615 1 3.0 3.0 0.0 "key": "ssh-keys",
  175. 616 # Format is not removed from public key portion
  176. 617 1 3.0 3.0 0.0 "value": "{}:{} {}".format(
  177. 618 1 10.0 10.0 0.0 self.provider.vm_default_user_name,
  178. 619 1 5.0 5.0 0.0 kp.public_key,
  179. 620 1 7.0 7.0 0.0 kp.name)
  180. 621 }
  181. 622 1 4.0 4.0 0.0 meta = config.get('metadata', {})
  182. 623 1 3.0 3.0 0.0 if meta:
  183. 624 items = meta.get('items', [])
  184. 625 items.append(kp_entry)
  185. 626 else:
  186. 627 1 4.0 4.0 0.0 config['metadata'] = {'items': [kp_entry]}
  187. 628
  188. 629 4 13.0 3.2 0.0 config['labels'] = {'cblabel': label}
  189. 630
  190. 631 4 108434.0 27108.5 0.0 operation = (self.provider
  191. 632 .gcp_compute.instances()
  192. 633 4 31.0 7.8 0.0 .insert(project=self.provider.project_name,
  193. 634 4 7.0 1.8 0.0 zone=zone_name,
  194. 635 4 5754771.0 1438692.8 2.4 body=config)
  195. 636 .execute())
  196. 637 4 17.0 4.2 0.0 instance_id = operation.get('targetLink')
  197. 638 4 175462029.0 43865507.2 72.5 self.provider.wait_for_operation(operation, zone=zone_name)
  198. 639 4 1412949.0 353237.2 0.6 cb_inst = self.get(instance_id)
  199. 640 4 13.0 3.2 0.0 return cb_inst
  200. Total time: 36.3814 s
  201. Function: create at line 205
  202. Line # Hits Time Per Hit % Time Line Contents
  203. ==============================================================
  204. 205 @dispatch(event="provider.security.vm_firewalls.create",
  205. 206 priority=BaseVMFirewallService.STANDARD_EVENT_PRIORITY)
  206. 207 @profile
  207. 208 def create(self, label, network, description=None):
  208. 209 2 22.0 11.0 0.0 GCPVMFirewall.assert_valid_resource_label(label)
  209. 210 2 5.0 2.5 0.0 network = (network if isinstance(network, GCPNetwork)
  210. 211 2 510381.0 255190.5 1.4 else self.provider.networking.networks.get(network))
  211. 212 2 46.0 23.0 0.0 fw = GCPVMFirewall(self._delegate, label, network, description)
  212. 213 2 19958778.0 9979389.0 54.9 fw.label = label
  213. 214 # This rule exists implicitly. Add it explicitly so that the firewall
  214. 215 # is not empty and the rule is shown by list/get/find methods.
  215. 216 # pylint:disable=protected-access
  216. 217 2 26.0 13.0 0.0 self.provider.security._vm_firewall_rules.create_with_priority(
  217. 218 2 10.0 5.0 0.0 fw, direction=TrafficDirection.OUTBOUND, protocol='tcp',
  218. 219 2 15912115.0 7956057.5 43.7 priority=65534, cidr='0.0.0.0/0')
  219. 220 2 1.0 0.5 0.0 return fw
  220. Total time: 28.846 s
  221. Function: delete at line 222
  222. Line # Hits Time Per Hit % Time Line Contents
  223. ==============================================================
  224. 222 @dispatch(event="provider.security.vm_firewalls.delete",
  225. 223 priority=BaseVMFirewallService.STANDARD_EVENT_PRIORITY)
  226. 224 @profile
  227. 225 def delete(self, vm_firewall):
  228. 226 2 57.0 28.5 0.0 fw_id = (vm_firewall.id if isinstance(vm_firewall, GCPVMFirewall)
  229. 227 else vm_firewall)
  230. 228 2 28845964.0 14422982.0 100.0 return self._delegate.delete_tag_network_with_id(fw_id)
  231. Total time: 25.7981 s
  232. Function: create at line 1032
  233. Line # Hits Time Per Hit % Time Line Contents
  234. ==============================================================
  235. 1032 @dispatch(event="provider.networking.subnets.create",
  236. 1033 priority=BaseSubnetService.STANDARD_EVENT_PRIORITY)
  237. 1034 @profile
  238. 1035 def create(self, label, network, cidr_block, zone):
  239. 1036 """
  240. 1037 GCP subnets are regional. The region is inferred from the zone;
  241. 1038 otherwise, the default region, as set in the
  242. 1039 provider, is used.
  243. 1040
  244. 1041 If a subnet with overlapping IP range exists already, we return that
  245. 1042 instead of creating a new subnet. In this case, other parameters, i.e.
  246. 1043 the name and the zone, are ignored.
  247. 1044 """
  248. 1045 1 11.0 11.0 0.0 GCPSubnet.assert_valid_resource_label(label)
  249. 1046 1 52.0 52.0 0.0 name = GCPSubnet._generate_name_from_label(label, 'cbsubnet')
  250. 1047 1 9.0 9.0 0.0 region_name = self._zone_to_region(zone)
  251. 1048 # for subnet in self.iter(network=network):
  252. 1049 # if BaseNetwork.cidr_blocks_overlap(subnet.cidr_block, cidr_block):
  253. 1050 # if subnet.region_name != region_name:
  254. 1051 # log.error('Failed to create subnetwork in region %s: '
  255. 1052 # 'the given IP range %s overlaps with a '
  256. 1053 # 'subnetwork in a different region %s',
  257. 1054 # region_name, cidr_block, subnet.region_name)
  258. 1055 # return None
  259. 1056 # return subnet
  260. 1057 # if subnet.label == label and subnet.region_name == region_name:
  261. 1058 # return subnet
  262. 1059
  263. 1060 1 1.0 1.0 0.0 body = {'ipCidrRange': cidr_block,
  264. 1061 1 1.0 1.0 0.0 'name': name,
  265. 1062 1 3.0 3.0 0.0 'network': network.resource_url,
  266. 1063 1 1.0 1.0 0.0 'region': region_name
  267. 1064 }
  268. 1065 1 11972.0 11972.0 0.0 response = (self.provider
  269. 1066 .gcp_compute
  270. 1067 .subnetworks()
  271. 1068 1 4.0 4.0 0.0 .insert(project=self.provider.project_name,
  272. 1069 1 0.0 0.0 0.0 region=region_name,
  273. 1070 1 1025636.0 1025636.0 4.0 body=body)
  274. 1071 .execute())
  275. 1072 1 16362161.0 16362161.0 63.4 self.provider.wait_for_operation(response, region=region_name)
  276. 1073 1 351602.0 351602.0 1.4 cb_subnet = self.get(name)
  277. 1074 1 8046680.0 8046680.0 31.2 cb_subnet.label = label
  278. 1075 1 2.0 2.0 0.0 return cb_subnet
  279. Total time: 25.4765 s
  280. Function: delete at line 861
  281. Line # Hits Time Per Hit % Time Line Contents
  282. ==============================================================
  283. 861 @dispatch(event="provider.networking.networks.delete",
  284. 862 priority=BaseNetworkService.STANDARD_EVENT_PRIORITY)
  285. 863 @profile
  286. 864 def delete(self, network):
  287. 865 # Accepts network object
  288. 866 1 2.0 2.0 0.0 if isinstance(network, GCPNetwork):
  289. 867 1 3.0 3.0 0.0 name = network.name
  290. 868 # Accepts both name and ID
  291. 869 elif 'googleapis' in network:
  292. 870 name = network.split('/')[-1]
  293. 871 else:
  294. 872 name = network
  295. 873 1 5053.0 5053.0 0.0 response = (self.provider
  296. 874 .gcp_compute
  297. 875 .networks()
  298. 876 1 3.0 3.0 0.0 .delete(project=self.provider.project_name,
  299. 877 1 967890.0 967890.0 3.8 network=name)
  300. 878 .execute())
  301. 879 1 16367108.0 16367108.0 64.2 self.provider.wait_for_operation(response)
  302. 880 # Remove label
  303. 881 1 4.0 4.0 0.0 tag_name = "_".join(["network", name, "label"])
  304. 882 1 8136406.0 8136406.0 31.9 if not helpers.remove_metadata_item(self.provider, tag_name):
  305. 883 log.warning('No label was found associated with this network '
  306. 884 '"{}" when deleted.'.format(network))
  307. 885 1 2.0 2.0 0.0 return True
  308. Total time: 22.9287 s
  309. Function: create at line 824
  310. Line # Hits Time Per Hit % Time Line Contents
  311. ==============================================================
  312. 824 @dispatch(event="provider.networking.networks.create",
  313. 825 priority=BaseNetworkService.STANDARD_EVENT_PRIORITY)
  314. 826 @profile
  315. 827 def create(self, label, cidr_block):
  316. 828 """
  317. 829 Creates an auto mode VPC network with default subnets. It is possible
  318. 830 to add additional subnets later.
  319. 831 """
  320. 832 1 9.0 9.0 0.0 GCPNetwork.assert_valid_resource_label(label)
  321. 833 1 41.0 41.0 0.0 name = GCPNetwork._generate_name_from_label(label, 'cbnet')
  322. 834 1 1.0 1.0 0.0 body = {'name': name}
  323. 835 # This results in a custom mode network
  324. 836 1 0.0 0.0 0.0 body['autoCreateSubnetworks'] = False
  325. 837 1 193516.0 193516.0 0.8 response = (self.provider
  326. 838 .gcp_compute
  327. 839 .networks()
  328. 840 1 4.0 4.0 0.0 .insert(project=self.provider.project_name,
  329. 841 1 1227328.0 1227328.0 5.4 body=body)
  330. 842 .execute())
  331. 843 1 13926261.0 13926261.0 60.7 self.provider.wait_for_operation(response)
  332. 844 1 264097.0 264097.0 1.2 cb_net = self.get(name)
  333. 845 1 7317483.0 7317483.0 31.9 cb_net.label = label
  334. 846 1 1.0 1.0 0.0 return cb_net
  335. Total time: 22.513 s
  336. Function: delete at line 1077
  337. Line # Hits Time Per Hit % Time Line Contents
  338. ==============================================================
  339. 1077 @dispatch(event="provider.networking.subnets.delete",
  340. 1078 priority=BaseSubnetService.STANDARD_EVENT_PRIORITY)
  341. 1079 @profile
  342. 1080 def delete(self, subnet):
  343. 1081 1 3.0 3.0 0.0 sn = subnet if isinstance(subnet, GCPSubnet) else self.get(subnet)
  344. 1082 1 1.0 1.0 0.0 if not sn:
  345. 1083 return
  346. 1084 1 9758.0 9758.0 0.0 response = (self.provider
  347. 1085 .gcp_compute
  348. 1086 .subnetworks()
  349. 1087 1 5.0 5.0 0.0 .delete(project=self.provider.project_name,
  350. 1088 1 371.0 371.0 0.0 region=sn.region_name,
  351. 1089 1 819133.0 819133.0 3.6 subnetwork=sn.name)
  352. 1090 .execute())
  353. 1091 1 14504569.0 14504569.0 64.4 self.provider.wait_for_operation(response, region=sn.region_name)
  354. 1092 # Remove label
  355. 1093 1 11.0 11.0 0.0 tag_name = "_".join(["subnet", sn.name, "label"])
  356. 1094 1 7179153.0 7179153.0 31.9 if not helpers.remove_metadata_item(self._provider, tag_name):
  357. 1095 log.warning('No label was found associated with this subnet '
  358. 1096 '"{}" when deleted.'.format(sn.name))
  359. Total time: 19.9587 s
  360. Function: label at line 482
  361. Line # Hits Time Per Hit % Time Line Contents
  362. ==============================================================
  363. 482 @label.setter
  364. 483 @profile
  365. 484 def label(self, value):
  366. 485 2 17.0 8.5 0.0 self.assert_valid_resource_label(value)
  367. 486 2 8.0 4.0 0.0 tag_name = "_".join(["firewall", self.name, "label"])
  368. 487 2 19958719.0 9979359.5 100.0 helpers.modify_or_add_metadata_item(self._provider, tag_name, value)
  369. Total time: 19.7516 s
  370. Function: create at line 1269
  371. Line # Hits Time Per Hit % Time Line Contents
  372. ==============================================================
  373. 1269 @dispatch(event="provider.storage.volumes.create",
  374. 1270 priority=BaseVolumeService.STANDARD_EVENT_PRIORITY)
  375. 1271 @profile
  376. 1272 def create(self, label, size, zone, snapshot=None, description=None):
  377. 1273 14 150.0 10.7 0.0 GCPVolume.assert_valid_resource_label(label)
  378. 1274 14 678.0 48.4 0.0 name = GCPVolume._generate_name_from_label(label, 'cb-vol')
  379. 1275 14 27.0 1.9 0.0 if not isinstance(zone, GCPPlacementZone):
  380. 1276 1 1.0 1.0 0.0 zone = GCPPlacementZone(
  381. 1277 1 1.0 1.0 0.0 self.provider,
  382. 1278 1 826571.0 826571.0 4.2 self.provider.get_resource('zones', zone))
  383. 1279 14 55.0 3.9 0.0 zone_name = zone.name
  384. 1280 14 16.0 1.1 0.0 snapshot_id = snapshot.id if isinstance(
  385. 1281 14 32.0 2.3 0.0 snapshot, GCPSnapshot) and snapshot else snapshot
  386. 1282 14 19.0 1.4 0.0 labels = {'cblabel': label}
  387. 1283 14 19.0 1.4 0.0 if description:
  388. 1284 labels['description'] = description
  389. 1285 disk_body = {
  390. 1286 14 13.0 0.9 0.0 'name': name,
  391. 1287 14 16.0 1.1 0.0 'sizeGb': size,
  392. 1288 14 48.0 3.4 0.0 'type': 'zones/{0}/diskTypes/{1}'.format(zone_name, 'pd-standard'),
  393. 1289 14 16.0 1.1 0.0 'sourceSnapshot': snapshot_id,
  394. 1290 14 22.0 1.6 0.0 'labels': labels
  395. 1291 }
  396. 1292 14 129817.0 9272.6 0.7 operation = (self.provider
  397. 1293 .gcp_compute
  398. 1294 .disks()
  399. 1295 .insert(
  400. 1296 14 35.0 2.5 0.0 project=self._provider.project_name,
  401. 1297 14 13.0 0.9 0.0 zone=zone_name,
  402. 1298 14 13700287.0 978591.9 69.4 body=disk_body)
  403. 1299 .execute())
  404. 1300 14 5093711.0 363836.5 25.8 cb_vol = self.get(operation.get('targetLink'))
  405. 1301 14 18.0 1.3 0.0 return cb_vol
  406. Total time: 18.3208 s
  407. Function: list at line 1645
  408. Line # Hits Time Per Hit % Time Line Contents
  409. ==============================================================
  410. 1645 @dispatch(event="provider.networking.floating_ips.list",
  411. 1646 priority=BaseFloatingIPService.STANDARD_EVENT_PRIORITY)
  412. 1647 @profile
  413. 1648 def list(self, gateway, limit=None, marker=None):
  414. 1649 13 24.0 1.8 0.0 max_result = limit if limit is not None and limit < 500 else 500
  415. 1650 13 53702.0 4130.9 0.3 response = (self.provider
  416. 1651 .gcp_compute
  417. 1652 .addresses()
  418. 1653 13 50.0 3.8 0.0 .list(project=self.provider.project_name,
  419. 1654 13 18.0 1.4 0.0 region=self.provider.region_name,
  420. 1655 13 12.0 0.9 0.0 maxResults=max_result,
  421. 1656 13 5317579.0 409044.5 29.0 pageToken=marker)
  422. 1657 .execute())
  423. 1658 13 47.0 3.6 0.0 ips = [GCPFloatingIP(self.provider, ip)
  424. 1659 13 12949130.0 996086.9 70.7 for ip in response.get('items', [])]
  425. 1660 13 42.0 3.2 0.0 if len(ips) > max_result:
  426. 1661 log.warning('Expected at most %d results; got %d',
  427. 1662 max_result, len(ips))
  428. 1663 13 21.0 1.6 0.0 return ServerPagedResultList('nextPageToken' in response,
  429. 1664 13 25.0 1.9 0.0 response.get('nextPageToken'),
  430. 1665 13 148.0 11.4 0.0 False, data=ips)
  431. Total time: 15.9121 s
  432. Function: create_with_priority at line 284
  433. Line # Hits Time Per Hit % Time Line Contents
  434. ==============================================================
  435. 284 @profile
  436. 285 def create_with_priority(self, firewall, direction, protocol, priority,
  437. 286 from_port=None, to_port=None, cidr=None,
  438. 287 src_dest_fw=None):
  439. 288 2 8.0 4.0 0.0 port = GCPVMFirewallRuleService.to_port_range(from_port, to_port)
  440. 289 2 2.0 1.0 0.0 src_dest_tag = None
  441. 290 2 1.0 0.5 0.0 src_dest_fw_id = None
  442. 291 2 2.0 1.0 0.0 if src_dest_fw:
  443. 292 src_dest_tag = src_dest_fw.name
  444. 293 src_dest_fw_id = src_dest_fw.id
  445. 294 2 9.0 4.5 0.0 if not firewall.delegate.add_firewall(
  446. 295 2 5.0 2.5 0.0 firewall.name, direction, protocol, priority, port, cidr,
  447. 296 2 7.0 3.5 0.0 src_dest_tag, firewall.description,
  448. 297 2 15863023.0 7931511.5 99.7 firewall.network.name):
  449. 298 return None
  450. 299 2 7.0 3.5 0.0 rules = self.find(firewall, direction=direction, protocol=protocol,
  451. 300 2 1.0 0.5 0.0 from_port=from_port, to_port=to_port, cidr=cidr,
  452. 301 2 48992.0 24496.0 0.3 src_dest_fw_id=src_dest_fw_id)
  453. 302 2 2.0 1.0 0.0 if len(rules) < 1:
  454. 303 2 1.0 0.5 0.0 return None
  455. 304 return rules[0]
  456. Total time: 14.5569 s
  457. Function: get at line 1196
  458. Line # Hits Time Per Hit % Time Line Contents
  459. ==============================================================
  460. 1196 @dispatch(event="provider.storage.volumes.get",
  461. 1197 priority=BaseVolumeService.STANDARD_EVENT_PRIORITY)
  462. 1198 @profile
  463. 1199 def get(self, volume_id):
  464. 1200 45 14556025.0 323467.2 100.0 vol = self.provider.get_resource('disks', volume_id)
  465. 1201 45 900.0 20.0 0.0 return GCPVolume(self.provider, vol) if vol else None
  466. Total time: 13.8162 s
  467. Function: label at line 822
  468. Line # Hits Time Per Hit % Time Line Contents
  469. ==============================================================
  470. 822 @label.setter
  471. 823 # pylint:disable=arguments-differ
  472. 824 @profile
  473. 825 def label(self, value):
  474. 826 11 219616.0 19965.1 1.6 req = (self._provider
  475. 827 .gcp_compute
  476. 828 .instances()
  477. 829 11 39.0 3.5 0.0 .setLabels(project=self._provider.project_name,
  478. 830 11 4303.0 391.2 0.0 zone=self.zone_name,
  479. 831 11 24.0 2.2 0.0 instance=self.name,
  480. 832 11 4395.0 399.5 0.0 body={}))
  481. 833
  482. 834 11 13587832.0 1235257.5 98.3 helpers.change_label(self, 'cblabel', value, '_gcp_instance', req)
  483. Total time: 13.7372 s
  484. Function: create at line 935
  485. Line # Hits Time Per Hit % Time Line Contents
  486. ==============================================================
  487. 935 @dispatch(event="provider.networking.routers.create",
  488. 936 priority=BaseRouterService.STANDARD_EVENT_PRIORITY)
  489. 937 @profile
  490. 938 def create(self, label, network):
  491. 939 1 3.0 3.0 0.0 log.debug("Creating GCP Router Service with params "
  492. 940 1 10.0 10.0 0.0 "[label: %s network: %s]", label, network)
  493. 941 1 13.0 13.0 0.0 GCPRouter.assert_valid_resource_label(label)
  494. 942 1 53.0 53.0 0.0 name = GCPRouter._generate_name_from_label(label, 'cb-router')
  495. 943
  496. 944 1 1.0 1.0 0.0 if not isinstance(network, GCPNetwork):
  497. 945 network = self.provider.networking.networks.get(network)
  498. 946 1 4.0 4.0 0.0 network_url = network.resource_url
  499. 947 1 4.0 4.0 0.0 region_name = self.provider.region_name
  500. 948 1 11796.0 11796.0 0.1 response = (self.provider
  501. 949 .gcp_compute
  502. 950 .routers()
  503. 951 1 3.0 3.0 0.0 .insert(project=self.provider.project_name,
  504. 952 1 1.0 1.0 0.0 region=region_name,
  505. 953 1 0.0 0.0 0.0 body={'name': name,
  506. 954 1 1130879.0 1130879.0 8.2 'network': network_url})
  507. 955 .execute())
  508. 956 1 1968172.0 1968172.0 14.3 self.provider.wait_for_operation(response, region=region_name)
  509. 957 1 409329.0 409329.0 3.0 cb_router = self.get(name)
  510. 958 1 10216949.0 10216949.0 74.4 cb_router.label = label
  511. 959 1 2.0 2.0 0.0 return cb_router
  512. Total time: 13.1326 s
  513. Function: create at line 1381
  514. Line # Hits Time Per Hit % Time Line Contents
  515. ==============================================================
  516. 1381 @dispatch(event="provider.storage.snapshots.create",
  517. 1382 priority=BaseSnapshotService.STANDARD_EVENT_PRIORITY)
  518. 1383 @profile
  519. 1384 def create(self, label, volume, description=None):
  520. 1385 1 10.0 10.0 0.0 GCPSnapshot.assert_valid_resource_label(label)
  521. 1386 1 53.0 53.0 0.0 name = GCPSnapshot._generate_name_from_label(label, 'cbsnap')
  522. 1387 1 4.0 4.0 0.0 volume_name = volume.name if isinstance(volume, GCPVolume) else volume
  523. 1388 1 1.0 1.0 0.0 labels = {'cblabel': label}
  524. 1389 1 1.0 1.0 0.0 if description:
  525. 1390 1 1.0 1.0 0.0 labels['description'] = description
  526. 1391 snapshot_body = {
  527. 1392 1 1.0 1.0 0.0 "name": name,
  528. 1393 1 1.0 1.0 0.0 "labels": labels
  529. 1394 }
  530. 1395 1 8395.0 8395.0 0.1 operation = (self.provider
  531. 1396 .gcp_compute
  532. 1397 .disks()
  533. 1398 .createSnapshot(
  534. 1399 1 3.0 3.0 0.0 project=self.provider.project_name,
  535. 1400 1 1.0 1.0 0.0 zone=self.provider.default_zone,
  536. 1401 1 876631.0 876631.0 6.7 disk=volume_name, body=snapshot_body)
  537. 1402 .execute())
  538. 1403 1 2.0 2.0 0.0 if 'zone' not in operation:
  539. 1404 return None
  540. 1405 1 8.0 8.0 0.0 self.provider.wait_for_operation(operation,
  541. 1406 1 11986182.0 11986182.0 91.3 zone=self.provider.default_zone)
  542. 1407 1 261346.0 261346.0 2.0 cb_snap = self.get(name)
  543. 1408 1 1.0 1.0 0.0 return cb_snap
  544. Total time: 10.9667 s
  545. Function: delete at line 961
  546. Line # Hits Time Per Hit % Time Line Contents
  547. ==============================================================
  548. 961 @dispatch(event="provider.networking.routers.delete",
  549. 962 priority=BaseRouterService.STANDARD_EVENT_PRIORITY)
  550. 963 @profile
  551. 964 def delete(self, router):
  552. 965 1 3.0 3.0 0.0 r = router if isinstance(router, GCPRouter) else self.get(router)
  553. 966 1 1.0 1.0 0.0 if r:
  554. 967 1 7093.0 7093.0 0.1 (self.provider
  555. 968 .gcp_compute
  556. 969 .routers()
  557. 970 1 3.0 3.0 0.0 .delete(project=self.provider.project_name,
  558. 971 1 318.0 318.0 0.0 region=r.region_name,
  559. 972 1 611062.0 611062.0 5.6 router=r.name)
  560. 973 .execute())
  561. 974 # Remove label
  562. 975 1 8.0 8.0 0.0 tag_name = "_".join(["router", r.name, "label"])
  563. 976 1 10348188.0 10348188.0 94.4 if not helpers.remove_metadata_item(self.provider, tag_name):
  564. 977 log.warning('No label was found associated with this router '
  565. 978 '"{}" when deleted.'.format(r.name))
  566. Total time: 10.2169 s
  567. Function: label at line 1445
  568. Line # Hits Time Per Hit % Time Line Contents
  569. ==============================================================
  570. 1445 @label.setter
  571. 1446 @profile
  572. 1447 def label(self, value):
  573. 1448 1 6.0 6.0 0.0 self.assert_valid_resource_label(value)
  574. 1449 1 3.0 3.0 0.0 tag_name = "_".join(["router", self.name, "label"])
  575. 1450 1 10216885.0 10216885.0 100.0 helpers.modify_or_add_metadata_item(self._provider, tag_name, value)
  576. Total time: 9.36634 s
  577. Function: get_or_create_default at line 1098
  578. Line # Hits Time Per Hit % Time Line Contents
  579. ==============================================================
  580. 1098 @profile
  581. 1099 def get_or_create_default(self, zone):
  582. 1100 """
  583. 1101 Return an existing or create a new subnet for the supplied zone.
  584. 1102
  585. 1103 In GCP, subnets are a regional resource so a single subnet can services
  586. 1104 an entire region. The supplied zone parameter is used to derive the
  587. 1105 parent region under which the default subnet then exists.
  588. 1106 """
  589. 1107 # In case the supplied zone param is `None`, resort to the default one
  590. 1108 3 7.0 2.3 0.0 region = self._zone_to_region(zone or self.provider.default_zone,
  591. 1109 3 1330108.0 443369.3 14.2 return_name_only=False)
  592. 1110 # Check if a default subnet already exists for the given region/zone
  593. 1111 3 8036183.0 2678727.7 85.8 for sn in self.find(label=GCPSubnet.CB_DEFAULT_SUBNET_LABEL):
  594. 1112 3 33.0 11.0 0.0 if sn.region == region.id:
  595. 1113 3 9.0 3.0 0.0 return sn
  596. 1114 # No default subnet in the supplied zone. Look for a default network,
  597. 1115 # then create a subnet whose address space does not overlap with any
  598. 1116 # other existing subnets. If there are existing subnets, this process
  599. 1117 # largely assumes the subnet address spaces are contiguous when it
  600. 1118 # does the calculations (e.g., 10.0.0.0/24, 10.0.1.0/24).
  601. 1119 cidr_block = GCPSubnet.CB_DEFAULT_SUBNET_IPV4RANGE
  602. 1120 net = self.provider.networking.networks.get_or_create_default()
  603. 1121 if net.subnets:
  604. 1122 max_sn = net.subnets[0]
  605. 1123 # Find the maximum address subnet address space within the network
  606. 1124 for esn in net.subnets:
  607. 1125 if (ipaddress.ip_network(esn.cidr_block) >
  608. 1126 ipaddress.ip_network(max_sn.cidr_block)):
  609. 1127 max_sn = esn
  610. 1128 max_sn_ipa = ipaddress.ip_network(max_sn.cidr_block)
  611. 1129 # Find the next available subnet after the max one, based on the
  612. 1130 # max subnet size
  613. 1131 next_sn_address = (
  614. 1132 next(max_sn_ipa.hosts()) + max_sn_ipa.num_addresses - 1)
  615. 1133 cidr_block = "{}/{}".format(next_sn_address, max_sn_ipa.prefixlen)
  616. 1134 sn = self.provider.networking.subnets.create(
  617. 1135 label=GCPSubnet.CB_DEFAULT_SUBNET_LABEL,
  618. 1136 cidr_block=cidr_block, network=net, zone=zone)
  619. 1137 router = self.provider.networking.routers.get_or_create_default(net)
  620. 1138 router.attach_subnet(sn)
  621. 1139 gateway = net.gateways.get_or_create()
  622. 1140 router.attach_gateway(gateway)
  623. 1141 return sn
  624. Total time: 9.10339 s
  625. Function: refresh at line 1789
  626. Line # Hits Time Per Hit % Time Line Contents
  627. ==============================================================
  628. 1789 @profile
  629. 1790 def refresh(self):
  630. 1791 """
  631. 1792 Refreshes the state of this volume by re-querying the cloud provider
  632. 1793 for its latest state.
  633. 1794 """
  634. 1795 30 9103248.0 303441.6 100.0 vol = self._provider.storage.volumes.get(self.id)
  635. 1796 30 36.0 1.2 0.0 if vol:
  636. 1797 # pylint:disable=protected-access
  637. 1798 30 111.0 3.7 0.0 self._volume = vol._volume
  638. 1799 else:
  639. 1800 # volume no longer exists
  640. 1801 self._volume['status'] = VolumeState.UNKNOWN
  641. Total time: 8.04666 s
  642. Function: label at line 1565
  643. Line # Hits Time Per Hit % Time Line Contents
  644. ==============================================================
  645. 1565 @label.setter
  646. 1566 @profile
  647. 1567 def label(self, value):
  648. 1568 1 8.0 8.0 0.0 self.assert_valid_resource_label(value)
  649. 1569 1 4.0 4.0 0.0 tag_name = "_".join(["subnet", self.name, "label"])
  650. 1570 1 8046653.0 8046653.0 100.0 helpers.modify_or_add_metadata_item(self._provider, tag_name, value)
  651. Total time: 7.99967 s
  652. Function: find at line 308
  653. Line # Hits Time Per Hit % Time Line Contents
  654. ==============================================================
  655. 308 @dispatch(event="provider.networking.subnets.find",
  656. 309 priority=BaseCloudService.STANDARD_EVENT_PRIORITY)
  657. 310 @profile
  658. 311 def find(self, network=None, **kwargs):
  659. 312 3 3.0 1.0 0.0 if not network:
  660. 313 3 1.0 0.3 0.0 obj_list = self
  661. 314 else:
  662. 315 obj_list = network.subnets
  663. 316 3 3.0 1.0 0.0 filters = ['label']
  664. 317 3 7999509.0 2666503.0 100.0 matches = cb_helpers.generic_find(filters, kwargs, obj_list)
  665. 318 3 158.0 52.7 0.0 return ClientPagedResultList(self._provider, list(matches))
  666. Total time: 7.70415 s
  667. Function: delete at line 164
  668. Line # Hits Time Per Hit % Time Line Contents
  669. ==============================================================
  670. 164 @dispatch(event="provider.security.key_pairs.delete",
  671. 165 priority=BaseKeyPairService.STANDARD_EVENT_PRIORITY)
  672. 166 @profile
  673. 167 def delete(self, key_pair):
  674. 168 1 3.0 3.0 0.0 key_pair = (key_pair if isinstance(key_pair, GCPKeyPair) else
  675. 169 1 241435.0 241435.0 3.1 self.get(key_pair))
  676. 170 1 0.0 0.0 0.0 if key_pair:
  677. 171 1 1.0 1.0 0.0 helpers.remove_metadata_item(
  678. 172 1 7462710.0 7462710.0 96.9 self.provider, GCPKeyPair.KP_TAG_PREFIX + key_pair.name)
  679. Total time: 7.31747 s
  680. Function: label at line 1305
  681. Line # Hits Time Per Hit % Time Line Contents
  682. ==============================================================
  683. 1305 @label.setter
  684. 1306 @profile
  685. 1307 def label(self, value):
  686. 1308 1 8.0 8.0 0.0 self.assert_valid_resource_label(value)
  687. 1309 1 4.0 4.0 0.0 tag_name = "_".join(["network", self.name, "label"])
  688. 1310 1 7317456.0 7317456.0 100.0 helpers.modify_or_add_metadata_item(self._provider, tag_name, value)
  689. Total time: 5.62269 s
  690. Function: create at line 137
  691. Line # Hits Time Per Hit % Time Line Contents
  692. ==============================================================
  693. 137 @dispatch(event="provider.security.key_pairs.create",
  694. 138 priority=BaseKeyPairService.STANDARD_EVENT_PRIORITY)
  695. 139 @profile
  696. 140 def create(self, name, public_key_material=None):
  697. 141 1 9.0 9.0 0.0 GCPKeyPair.assert_valid_resource_name(name)
  698. 142 1 1.0 1.0 0.0 private_key = None
  699. 143 1 1.0 1.0 0.0 if not public_key_material:
  700. 144 1 150514.0 150514.0 2.7 public_key_material, private_key = cb_helpers.generate_key_pair()
  701. 145 # TODO: Add support for other formats not assume ssh-rsa
  702. 146 elif "ssh-rsa" not in public_key_material:
  703. 147 public_key_material = "ssh-rsa {}".format(public_key_material)
  704. 148 1 5.0 5.0 0.0 kp_info = GCPKeyPair.GCPKeyInfo(name, public_key_material)
  705. 149 1 39.0 39.0 0.0 metadata_value = json.dumps(kp_info._asdict())
  706. 150 1 1.0 1.0 0.0 try:
  707. 151 1 5.0 5.0 0.0 helpers.add_metadata_item(self.provider,
  708. 152 1 1.0 1.0 0.0 GCPKeyPair.KP_TAG_PREFIX + name,
  709. 153 1 5472093.0 5472093.0 97.3 metadata_value)
  710. 154 1 19.0 19.0 0.0 return GCPKeyPair(self.provider, kp_info, private_key)
  711. 155 except googleapiclient.errors.HttpError as err:
  712. 156 if err.resp.get('content-type', '').startswith('application/json'):
  713. 157 message = (json.loads(err.content).get('error', {})
  714. 158 .get('errors', [{}])[0].get('message'))
  715. 159 if "duplicate keys" in message:
  716. 160 raise DuplicateResourceException(
  717. 161 'A KeyPair with name {0} already exists'.format(name))
  718. 162 raise
  719. Total time: 4.11383 s
  720. Function: delete at line 1683
  721. Line # Hits Time Per Hit % Time Line Contents
  722. ==============================================================
  723. 1683 @dispatch(event="provider.networking.floating_ips.delete",
  724. 1684 priority=BaseFloatingIPService.STANDARD_EVENT_PRIORITY)
  725. 1685 @profile
  726. 1686 def delete(self, gateway, fip):
  727. 1687 1 3.0 3.0 0.0 fip = (fip if isinstance(fip, GCPFloatingIP)
  728. 1688 1 426432.0 426432.0 10.4 else self.get(gateway, fip))
  729. 1689 1 2.0 2.0 0.0 project_name = self.provider.project_name
  730. 1690 # First, delete the forwarding rule, if there is any.
  731. 1691 # pylint:disable=protected-access
  732. 1692 1 1.0 1.0 0.0 if fip._rule:
  733. 1693 response = (self.provider
  734. 1694 .gcp_compute
  735. 1695 .forwardingRules()
  736. 1696 .delete(project=project_name,
  737. 1697 region=fip.region_name,
  738. 1698 forwardingRule=fip._rule['name'])
  739. 1699 .execute())
  740. 1700 self.provider.wait_for_operation(response,
  741. 1701 region=fip.region_name)
  742. 1702
  743. 1703 # Release the address.
  744. 1704 1 3558.0 3558.0 0.1 response = (self.provider
  745. 1705 .gcp_compute
  746. 1706 .addresses()
  747. 1707 1 1.0 1.0 0.0 .delete(project=project_name,
  748. 1708 1 329.0 329.0 0.0 region=fip.region_name,
  749. 1709 1 815837.0 815837.0 19.8 address=fip._ip['name'])
  750. 1710 .execute())
  751. 1711 1 10.0 10.0 0.0 self.provider.wait_for_operation(response,
  752. 1712 1 2867653.0 2867653.0 69.7 region=fip.region_name)
  753. Total time: 3.9701 s
  754. Function: get at line 786
  755. Line # Hits Time Per Hit % Time Line Contents
  756. ==============================================================
  757. 786 @dispatch(event="provider.networking.networks.get",
  758. 787 priority=BaseNetworkService.STANDARD_EVENT_PRIORITY)
  759. 788 @profile
  760. 789 def get(self, network_id):
  761. 790 14 3969650.0 283546.4 100.0 network = self.provider.get_resource('networks', network_id)
  762. 791 14 452.0 32.3 0.0 return GCPNetwork(self.provider, network) if network else None
  763. Total time: 3.07852 s
  764. Function: create at line 1667
  765. Line # Hits Time Per Hit % Time Line Contents
  766. ==============================================================
  767. 1667 @dispatch(event="provider.networking.floating_ips.create",
  768. 1668 priority=BaseFloatingIPService.STANDARD_EVENT_PRIORITY)
  769. 1669 @profile
  770. 1670 def create(self, gateway):
  771. 1671 1 4.0 4.0 0.0 region_name = self.provider.region_name
  772. 1672 1 50.0 50.0 0.0 ip_name = 'ip-{0}'.format(uuid.uuid4())
  773. 1673 1 4379.0 4379.0 0.1 response = (self.provider
  774. 1674 .gcp_compute
  775. 1675 .addresses()
  776. 1676 1 2.0 2.0 0.0 .insert(project=self.provider.project_name,
  777. 1677 1 0.0 0.0 0.0 region=region_name,
  778. 1678 1 899000.0 899000.0 29.2 body={'name': ip_name})
  779. 1679 .execute())
  780. 1680 1 1923116.0 1923116.0 62.5 self.provider.wait_for_operation(response, region=region_name)
  781. 1681 1 251972.0 251972.0 8.2 return self.get(gateway, ip_name)
  782. Total time: 3.00229 s
  783. Function: refresh at line 1390
  784. Line # Hits Time Per Hit % Time Line Contents
  785. ==============================================================
  786. 1390 @profile
  787. 1391 def refresh(self):
  788. 1392 # pylint:disable=protected-access
  789. 1393 2 1773439.0 886719.5 59.1 fip = self._provider.networking._floating_ips.get(None, self.id)
  790. 1394 # pylint:disable=protected-access
  791. 1395 2 6.0 3.0 0.0 self._ip = fip._ip
  792. 1396 1 1228844.0 1228844.0 40.9 self._process_ip_users()
  793. Total time: 2.73658 s
  794. Function: delete at line 704
  795. Line # Hits Time Per Hit % Time Line Contents
  796. ==============================================================
  797. 704 @dispatch(event="provider.compute.instances.delete",
  798. 705 priority=BaseInstanceService.STANDARD_EVENT_PRIORITY)
  799. 706 @profile
  800. 707 def delete(self, instance):
  801. 708 4 8.0 2.0 0.0 instance = (instance if isinstance(instance, GCPInstance) else
  802. 709 self.get(instance))
  803. 710 4 4.0 1.0 0.0 if instance:
  804. 711 4 84021.0 21005.2 3.1 (self._provider
  805. 712 .gcp_compute
  806. 713 .instances()
  807. 714 4 23.0 5.8 0.0 .delete(project=self.provider.project_name,
  808. 715 4 1570.0 392.5 0.1 zone=instance.zone_name,
  809. 716 4 2650951.0 662737.8 96.9 instance=instance.name)
  810. 717 .execute())
  811. Total time: 2.43989 s
  812. Function: get at line 1637
  813. Line # Hits Time Per Hit % Time Line Contents
  814. ==============================================================
  815. 1637 @dispatch(event="provider.networking.floating_ips.get",
  816. 1638 priority=BaseFloatingIPService.STANDARD_EVENT_PRIORITY)
  817. 1639 @profile
  818. 1640 def get(self, gateway, floating_ip_id):
  819. 1641 4 1385894.0 346473.5 56.8 fip = self.provider.get_resource('addresses', floating_ip_id)
  820. 1642 return (GCPFloatingIP(self.provider, fip)
  821. 1643 4 1053999.0 263499.8 43.2 if fip else None)
  822. Total time: 1.69472 s
  823. Function: find_by_network_and_tags at line 230
  824. Line # Hits Time Per Hit % Time Line Contents
  825. ==============================================================
  826. 230 @profile
  827. 231 def find_by_network_and_tags(self, network_name, tags):
  828. 232 """
  829. 233 Finds non-empty VM firewalls by network name and VM firewall names
  830. 234 (tags). If no matching VM firewall is found, an empty list is returned.
  831. 235 """
  832. 236 6 5.0 0.8 0.0 vm_firewalls = []
  833. 237 42 10859.0 258.5 0.6 for tag, net_name in self._delegate.tag_networks:
  834. 238 36 23.0 0.6 0.0 if network_name != net_name:
  835. 239 14 10.0 0.7 0.0 continue
  836. 240 22 13.0 0.6 0.0 if tag not in tags:
  837. 241 16 8.0 0.5 0.0 continue
  838. 242 6 1683662.0 280610.3 99.3 network = self.provider.networking.networks.get(net_name)
  839. 243 6 7.0 1.2 0.0 vm_firewalls.append(
  840. 244 6 126.0 21.0 0.0 GCPVMFirewall(self._delegate, tag, network))
  841. 245 6 4.0 0.7 0.0 return vm_firewalls
  842. Total time: 1.44253 s
  843. Function: get at line 382
  844. Line # Hits Time Per Hit % Time Line Contents
  845. ==============================================================
  846. 382 @dispatch(event="provider.compute.regions.get",
  847. 383 priority=BaseRegionService.STANDARD_EVENT_PRIORITY)
  848. 384 @profile
  849. 385 def get(self, region_id):
  850. 386 4 16.0 4.0 0.0 region = self.provider.get_resource('regions', region_id,
  851. 387 4 1442438.0 360609.5 100.0 region=region_id)
  852. 388 4 80.0 20.0 0.0 return GCPRegion(self.provider, region) if region else None
  853. Total time: 1.366 s
  854. Function: get at line 435
  855. Line # Hits Time Per Hit % Time Line Contents
  856. ==============================================================
  857. 435 @profile
  858. 436 def get(self, image_id):
  859. 437 """
  860. 438 Returns an Image given its id
  861. 439 """
  862. 440 5 1365888.0 273177.6 100.0 image = self.provider.get_resource('images', image_id)
  863. 441 5 12.0 2.4 0.0 if image:
  864. 442 5 102.0 20.4 0.0 return GCPMachineImage(self.provider, image)
  865. 443 self._retrieve_public_images()
  866. 444 for public_image in self._public_images:
  867. 445 if public_image.id == image_id or public_image.name == image_id:
  868. 446 return public_image
  869. 447 return None
  870. Total time: 1.00271 s
  871. Function: delete at line 1410
  872. Line # Hits Time Per Hit % Time Line Contents
  873. ==============================================================
  874. 1410 @dispatch(event="provider.storage.snapshots.delete",
  875. 1411 priority=BaseSnapshotService.STANDARD_EVENT_PRIORITY)
  876. 1412 @profile
  877. 1413 def delete(self, snapshot):
  878. 1414 1 2.0 2.0 0.0 snapshot = (snapshot if isinstance(snapshot, GCPSnapshot)
  879. 1415 else self.get(snapshot))
  880. 1416 1 0.0 0.0 0.0 if snapshot:
  881. 1417 1 4602.0 4602.0 0.5 (self.provider
  882. 1418 .gcp_compute
  883. 1419 .snapshots()
  884. 1420 1 3.0 3.0 0.0 .delete(project=self.provider.project_name,
  885. 1421 1 998101.0 998101.0 99.5 snapshot=snapshot.name)
  886. 1422 .execute())
  887. Total time: 0.96113 s
  888. Function: list at line 677
  889. Line # Hits Time Per Hit % Time Line Contents
  890. ==============================================================
  891. 677 @dispatch(event="provider.compute.instances.list",
  892. 678 priority=BaseInstanceService.STANDARD_EVENT_PRIORITY)
  893. 679 @profile
  894. 680 def list(self, limit=None, marker=None):
  895. 681 """
  896. 682 List all instances.
  897. 683 """
  898. 684 # For GCP API, Acceptable values are 0 to 500, inclusive.
  899. 685 # (Default: 500).
  900. 686 5 7.0 1.4 0.0 max_result = limit if limit is not None and limit < 500 else 500
  901. 687 5 105195.0 21039.0 10.9 response = (self.provider
  902. 688 .gcp_compute
  903. 689 .instances()
  904. 690 5 24.0 4.8 0.0 .list(project=self.provider.project_name,
  905. 691 5 5.0 1.0 0.0 zone=self.provider.default_zone,
  906. 692 5 2.0 0.4 0.0 maxResults=max_result,
  907. 693 5 855671.0 171134.2 89.0 pageToken=marker)
  908. 694 .execute())
  909. 695 5 20.0 4.0 0.0 instances = [GCPInstance(self.provider, inst)
  910. 696 5 124.0 24.8 0.0 for inst in response.get('items', [])]
  911. 697 5 11.0 2.2 0.0 if len(instances) > max_result:
  912. 698 log.warning('Expected at most %d results; got %d',
  913. 699 max_result, len(instances))
  914. 700 5 9.0 1.8 0.0 return ServerPagedResultList('nextPageToken' in response,
  915. 701 5 9.0 1.8 0.0 response.get('nextPageToken'),
  916. 702 5 53.0 10.6 0.0 False, data=instances)
  917. Total time: 0.864771 s
  918. Function: list at line 1003
  919. Line # Hits Time Per Hit % Time Line Contents
  920. ==============================================================
  921. 1003 @dispatch(event="provider.networking.subnets.list",
  922. 1004 priority=BaseSubnetService.STANDARD_EVENT_PRIORITY)
  923. 1005 @profile
  924. 1006 def list(self, network=None, zone=None, limit=None, marker=None):
  925. 1007 """
  926. 1008 If the zone is not given, we list all subnets in the default region.
  927. 1009 """
  928. 1010 4 5.0 1.2 0.0 filter = None
  929. 1011 4 5.0 1.2 0.0 if network is not None:
  930. 1012 1 2.0 2.0 0.0 network = (network if isinstance(network, GCPNetwork)
  931. 1013 else self.provider.networking.networks.get(network))
  932. 1014 1 4.0 4.0 0.0 filter = 'network eq %s' % network.resource_url
  933. 1015 4 2.0 0.5 0.0 if zone:
  934. 1016 region_name = self._zone_to_region(zone)
  935. 1017 else:
  936. 1018 4 10.0 2.5 0.0 region_name = self.provider.region_name
  937. 1019 4 1.0 0.2 0.0 subnets = []
  938. 1020 4 37389.0 9347.2 4.3 response = (self.provider
  939. 1021 .gcp_compute
  940. 1022 .subnetworks()
  941. 1023 4 11.0 2.8 0.0 .list(project=self.provider.project_name,
  942. 1024 4 4.0 1.0 0.0 region=region_name,
  943. 1025 4 826917.0 206729.2 95.6 filter=filter)
  944. 1026 .execute())
  945. 1027 26 38.0 1.5 0.0 for subnet in response.get('items', []):
  946. 1028 22 185.0 8.4 0.0 subnets.append(GCPSubnet(self.provider, subnet))
  947. 1029 4 8.0 2.0 0.0 return ClientPagedResultList(self.provider, subnets,
  948. 1030 4 190.0 47.5 0.0 limit=limit, marker=marker)
  949. Total time: 0.790459 s
  950. Function: get at line 341
  951. Line # Hits Time Per Hit % Time Line Contents
  952. ==============================================================
  953. 341 @dispatch(event="provider.compute.vm_types.get",
  954. 342 priority=BaseVMTypeService.STANDARD_EVENT_PRIORITY)
  955. 343 @profile
  956. 344 def get(self, vm_type_id):
  957. 345 5 790367.0 158073.4 100.0 vm_type = self.provider.get_resource('machineTypes', vm_type_id)
  958. 346 5 92.0 18.4 0.0 return GCPVMType(self.provider, vm_type) if vm_type else None
  959. Total time: 0.680198 s
  960. Function: get at line 1322
  961. Line # Hits Time Per Hit % Time Line Contents
  962. ==============================================================
  963. 1322 @dispatch(event="provider.storage.snapshots.get",
  964. 1323 priority=BaseSnapshotService.STANDARD_EVENT_PRIORITY)
  965. 1324 @profile
  966. 1325 def get(self, snapshot_id):
  967. 1326 2 680154.0 340077.0 100.0 snapshot = self.provider.get_resource('snapshots', snapshot_id)
  968. 1327 2 44.0 22.0 0.0 return GCPSnapshot(self.provider, snapshot) if snapshot else None
  969. Total time: 0.672234 s
  970. Function: get at line 996
  971. Line # Hits Time Per Hit % Time Line Contents
  972. ==============================================================
  973. 996 @dispatch(event="provider.networking.subnets.get",
  974. 997 priority=BaseSubnetService.STANDARD_EVENT_PRIORITY)
  975. 998 @profile
  976. 999 def get(self, subnet_id):
  977. 1000 2 672214.0 336107.0 100.0 subnet = self.provider.get_resource('subnetworks', subnet_id)
  978. 1001 2 20.0 10.0 0.0 return GCPSubnet(self.provider, subnet) if subnet else None
  979. Total time: 0.431264 s
  980. Function: refresh at line 1880
  981. Line # Hits Time Per Hit % Time Line Contents
  982. ==============================================================
  983. 1880 @profile
  984. 1881 def refresh(self):
  985. 1882 """
  986. 1883 Refreshes the state of this snapshot by re-querying the cloud provider
  987. 1884 for its latest state.
  988. 1885 """
  989. 1886 1 431258.0 431258.0 100.0 snap = self._provider.storage.snapshots.get(self.id)
  990. 1887 1 1.0 1.0 0.0 if snap:
  991. 1888 # pylint:disable=protected-access
  992. 1889 1 5.0 5.0 0.0 self._snapshot = snap._snapshot
  993. 1890 else:
  994. 1891 # snapshot no longer exists
  995. 1892 self._snapshot['status'] = SnapshotState.UNKNOWN
  996. Total time: 0.405631 s
  997. Function: delete at line 1303
  998. Line # Hits Time Per Hit % Time Line Contents
  999. ==============================================================
  1000. 1303 @dispatch(event="provider.storage.volumes.delete",
  1001. 1304 priority=BaseVolumeService.STANDARD_EVENT_PRIORITY)
  1002. 1305 @profile
  1003. 1306 def delete(self, volume):
  1004. 1307 1 2.0 2.0 0.0 volume = volume if isinstance(volume, GCPVolume) else self.get(volume)
  1005. 1308 1 1.0 1.0 0.0 if volume:
  1006. 1309 1 8432.0 8432.0 2.1 (self._provider.gcp_compute
  1007. 1310 .disks()
  1008. 1311 1 3.0 3.0 0.0 .delete(project=self.provider.project_name,
  1009. 1312 1 475.0 475.0 0.1 zone=volume.zone_name,
  1010. 1313 1 396718.0 396718.0 97.8 disk=volume.name)
  1011. 1314 .execute())
  1012. Total time: 0.397005 s
  1013. Function: get at line 893
  1014. Line # Hits Time Per Hit % Time Line Contents
  1015. ==============================================================
  1016. 893 @dispatch(event="provider.networking.routers.get",
  1017. 894 priority=BaseRouterService.STANDARD_EVENT_PRIORITY)
  1018. 895 @profile
  1019. 896 def get(self, router_id):
  1020. 897 1 3.0 3.0 0.0 router = self.provider.get_resource(
  1021. 898 1 396986.0 396986.0 100.0 'routers', router_id, region=self.provider.region_name)
  1022. 899 1 16.0 16.0 0.0 return GCPRouter(self.provider, router) if router else None
  1023. Total time: 0.38114 s
  1024. Function: find at line 656
  1025. Line # Hits Time Per Hit % Time Line Contents
  1026. ==============================================================
  1027. 656 @dispatch(event="provider.compute.instances.find",
  1028. 657 priority=BaseInstanceService.STANDARD_EVENT_PRIORITY)
  1029. 658 @profile
  1030. 659 def find(self, limit=None, marker=None, **kwargs):
  1031. 660 """
  1032. 661 Searches for instances by instance label.
  1033. 662 :return: a list of Instance objects
  1034. 663 """
  1035. 664 3 6.0 2.0 0.0 label = kwargs.pop('label', None)
  1036. 665
  1037. 666 # All kwargs should have been popped at this time.
  1038. 667 3 3.0 1.0 0.0 if len(kwargs) > 0:
  1039. 668 1 1.0 1.0 0.0 raise InvalidParamException(
  1040. 669 1 1.0 1.0 0.0 "Unrecognised parameters for search: %s. Supported "
  1041. 670 1 16.0 16.0 0.0 "attributes: %s" % (kwargs, 'label'))
  1042. 671
  1043. 672 2 381024.0 190512.0 100.0 instances = [instance for instance in self.list()
  1044. 673 if instance.label == label]
  1045. 674 2 6.0 3.0 0.0 return ClientPagedResultList(self.provider, instances,
  1046. 675 2 83.0 41.5 0.0 limit=limit, marker=marker)
  1047. Total time: 0.348102 s
  1048. Function: find at line 348
  1049. Line # Hits Time Per Hit % Time Line Contents
  1050. ==============================================================
  1051. 348 @dispatch(event="provider.compute.vm_types.find",
  1052. 349 priority=BaseVMTypeService.STANDARD_EVENT_PRIORITY)
  1053. 350 @profile
  1054. 351 def find(self, **kwargs):
  1055. 352 2 2.0 1.0 0.0 matched_inst_types = []
  1056. 353 58 347756.0 5995.8 99.9 for inst_type in self.instance_data:
  1057. 354 56 43.0 0.8 0.0 is_match = True
  1058. 355 58 59.0 1.0 0.0 for key, value in kwargs.items():
  1059. 356 56 38.0 0.7 0.0 if key not in inst_type:
  1060. 357 raise InvalidParamException(
  1061. 358 "Unrecognised parameters for search: %s." % key)
  1062. 359 56 52.0 0.9 0.0 if inst_type.get(key) != value:
  1063. 360 54 38.0 0.7 0.0 is_match = False
  1064. 361 54 37.0 0.7 0.0 break
  1065. 362 56 36.0 0.6 0.0 if is_match:
  1066. 363 2 2.0 1.0 0.0 matched_inst_types.append(
  1067. 364 2 37.0 18.5 0.0 GCPVMType(self.provider, inst_type))
  1068. 365 2 2.0 1.0 0.0 return matched_inst_types
  1069. Total time: 0.332845 s
  1070. Function: refresh at line 1603
  1071. Line # Hits Time Per Hit % Time Line Contents
  1072. ==============================================================
  1073. 1603 @profile
  1074. 1604 def refresh(self):
  1075. 1605 1 332840.0 332840.0 100.0 subnet = self._provider.networking.subnets.get(self.id)
  1076. 1606 1 1.0 1.0 0.0 if subnet:
  1077. 1607 # pylint:disable=protected-access
  1078. 1608 self._subnet = subnet._subnet
  1079. 1609 else:
  1080. 1610 # subnet no longer exists
  1081. 1611 1 4.0 4.0 0.0 self._subnet['status'] = SubnetState.UNKNOWN
  1082. Total time: 0.258014 s
  1083. Function: refresh at line 1340
  1084. Line # Hits Time Per Hit % Time Line Contents
  1085. ==============================================================
  1086. 1340 @profile
  1087. 1341 def refresh(self):
  1088. 1342 1 258010.0 258010.0 100.0 net = self._provider.networking.networks.get(self.id)
  1089. 1343 1 1.0 1.0 0.0 if net:
  1090. 1344 # pylint:disable=protected-access
  1091. 1345 self._network = net._network
  1092. 1346 else:
  1093. 1347 # network no longer exists
  1094. 1348 1 3.0 3.0 0.0 self._network['status'] = NetworkState.UNKNOWN
  1095. Total time: 0.230138 s
  1096. Function: get at line 91
  1097. Line # Hits Time Per Hit % Time Line Contents
  1098. ==============================================================
  1099. 91 @dispatch(event="provider.security.key_pairs.get",
  1100. 92 priority=BaseKeyPairService.STANDARD_EVENT_PRIORITY)
  1101. 93 @profile
  1102. 94 def get(self, key_pair_id):
  1103. 95 """
  1104. 96 Returns a KeyPair given its ID.
  1105. 97 """
  1106. 98 4 230124.0 57531.0 100.0 for kp in self:
  1107. 99 4 8.0 2.0 0.0 if kp.id == key_pair_id:
  1108. 100 1 6.0 6.0 0.0 return kp
  1109. 101 else:
  1110. 102 return None
  1111. Total time: 0.22026 s
  1112. Function: list at line 104
  1113. Line # Hits Time Per Hit % Time Line Contents
  1114. ==============================================================
  1115. 104 @dispatch(event="provider.security.key_pairs.list",
  1116. 105 priority=BaseKeyPairService.STANDARD_EVENT_PRIORITY)
  1117. 106 @profile
  1118. 107 def list(self, limit=None, marker=None):
  1119. 108 1 1.0 1.0 0.0 key_pairs = []
  1120. 109 1 1.0 1.0 0.0 for item in helpers.find_matching_metadata_items(
  1121. 110 5 220108.0 44021.6 99.9 self.provider, GCPKeyPair.KP_TAG_REGEX):
  1122. 111 4 60.0 15.0 0.0 metadata_value = json.loads(item['value'])
  1123. 112 4 15.0 3.8 0.0 kp_info = GCPKeyPair.GCPKeyInfo(**metadata_value)
  1124. 113 4 36.0 9.0 0.0 key_pairs.append(GCPKeyPair(self.provider, kp_info))
  1125. 114 1 2.0 2.0 0.0 return ClientPagedResultList(self.provider, key_pairs,
  1126. 115 1 37.0 37.0 0.0 limit=limit, marker=marker)
  1127. Total time: 0.024806 s
  1128. Function: find at line 121
  1129. Line # Hits Time Per Hit % Time Line Contents
  1130. ==============================================================
  1131. 121 @dispatch(event="provider.security.vm_firewall_rules.find",
  1132. 122 priority=BaseCloudService.STANDARD_EVENT_PRIORITY)
  1133. 123 @profile
  1134. 124 def find(self, firewall, **kwargs):
  1135. 125 2 8.0 4.0 0.0 obj_list = firewall.rules
  1136. 126 2 1.0 0.5 0.0 filters = ['name', 'direction', 'protocol', 'from_port', 'to_port',
  1137. 127 2 2.0 1.0 0.0 'cidr', 'src_dest_fw', 'src_dest_fw_id']
  1138. 128 2 24757.0 12378.5 99.8 matches = cb_helpers.generic_find(filters, kwargs, obj_list)
  1139. 129 2 38.0 19.0 0.2 return ClientPagedResultList(self._provider, list(matches))
  1140. Total time: 0.015576 s
  1141. Function: list at line 254
  1142. Line # Hits Time Per Hit % Time Line Contents
  1143. ==============================================================
  1144. 254 @dispatch(event="provider.security.vm_firewall_rules.list",
  1145. 255 priority=BaseVMFirewallRuleService.STANDARD_EVENT_PRIORITY)
  1146. 256 @profile
  1147. 257 def list(self, firewall, limit=None, marker=None):
  1148. 258 6 8.0 1.3 0.1 rules = []
  1149. 259 6 18.0 3.0 0.1 for fw in firewall.delegate.iter_firewalls(
  1150. 260 12 1497.0 124.8 9.6 firewall.name, firewall.network.name):
  1151. 261 6 8162.0 1360.3 52.4 rule = GCPVMFirewallRule(firewall, fw['id'])
  1152. 262 6 5667.0 944.5 36.4 if rule.is_dummy_rule():
  1153. 263 6 11.0 1.8 0.1 self._dummy_rule = rule
  1154. 264 else:
  1155. 265 rules.append(rule)
  1156. 266 6 15.0 2.5 0.1 return ClientPagedResultList(self.provider, rules,
  1157. 267 6 198.0 33.0 1.3 limit=limit, marker=marker)
  1158. Total time: 2e-05 s
  1159. Function: create_launch_config at line 719
  1160. Line # Hits Time Per Hit % Time Line Contents
  1161. ==============================================================
  1162. 719 @profile
  1163. 720 def create_launch_config(self):
  1164. 721 2 20.0 10.0 100.0 return GCPLaunchConfig(self.provider)
  1165. Total time: 5e-06 s
  1166. Function: get_or_create at line 1610
  1167. Line # Hits Time Per Hit % Time Line Contents
  1168. ==============================================================
  1169. 1610 @dispatch(event="provider.networking.gateways.get_or_create",
  1170. 1611 priority=BaseGatewayService.STANDARD_EVENT_PRIORITY)
  1171. 1612 @profile
  1172. 1613 def get_or_create(self, network):
  1173. 1614 4 5.0 1.2 100.0 return self._default_internet_gateway