How to use delete_policy method in tempest

Best Python code snippet using tempest_python

test_qos.py

Source:test_qos.py Github

copy

Full Screen

...208 retrieved_policy['description'])209 self.assertTrue(retrieved_policy['shared'])210 self.assertEmpty(retrieved_policy['rules'])211 @decorators.idempotent_id('1cb42653-54bd-4a9a-b888-c55e18199201')212 def test_delete_policy(self):213 """qos-policy-delete POLICY_ID."""214 policy = self.create_qos_policy(215 'test-policy', 'desc', True)216 self.addCleanup(test_utils.call_and_ignore_notfound_exc,217 self.adm_qos_client.delete_policy, policy['id'])218 retrieved_policy = self.adm_qos_client.show_policy(policy['id'])219 self.assertEqual('test-policy', retrieved_policy['name'])220 self.adm_qos_client.delete_policy(policy['id'])221 self.assertRaises(exceptions.NotFound,222 self.adm_qos_client.show_policy, policy['id'])223 def _test_list_admin_rule_types(self):224 """qos-available-rule-types: available rule type from admin view."""225 self._test_list_rule_types(self.adm_qos_client)226 def _test_list_regular_rule_types(self):227 """qos-available-rule-types: available rule type from project view."""228 self._test_list_rule_types(self.pri_qos_client)229 def _test_list_rule_types(self, client):230 # List supported rule types231 # TODO(QoS): since in gate we run both ovs and linuxbridge ml2 drivers,232 # and since Linux Bridge ml2 driver does not have QoS support yet, ml2233 # plugin reports no rule types are supported. Once linuxbridge will234 # receive support for QoS, the list of expected rule types will change.235 #236 # In theory, we could make the test conditional on which ml2 drivers237 # are enabled in gate (or more specifically, on which supported qos238 # rules are claimed by core plugin), but that option doesn't seem to be239 # available thru tempest.lib framework240 expected_rule_types = []241 expected_rule_details = ['type']242 rule_types = client.available_rule_types()243 actual_rule_types = [rule['type'] for rule in rule_types]244 # TODO(akang): seems not correct245 # Verify that only required fields present in rule details246 for rule in actual_rule_types:247 self.assertEqual(tuple(rule.keys()), tuple(expected_rule_details))248 # Verify if expected rules are present in the actual rules list249 for rule in expected_rule_types:250 self.assertIn(rule, actual_rule_types)251 def _disassociate_network(self, network_id, client_mgr=None):252 self.update_network(network_id, client_mgr=client_mgr,253 qos_policy_id=None)254 updated_network = self.show_network(network_id,255 client_mgr=client_mgr)256 self.assertIsNone(updated_network['qos_policy_id'])257 @decorators.idempotent_id('65b9ef75-1911-406a-bbdb-ca1d68d528b0')258 def test_policy_association_with_admin_network(self):259 """admin can create network with non-shared policy."""260 policy = self.create_qos_policy(name='test-policy',261 description='test policy',262 shared=False)263 self.addCleanup(test_utils.call_and_ignore_notfound_exc,264 self.adm_qos_client.delete_policy, policy['id'])265 network = self.create_shared_network('test network',266 qos_policy_id=policy['id'])267 self.addCleanup(test_utils.call_and_ignore_notfound_exc,268 self.delete_network, network['id'])269 retrieved_network = self.show_network(network['id'])270 self.assertEqual(271 policy['id'], retrieved_network['qos_policy_id'])272 self._disassociate_network(network['id'], self.admin_mgr)273 @decorators.idempotent_id('1738de5d-0476-4163-9022-5e1b548c208e')274 def test_policy_association_with_tenant_network(self):275 """project/tenant can create network with shared policy."""276 policy = self.create_qos_policy(name='test-policy',277 description='test policy',278 shared=True)279 self.addCleanup(test_utils.call_and_ignore_notfound_exc,280 self.adm_qos_client.delete_policy, policy['id'])281 network = self.create_network('test network',282 client_mgr=self.primary_mgr,283 qos_policy_id=policy['id'])284 self.addCleanup(test_utils.call_and_ignore_notfound_exc,285 self.delete_network, network['id'])286 retrieved_network = self.show_network(network['id'],287 client_mgr=self.primary_mgr)288 self.assertEqual(289 policy['id'], retrieved_network['qos_policy_id'])290 self._disassociate_network(network['id'], self.primary_mgr)291 @test.attr(type='negative')292 @decorators.idempotent_id('9efe63d0-836f-4cc2-b00c-468e63aa614e')293 def test_policy_association_with_network_nonexistent_policy(self):294 """Can not attach network to a nonexist policy."""295 network = self.create_network(296 'test network',297 qos_policy_id='9efe63d0-836f-4cc2-b00c-468e63aa614e')298 self.addCleanup(test_utils.call_and_ignore_notfound_exc,299 self.delete_network, network['id'])300 retrieved_network = self.show_network(network['id'])301 # check if network is not attached to the policy302 self.assertIsNone(retrieved_network['qos_policy_id'],303 'Error: Network is attached to non-existent policy')304 @test.attr(type='negative')305 @decorators.idempotent_id('1aa55a79-324f-47d9-a076-894a8fc2448b')306 def test_policy_association_with_network_non_shared_policy(self):307 """tenant/project can not attach network with not-shared policy."""308 policy = self.create_qos_policy(name='test-policy',309 description='test policy',310 shared=False)311 self.addCleanup(test_utils.call_and_ignore_notfound_exc,312 self.adm_qos_client.delete_policy, policy['id'])313 network = self.create_network(314 'test network',315 qos_policy_id=policy['id'],316 client_mgr=self.primary_mgr)317 self.addCleanup(test_utils.call_and_ignore_notfound_exc,318 self.delete_network, network['id'])319 retrieved_network = self.show_network(network['id'],320 client_mgr=self.primary_mgr)321 # check if network is not attached to the policy322 self.assertIsNone(retrieved_network['qos_policy_id'],323 'Error: Network is attached to QoS policy')324 @decorators.idempotent_id('10a9392c-1359-4cbb-989f-fb768e5834a8')325 def test_policy_update_association_with_admin_network(self):326 """admin can create associate non-shared policy to network."""327 policy = self.create_qos_policy(name='test-policy',328 description='test policy',329 shared=False)330 self.addCleanup(test_utils.call_and_ignore_notfound_exc,331 self.adm_qos_client.delete_policy, policy['id'])332 network = self.create_shared_network('test network')333 self.addCleanup(test_utils.call_and_ignore_notfound_exc,334 self.delete_network, network['id'])335 retrieved_network = self.show_network(network['id'])336 self.assertIsNone(retrieved_network['qos_policy_id'])337 self.update_network(338 network['id'], qos_policy_id=policy['id'])339 retrieved_network = self.show_network(network['id'])340 self.assertEqual(341 policy['id'], retrieved_network['qos_policy_id'])342 self._disassociate_network(network['id'], self.admin_mgr)343 def _disassociate_port(self, port_id, client_mgr=None):344 client_mgr = client_mgr if client_mgr else self.admin_mgr345 self.update_port(port_id, qos_policy_id=None,346 client_mgr=client_mgr)347 updated_port = self.show_port(port_id, client_mgr=client_mgr)348 self.assertIsNone(updated_port['qos_policy_id'])349 @test.attr(type='nsxv3')350 @test.attr(type='negative')351 @decorators.idempotent_id('98fcd95e-84cf-4746-860e-44692e674f2e')352 def test_policy_association_with_port_shared_policy(self):353 """test port can associate shared policy."""354 policy = self.create_qos_policy(name='test-policy',355 description='test policy',356 shared=True)357 self.addCleanup(test_utils.call_and_ignore_notfound_exc,358 self.adm_qos_client.delete_policy, policy['id'])359 network = self.create_shared_network('test network')360 self.addCleanup(test_utils.call_and_ignore_notfound_exc,361 self.delete_network, network['id'])362 port = self.create_port(network, qos_policy_id=policy['id'],363 client_mgr=self.primary_mgr)364 self.addCleanup(test_utils.call_and_ignore_notfound_exc,365 self.delete_port, port['id'])366 retrieved_port = self.show_port(port['id'],367 client_mgr=self.primary_mgr)368 self.assertEqual(369 policy['id'], retrieved_port['qos_policy_id'])370 self._disassociate_port(port['id'], client_mgr=self.primary_mgr)371 @test.attr(type='negative')372 @test.attr(type='nsxv3')373 @decorators.idempotent_id('49e02f5a-e1dd-41d5-9855-cfa37f2d195e')374 def test_policy_association_with_port_nonexistent_policy(self):375 """test port cannot be created with nonexist policy."""376 network = self.create_shared_network('test network')377 self.addCleanup(test_utils.call_and_ignore_notfound_exc,378 self.delete_network, network['id'])379 self.assertRaises(380 exceptions.NotFound,381 self.create_port,382 network,383 qos_policy_id='49e02f5a-e1dd-41d5-9855-cfa37f2d195e')384 @test.attr(type='negative')385 @test.attr(type='nsxv3')386 @decorators.idempotent_id('f53d961c-9fe5-4422-8b66-7add972c6031')387 def test_policy_association_with_port_non_shared_policy(self):388 """project/tenant can not associate port with non-shared policy."""389 policy = self.create_qos_policy(name='test-policy',390 description='test policy',391 shared=False)392 self.addCleanup(test_utils.call_and_ignore_notfound_exc,393 self.adm_qos_client.delete_policy, policy['id'])394 network = self.create_shared_network('test network')395 self.addCleanup(test_utils.call_and_ignore_notfound_exc,396 self.delete_network, network['id'])397 port = self.create_port(network, qos_policy_id=policy['id'],398 client_mgr=self.primary_mgr)399 self.addCleanup(test_utils.call_and_ignore_notfound_exc,400 self.delete_port, port['id'])401 retrieved_port = self.show_port(port['id'],402 client_mgr=self.primary_mgr)403 # check if port is not attached to the policy404 self.assertIsNone(retrieved_port['qos_policy_id'],405 'Error:Port is attached to qos policy')406 @test.attr(type='nsxv3')407 @decorators.idempotent_id('f8163237-fba9-4db5-9526-bad6d2343c76')408 def test_policy_update_association_with_port_shared_policy(self):409 """project/tenant can update port with shared policy."""410 policy = self.create_qos_policy(name='test-policy',411 description='test policy',412 shared=True)413 self.addCleanup(test_utils.call_and_ignore_notfound_exc,414 self.adm_qos_client.delete_policy, policy['id'])415 network = self.create_shared_network('test network')416 self.addCleanup(test_utils.call_and_ignore_notfound_exc,417 self.delete_network, network['id'])418 port = self.create_port(network, client_mgr=self.primary_mgr)419 self.addCleanup(test_utils.call_and_ignore_notfound_exc,420 self.delete_port, port['id'])421 retrieved_port = self.show_port(port['id'],422 client_mgr=self.primary_mgr)423 self.assertIsNone(retrieved_port['qos_policy_id'])424 self.update_port(port['id'], qos_policy_id=policy['id'],425 client_mgr=self.primary_mgr)426 retrieved_port = self.show_port(port['id'],427 client_mgr=self.primary_mgr)428 self.assertEqual(429 policy['id'], retrieved_port['qos_policy_id'])430 self._disassociate_port(port['id'])431 @test.attr(type='negative')432 @decorators.idempotent_id('18163237-8ba9-4db5-9525-bad6d2343c75')433 def test_delete_not_allowed_if_policy_in_use_by_network(self):434 """can not delete policy if used by network."""435 policy = self.create_qos_policy(name='test-policy',436 description='test policy',437 shared=True)438 self.addCleanup(test_utils.call_and_ignore_notfound_exc,439 self.adm_qos_client.delete_policy, policy['id'])440 network = self.create_shared_network(441 'test network', qos_policy_id=policy['id'])442 self.addCleanup(test_utils.call_and_ignore_notfound_exc,443 self.delete_network, network['id'])444 self.assertRaises(445 exceptions.Conflict,446 self.adm_qos_client.delete_policy, policy['id'])447 self._disassociate_network(network['id'], self.admin_mgr)448 self.adm_qos_client.delete_policy(policy['id'])449 @test.attr(type='negative')450 @test.attr(type='nsxv3')451 @decorators.idempotent_id('24153230-84a9-4dd5-9525-bad6d2343c75')452 def test_delete_not_allowed_if_policy_in_use_by_port(self):453 """can not delete policy if used by port."""454 policy = self.create_qos_policy(name='test-policy',455 description='test policy',456 shared=True)457 self.addCleanup(test_utils.call_and_ignore_notfound_exc,458 self.adm_qos_client.delete_policy, policy['id'])459 network = self.create_shared_network('test network')460 self.addCleanup(test_utils.call_and_ignore_notfound_exc,461 self.delete_network, network['id'])462 port = self.create_port(network, qos_policy_id=policy['id'],463 client_mgr=self.primary_mgr)464 self.addCleanup(test_utils.call_and_ignore_notfound_exc,465 self.delete_port, port['id'])466 self.assertRaises(467 exceptions.Conflict,468 self.adm_qos_client.delete_policy, policy['id'])469 self._disassociate_port(port['id'], client_mgr=self.primary_mgr)470 self.adm_qos_client.delete_policy(policy['id'])471 @decorators.idempotent_id('a2a5849b-dd06-4b18-9664-0b6828a1fc27')472 def test_qos_policy_delete_with_rules(self):473 """Policy with rules attached can be deleted."""474 policy = self.create_qos_policy(name='test-policy',475 description='test policy',476 shared=False)477 self.addCleanup(test_utils.call_and_ignore_notfound_exc,478 self.adm_qos_client.delete_policy, policy['id'])479 self.adm_qos_client.create_bandwidth_limit_rule(480 policy['id'], 200, 1337)481 self.adm_qos_client.delete_policy(policy['id'])482 with testtools.ExpectedException(exceptions.NotFound):483 self.adm_qos_client.show_policy(policy['id'])484class QosBandwidthLimitRuleTest(BaseQosTest):485 """QoS Bandwidth limit rule CURD operations."""486 @decorators.idempotent_id('8a59b00b-3e9c-4787-92f8-93a5cdf5e378')487 def test_rule_create(self):488 """qos-bandwidth-limit-rule-create POLICY_ID."""489 qos_client = self.adm_qos_client490 policy = self.create_qos_policy(name='test-policy',491 description='test policy',492 shared=False)493 self.addCleanup(test_utils.call_and_ignore_notfound_exc,494 self.adm_qos_client.delete_policy, policy['id'])495 rule = self.create_qos_bandwidth_limit_rule(...

