def update_pool(self, uuid, pool_name=None, ns_records=None, params=None): """Update a pool with the specified parameters. :param uuid: The unique identifier of the pool. :param pool_name: name of the pool. Default: Random Value. :param pool: A dictionary represening the nameservers detail with priority. Default: Random Value. :param params: A Python dict that represents the query paramaters to include in the request URI. :return: A tuple with the server response and the updated pool. """ pool = { "name": pool_name or data_utils.rand_name(name="Demo pool"), "ns_records": ns_records or dns_data_utils.rand_ns_records() } resp, body = self._update_request('pools', uuid, pool, params=params) # Update Pool should Return a HTTP 202 self.expected_success(202, resp.status) return resp, body
def create_pool(self, pool_name=None, ns_records=None, params=None, project_id=None): """Create a pool with the specified parameters. :param pool_name: name of the pool. Default: Random Value. :param ns_records: A dictionary representing the nameservers detail with priority. :param params: A Python dict that represents the query paramaters to include in the request URI. :param project_id: The project ID to associate the pool with. :return: A tuple with the server response and the created pool. """ pool = { "name": pool_name or data_utils.rand_name(name="Demo pool"), "ns_records": ns_records or dns_data_utils.rand_ns_records() } if project_id: pool["project_id"] = project_id resp, body = self._create_request('pools', data=pool, params=params) # Create Pool should Return a HTTP 201 self.expected_success(201, resp.status) return resp, body
def test_admin_updates_soa_and_ns_recordsets(self): # HTTP headers to be used in the test sudo_header = {'X-Auth-All-Projects': True} managed_records_header = {'X-Designate-Edit-Managed-Records': True} sudo_managed_headers = sudo_header.copy() sudo_managed_headers.update(managed_records_header) LOG.info('Primary user creates a Zone') zone_name = dns_data_utils.rand_zone_name(name="update_soa_ns", suffix=self.tld_name) zone = self.zone_client.create_zone( name=zone_name, description='Zone for "managed recordsets update" test', wait_until=const.ACTIVE)[1] self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id']) recordsets = self.admin_client.list_recordset( zone['id'], headers=sudo_header)[1]['recordsets'] LOG.info('As Admin try to update SOA and NS recordsets,' ' Expected not allowed') for recordset in recordsets: if recordset['type'] == 'NS': self.assertRaisesDns( lib_exc.BadRequest, 'bad_request', 400, self.admin_client.update_recordset, zone['id'], recordset['id'], recordet_data=dns_data_utils.rand_ns_records(), headers=sudo_managed_headers, extra_headers=True) if recordset['type'] == 'SOA': self.assertRaisesDns( lib_exc.BadRequest, 'bad_request', 400, self.admin_client.update_recordset, zone['id'], recordset['id'], recordet_data=dns_data_utils.rand_soa_recordset( zone['name']), headers=sudo_managed_headers, extra_headers=True)