def test_validate_payload_v6(self, mock_session): mock_session.return_value.get.side_effect = get_side_effect mock_session.return_value.post.side_effect = post_side_effect VraConfig(get_test_config_file_path()) auth = VraAuthenticate('PRD').auth_login_password( 'fake_login', 'fake_password', 'foo.fuu.com') sdk = VraSdk(auth, 'fake_bg') data = { "payload_version": 6, "provider-fake_data1": "fake_value1", "fake_data2": 122 } fake_item_request = sdk.request_catalog_item("fake_catalog_item", **data) self.assertTrue( self.validator.catalog_item(fake_item_request.payload.customized)) fake_action_request = sdk.request_resource_action( "fake_action_name", "fake_resource_id", **data) self.assertTrue( self.validator.resource_action( fake_action_request.payload.customized))
###### # request a catalog item param = { "NbMachine": 1, "LeaseDays": 1, "Environment": "DEV", "Size": "", "DataDiskSize": 20, } # if i have added 'payload_version':6 to my param dict, the request would have generate a vRa6 payload object # doing so, the 'provider-' prefix would have been added automatically(or not if it's already set) def my_payload_customization(payload, **kwargs): # for some business reason, i need to add the business group id to the data section of my payload # i can perform it (or any needed customization) inducing a payload customization function this way # kwargs contain data you can found in the 'not_in_data' section of your configuration file # note that that it depends of the context (not the same data if you request a catalog item or a resource action) payload['data']['business_group_id'] = kwargs['business_group_id'] return payload create_vm_request = my_client.request_catalog_item('My Awesome RHEL', my_payload_customization, **param) pprint(create_vm_request.payload.customized) # have a look at the payload req = create_vm_request.execute_sync( ), # execute it synchronously, the script will wait for either a fail or success of the request by polling the status url regularly ######