Full Screen

Full Screen

deployment.py

Source:deployment.py Github

copy

Full Screen

...101 def create_policy(self, value: Optional[pulumi.Input[str]]):102 pulumi.set(self, "create_policy", value)103 @property104 @pulumi.getter(name="deletePolicy")105 def delete_policy(self) -> Optional[pulumi.Input[str]]:106 """107 Set the policy to use for deleting new resources on update/delete.108 Valid values are `DELETE` (default) or `ABANDON`. If `DELETE`,109 resource is deleted after removal from Deployment Manager. If110 `ABANDON`, the resource is only removed from Deployment Manager111 and is not actually deleted. Note that updating this field does not112 actually change the deployment, just how it is updated.113 Default value is `DELETE`.114 Possible values are `ABANDON` and `DELETE`.115 """116 return pulumi.get(self, "delete_policy")117 @delete_policy.setter118 def delete_policy(self, value: Optional[pulumi.Input[str]]):119 pulumi.set(self, "delete_policy", value)120 @property121 @pulumi.getter122 def description(self) -> Optional[pulumi.Input[str]]:123 """124 Optional user-provided description of deployment.125 """126 return pulumi.get(self, "description")127 @description.setter128 def description(self, value: Optional[pulumi.Input[str]]):129 pulumi.set(self, "description", value)130 @property131 @pulumi.getter132 def labels(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['DeploymentLabelArgs']]]]:133 """134 Key-value pairs to apply to this labels.135 Structure is documented below.136 """137 return pulumi.get(self, "labels")138 @labels.setter139 def labels(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['DeploymentLabelArgs']]]]):140 pulumi.set(self, "labels", value)141 @property142 @pulumi.getter143 def name(self) -> Optional[pulumi.Input[str]]:144 """145 The name of the template to import, as declared in the YAML146 configuration.147 """148 return pulumi.get(self, "name")149 @name.setter150 def name(self, value: Optional[pulumi.Input[str]]):151 pulumi.set(self, "name", value)152 @property153 @pulumi.getter154 def preview(self) -> Optional[pulumi.Input[bool]]:155 """156 If set to true, a deployment is created with "shell" resources157 that are not actually instantiated. This allows you to preview a158 deployment. It can be updated to false to actually deploy159 with real resources.160 ~>**NOTE:** Deployment Manager does not allow update161 of a deployment in preview (unless updating to preview=false). Thus,162 the provider will force-recreate deployments if either preview is updated163 to true or if other fields are updated while preview is true.164 """165 return pulumi.get(self, "preview")166 @preview.setter167 def preview(self, value: Optional[pulumi.Input[bool]]):168 pulumi.set(self, "preview", value)169 @property170 @pulumi.getter171 def project(self) -> Optional[pulumi.Input[str]]:172 """173 The ID of the project in which the resource belongs.174 If it is not provided, the provider project is used.175 """176 return pulumi.get(self, "project")177 @project.setter178 def project(self, value: Optional[pulumi.Input[str]]):179 pulumi.set(self, "project", value)180@pulumi.input_type181class _DeploymentState:182 def __init__(__self__, *,183 create_policy: Optional[pulumi.Input[str]] = None,184 delete_policy: Optional[pulumi.Input[str]] = None,185 deployment_id: Optional[pulumi.Input[str]] = None,186 description: Optional[pulumi.Input[str]] = None,187 labels: Optional[pulumi.Input[Sequence[pulumi.Input['DeploymentLabelArgs']]]] = None,188 manifest: Optional[pulumi.Input[str]] = None,189 name: Optional[pulumi.Input[str]] = None,190 preview: Optional[pulumi.Input[bool]] = None,191 project: Optional[pulumi.Input[str]] = None,192 self_link: Optional[pulumi.Input[str]] = None,193 target: Optional[pulumi.Input['DeploymentTargetArgs']] = None):194 """195 Input properties used for looking up and filtering Deployment resources.196 :param pulumi.Input[str] create_policy: Set the policy to use for creating new resources. Only used on197 create and update. Valid values are `CREATE_OR_ACQUIRE` (default) or198 `ACQUIRE`. If set to `ACQUIRE` and resources do not already exist,199 the deployment will fail. Note that updating this field does not200 actually affect the deployment, just how it is updated.201 Default value is `CREATE_OR_ACQUIRE`.202 Possible values are `ACQUIRE` and `CREATE_OR_ACQUIRE`.203 :param pulumi.Input[str] delete_policy: Set the policy to use for deleting new resources on update/delete.204 Valid values are `DELETE` (default) or `ABANDON`. If `DELETE`,205 resource is deleted after removal from Deployment Manager. If206 `ABANDON`, the resource is only removed from Deployment Manager207 and is not actually deleted. Note that updating this field does not208 actually change the deployment, just how it is updated.209 Default value is `DELETE`.210 Possible values are `ABANDON` and `DELETE`.211 :param pulumi.Input[str] deployment_id: Unique identifier for deployment. Output only.212 :param pulumi.Input[str] description: Optional user-provided description of deployment.213 :param pulumi.Input[Sequence[pulumi.Input['DeploymentLabelArgs']]] labels: Key-value pairs to apply to this labels.214 Structure is documented below.215 :param pulumi.Input[str] manifest: Output only. URL of the manifest representing the last manifest that was successfully deployed.216 :param pulumi.Input[str] name: The name of the template to import, as declared in the YAML217 configuration.218 :param pulumi.Input[bool] preview: If set to true, a deployment is created with "shell" resources219 that are not actually instantiated. This allows you to preview a220 deployment. It can be updated to false to actually deploy221 with real resources.222 ~>**NOTE:** Deployment Manager does not allow update223 of a deployment in preview (unless updating to preview=false). Thus,224 the provider will force-recreate deployments if either preview is updated225 to true or if other fields are updated while preview is true.226 :param pulumi.Input[str] project: The ID of the project in which the resource belongs.227 If it is not provided, the provider project is used.228 :param pulumi.Input[str] self_link: Output only. Server defined URL for the resource.229 :param pulumi.Input['DeploymentTargetArgs'] target: Parameters that define your deployment, including the deployment230 configuration and relevant templates.231 Structure is documented below.232 """233 if create_policy is not None:234 pulumi.set(__self__, "create_policy", create_policy)235 if delete_policy is not None:236 pulumi.set(__self__, "delete_policy", delete_policy)237 if deployment_id is not None:238 pulumi.set(__self__, "deployment_id", deployment_id)239 if description is not None:240 pulumi.set(__self__, "description", description)241 if labels is not None:242 pulumi.set(__self__, "labels", labels)243 if manifest is not None:244 pulumi.set(__self__, "manifest", manifest)245 if name is not None:246 pulumi.set(__self__, "name", name)247 if preview is not None:248 pulumi.set(__self__, "preview", preview)249 if project is not None:250 pulumi.set(__self__, "project", project)251 if self_link is not None:252 pulumi.set(__self__, "self_link", self_link)253 if target is not None:254 pulumi.set(__self__, "target", target)255 @property256 @pulumi.getter(name="createPolicy")257 def create_policy(self) -> Optional[pulumi.Input[str]]:258 """259 Set the policy to use for creating new resources. Only used on260 create and update. Valid values are `CREATE_OR_ACQUIRE` (default) or261 `ACQUIRE`. If set to `ACQUIRE` and resources do not already exist,262 the deployment will fail. Note that updating this field does not263 actually affect the deployment, just how it is updated.264 Default value is `CREATE_OR_ACQUIRE`.265 Possible values are `ACQUIRE` and `CREATE_OR_ACQUIRE`.266 """267 return pulumi.get(self, "create_policy")268 @create_policy.setter269 def create_policy(self, value: Optional[pulumi.Input[str]]):270 pulumi.set(self, "create_policy", value)271 @property272 @pulumi.getter(name="deletePolicy")273 def delete_policy(self) -> Optional[pulumi.Input[str]]:274 """275 Set the policy to use for deleting new resources on update/delete.276 Valid values are `DELETE` (default) or `ABANDON`. If `DELETE`,277 resource is deleted after removal from Deployment Manager. If278 `ABANDON`, the resource is only removed from Deployment Manager279 and is not actually deleted. Note that updating this field does not280 actually change the deployment, just how it is updated.281 Default value is `DELETE`.282 Possible values are `ABANDON` and `DELETE`.283 """284 return pulumi.get(self, "delete_policy")285 @delete_policy.setter286 def delete_policy(self, value: Optional[pulumi.Input[str]]):287 pulumi.set(self, "delete_policy", value)288 @property289 @pulumi.getter(name="deploymentId")290 def deployment_id(self) -> Optional[pulumi.Input[str]]:291 """292 Unique identifier for deployment. Output only.293 """294 return pulumi.get(self, "deployment_id")295 @deployment_id.setter296 def deployment_id(self, value: Optional[pulumi.Input[str]]):297 pulumi.set(self, "deployment_id", value)298 @property299 @pulumi.getter300 def description(self) -> Optional[pulumi.Input[str]]:301 """302 Optional user-provided description of deployment.303 """304 return pulumi.get(self, "description")305 @description.setter306 def description(self, value: Optional[pulumi.Input[str]]):307 pulumi.set(self, "description", value)308 @property309 @pulumi.getter310 def labels(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['DeploymentLabelArgs']]]]:311 """312 Key-value pairs to apply to this labels.313 Structure is documented below.314 """315 return pulumi.get(self, "labels")316 @labels.setter317 def labels(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['DeploymentLabelArgs']]]]):318 pulumi.set(self, "labels", value)319 @property320 @pulumi.getter321 def manifest(self) -> Optional[pulumi.Input[str]]:322 """323 Output only. URL of the manifest representing the last manifest that was successfully deployed.324 """325 return pulumi.get(self, "manifest")326 @manifest.setter327 def manifest(self, value: Optional[pulumi.Input[str]]):328 pulumi.set(self, "manifest", value)329 @property330 @pulumi.getter331 def name(self) -> Optional[pulumi.Input[str]]:332 """333 The name of the template to import, as declared in the YAML334 configuration.335 """336 return pulumi.get(self, "name")337 @name.setter338 def name(self, value: Optional[pulumi.Input[str]]):339 pulumi.set(self, "name", value)340 @property341 @pulumi.getter342 def preview(self) -> Optional[pulumi.Input[bool]]:343 """344 If set to true, a deployment is created with "shell" resources345 that are not actually instantiated. This allows you to preview a346 deployment. It can be updated to false to actually deploy347 with real resources.348 ~>**NOTE:** Deployment Manager does not allow update349 of a deployment in preview (unless updating to preview=false). Thus,350 the provider will force-recreate deployments if either preview is updated351 to true or if other fields are updated while preview is true.352 """353 return pulumi.get(self, "preview")354 @preview.setter355 def preview(self, value: Optional[pulumi.Input[bool]]):356 pulumi.set(self, "preview", value)357 @property358 @pulumi.getter359 def project(self) -> Optional[pulumi.Input[str]]:360 """361 The ID of the project in which the resource belongs.362 If it is not provided, the provider project is used.363 """364 return pulumi.get(self, "project")365 @project.setter366 def project(self, value: Optional[pulumi.Input[str]]):367 pulumi.set(self, "project", value)368 @property369 @pulumi.getter(name="selfLink")370 def self_link(self) -> Optional[pulumi.Input[str]]:371 """372 Output only. Server defined URL for the resource.373 """374 return pulumi.get(self, "self_link")375 @self_link.setter376 def self_link(self, value: Optional[pulumi.Input[str]]):377 pulumi.set(self, "self_link", value)378 @property379 @pulumi.getter380 def target(self) -> Optional[pulumi.Input['DeploymentTargetArgs']]:381 """382 Parameters that define your deployment, including the deployment383 configuration and relevant templates.384 Structure is documented below.385 """386 return pulumi.get(self, "target")387 @target.setter388 def target(self, value: Optional[pulumi.Input['DeploymentTargetArgs']]):389 pulumi.set(self, "target", value)390class Deployment(pulumi.CustomResource):391 @overload392 def __init__(__self__,393 resource_name: str,394 opts: Optional[pulumi.ResourceOptions] = None,395 create_policy: Optional[pulumi.Input[str]] = None,396 delete_policy: Optional[pulumi.Input[str]] = None,397 description: Optional[pulumi.Input[str]] = None,398 labels: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['DeploymentLabelArgs']]]]] = None,399 name: Optional[pulumi.Input[str]] = None,400 preview: Optional[pulumi.Input[bool]] = None,401 project: Optional[pulumi.Input[str]] = None,402 target: Optional[pulumi.Input[pulumi.InputType['DeploymentTargetArgs']]] = None,403 __props__=None):404 """405 A collection of resources that are deployed and managed together using406 a configuration file407 > **Warning:** This resource is intended only to manage a Deployment resource,408 and attempts to manage the Deployment's resources in the provider as well409 will likely result in errors or unexpected behavior as the two tools410 fight over ownership. We strongly discourage doing so unless you are an411 experienced user of both tools.412 In addition, due to limitations of the API, the provider will treat413 deployments in preview as recreate-only for any update operation other414 than actually deploying an in-preview deployment (i.e. `preview=true` to415 `preview=false`).416 ## Example Usage417 ### Deployment Manager Deployment Basic418 ```python419 import pulumi420 import pulumi_gcp as gcp421 deployment = gcp.deploymentmanager.Deployment("deployment",422 target=gcp.deploymentmanager.DeploymentTargetArgs(423 config=gcp.deploymentmanager.DeploymentTargetConfigArgs(424 content=(lambda path: open(path).read())("path/to/config.yml"),425 ),426 ),427 labels=[gcp.deploymentmanager.DeploymentLabelArgs(428 key="foo",429 value="bar",430 )])431 ```432 ## Import433 Deployment can be imported using any of these accepted formats434 ```sh435 $ pulumi import gcp:deploymentmanager/deployment:Deployment default projects/{{project}}/deployments/{{name}}436 ```437 ```sh438 $ pulumi import gcp:deploymentmanager/deployment:Deployment default {{project}}/{{name}}439 ```440 ```sh441 $ pulumi import gcp:deploymentmanager/deployment:Deployment default {{name}}442 ```443 :param str resource_name: The name of the resource.444 :param pulumi.ResourceOptions opts: Options for the resource.445 :param pulumi.Input[str] create_policy: Set the policy to use for creating new resources. Only used on446 create and update. Valid values are `CREATE_OR_ACQUIRE` (default) or447 `ACQUIRE`. If set to `ACQUIRE` and resources do not already exist,448 the deployment will fail. Note that updating this field does not449 actually affect the deployment, just how it is updated.450 Default value is `CREATE_OR_ACQUIRE`.451 Possible values are `ACQUIRE` and `CREATE_OR_ACQUIRE`.452 :param pulumi.Input[str] delete_policy: Set the policy to use for deleting new resources on update/delete.453 Valid values are `DELETE` (default) or `ABANDON`. If `DELETE`,454 resource is deleted after removal from Deployment Manager. If455 `ABANDON`, the resource is only removed from Deployment Manager456 and is not actually deleted. Note that updating this field does not457 actually change the deployment, just how it is updated.458 Default value is `DELETE`.459 Possible values are `ABANDON` and `DELETE`.460 :param pulumi.Input[str] description: Optional user-provided description of deployment.461 :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['DeploymentLabelArgs']]]] labels: Key-value pairs to apply to this labels.462 Structure is documented below.463 :param pulumi.Input[str] name: The name of the template to import, as declared in the YAML464 configuration.465 :param pulumi.Input[bool] preview: If set to true, a deployment is created with "shell" resources466 that are not actually instantiated. This allows you to preview a467 deployment. It can be updated to false to actually deploy468 with real resources.469 ~>**NOTE:** Deployment Manager does not allow update470 of a deployment in preview (unless updating to preview=false). Thus,471 the provider will force-recreate deployments if either preview is updated472 to true or if other fields are updated while preview is true.473 :param pulumi.Input[str] project: The ID of the project in which the resource belongs.474 If it is not provided, the provider project is used.475 :param pulumi.Input[pulumi.InputType['DeploymentTargetArgs']] target: Parameters that define your deployment, including the deployment476 configuration and relevant templates.477 Structure is documented below.478 """479 ...480 @overload481 def __init__(__self__,482 resource_name: str,483 args: DeploymentArgs,484 opts: Optional[pulumi.ResourceOptions] = None):485 """486 A collection of resources that are deployed and managed together using487 a configuration file488 > **Warning:** This resource is intended only to manage a Deployment resource,489 and attempts to manage the Deployment's resources in the provider as well490 will likely result in errors or unexpected behavior as the two tools491 fight over ownership. We strongly discourage doing so unless you are an492 experienced user of both tools.493 In addition, due to limitations of the API, the provider will treat494 deployments in preview as recreate-only for any update operation other495 than actually deploying an in-preview deployment (i.e. `preview=true` to496 `preview=false`).497 ## Example Usage498 ### Deployment Manager Deployment Basic499 ```python500 import pulumi501 import pulumi_gcp as gcp502 deployment = gcp.deploymentmanager.Deployment("deployment",503 target=gcp.deploymentmanager.DeploymentTargetArgs(504 config=gcp.deploymentmanager.DeploymentTargetConfigArgs(505 content=(lambda path: open(path).read())("path/to/config.yml"),506 ),507 ),508 labels=[gcp.deploymentmanager.DeploymentLabelArgs(509 key="foo",510 value="bar",511 )])512 ```513 ## Import514 Deployment can be imported using any of these accepted formats515 ```sh516 $ pulumi import gcp:deploymentmanager/deployment:Deployment default projects/{{project}}/deployments/{{name}}517 ```518 ```sh519 $ pulumi import gcp:deploymentmanager/deployment:Deployment default {{project}}/{{name}}520 ```521 ```sh522 $ pulumi import gcp:deploymentmanager/deployment:Deployment default {{name}}523 ```524 :param str resource_name: The name of the resource.525 :param DeploymentArgs args: The arguments to use to populate this resource's properties.526 :param pulumi.ResourceOptions opts: Options for the resource.527 """528 ...529 def __init__(__self__, resource_name: str, *args, **kwargs):530 resource_args, opts = _utilities.get_resource_args_opts(DeploymentArgs, pulumi.ResourceOptions, *args, **kwargs)531 if resource_args is not None:532 __self__._internal_init(resource_name, opts, **resource_args.__dict__)533 else:534 __self__._internal_init(resource_name, *args, **kwargs)535 def _internal_init(__self__,536 resource_name: str,537 opts: Optional[pulumi.ResourceOptions] = None,538 create_policy: Optional[pulumi.Input[str]] = None,539 delete_policy: Optional[pulumi.Input[str]] = None,540 description: Optional[pulumi.Input[str]] = None,541 labels: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['DeploymentLabelArgs']]]]] = None,542 name: Optional[pulumi.Input[str]] = None,543 preview: Optional[pulumi.Input[bool]] = None,544 project: Optional[pulumi.Input[str]] = None,545 target: Optional[pulumi.Input[pulumi.InputType['DeploymentTargetArgs']]] = None,546 __props__=None):547 opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)548 if not isinstance(opts, pulumi.ResourceOptions):549 raise TypeError('Expected resource options to be a ResourceOptions instance')550 if opts.id is None:551 if __props__ is not None:552 raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')553 __props__ = DeploymentArgs.__new__(DeploymentArgs)554 __props__.__dict__["create_policy"] = create_policy555 __props__.__dict__["delete_policy"] = delete_policy556 __props__.__dict__["description"] = description557 __props__.__dict__["labels"] = labels558 __props__.__dict__["name"] = name559 __props__.__dict__["preview"] = preview560 __props__.__dict__["project"] = project561 if target is None and not opts.urn:562 raise TypeError("Missing required property 'target'")563 __props__.__dict__["target"] = target564 __props__.__dict__["deployment_id"] = None565 __props__.__dict__["manifest"] = None566 __props__.__dict__["self_link"] = None567 super(Deployment, __self__).__init__(568 'gcp:deploymentmanager/deployment:Deployment',569 resource_name,570 __props__,571 opts)572 @staticmethod573 def get(resource_name: str,574 id: pulumi.Input[str],575 opts: Optional[pulumi.ResourceOptions] = None,576 create_policy: Optional[pulumi.Input[str]] = None,577 delete_policy: Optional[pulumi.Input[str]] = None,578 deployment_id: Optional[pulumi.Input[str]] = None,579 description: Optional[pulumi.Input[str]] = None,580 labels: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['DeploymentLabelArgs']]]]] = None,581 manifest: Optional[pulumi.Input[str]] = None,582 name: Optional[pulumi.Input[str]] = None,583 preview: Optional[pulumi.Input[bool]] = None,584 project: Optional[pulumi.Input[str]] = None,585 self_link: Optional[pulumi.Input[str]] = None,586 target: Optional[pulumi.Input[pulumi.InputType['DeploymentTargetArgs']]] = None) -> 'Deployment':587 """588 Get an existing Deployment resource's state with the given name, id, and optional extra589 properties used to qualify the lookup.590 :param str resource_name: The unique name of the resulting resource.591 :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.592 :param pulumi.ResourceOptions opts: Options for the resource.593 :param pulumi.Input[str] create_policy: Set the policy to use for creating new resources. Only used on594 create and update. Valid values are `CREATE_OR_ACQUIRE` (default) or595 `ACQUIRE`. If set to `ACQUIRE` and resources do not already exist,596 the deployment will fail. Note that updating this field does not597 actually affect the deployment, just how it is updated.598 Default value is `CREATE_OR_ACQUIRE`.599 Possible values are `ACQUIRE` and `CREATE_OR_ACQUIRE`.600 :param pulumi.Input[str] delete_policy: Set the policy to use for deleting new resources on update/delete.601 Valid values are `DELETE` (default) or `ABANDON`. If `DELETE`,602 resource is deleted after removal from Deployment Manager. If603 `ABANDON`, the resource is only removed from Deployment Manager604 and is not actually deleted. Note that updating this field does not605 actually change the deployment, just how it is updated.606 Default value is `DELETE`.607 Possible values are `ABANDON` and `DELETE`.608 :param pulumi.Input[str] deployment_id: Unique identifier for deployment. Output only.609 :param pulumi.Input[str] description: Optional user-provided description of deployment.610 :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['DeploymentLabelArgs']]]] labels: Key-value pairs to apply to this labels.611 Structure is documented below.612 :param pulumi.Input[str] manifest: Output only. URL of the manifest representing the last manifest that was successfully deployed.613 :param pulumi.Input[str] name: The name of the template to import, as declared in the YAML614 configuration.615 :param pulumi.Input[bool] preview: If set to true, a deployment is created with "shell" resources616 that are not actually instantiated. This allows you to preview a617 deployment. It can be updated to false to actually deploy618 with real resources.619 ~>**NOTE:** Deployment Manager does not allow update620 of a deployment in preview (unless updating to preview=false). Thus,621 the provider will force-recreate deployments if either preview is updated622 to true or if other fields are updated while preview is true.623 :param pulumi.Input[str] project: The ID of the project in which the resource belongs.624 If it is not provided, the provider project is used.625 :param pulumi.Input[str] self_link: Output only. Server defined URL for the resource.626 :param pulumi.Input[pulumi.InputType['DeploymentTargetArgs']] target: Parameters that define your deployment, including the deployment627 configuration and relevant templates.628 Structure is documented below.629 """630 opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))631 __props__ = _DeploymentState.__new__(_DeploymentState)632 __props__.__dict__["create_policy"] = create_policy633 __props__.__dict__["delete_policy"] = delete_policy634 __props__.__dict__["deployment_id"] = deployment_id635 __props__.__dict__["description"] = description636 __props__.__dict__["labels"] = labels637 __props__.__dict__["manifest"] = manifest638 __props__.__dict__["name"] = name639 __props__.__dict__["preview"] = preview640 __props__.__dict__["project"] = project641 __props__.__dict__["self_link"] = self_link642 __props__.__dict__["target"] = target643 return Deployment(resource_name, opts=opts, __props__=__props__)644 @property645 @pulumi.getter(name="createPolicy")646 def create_policy(self) -> pulumi.Output[Optional[str]]:647 """648 Set the policy to use for creating new resources. Only used on649 create and update. Valid values are `CREATE_OR_ACQUIRE` (default) or650 `ACQUIRE`. If set to `ACQUIRE` and resources do not already exist,651 the deployment will fail. Note that updating this field does not652 actually affect the deployment, just how it is updated.653 Default value is `CREATE_OR_ACQUIRE`.654 Possible values are `ACQUIRE` and `CREATE_OR_ACQUIRE`.655 """656 return pulumi.get(self, "create_policy")657 @property658 @pulumi.getter(name="deletePolicy")659 def delete_policy(self) -> pulumi.Output[Optional[str]]:660 """661 Set the policy to use for deleting new resources on update/delete.662 Valid values are `DELETE` (default) or `ABANDON`. If `DELETE`,663 resource is deleted after removal from Deployment Manager. If664 `ABANDON`, the resource is only removed from Deployment Manager665 and is not actually deleted. Note that updating this field does not666 actually change the deployment, just how it is updated.667 Default value is `DELETE`.668 Possible values are `ABANDON` and `DELETE`.669 """670 return pulumi.get(self, "delete_policy")671 @property672 @pulumi.getter(name="deploymentId")673 def deployment_id(self) -> pulumi.Output[str]:...

Full Screen

Full Screen

test_policy.py

Source:test_policy.py Github

copy

Full Screen

...60 * whether the persona can update a policy that does not exist61 """62 pass63 @abc.abstractmethod64 def test_identity_delete_policy(self):65 """Test identity:delete_policy policy.66 This test must check67 * whether the persona can delete a policy68 * whether the persona can delete a policy that does not exist69 """70 pass71class SystemAdminTests(IdentityV3RbacPolicyTests, base.BaseIdentityTest):72 credentials = ['system_admin']73 def test_identity_create_policy(self):74 policy_id = self.do_request(75 'create_policy', expected_status=201,76 **self.policy())['policy']['id']77 self.addCleanup(78 self.admin_policies_client.delete_policy,79 policy_id=policy_id)80 def test_identity_get_policy(self):81 policy_id = self.admin_policies_client.create_policy(82 **self.policy())['policy']['id']83 self.addCleanup(84 self.admin_policies_client.delete_policy,85 policy_id=policy_id)86 self.do_request('show_policy', policy_id=policy_id)87 # user gets a 404 for nonexistent policy88 self.do_request('show_policy', expected_status=exceptions.NotFound,89 policy_id=data_utils.rand_uuid_hex())90 def test_identity_list_policies(self):91 policy_id = self.admin_policies_client.create_policy(92 **self.policy())['policy']['id']93 self.addCleanup(94 self.admin_policies_client.delete_policy,95 policy_id=policy_id)96 resp = self.do_request('list_policies')97 self.assertIn(policy_id, [e['id'] for e in resp['policies']])98 def test_identity_update_policy(self):99 policy_id = self.admin_policies_client.create_policy(100 **self.policy())['policy']['id']101 self.addCleanup(102 self.admin_policies_client.delete_policy,103 policy_id=policy_id)104 self.do_request('update_policy',105 policy_id=policy_id,106 blob=data_utils.rand_uuid_hex())107 # user gets a 404 for nonexistent policy108 self.do_request('update_policy', expected_status=exceptions.NotFound,109 policy_id=data_utils.rand_uuid_hex(),110 blob=data_utils.rand_uuid_hex())111 def test_identity_delete_policy(self):112 policy_id = self.admin_policies_client.create_policy(113 **self.policy())['policy']['id']114 self.do_request('delete_policy', expected_status=204,115 policy_id=policy_id)116 # user gets a 404 for nonexistent policy117 self.do_request('delete_policy', expected_status=exceptions.NotFound,118 policy_id=data_utils.rand_uuid_hex())119class SystemMemberTests(SystemAdminTests, base.BaseIdentityTest):120 credentials = ['system_member', 'system_admin']121 def test_identity_create_policy(self):122 self.do_request(123 'create_policy', expected_status=exceptions.Forbidden,124 **self.policy())125 def test_identity_update_policy(self):126 policy_id = self.admin_policies_client.create_policy(127 **self.policy())['policy']['id']128 self.addCleanup(129 self.admin_policies_client.delete_policy,130 policy_id=policy_id)131 self.do_request('update_policy', expected_status=exceptions.Forbidden,132 policy_id=policy_id,133 blob=data_utils.rand_uuid_hex())134 # user gets a 403 for nonexistent policy135 self.do_request('update_policy', expected_status=exceptions.Forbidden,136 policy_id=data_utils.rand_uuid_hex(),137 blob=data_utils.rand_uuid_hex())138 def test_identity_delete_policy(self):139 policy_id = self.admin_policies_client.create_policy(140 **self.policy())['policy']['id']141 self.do_request('delete_policy',142 expected_status=exceptions.Forbidden,143 policy_id=policy_id)144 # user gets a 403 for nonexistent policy145 self.do_request('delete_policy', expected_status=exceptions.Forbidden,146 policy_id=data_utils.rand_uuid_hex())147class SystemReaderTests(SystemMemberTests):148 credentials = ['system_reader', 'system_admin']149class DomainAdminTests(SystemReaderTests, base.BaseIdentityTest):150 credentials = ['domain_admin', 'system_admin']151 def test_identity_get_policy(self):152 policy_id = self.admin_policies_client.create_policy(...

