security.res 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467
  1. Test output
  2. .........
  3. ----------------------------------------------------------------------
  4. Ran 9 tests in 788.805s
  5. OK
  6. Wrote profile results to run_tests.py.lprof
  7. Timer unit: 1e-06 s
  8. Total time: 3.0717 s
  9. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  10. Function: __init__ at line 160
  11. Line # Hits Time Per Hit % Time Line Contents
  12. ==============================================================
  13. 160 @profile
  14. 161 def __init__(self, config):
  15. 162 9 28.0 3.1 0.0 self._config = config
  16. 163 9 21.0 2.3 0.0 self.subscription_id = str(config.get('azure_subscription_id'))
  17. 164 9 8.0 0.9 0.0 self._credentials = ServicePrincipalCredentials(
  18. 165 9 8.0 0.9 0.0 client_id=config.get('azure_client_id'),
  19. 166 9 11.0 1.2 0.0 secret=config.get('azure_secret'),
  20. 167 9 3071465.0 341273.9 100.0 tenant=config.get('azure_tenant')
  21. 168 )
  22. 169
  23. 170 9 27.0 3.0 0.0 self._access_token = config.get('azure_access_token')
  24. 171 9 9.0 1.0 0.0 self._resource_client = None
  25. 172 9 8.0 0.9 0.0 self._storage_client = None
  26. 173 9 6.0 0.7 0.0 self._network_management_client = None
  27. 174 9 9.0 1.0 0.0 self._subscription_client = None
  28. 175 9 6.0 0.7 0.0 self._compute_client = None
  29. 176 9 7.0 0.8 0.0 self._access_key_result = None
  30. 177 9 10.0 1.1 0.0 self._block_blob_service = None
  31. 178 9 7.0 0.8 0.0 self._table_service = None
  32. 179 9 6.0 0.7 0.0 self._storage_account = None
  33. 180
  34. 181 9 62.0 6.9 0.0 log.debug("azure subscription : %s", self.subscription_id)
  35. Total time: 1.4842 s
  36. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  37. Function: access_key_result at line 183
  38. Line # Hits Time Per Hit % Time Line Contents
  39. ==============================================================
  40. 183 @property
  41. 184 @tenacity.retry(stop=tenacity.stop_after_attempt(5), reraise=True)
  42. 185 @profile
  43. 186 def access_key_result(self):
  44. 187 3 3.0 1.0 0.0 if not self._access_key_result:
  45. 188 3 13.0 4.3 0.0 storage_account = self.storage_account
  46. 189
  47. 190 3 696130.0 232043.3 46.9 if self.get_storage_account(storage_account).\
  48. 191 3 5.0 1.7 0.0 provisioning_state.value != 'Succeeded':
  49. 192 log.debug(
  50. 193 "Storage account %s is not in Succeeded state yet. ",
  51. 194 storage_account)
  52. 195 raise WaitStateException(
  53. 196 "Waited too long for storage account: {0} to "
  54. 197 "become ready.".format(
  55. 198 storage_account,
  56. 199 self.get_storage_account(storage_account).
  57. 200 provisioning_state))
  58. 201
  59. 202 3 699.0 233.0 0.0 self._access_key_result = self.storage_client.storage_accounts. \
  60. 203 3 787347.0 262449.0 53.0 list_keys(self.resource_group, storage_account)
  61. 204 3 6.0 2.0 0.0 return self._access_key_result
  62. Total time: 0.000205 s
  63. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  64. Function: resource_group at line 206
  65. Line # Hits Time Per Hit % Time Line Contents
  66. ==============================================================
  67. 206 @property
  68. 207 @profile
  69. 208 def resource_group(self):
  70. 209 115 205.0 1.8 100.0 return self._config.get('azure_resource_group')
  71. Total time: 1.5e-05 s
  72. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  73. Function: storage_account at line 211
  74. Line # Hits Time Per Hit % Time Line Contents
  75. ==============================================================
  76. 211 @property
  77. 212 @profile
  78. 213 def storage_account(self):
  79. 214 9 15.0 1.7 100.0 return self._config.get('azure_storage_account')
  80. Total time: 3e-06 s
  81. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  82. Function: region_name at line 216
  83. Line # Hits Time Per Hit % Time Line Contents
  84. ==============================================================
  85. 216 @property
  86. 217 @profile
  87. 218 def region_name(self):
  88. 219 3 3.0 1.0 100.0 return self._config.get('azure_region_name')
  89. Total time: 0.000115 s
  90. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  91. Function: public_key_storage_table_name at line 221
  92. Line # Hits Time Per Hit % Time Line Contents
  93. ==============================================================
  94. 221 @property
  95. 222 @profile
  96. 223 def public_key_storage_table_name(self):
  97. 224 46 115.0 2.5 100.0 return self._config.get('azure_public_key_storage_table_name')
  98. Total time: 0.020725 s
  99. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  100. Function: storage_client at line 226
  101. Line # Hits Time Per Hit % Time Line Contents
  102. ==============================================================
  103. 226 @property
  104. 227 @profile
  105. 228 def storage_client(self):
  106. 229 9 11.0 1.2 0.1 if not self._storage_client:
  107. 230 self._storage_client = \
  108. 231 3 8.0 2.7 0.0 StorageManagementClient(self._credentials,
  109. 232 3 20698.0 6899.3 99.9 self.subscription_id)
  110. 233 9 8.0 0.9 0.0 return self._storage_client
  111. Total time: 0 s
  112. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  113. Function: subscription_client at line 235
  114. Line # Hits Time Per Hit % Time Line Contents
  115. ==============================================================
  116. 235 @property
  117. 236 @profile
  118. 237 def subscription_client(self):
  119. 238 if not self._subscription_client:
  120. 239 self._subscription_client = SubscriptionClient(self._credentials)
  121. 240 return self._subscription_client
  122. Total time: 0.081115 s
  123. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  124. Function: resource_client at line 242
  125. Line # Hits Time Per Hit % Time Line Contents
  126. ==============================================================
  127. 242 @property
  128. 243 @profile
  129. 244 def resource_client(self):
  130. 245 9 6.0 0.7 0.0 if not self._resource_client:
  131. 246 self._resource_client = \
  132. 247 9 8.0 0.9 0.0 ResourceManagementClient(self._credentials,
  133. 248 9 81081.0 9009.0 100.0 self.subscription_id)
  134. 249 9 20.0 2.2 0.0 return self._resource_client
  135. Total time: 0 s
  136. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  137. Function: compute_client at line 251
  138. Line # Hits Time Per Hit % Time Line Contents
  139. ==============================================================
  140. 251 @property
  141. 252 @profile
  142. 253 def compute_client(self):
  143. 254 if not self._compute_client:
  144. 255 self._compute_client = \
  145. 256 ComputeManagementClient(self._credentials,
  146. 257 self.subscription_id)
  147. 258 return self._compute_client
  148. Total time: 0.043287 s
  149. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  150. Function: network_management_client at line 260
  151. Line # Hits Time Per Hit % Time Line Contents
  152. ==============================================================
  153. 260 @property
  154. 261 @profile
  155. 262 def network_management_client(self):
  156. 263 106 110.0 1.0 0.3 if not self._network_management_client:
  157. 264 6 10.0 1.7 0.0 self._network_management_client = NetworkManagementClient(
  158. 265 6 43100.0 7183.3 99.6 self._credentials, self.subscription_id)
  159. 266 106 67.0 0.6 0.2 return self._network_management_client
  160. Total time: 0 s
  161. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  162. Function: blob_service at line 268
  163. Line # Hits Time Per Hit % Time Line Contents
  164. ==============================================================
  165. 268 @property
  166. 269 @profile
  167. 270 def blob_service(self):
  168. 271 self._get_or_create_storage_account()
  169. 272 if not self._block_blob_service:
  170. 273 if self._access_token:
  171. 274 token_credential = TokenCredential(self._access_token)
  172. 275 self._block_blob_service = BlockBlobService(
  173. 276 account_name=self.storage_account,
  174. 277 token_credential=token_credential)
  175. 278 else:
  176. 279 self._block_blob_service = BlockBlobService(
  177. 280 account_name=self.storage_account,
  178. 281 account_key=self.access_key_result.keys[0].value)
  179. 282 return self._block_blob_service
  180. Total time: 3.8387 s
  181. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  182. Function: table_service at line 284
  183. Line # Hits Time Per Hit % Time Line Contents
  184. ==============================================================
  185. 284 @property
  186. 285 @profile
  187. 286 def table_service(self):
  188. 287 23 990231.0 43053.5 25.8 self._get_or_create_storage_account()
  189. 288 23 27.0 1.2 0.0 if not self._table_service:
  190. 289 3 3.0 1.0 0.0 self._table_service = TableService(
  191. 290 3 22.0 7.3 0.0 self.storage_account,
  192. 291 3 1485303.0 495101.0 38.7 self.access_key_result.keys[0].value)
  193. 292 23 25.0 1.1 0.0 if not self._table_service. \
  194. 293 23 1363026.0 59262.0 35.5 exists(table_name=self.public_key_storage_table_name):
  195. 294 self._table_service.create_table(
  196. 295 self.public_key_storage_table_name)
  197. 296 23 67.0 2.9 0.0 return self._table_service
  198. Total time: 1.99059 s
  199. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  200. Function: get_resource_group at line 298
  201. Line # Hits Time Per Hit % Time Line Contents
  202. ==============================================================
  203. 298 @profile
  204. 299 def get_resource_group(self, name):
  205. 300 9 1990586.0 221176.2 100.0 return self.resource_client.resource_groups.get(name)
  206. Total time: 0 s
  207. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  208. Function: create_resource_group at line 302
  209. Line # Hits Time Per Hit % Time Line Contents
  210. ==============================================================
  211. 302 @profile
  212. 303 def create_resource_group(self, name, parameters):
  213. 304 return self.resource_client.resource_groups. \
  214. 305 create_or_update(name, parameters)
  215. Total time: 1.68342 s
  216. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  217. Function: get_storage_account at line 307
  218. Line # Hits Time Per Hit % Time Line Contents
  219. ==============================================================
  220. 307 @profile
  221. 308 def get_storage_account(self, storage_account):
  222. 309 6 100101.0 16683.5 5.9 return self.storage_client.storage_accounts. \
  223. 310 6 1583319.0 263886.5 94.1 get_properties(self.resource_group, storage_account)
  224. Total time: 0 s
  225. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  226. Function: create_storage_account at line 312
  227. Line # Hits Time Per Hit % Time Line Contents
  228. ==============================================================
  229. 312 @profile
  230. 313 def create_storage_account(self, name, params):
  231. 314 return self.storage_client.storage_accounts. \
  232. 315 create(self.resource_group, name.lower(), params).result()
  233. Total time: 0.987488 s
  234. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  235. Function: _get_or_create_storage_account at line 319
  236. Line # Hits Time Per Hit % Time Line Contents
  237. ==============================================================
  238. 319 @tenacity.retry(stop=tenacity.stop_after_attempt(2),
  239. 320 retry=tenacity.retry_if_exception_type(CloudError),
  240. 321 reraise=True)
  241. 322 @profile
  242. 323 def _get_or_create_storage_account(self):
  243. 324 23 37.0 1.6 0.0 if self._storage_account:
  244. 325 20 17.0 0.8 0.0 return self._storage_account
  245. 326 else:
  246. 327 3 2.0 0.7 0.0 try:
  247. 328 self._storage_account = \
  248. 329 3 987432.0 329144.0 100.0 self.get_storage_account(self.storage_account)
  249. 330 except CloudError as cloud_error:
  250. 331 if cloud_error.error.error == "ResourceNotFound":
  251. 332 storage_account_params = {
  252. 333 'sku': {
  253. 334 'name': 'Standard_LRS'
  254. 335 },
  255. 336 'kind': 'storage',
  256. 337 'location': self.region_name,
  257. 338 }
  258. 339 try:
  259. 340 self._storage_account = \
  260. 341 self.create_storage_account(self.storage_account,
  261. 342 storage_account_params)
  262. 343 except CloudError as cloud_error2: # pragma: no cover
  263. 344 if cloud_error2.error.error == "AuthorizationFailed":
  264. 345 mess = 'The following error was returned by ' \
  265. 346 'Azure:\n%s\n\nThis is likely because the' \
  266. 347 ' Role associated with the provided ' \
  267. 348 'credentials does not allow for Storage ' \
  268. 349 'Account creation.\nA Storage Account is ' \
  269. 350 'necessary in order to perform the ' \
  270. 351 'desired operation. You must either ' \
  271. 352 'provide an existing Storage Account name' \
  272. 353 ' as part of the configuration, or ' \
  273. 354 'elevate the associated Role.\nFor more ' \
  274. 355 'information on roles, see: https://docs.' \
  275. 356 'microsoft.com/en-us/azure/role-based-' \
  276. 357 'access-control/overview\n' % cloud_error2
  277. 358 raise ProviderConnectionException(mess)
  278. 359
  279. 360 elif cloud_error2.error.error == \
  280. 361 "StorageAccountAlreadyTaken":
  281. 362 mess = 'The following error was ' \
  282. 363 'returned by Azure:\n%s\n\n' \
  283. 364 'Note that Storage Account names must be ' \
  284. 365 'unique across Azure (not just in your ' \
  285. 366 'subscription).\nFor more information ' \
  286. 367 'see https://docs.microsoft.com/en-us/' \
  287. 368 'azure/azure-resource-manager/resource-' \
  288. 369 'manager-storage-account-name-errors\n' \
  289. 370 % cloud_error2
  290. 371 raise InvalidLabelException(mess)
  291. 372 else:
  292. 373 raise cloud_error2
  293. 374 else:
  294. 375 raise cloud_error
  295. Total time: 0 s
  296. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  297. Function: list_locations at line 377
  298. Line # Hits Time Per Hit % Time Line Contents
  299. ==============================================================
  300. 377 @profile
  301. 378 def list_locations(self):
  302. 379 return self.subscription_client.subscriptions. \
  303. 380 list_locations(self.subscription_id)
  304. Total time: 0.005836 s
  305. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  306. Function: list_vm_firewall at line 382
  307. Line # Hits Time Per Hit % Time Line Contents
  308. ==============================================================
  309. 382 @profile
  310. 383 def list_vm_firewall(self):
  311. 384 7 5458.0 779.7 93.5 return self.network_management_client.network_security_groups. \
  312. 385 7 378.0 54.0 6.5 list(self.resource_group)
  313. Total time: 68.5755 s
  314. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  315. Function: create_vm_firewall at line 387
  316. Line # Hits Time Per Hit % Time Line Contents
  317. ==============================================================
  318. 387 @profile
  319. 388 def create_vm_firewall(self, name, parameters):
  320. 389 6 4447.0 741.2 0.0 return self.network_management_client.network_security_groups. \
  321. 390 6 51.0 8.5 0.0 create_or_update(self.resource_group, name,
  322. 391 6 68570982.0 11428497.0 100.0 parameters).result()
  323. Total time: 72.8747 s
  324. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  325. Function: update_vm_firewall_tags at line 393
  326. Line # Hits Time Per Hit % Time Line Contents
  327. ==============================================================
  328. 393 @profile
  329. 394 def update_vm_firewall_tags(self, fw_id, tags):
  330. 395 3 8.0 2.7 0.0 url_params = azure_helpers.parse_url(VM_FIREWALL_RESOURCE_ID,
  331. 396 3 73.0 24.3 0.0 fw_id)
  332. 397 3 3.0 1.0 0.0 name = url_params.get(VM_FIREWALL_NAME)
  333. 398 3 2084.0 694.7 0.0 return self.network_management_client.network_security_groups. \
  334. 399 3 23.0 7.7 0.0 create_or_update(self.resource_group, name,
  335. 400 3 2.0 0.7 0.0 {'tags': tags,
  336. 401 3 72872468.0 24290822.7 100.0 'location': self.region_name}).result()
  337. Total time: 1.05494 s
  338. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  339. Function: get_vm_firewall at line 403
  340. Line # Hits Time Per Hit % Time Line Contents
  341. ==============================================================
  342. 403 @profile
  343. 404 def get_vm_firewall(self, fw_id):
  344. 405 4 11.0 2.8 0.0 url_params = azure_helpers.parse_url(VM_FIREWALL_RESOURCE_ID,
  345. 406 4 99.0 24.8 0.0 fw_id)
  346. 407 4 4.0 1.0 0.0 fw_name = url_params.get(VM_FIREWALL_NAME)
  347. 408 4 2974.0 743.5 0.3 return self.network_management_client.network_security_groups. \
  348. 409 4 1051851.0 262962.8 99.7 get(self.resource_group, fw_name)
  349. Total time: 64.2852 s
  350. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  351. Function: delete_vm_firewall at line 411
  352. Line # Hits Time Per Hit % Time Line Contents
  353. ==============================================================
  354. 411 @profile
  355. 412 def delete_vm_firewall(self, fw_id):
  356. 413 6 16.0 2.7 0.0 url_params = azure_helpers.parse_url(VM_FIREWALL_RESOURCE_ID,
  357. 414 6 154.0 25.7 0.0 fw_id)
  358. 415 6 6.0 1.0 0.0 name = url_params.get(VM_FIREWALL_NAME)
  359. 416 6 4320.0 720.0 0.0 self.network_management_client \
  360. 417 6 64280695.0 10713449.2 100.0 .network_security_groups.delete(self.resource_group, name).wait()
  361. Total time: 528.549 s
  362. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  363. Function: create_vm_firewall_rule at line 419
  364. Line # Hits Time Per Hit % Time Line Contents
  365. ==============================================================
  366. 419 @profile
  367. 420 def create_vm_firewall_rule(self, fw_id,
  368. 421 rule_name, parameters):
  369. 422 47 123.0 2.6 0.0 url_params = azure_helpers.parse_url(VM_FIREWALL_RESOURCE_ID,
  370. 423 47 1298.0 27.6 0.0 fw_id)
  371. 424 47 71.0 1.5 0.0 vm_firewall_name = url_params.get(VM_FIREWALL_NAME)
  372. 425 47 35143.0 747.7 0.0 return self.network_management_client.security_rules. \
  373. 426 47 457.0 9.7 0.0 create_or_update(self.resource_group, vm_firewall_name,
  374. 427 47 528511698.0 11244929.7 100.0 rule_name, parameters).result()
  375. Total time: 32.4044 s
  376. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  377. Function: delete_vm_firewall_rule at line 429
  378. Line # Hits Time Per Hit % Time Line Contents
  379. ==============================================================
  380. 429 @profile
  381. 430 def delete_vm_firewall_rule(self, fw_rule_id, vm_firewall):
  382. 431 3 8.0 2.7 0.0 url_params = azure_helpers.parse_url(VM_FIREWALL_RULE_RESOURCE_ID,
  383. 432 3 92.0 30.7 0.0 fw_rule_id)
  384. 433 3 5.0 1.7 0.0 name = url_params.get(VM_FIREWALL_RULE_NAME)
  385. 434 3 2354.0 784.7 0.0 return self.network_management_client.security_rules. \
  386. 435 3 32401986.0 10800662.0 100.0 delete(self.resource_group, vm_firewall, name).result()
  387. Total time: 0 s
  388. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  389. Function: list_containers at line 437
  390. Line # Hits Time Per Hit % Time Line Contents
  391. ==============================================================
  392. 437 @profile
  393. 438 def list_containers(self, prefix=None, limit=None, marker=None):
  394. 439 results = self.blob_service.list_containers(prefix=prefix,
  395. 440 num_results=limit,
  396. 441 marker=marker)
  397. 442 return (results.items, results.next_marker)
  398. Total time: 0 s
  399. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  400. Function: create_container at line 444
  401. Line # Hits Time Per Hit % Time Line Contents
  402. ==============================================================
  403. 444 @profile
  404. 445 def create_container(self, container_name):
  405. 446 try:
  406. 447 self.blob_service.create_container(container_name,
  407. 448 fail_on_exist=True)
  408. 449 except AzureConflictHttpError as cloud_error:
  409. 450 if cloud_error.error_code == "ContainerAlreadyExists":
  410. 451 msg = "The given Bucket name '%s' already exists. Please " \
  411. 452 "use the `get` or `find` method to get a reference to " \
  412. 453 "an existing Bucket, or specify a new Bucket name to " \
  413. 454 "create.\nNote that in Azure, Buckets are contained " \
  414. 455 "in Storage Accounts." % container_name
  415. 456 raise DuplicateResourceException(msg)
  416. 457
  417. 458 return self.blob_service.get_container_properties(container_name)
  418. Total time: 0 s
  419. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  420. Function: get_container at line 460
  421. Line # Hits Time Per Hit % Time Line Contents
  422. ==============================================================
  423. 460 @profile
  424. 461 def get_container(self, container_name):
  425. 462 return self.blob_service.get_container_properties(container_name)
  426. Total time: 0 s
  427. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  428. Function: delete_container at line 464
  429. Line # Hits Time Per Hit % Time Line Contents
  430. ==============================================================
  431. 464 @profile
  432. 465 def delete_container(self, container_name):
  433. 466 self.blob_service.delete_container(container_name)
  434. Total time: 0 s
  435. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  436. Function: list_blobs at line 468
  437. Line # Hits Time Per Hit % Time Line Contents
  438. ==============================================================
  439. 468 @profile
  440. 469 def list_blobs(self, container_name, prefix=None):
  441. 470 return self.blob_service.list_blobs(container_name, prefix=prefix)
  442. Total time: 0 s
  443. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  444. Function: get_blob at line 472
  445. Line # Hits Time Per Hit % Time Line Contents
  446. ==============================================================
  447. 472 @profile
  448. 473 def get_blob(self, container_name, blob_name):
  449. 474 return self.blob_service.get_blob_properties(container_name, blob_name)
  450. Total time: 0 s
  451. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  452. Function: create_blob_from_text at line 476
  453. Line # Hits Time Per Hit % Time Line Contents
  454. ==============================================================
  455. 476 @profile
  456. 477 def create_blob_from_text(self, container_name, blob_name, text):
  457. 478 self.blob_service.create_blob_from_text(container_name,
  458. 479 blob_name, text)
  459. Total time: 0 s
  460. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  461. Function: create_blob_from_file at line 481
  462. Line # Hits Time Per Hit % Time Line Contents
  463. ==============================================================
  464. 481 @profile
  465. 482 def create_blob_from_file(self, container_name, blob_name, file_path):
  466. 483 self.blob_service.create_blob_from_path(container_name,
  467. 484 blob_name, file_path)
  468. Total time: 0 s
  469. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  470. Function: delete_blob at line 486
  471. Line # Hits Time Per Hit % Time Line Contents
  472. ==============================================================
  473. 486 @profile
  474. 487 def delete_blob(self, container_name, blob_name):
  475. 488 self.blob_service.delete_blob(container_name, blob_name)
  476. Total time: 0 s
  477. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  478. Function: get_blob_url at line 490
  479. Line # Hits Time Per Hit % Time Line Contents
  480. ==============================================================
  481. 490 @profile
  482. 491 def get_blob_url(self, container_name, blob_name, expiry_time):
  483. 492 expiry_date = datetime.datetime.utcnow() + datetime.timedelta(
  484. 493 seconds=expiry_time)
  485. 494 sas = self.blob_service.generate_blob_shared_access_signature(
  486. 495 container_name, blob_name, permission=BlobPermissions.READ,
  487. 496 expiry=expiry_date)
  488. 497 return self.blob_service.make_blob_url(container_name, blob_name,
  489. 498 sas_token=sas)
  490. Total time: 0 s
  491. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  492. Function: get_blob_content at line 500
  493. Line # Hits Time Per Hit % Time Line Contents
  494. ==============================================================
  495. 500 @profile
  496. 501 def get_blob_content(self, container_name, blob_name):
  497. 502 out_stream = BytesIO()
  498. 503 self.blob_service.get_blob_to_stream(container_name,
  499. 504 blob_name, out_stream)
  500. 505 return out_stream
  501. Total time: 0 s
  502. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  503. Function: create_empty_disk at line 507
  504. Line # Hits Time Per Hit % Time Line Contents
  505. ==============================================================
  506. 507 @profile
  507. 508 def create_empty_disk(self, disk_name, params):
  508. 509 return self.compute_client.disks.create_or_update(
  509. 510 self.resource_group,
  510. 511 disk_name,
  511. 512 params
  512. 513 ).result()
  513. Total time: 0 s
  514. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  515. Function: create_snapshot_disk at line 515
  516. Line # Hits Time Per Hit % Time Line Contents
  517. ==============================================================
  518. 515 @profile
  519. 516 def create_snapshot_disk(self, disk_name, params):
  520. 517 return self.compute_client.disks.create_or_update(
  521. 518 self.resource_group,
  522. 519 disk_name,
  523. 520 params
  524. 521 ).result()
  525. Total time: 0 s
  526. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  527. Function: get_disk at line 523
  528. Line # Hits Time Per Hit % Time Line Contents
  529. ==============================================================
  530. 523 @profile
  531. 524 def get_disk(self, disk_id):
  532. 525 url_params = azure_helpers.parse_url(VOLUME_RESOURCE_ID,
  533. 526 disk_id)
  534. 527 disk_name = url_params.get(VOLUME_NAME)
  535. 528 return self.compute_client.disks.get(self.resource_group, disk_name)
  536. Total time: 0 s
  537. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  538. Function: list_disks at line 530
  539. Line # Hits Time Per Hit % Time Line Contents
  540. ==============================================================
  541. 530 @profile
  542. 531 def list_disks(self):
  543. 532 return self.compute_client.disks. \
  544. 533 list_by_resource_group(self.resource_group)
  545. Total time: 0 s
  546. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  547. Function: delete_disk at line 535
  548. Line # Hits Time Per Hit % Time Line Contents
  549. ==============================================================
  550. 535 @profile
  551. 536 def delete_disk(self, disk_id):
  552. 537 url_params = azure_helpers.parse_url(VOLUME_RESOURCE_ID,
  553. 538 disk_id)
  554. 539 disk_name = url_params.get(VOLUME_NAME)
  555. 540 self.compute_client.disks.delete(self.resource_group, disk_name).wait()
  556. Total time: 0 s
  557. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  558. Function: update_disk_tags at line 542
  559. Line # Hits Time Per Hit % Time Line Contents
  560. ==============================================================
  561. 542 @profile
  562. 543 def update_disk_tags(self, disk_id, tags):
  563. 544 url_params = azure_helpers.parse_url(VOLUME_RESOURCE_ID,
  564. 545 disk_id)
  565. 546 disk_name = url_params.get(VOLUME_NAME)
  566. 547 return self.compute_client.disks.update(
  567. 548 self.resource_group,
  568. 549 disk_name,
  569. 550 {'tags': tags},
  570. 551 raw=True
  571. 552 )
  572. Total time: 0 s
  573. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  574. Function: list_snapshots at line 554
  575. Line # Hits Time Per Hit % Time Line Contents
  576. ==============================================================
  577. 554 @profile
  578. 555 def list_snapshots(self):
  579. 556 return self.compute_client.snapshots. \
  580. 557 list_by_resource_group(self.resource_group)
  581. Total time: 0 s
  582. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  583. Function: get_snapshot at line 559
  584. Line # Hits Time Per Hit % Time Line Contents
  585. ==============================================================
  586. 559 @profile
  587. 560 def get_snapshot(self, snapshot_id):
  588. 561 url_params = azure_helpers.parse_url(SNAPSHOT_RESOURCE_ID,
  589. 562 snapshot_id)
  590. 563 snapshot_name = url_params.get(SNAPSHOT_NAME)
  591. 564 return self.compute_client.snapshots.get(self.resource_group,
  592. 565 snapshot_name)
  593. Total time: 0 s
  594. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  595. Function: create_snapshot at line 567
  596. Line # Hits Time Per Hit % Time Line Contents
  597. ==============================================================
  598. 567 @profile
  599. 568 def create_snapshot(self, snapshot_name, params):
  600. 569 return self.compute_client.snapshots.create_or_update(
  601. 570 self.resource_group,
  602. 571 snapshot_name,
  603. 572 params
  604. 573 ).result()
  605. Total time: 0 s
  606. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  607. Function: delete_snapshot at line 575
  608. Line # Hits Time Per Hit % Time Line Contents
  609. ==============================================================
  610. 575 @profile
  611. 576 def delete_snapshot(self, snapshot_id):
  612. 577 url_params = azure_helpers.parse_url(SNAPSHOT_RESOURCE_ID,
  613. 578 snapshot_id)
  614. 579 snapshot_name = url_params.get(SNAPSHOT_NAME)
  615. 580 self.compute_client.snapshots.delete(self.resource_group,
  616. 581 snapshot_name).wait()
  617. Total time: 0 s
  618. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  619. Function: update_snapshot_tags at line 583
  620. Line # Hits Time Per Hit % Time Line Contents
  621. ==============================================================
  622. 583 @profile
  623. 584 def update_snapshot_tags(self, snapshot_id, tags):
  624. 585 url_params = azure_helpers.parse_url(SNAPSHOT_RESOURCE_ID,
  625. 586 snapshot_id)
  626. 587 snapshot_name = url_params.get(SNAPSHOT_NAME)
  627. 588 return self.compute_client.snapshots.update(
  628. 589 self.resource_group,
  629. 590 snapshot_name,
  630. 591 {'tags': tags},
  631. 592 raw=True
  632. 593 )
  633. Total time: 0 s
  634. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  635. Function: is_gallery_image at line 595
  636. Line # Hits Time Per Hit % Time Line Contents
  637. ==============================================================
  638. 595 @profile
  639. 596 def is_gallery_image(self, image_id):
  640. 597 url_params = azure_helpers.parse_url(IMAGE_RESOURCE_ID,
  641. 598 image_id)
  642. 599 # If it is a gallery image, it will always have an offer
  643. 600 return 'offer' in url_params
  644. Total time: 0 s
  645. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  646. Function: create_image at line 602
  647. Line # Hits Time Per Hit % Time Line Contents
  648. ==============================================================
  649. 602 @profile
  650. 603 def create_image(self, name, params):
  651. 604 return self.compute_client.images. \
  652. 605 create_or_update(self.resource_group, name,
  653. 606 params).result()
  654. Total time: 0 s
  655. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  656. Function: delete_image at line 608
  657. Line # Hits Time Per Hit % Time Line Contents
  658. ==============================================================
  659. 608 @profile
  660. 609 def delete_image(self, image_id):
  661. 610 url_params = azure_helpers.parse_url(IMAGE_RESOURCE_ID,
  662. 611 image_id)
  663. 612 if not self.is_gallery_image(image_id):
  664. 613 name = url_params.get(IMAGE_NAME)
  665. 614 self.compute_client.images.delete(self.resource_group, name).wait()
  666. Total time: 0 s
  667. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  668. Function: list_images at line 616
  669. Line # Hits Time Per Hit % Time Line Contents
  670. ==============================================================
  671. 616 @profile
  672. 617 def list_images(self):
  673. 618 azure_images = list(self.compute_client.images.
  674. 619 list_by_resource_group(self.resource_group))
  675. 620 return azure_images
  676. Total time: 0 s
  677. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  678. Function: list_gallery_refs at line 622
  679. Line # Hits Time Per Hit % Time Line Contents
  680. ==============================================================
  681. 622 @profile
  682. 623 def list_gallery_refs(self):
  683. 624 return gallery_image_references
  684. Total time: 0 s
  685. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  686. Function: get_image at line 626
  687. Line # Hits Time Per Hit % Time Line Contents
  688. ==============================================================
  689. 626 @profile
  690. 627 def get_image(self, image_id):
  691. 628 url_params = azure_helpers.parse_url(IMAGE_RESOURCE_ID,
  692. 629 image_id)
  693. 630 if self.is_gallery_image(image_id):
  694. 631 return GalleryImageReference(publisher=url_params['publisher'],
  695. 632 offer=url_params['offer'],
  696. 633 sku=url_params['sku'],
  697. 634 version=url_params['version'])
  698. 635 else:
  699. 636 name = url_params.get(IMAGE_NAME)
  700. 637 return self.compute_client.images.get(self.resource_group, name)
  701. Total time: 0 s
  702. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  703. Function: update_image_tags at line 639
  704. Line # Hits Time Per Hit % Time Line Contents
  705. ==============================================================
  706. 639 @profile
  707. 640 def update_image_tags(self, image_id, tags):
  708. 641 url_params = azure_helpers.parse_url(IMAGE_RESOURCE_ID,
  709. 642 image_id)
  710. 643 if self.is_gallery_image(image_id):
  711. 644 return True
  712. 645 else:
  713. 646 name = url_params.get(IMAGE_NAME)
  714. 647 return self.compute_client.images. \
  715. 648 create_or_update(self.resource_group, name,
  716. 649 {
  717. 650 'tags': tags,
  718. 651 'location': self.region_name
  719. 652 }).result()
  720. Total time: 0 s
  721. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  722. Function: list_vm_types at line 654
  723. Line # Hits Time Per Hit % Time Line Contents
  724. ==============================================================
  725. 654 @profile
  726. 655 def list_vm_types(self):
  727. 656 return self.compute_client.virtual_machine_sizes. \
  728. 657 list(self.region_name)
  729. Total time: 0.048469 s
  730. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  731. Function: list_networks at line 659
  732. Line # Hits Time Per Hit % Time Line Contents
  733. ==============================================================
  734. 659 @profile
  735. 660 def list_networks(self):
  736. 661 6 48111.0 8018.5 99.3 return self.network_management_client.virtual_networks.list(
  737. 662 6 358.0 59.7 0.7 self.resource_group)
  738. Total time: 4.84816 s
  739. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  740. Function: get_network at line 664
  741. Line # Hits Time Per Hit % Time Line Contents
  742. ==============================================================
  743. 664 @profile
  744. 665 def get_network(self, network_id):
  745. 666 18 16.0 0.9 0.0 url_params = azure_helpers.parse_url(NETWORK_RESOURCE_ID,
  746. 667 18 323.0 17.9 0.0 network_id)
  747. 668 18 18.0 1.0 0.0 network_name = url_params.get(NETWORK_NAME)
  748. 669 18 13505.0 750.3 0.3 return self.network_management_client.virtual_networks.get(
  749. 670 18 4834293.0 268571.8 99.7 self.resource_group, network_name)
  750. Total time: 0 s
  751. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  752. Function: create_network at line 672
  753. Line # Hits Time Per Hit % Time Line Contents
  754. ==============================================================
  755. 672 @profile
  756. 673 def create_network(self, name, params):
  757. 674 return self.network_management_client.virtual_networks. \
  758. 675 create_or_update(self.resource_group,
  759. 676 name,
  760. 677 parameters=params).result()
  761. Total time: 0 s
  762. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  763. Function: delete_network at line 679
  764. Line # Hits Time Per Hit % Time Line Contents
  765. ==============================================================
  766. 679 @profile
  767. 680 def delete_network(self, network_id):
  768. 681 url_params = azure_helpers.parse_url(NETWORK_RESOURCE_ID, network_id)
  769. 682 network_name = url_params.get(NETWORK_NAME)
  770. 683 return self.network_management_client.virtual_networks. \
  771. 684 delete(self.resource_group, network_name).wait()
  772. Total time: 0 s
  773. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  774. Function: update_network_tags at line 686
  775. Line # Hits Time Per Hit % Time Line Contents
  776. ==============================================================
  777. 686 @profile
  778. 687 def update_network_tags(self, network_id, tags):
  779. 688 url_params = azure_helpers.parse_url(NETWORK_RESOURCE_ID, network_id)
  780. 689 network_name = url_params.get(NETWORK_NAME)
  781. 690 return self.network_management_client.virtual_networks. \
  782. 691 create_or_update(self.resource_group,
  783. 692 network_name, tags).result()
  784. Total time: 0.000751 s
  785. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  786. Function: get_network_id_for_subnet at line 694
  787. Line # Hits Time Per Hit % Time Line Contents
  788. ==============================================================
  789. 694 @profile
  790. 695 def get_network_id_for_subnet(self, subnet_id):
  791. 696 18 522.0 29.0 69.5 url_params = azure_helpers.parse_url(SUBNET_RESOURCE_ID, subnet_id)
  792. 697 18 26.0 1.4 3.5 network_id = NETWORK_RESOURCE_ID[0]
  793. 698 90 63.0 0.7 8.4 for key, val in url_params.items():
  794. 699 72 130.0 1.8 17.3 network_id = network_id.replace("{" + key + "}", val)
  795. 700 18 10.0 0.6 1.3 return network_id
  796. Total time: 0.004972 s
  797. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  798. Function: list_subnets at line 702
  799. Line # Hits Time Per Hit % Time Line Contents
  800. ==============================================================
  801. 702 @profile
  802. 703 def list_subnets(self, network_id):
  803. 704 6 180.0 30.0 3.6 url_params = azure_helpers.parse_url(NETWORK_RESOURCE_ID, network_id)
  804. 705 6 11.0 1.8 0.2 network_name = url_params.get(NETWORK_NAME)
  805. 706 6 4469.0 744.8 89.9 return self.network_management_client.subnets. \
  806. 707 6 312.0 52.0 6.3 list(self.resource_group, network_name)
  807. Total time: 0 s
  808. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  809. Function: get_subnet at line 709
  810. Line # Hits Time Per Hit % Time Line Contents
  811. ==============================================================
  812. 709 @profile
  813. 710 def get_subnet(self, subnet_id):
  814. 711 url_params = azure_helpers.parse_url(SUBNET_RESOURCE_ID,
  815. 712 subnet_id)
  816. 713 network_name = url_params.get(NETWORK_NAME)
  817. 714 subnet_name = url_params.get(SUBNET_NAME)
  818. 715 return self.network_management_client.subnets. \
  819. 716 get(self.resource_group, network_name, subnet_name)
  820. Total time: 0 s
  821. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  822. Function: create_subnet at line 718
  823. Line # Hits Time Per Hit % Time Line Contents
  824. ==============================================================
  825. 718 @profile
  826. 719 def create_subnet(self, network_id, subnet_name, params):
  827. 720 url_params = azure_helpers.parse_url(NETWORK_RESOURCE_ID, network_id)
  828. 721 network_name = url_params.get(NETWORK_NAME)
  829. 722 result_create = self.network_management_client \
  830. 723 .subnets.create_or_update(
  831. 724 self.resource_group,
  832. 725 network_name,
  833. 726 subnet_name,
  834. 727 params
  835. 728 )
  836. 729 subnet_info = result_create.result()
  837. 730
  838. 731 return subnet_info
  839. Total time: 0 s
  840. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  841. Function: __if_subnet_in_use at line 733
  842. Line # Hits Time Per Hit % Time Line Contents
  843. ==============================================================
  844. 733 @profile
  845. 734 def __if_subnet_in_use(e):
  846. 735 # return True if the CloudError exception is due to subnet being in use
  847. 736 if isinstance(e, CloudError):
  848. 737 if e.error.error == "InUseSubnetCannotBeDeleted":
  849. 738 return True
  850. 739 return False
  851. Total time: 0 s
  852. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  853. Function: delete_subnet at line 741
  854. Line # Hits Time Per Hit % Time Line Contents
  855. ==============================================================
  856. 741 @tenacity.retry(stop=tenacity.stop_after_attempt(5),
  857. 742 retry=tenacity.retry_if_exception(__if_subnet_in_use),
  858. 743 wait=tenacity.wait_fixed(5),
  859. 744 reraise=True)
  860. 745 @profile
  861. 746 def delete_subnet(self, subnet_id):
  862. 747 url_params = azure_helpers.parse_url(SUBNET_RESOURCE_ID,
  863. 748 subnet_id)
  864. 749 network_name = url_params.get(NETWORK_NAME)
  865. 750 subnet_name = url_params.get(SUBNET_NAME)
  866. 751
  867. 752 try:
  868. 753 result_delete = self.network_management_client \
  869. 754 .subnets.delete(
  870. 755 self.resource_group,
  871. 756 network_name,
  872. 757 subnet_name
  873. 758 )
  874. 759 result_delete.wait()
  875. 760 except CloudError as cloud_error:
  876. 761 log.exception(cloud_error.message)
  877. 762 raise cloud_error
  878. Total time: 0 s
  879. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  880. Function: create_floating_ip at line 764
  881. Line # Hits Time Per Hit % Time Line Contents
  882. ==============================================================
  883. 764 @profile
  884. 765 def create_floating_ip(self, public_ip_name, public_ip_parameters):
  885. 766 return self.network_management_client.public_ip_addresses. \
  886. 767 create_or_update(self.resource_group,
  887. 768 public_ip_name,
  888. 769 public_ip_parameters).result()
  889. Total time: 0 s
  890. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  891. Function: get_floating_ip at line 771
  892. Line # Hits Time Per Hit % Time Line Contents
  893. ==============================================================
  894. 771 @profile
  895. 772 def get_floating_ip(self, public_ip_id):
  896. 773 url_params = azure_helpers.parse_url(PUBLIC_IP_RESOURCE_ID,
  897. 774 public_ip_id)
  898. 775 public_ip_name = url_params.get(PUBLIC_IP_NAME)
  899. 776 return self.network_management_client. \
  900. 777 public_ip_addresses.get(self.resource_group, public_ip_name)
  901. Total time: 0 s
  902. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  903. Function: delete_floating_ip at line 779
  904. Line # Hits Time Per Hit % Time Line Contents
  905. ==============================================================
  906. 779 @profile
  907. 780 def delete_floating_ip(self, public_ip_id):
  908. 781 url_params = azure_helpers.parse_url(PUBLIC_IP_RESOURCE_ID,
  909. 782 public_ip_id)
  910. 783 public_ip_name = url_params.get(PUBLIC_IP_NAME)
  911. 784 self.network_management_client. \
  912. 785 public_ip_addresses.delete(self.resource_group,
  913. 786 public_ip_name).wait()
  914. Total time: 0 s
  915. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  916. Function: update_fip_tags at line 788
  917. Line # Hits Time Per Hit % Time Line Contents
  918. ==============================================================
  919. 788 @profile
  920. 789 def update_fip_tags(self, fip_id, tags):
  921. 790 url_params = azure_helpers.parse_url(PUBLIC_IP_RESOURCE_ID,
  922. 791 fip_id)
  923. 792 fip_name = url_params.get(PUBLIC_IP_NAME)
  924. 793 self.network_management_client.public_ip_addresses. \
  925. 794 create_or_update(self.resource_group,
  926. 795 fip_name, tags).result()
  927. Total time: 0 s
  928. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  929. Function: list_floating_ips at line 797
  930. Line # Hits Time Per Hit % Time Line Contents
  931. ==============================================================
  932. 797 @profile
  933. 798 def list_floating_ips(self):
  934. 799 return self.network_management_client.public_ip_addresses.list(
  935. 800 self.resource_group)
  936. Total time: 0 s
  937. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  938. Function: list_vm at line 802
  939. Line # Hits Time Per Hit % Time Line Contents
  940. ==============================================================
  941. 802 @profile
  942. 803 def list_vm(self):
  943. 804 return self.compute_client.virtual_machines.list(
  944. 805 self.resource_group
  945. 806 )
  946. Total time: 0 s
  947. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  948. Function: restart_vm at line 808
  949. Line # Hits Time Per Hit % Time Line Contents
  950. ==============================================================
  951. 808 @profile
  952. 809 def restart_vm(self, vm_id):
  953. 810 url_params = azure_helpers.parse_url(VM_RESOURCE_ID,
  954. 811 vm_id)
  955. 812 vm_name = url_params.get(VM_NAME)
  956. 813 return self.compute_client.virtual_machines.restart(
  957. 814 self.resource_group, vm_name).wait()
  958. Total time: 0 s
  959. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  960. Function: delete_vm at line 816
  961. Line # Hits Time Per Hit % Time Line Contents
  962. ==============================================================
  963. 816 @profile
  964. 817 def delete_vm(self, vm_id):
  965. 818 url_params = azure_helpers.parse_url(VM_RESOURCE_ID,
  966. 819 vm_id)
  967. 820 vm_name = url_params.get(VM_NAME)
  968. 821 return self.compute_client.virtual_machines.delete(
  969. 822 self.resource_group, vm_name).wait()
  970. Total time: 0 s
  971. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  972. Function: get_vm at line 824
  973. Line # Hits Time Per Hit % Time Line Contents
  974. ==============================================================
  975. 824 @profile
  976. 825 def get_vm(self, vm_id):
  977. 826 url_params = azure_helpers.parse_url(VM_RESOURCE_ID,
  978. 827 vm_id)
  979. 828 vm_name = url_params.get(VM_NAME)
  980. 829 return self.compute_client.virtual_machines.get(
  981. 830 self.resource_group,
  982. 831 vm_name,
  983. 832 expand='instanceView'
  984. 833 )
  985. Total time: 0 s
  986. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  987. Function: create_vm at line 835
  988. Line # Hits Time Per Hit % Time Line Contents
  989. ==============================================================
  990. 835 @profile
  991. 836 def create_vm(self, vm_name, params):
  992. 837 return self.compute_client.virtual_machines. \
  993. 838 create_or_update(self.resource_group,
  994. 839 vm_name, params).result()
  995. Total time: 0 s
  996. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  997. Function: update_vm at line 841
  998. Line # Hits Time Per Hit % Time Line Contents
  999. ==============================================================
  1000. 841 @profile
  1001. 842 def update_vm(self, vm_id, params):
  1002. 843 url_params = azure_helpers.parse_url(VM_RESOURCE_ID,
  1003. 844 vm_id)
  1004. 845 vm_name = url_params.get(VM_NAME)
  1005. 846 return self.compute_client.virtual_machines. \
  1006. 847 create_or_update(self.resource_group,
  1007. 848 vm_name, params, raw=True)
  1008. Total time: 0 s
  1009. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1010. Function: deallocate_vm at line 850
  1011. Line # Hits Time Per Hit % Time Line Contents
  1012. ==============================================================
  1013. 850 @profile
  1014. 851 def deallocate_vm(self, vm_id):
  1015. 852 url_params = azure_helpers.parse_url(VM_RESOURCE_ID,
  1016. 853 vm_id)
  1017. 854 vm_name = url_params.get(VM_NAME)
  1018. 855 self.compute_client. \
  1019. 856 virtual_machines.deallocate(self.resource_group,
  1020. 857 vm_name).wait()
  1021. Total time: 0 s
  1022. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1023. Function: generalize_vm at line 859
  1024. Line # Hits Time Per Hit % Time Line Contents
  1025. ==============================================================
  1026. 859 @profile
  1027. 860 def generalize_vm(self, vm_id):
  1028. 861 url_params = azure_helpers.parse_url(VM_RESOURCE_ID,
  1029. 862 vm_id)
  1030. 863 vm_name = url_params.get(VM_NAME)
  1031. 864 self.compute_client.virtual_machines. \
  1032. 865 generalize(self.resource_group, vm_name)
  1033. Total time: 0 s
  1034. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1035. Function: start_vm at line 867
  1036. Line # Hits Time Per Hit % Time Line Contents
  1037. ==============================================================
  1038. 867 @profile
  1039. 868 def start_vm(self, vm_id):
  1040. 869 url_params = azure_helpers.parse_url(VM_RESOURCE_ID,
  1041. 870 vm_id)
  1042. 871 vm_name = url_params.get(VM_NAME)
  1043. 872 self.compute_client.virtual_machines. \
  1044. 873 start(self.resource_group,
  1045. 874 vm_name).wait()
  1046. Total time: 0 s
  1047. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1048. Function: update_vm_tags at line 876
  1049. Line # Hits Time Per Hit % Time Line Contents
  1050. ==============================================================
  1051. 876 @profile
  1052. 877 def update_vm_tags(self, vm_id, tags):
  1053. 878 url_params = azure_helpers.parse_url(VM_RESOURCE_ID,
  1054. 879 vm_id)
  1055. 880 vm_name = url_params.get(VM_NAME)
  1056. 881 self.compute_client.virtual_machines. \
  1057. 882 create_or_update(self.resource_group,
  1058. 883 vm_name, tags).result()
  1059. Total time: 0 s
  1060. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1061. Function: delete_nic at line 885
  1062. Line # Hits Time Per Hit % Time Line Contents
  1063. ==============================================================
  1064. 885 @profile
  1065. 886 def delete_nic(self, nic_id):
  1066. 887 nic_params = azure_helpers.\
  1067. 888 parse_url(NETWORK_INTERFACE_RESOURCE_ID, nic_id)
  1068. 889 nic_name = nic_params.get(NETWORK_INTERFACE_NAME)
  1069. 890 self.network_management_client. \
  1070. 891 network_interfaces.delete(self.resource_group,
  1071. 892 nic_name).wait()
  1072. Total time: 0 s
  1073. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1074. Function: get_nic at line 894
  1075. Line # Hits Time Per Hit % Time Line Contents
  1076. ==============================================================
  1077. 894 @profile
  1078. 895 def get_nic(self, nic_id):
  1079. 896 nic_params = azure_helpers.\
  1080. 897 parse_url(NETWORK_INTERFACE_RESOURCE_ID, nic_id)
  1081. 898 nic_name = nic_params.get(NETWORK_INTERFACE_NAME)
  1082. 899 return self.network_management_client. \
  1083. 900 network_interfaces.get(self.resource_group, nic_name)
  1084. Total time: 0 s
  1085. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1086. Function: update_nic at line 902
  1087. Line # Hits Time Per Hit % Time Line Contents
  1088. ==============================================================
  1089. 902 @profile
  1090. 903 def update_nic(self, nic_id, params):
  1091. 904 nic_params = azure_helpers.\
  1092. 905 parse_url(NETWORK_INTERFACE_RESOURCE_ID, nic_id)
  1093. 906 nic_name = nic_params.get(NETWORK_INTERFACE_NAME)
  1094. 907 async_nic_creation = self.network_management_client. \
  1095. 908 network_interfaces.create_or_update(
  1096. 909 self.resource_group,
  1097. 910 nic_name,
  1098. 911 params
  1099. 912 )
  1100. 913 nic_info = async_nic_creation.result()
  1101. 914 return nic_info
  1102. Total time: 0 s
  1103. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1104. Function: create_nic at line 916
  1105. Line # Hits Time Per Hit % Time Line Contents
  1106. ==============================================================
  1107. 916 @profile
  1108. 917 def create_nic(self, nic_name, params):
  1109. 918 return self.network_management_client. \
  1110. 919 network_interfaces.create_or_update(
  1111. 920 self.resource_group,
  1112. 921 nic_name,
  1113. 922 params
  1114. 923 ).result()
  1115. Total time: 0.295365 s
  1116. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1117. Function: create_public_key at line 925
  1118. Line # Hits Time Per Hit % Time Line Contents
  1119. ==============================================================
  1120. 925 @profile
  1121. 926 def create_public_key(self, entity):
  1122. 927 3 148018.0 49339.3 50.1 return self.table_service. \
  1123. 928 3 25.0 8.3 0.0 insert_or_replace_entity(self.public_key_storage_table_name,
  1124. 929 3 147322.0 49107.3 49.9 entity)
  1125. Total time: 3.71449 s
  1126. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1127. Function: get_public_key at line 931
  1128. Line # Hits Time Per Hit % Time Line Contents
  1129. ==============================================================
  1130. 931 @profile
  1131. 932 def get_public_key(self, name):
  1132. 933 11 3360211.0 305473.7 90.5 entities = self.table_service. \
  1133. 934 11 93.0 8.5 0.0 query_entities(self.public_key_storage_table_name,
  1134. 935 11 354149.0 32195.4 9.5 "Name eq '{0}'".format(name), num_results=1)
  1135. 936
  1136. 937 11 37.0 3.4 0.0 return entities.items[0] if len(entities.items) > 0 else None
  1137. Total time: 0.195861 s
  1138. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1139. Function: delete_public_key at line 939
  1140. Line # Hits Time Per Hit % Time Line Contents
  1141. ==============================================================
  1142. 939 @profile
  1143. 940 def delete_public_key(self, entity):
  1144. 941 3 106261.0 35420.3 54.3 self.table_service.delete_entity(self.public_key_storage_table_name,
  1145. 942 3 89600.0 29866.7 45.7 entity.PartitionKey, entity.RowKey)
  1146. Total time: 0.458264 s
  1147. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1148. Function: list_public_keys at line 944
  1149. Line # Hits Time Per Hit % Time Line Contents
  1150. ==============================================================
  1151. 944 @profile
  1152. 945 def list_public_keys(self, partition_key, limit=None, marker=None):
  1153. 946 6 224624.0 37437.3 49.0 entities = self.table_service. \
  1154. 947 6 58.0 9.7 0.0 query_entities(self.public_key_storage_table_name,
  1155. 948 6 11.0 1.8 0.0 "PartitionKey eq '{0}'".format(partition_key),
  1156. 949 6 233558.0 38926.3 51.0 marker=marker, num_results=limit)
  1157. 950 6 13.0 2.2 0.0 return (entities.items, entities.next_marker)
  1158. Total time: 0 s
  1159. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1160. Function: delete_route_table at line 952
  1161. Line # Hits Time Per Hit % Time Line Contents
  1162. ==============================================================
  1163. 952 @profile
  1164. 953 def delete_route_table(self, route_table_name):
  1165. 954 self.network_management_client. \
  1166. 955 route_tables.delete(self.resource_group, route_table_name
  1167. 956 ).wait()
  1168. Total time: 0 s
  1169. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1170. Function: attach_subnet_to_route_table at line 958
  1171. Line # Hits Time Per Hit % Time Line Contents
  1172. ==============================================================
  1173. 958 @profile
  1174. 959 def attach_subnet_to_route_table(self, subnet_id, route_table_id):
  1175. 960 url_params = azure_helpers.parse_url(SUBNET_RESOURCE_ID,
  1176. 961 subnet_id)
  1177. 962 network_name = url_params.get(NETWORK_NAME)
  1178. 963 subnet_name = url_params.get(SUBNET_NAME)
  1179. 964
  1180. 965 subnet_info = self.network_management_client.subnets.get(
  1181. 966 self.resource_group,
  1182. 967 network_name,
  1183. 968 subnet_name
  1184. 969 )
  1185. 970 if subnet_info:
  1186. 971 subnet_info.route_table = {
  1187. 972 'id': route_table_id
  1188. 973 }
  1189. 974
  1190. 975 result_create = self.network_management_client. \
  1191. 976 subnets.create_or_update(
  1192. 977 self.resource_group,
  1193. 978 network_name,
  1194. 979 subnet_name,
  1195. 980 subnet_info)
  1196. 981 subnet_info = result_create.result()
  1197. 982
  1198. 983 return subnet_info
  1199. Total time: 0 s
  1200. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1201. Function: detach_subnet_to_route_table at line 985
  1202. Line # Hits Time Per Hit % Time Line Contents
  1203. ==============================================================
  1204. 985 @profile
  1205. 986 def detach_subnet_to_route_table(self, subnet_id, route_table_id):
  1206. 987 url_params = azure_helpers.parse_url(SUBNET_RESOURCE_ID,
  1207. 988 subnet_id)
  1208. 989 network_name = url_params.get(NETWORK_NAME)
  1209. 990 subnet_name = url_params.get(SUBNET_NAME)
  1210. 991
  1211. 992 subnet_info = self.network_management_client.subnets.get(
  1212. 993 self.resource_group,
  1213. 994 network_name,
  1214. 995 subnet_name
  1215. 996 )
  1216. 997
  1217. 998 if subnet_info and subnet_info.route_table.id == route_table_id:
  1218. 999 subnet_info.route_table = None
  1219. 1000
  1220. 1001 result_create = self.network_management_client. \
  1221. 1002 subnets.create_or_update(
  1222. 1003 self.resource_group,
  1223. 1004 network_name,
  1224. 1005 subnet_name,
  1225. 1006 subnet_info)
  1226. 1007 subnet_info = result_create.result()
  1227. 1008
  1228. 1009 return subnet_info
  1229. Total time: 0 s
  1230. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1231. Function: list_route_tables at line 1011
  1232. Line # Hits Time Per Hit % Time Line Contents
  1233. ==============================================================
  1234. 1011 @profile
  1235. 1012 def list_route_tables(self):
  1236. 1013 return self.network_management_client. \
  1237. 1014 route_tables.list(self.resource_group)
  1238. Total time: 0 s
  1239. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1240. Function: get_route_table at line 1016
  1241. Line # Hits Time Per Hit % Time Line Contents
  1242. ==============================================================
  1243. 1016 @profile
  1244. 1017 def get_route_table(self, router_id):
  1245. 1018 url_params = azure_helpers.parse_url(ROUTER_RESOURCE_ID,
  1246. 1019 router_id)
  1247. 1020 router_name = url_params.get(ROUTER_NAME)
  1248. 1021 return self.network_management_client. \
  1249. 1022 route_tables.get(self.resource_group, router_name)
  1250. Total time: 0 s
  1251. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1252. Function: create_route_table at line 1024
  1253. Line # Hits Time Per Hit % Time Line Contents
  1254. ==============================================================
  1255. 1024 @profile
  1256. 1025 def create_route_table(self, route_table_name, params):
  1257. 1026 return self.network_management_client. \
  1258. 1027 route_tables.create_or_update(
  1259. 1028 self.resource_group,
  1260. 1029 route_table_name, params).result()
  1261. Total time: 0 s
  1262. File: /Users/alex/Desktop/work/cb-profiled/cloudbridge/cloudbridge/cloud/providers/azure/azure_client.py
  1263. Function: update_route_table_tags at line 1031
  1264. Line # Hits Time Per Hit % Time Line Contents
  1265. ==============================================================
  1266. 1031 @profile
  1267. 1032 def update_route_table_tags(self, route_table_name, tags):
  1268. 1033 self.network_management_client.route_tables. \
  1269. 1034 create_or_update(self.resource_group,
  1270. 1035 route_table_name, tags).result()