本文整理匯總了Python中tempest.lib.exceptions.Conflict方法的典型用法代碼示例。如果您正苦於以下問題:Python exceptions.Conflict方法的具體用法?Python exceptions.Conflict怎麽用?Python exceptions.Conflict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tempest.lib.exceptions
的用法示例。
在下文中一共展示了exceptions.Conflict方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_delete_not_allowed_if_policy_in_use_by_port
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_delete_not_allowed_if_policy_in_use_by_port(self):
"""can not delete policy if used by port."""
policy = self.create_qos_policy(name='test-policy',
description='test policy',
shared=True)
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.adm_qos_client.delete_policy, policy['id'])
network = self.create_shared_network('test network')
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.delete_network, network['id'])
port = self.create_port(network, qos_policy_id=policy['id'],
client_mgr=self.primary_mgr)
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.delete_port, port['id'])
self.assertRaises(
exceptions.Conflict,
self.adm_qos_client.delete_policy, policy['id'])
self._disassociate_port(port['id'], client_mgr=self.primary_mgr)
self.adm_qos_client.delete_policy(policy['id'])
示例2: test_active_l2_gateway_delete
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_active_l2_gateway_delete(self):
"""
Delete l2 gateway with active mapping.
"""
LOG.info("Testing test_l2_gateway_create api")
self.deploy_l2gateway_topology()
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
l2gw_id = l2gw_rsp[constants.L2GW]["id"]
# Delete l2gw must raise Conflict exception.
self.assertRaises(lib_exc.Conflict, self.delete_l2gw, l2gw_id)
示例3: test_recreate_l2_gateway_connection
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_recreate_l2_gateway_connection(self):
"""
Recreate l2 gateway connection using same parameters.
"""
LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology()
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name,
"vlans": [self.VLAN_1]}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"]}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
self.assertRaises(lib_exc.Conflict, self.create_l2gw_connection,
l2gwc_param)
示例4: test_create_l2gwc_with_nonexist_network
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_create_l2gwc_with_nonexist_network(self):
"""
Create l2 gateway connection using non exist l2gw uuid.
"""
LOG.info("Testing test_l2_gateway_connection_create api")
non_exist_network_uuid = NON_EXIST_UUID
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id": non_exist_network_uuid,
"segmentation_id": self.VLAN_1}
# Delete l2gw must raise Conflict exception.
self.assertRaises(lib_exc.NotFound, self.create_l2gw_connection,
l2gwc_param)
示例5: retry_on_conflict
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def retry_on_conflict(func):
def inner(*args, **kwargs):
# TODO(vsaienko): make number of retries and delay between
# them configurable in future.
e = None
for att in range(10):
try:
return func(*args, **kwargs)
except lib_exc.Conflict as e:
time.sleep(1)
raise lib_exc.Conflict(e)
return inner
# power/provision states as of icehouse
示例6: test_vif_already_set_on_extra
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_vif_already_set_on_extra(self):
self.useFixture(
api_microversion_fixture.APIMicroversionFixture('1.28'))
_, self.port = self.create_port(self.node['uuid'],
data_utils.rand_mac_address())
patch = [{'path': '/extra/vif_port_id',
'op': 'add',
'value': self.nport_id}]
self.client.update_port(self.port['uuid'], patch)
_, body = self.client.vif_list(self.node['uuid'])
self.assertEqual({'vifs': [{'id': self.nport_id}]}, body)
self.assertRaises(lib_exc.Conflict, self.client.vif_attach,
self.node['uuid'], self.nport_id)
self.client.vif_detach(self.node['uuid'], self.nport_id)
示例7: test_create_ports_in_portgroup_with_inconsistent_physical_network
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_create_ports_in_portgroup_with_inconsistent_physical_network(
self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
_, portgroup = self.create_portgroup(node_id, address=address)
_, _ = self.create_port(node_id=node_id, address=address,
portgroup_uuid=portgroup['uuid'],
physical_network='physnet1')
address = data_utils.rand_mac_address()
self.assertRaises(lib_exc.Conflict,
self.create_port,
node_id=node_id, address=address,
portgroup_uuid=portgroup['uuid'],
physical_network='physnet2')
示例8: test_update_ports_in_portgroup_with_inconsistent_physical_network
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_update_ports_in_portgroup_with_inconsistent_physical_network(
self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
_, portgroup = self.create_portgroup(node_id, address=address)
_, _ = self.create_port(node_id=node_id, address=address,
portgroup_uuid=portgroup['uuid'],
physical_network='physnet1')
address = data_utils.rand_mac_address()
_, port2 = self.create_port(node_id=node_id, address=address,
physical_network='physnet2')
patch = [{'path': '/portgroup_uuid',
'op': 'replace',
'value': portgroup['uuid']}]
self.assertRaises(lib_exc.Conflict,
self.client.update_port,
port2['uuid'], patch)
示例9: test_update_ports_in_portgroup_with_inconsistent_physical_network_2
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_update_ports_in_portgroup_with_inconsistent_physical_network_2(
self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
_, portgroup = self.create_portgroup(node_id, address=address)
_, _ = self.create_port(node_id=node_id, address=address,
portgroup_uuid=portgroup['uuid'],
physical_network='physnet1')
address = data_utils.rand_mac_address()
_, port2 = self.create_port(node_id=node_id, address=address,
portgroup_uuid=portgroup['uuid'],
physical_network='physnet1')
patch = [{'path': '/physical_network',
'op': 'replace',
'value': 'physnet2'}]
self.assertRaises(lib_exc.Conflict,
self.client.update_port,
port2['uuid'], patch)
示例10: give_role_to_user
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def give_role_to_user(tenants_client, roles_client, users_client, username,
tenant_name, role_name, role_required=True):
"""Give the user a role in the project (tenant).""",
tenant_id = tenants_client.get_project_by_name(tenant_name)['id']
users = users_client.list_users()
user_ids = [u['id'] for u in users['users'] if u['name'] == username]
user_id = user_ids[0]
roles = roles_client.list_roles()
role_ids = [r['id'] for r in roles['roles'] if r['name'] == role_name]
if not role_ids:
if role_required:
raise Exception("required role %s not found" % role_name)
LOG.debug("%s role not required", role_name)
return
role_id = role_ids[0]
try:
roles_client.create_user_role_on_project(tenant_id, user_id, role_id)
LOG.debug("User '%s' was given the '%s' role in project '%s'",
username, role_name, tenant_name)
except exceptions.Conflict:
LOG.debug("(no change) User '%s' already has the '%s' role in"
" project '%s'", username, role_name, tenant_name)
示例11: create_user_with_tenant
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def create_user_with_tenant(tenants_client, users_client, username,
password, tenant_name):
"""Create a user and a tenant if it doesn't exist."""
LOG.info("Creating user '%s' with tenant '%s' and password '%s'",
username, tenant_name, password)
tenant_description = "Tenant for Tempest %s user" % username
email = "%[email protected]" % username
# create a tenant
try:
tenants_client.create_project(name=tenant_name,
description=tenant_description)
except exceptions.Conflict:
LOG.info("(no change) Tenant '%s' already exists", tenant_name)
tenant_id = tenants_client.get_project_by_name(tenant_name)['id']
# create a user
try:
users_client.create_user(**{'name': username, 'password': password,
'tenantId': tenant_id, 'email': email})
except exceptions.Conflict:
LOG.info("User '%s' already exists.", username)
示例12: test_create_user_with_tenant_tenant_exists
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_create_user_with_tenant_tenant_exists(
self,
mock_create_user,
mock_create_project,
mock_get_project_by_name):
mock_get_project_by_name.return_value = {'id': "fake-id"}
exc = exceptions.Conflict
mock_create_project.side_effect = exc
tool.create_user_with_tenant(
tenants_client=self.tenants_client,
users_client=self.users_client,
username=self.username,
password=self.password,
tenant_name=self.tenant_name)
mock_create_project.assert_called_with(
name=self.tenant_name, description=self.tenant_description)
mock_create_user.assert_called_with(
name=self.username,
password=self.password,
tenantId="fake-id",
email=self.email)
示例13: test_create_user_with_tenant_user_exists
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_create_user_with_tenant_user_exists(
self, mock_create_user, mock_create_tenant,
mock_get_project_by_name,
mock_get_user_by_username,
mock_update_user_password):
mock_get_project_by_name.return_value = {'id': "fake-id"}
exc = exceptions.Conflict
mock_create_user.side_effect = exc
fake_user = {'id': "fake_user_id"}
mock_get_user_by_username.return_value = fake_user
tool.create_user_with_tenant(
tenants_client=self.tenants_client,
users_client=self.users_client,
username=self.username, password=self.password,
tenant_name=self.tenant_name)
mock_create_tenant.assert_called_with(
name=self.tenant_name, description=self.tenant_description)
mock_create_user.assert_called_with(name=self.username,
password=self.password,
tenantId="fake-id",
email=self.email)
示例14: test_create_user_with_tenant_exists_user_exists
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_create_user_with_tenant_exists_user_exists(
self, mock_create_user, mock_create_project,
mock_get_project_by_name,
mock_get_user_by_username,
mock_update_user_password):
mock_get_project_by_name.return_value = {'id': "fake-id"}
exc = exceptions.Conflict
mock_create_project.side_effects = exc
mock_create_user.side_effect = exc
fake_user = {'id': "fake_user_id"}
mock_get_user_by_username.return_value = fake_user
tool.create_user_with_tenant(tenants_client=self.tenants_client,
users_client=self.users_client,
username=self.username,
password=self.password,
tenant_name=self.tenant_name)
mock_create_project.assert_called_with(
name=self.tenant_name, description=self.tenant_description)
mock_create_user.assert_called_with(name=self.username,
password=self.password,
tenantId="fake-id",
email=self.email)
示例15: test_firewall_insertion_mode_one_firewall_per_router
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Conflict [as 別名]
def test_firewall_insertion_mode_one_firewall_per_router(self):
# Create router required for an ACTIVE firewall
firewall_topo = self._create_firewall_basic_topo('exclusive')
# Try to create firewall with the same router
self.assertRaisesRegexp(
lib_exc.Conflict,
"already associated with other Firewall",
self.fwaasv1_client.create_firewall,
name=data_utils.rand_name("firewall"),
firewall_policy_id=self.fw_policy['firewall_policy']['id'],
router_ids=[firewall_topo['router']['id']])