Full Screen

Full Screen

test_auto_allocated_topology.py

Source:test_auto_allocated_topology.py Github

copy

Full Screen

1# Copyright (c) 2021 Red Hat Inc.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or12# implied.13# See the License for the specific language governing permissions and14# limitations under the License.15from oslo_policy import policy as base_policy16from neutron import policy17from neutron.tests.unit.conf.policies import base18GET_POLICY = 'get_auto_allocated_topology'19DELETE_POLICY = 'delete_auto_allocated_topology'20class AutoAllocatedTopologyAPITestCase(base.PolicyBaseTestCase):21 def setUp(self):22 super(AutoAllocatedTopologyAPITestCase, self).setUp()23 self.target = {'project_id': self.project_id}24 self.alt_target = {'project_id': self.alt_project_id}25class SystemAdminTests(AutoAllocatedTopologyAPITestCase):26 def setUp(self):27 super(SystemAdminTests, self).setUp()28 self.context = self.system_admin_ctx29 def test_get_topology(self):30 # System admins can get topologies for any project.31 self.assertTrue(policy.enforce(self.context, GET_POLICY, self.target))32 self.assertTrue(policy.enforce(33 self.context, GET_POLICY, self.alt_target))34 def test_delete_topology(self):35 # System admins can delete topologies for any project.36 self.assertTrue(37 policy.enforce(self.context, DELETE_POLICY, self.target)38 )39 self.assertTrue(40 policy.enforce(self.context, DELETE_POLICY, self.alt_target)41 )42class SystemMemberTests(AutoAllocatedTopologyAPITestCase):43 def setUp(self):44 super(SystemMemberTests, self).setUp()45 self.context = self.system_member_ctx46 def test_delete_topology(self):47 self.assertRaises(48 base_policy.PolicyNotAuthorized,49 policy.enforce,50 self.context, DELETE_POLICY, self.target51 )52 self.assertRaises(53 base_policy.PolicyNotAuthorized,54 policy.enforce,55 self.context, DELETE_POLICY, self.alt_target56 )57class SystemReaderTests(SystemMemberTests):58 def setUp(self):59 super(SystemReaderTests, self).setUp()60 self.context = self.system_reader_ctx61class ProjectAdminTests(AutoAllocatedTopologyAPITestCase):62 def setUp(self):63 super(ProjectAdminTests, self).setUp()64 self.context = self.project_admin_ctx65 def test_get_topology(self):66 self.assertTrue(policy.enforce(self.context, GET_POLICY, self.target))67 self.assertRaises(68 base_policy.PolicyNotAuthorized,69 policy.enforce,70 self.context, GET_POLICY, self.alt_target71 )72 def test_delete_topology(self):73 # Project members can delete topolies inside project, but not outside74 # project75 self.assertTrue(76 policy.enforce(self.context, DELETE_POLICY, self.target)77 )78 self.assertRaises(79 base_policy.PolicyNotAuthorized,80 policy.enforce,81 self.context, DELETE_POLICY, self.alt_target82 )83class ProjectMemberTests(ProjectAdminTests):84 def setUp(self):85 super(ProjectMemberTests, self).setUp()86 self.context = self.project_member_ctx87class ProjectReaderTests(ProjectMemberTests):88 def setUp(self):89 super(ProjectReaderTests, self).setUp()90 self.context = self.project_reader_ctx91 def test_delete_topology(self):92 # Project readers can't delete allocation topologies inside or outside93 # of project94 self.assertRaises(95 base_policy.PolicyNotAuthorized,96 policy.enforce,97 self.context, DELETE_POLICY, self.target98 )99 self.assertRaises(100 base_policy.PolicyNotAuthorized,101 policy.enforce,102 self.context, DELETE_POLICY, self.alt_target...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful