本文整理汇总了Python中neutron.manager.NeutronManager类的典型用法代码示例。如果您正苦于以下问题:Python NeutronManager类的具体用法?Python NeutronManager怎么用?Python NeutronManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NeutronManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_resources
def get_resources(cls):
"""Returns Ext Resources."""
parent_resource = dict(member_name="tenant",
collection_name="extensions/csco/tenants")
controller = CredentialController(NeutronManager.get_plugin())
return [extensions.ResourceExtension('credentials', controller,
parent=parent_resource)]
示例2: test_port_vif_details
def test_port_vif_details(self):
plugin = NeutronManager.get_plugin()
with self.port(name='name') as port1:
ctx = context.get_admin_context()
port = plugin.get_port(ctx, port1['port']['id'])
self.assertEqual(port['binding:vif_type'],
portbindings.VIF_TYPE_OVS)
示例3: test_update_port_security_off_address_pairs
def test_update_port_security_off_address_pairs(self):
if self._skip_port_security:
self.skipTest("Plugin does not implement port-security extension")
with self.network() as net:
with self.subnet(network=net):
address_pairs = [{"mac_address": "00:00:00:00:00:01", "ip_address": "10.0.0.1"}]
res = self._create_port(
self.fmt,
net["network"]["id"],
arg_list=("port_security_enabled", addr_pair.ADDRESS_PAIRS),
port_security_enabled=True,
allowed_address_pairs=address_pairs,
)
port = self.deserialize(self.fmt, res)
print port
update_port = {"port": {psec.PORTSECURITY: False}}
# If plugin implements security groups we also need to remove
# the security group on port.
plugin_obj = NeutronManager.get_plugin()
if "security-groups" in plugin_obj.supported_extension_aliases:
update_port["port"]["security_groups"] = []
req = self.new_update_request("ports", update_port, port["port"]["id"])
res = req.get_response(self.api)
self.assertEqual(res.status_int, 409)
self._delete("ports", port["port"]["id"])
示例4: setUp
def setUp(self, plugin=None):
super(PortSecurityTestCase, self).setUp()
# Check if a plugin supports security groups
plugin_obj = NeutronManager.get_plugin()
self._skip_security_group = ('security-group' not in
plugin_obj.supported_extension_aliases)
示例5: test_network_admin_state
def test_network_admin_state(self):
name = "network_test"
admin_status_up = False
tenant_id = "tenant_test"
network = {"network": {"name": name, "admin_state_up": admin_status_up, "tenant_id": tenant_id}}
plugin = NeutronManager.get_plugin()
self.assertEqual(plugin._network_admin_state(network), network)
示例6: test_update_port_security_off_address_pairs
def test_update_port_security_off_address_pairs(self):
if self._skip_port_security:
self.skipTest("Plugin does not implement port-security extension")
with self.network() as net:
with self.subnet(network=net):
address_pairs = [{'mac_address': '00:00:00:00:00:01',
'ip_address': '10.0.0.1'}]
res = self._create_port(self.fmt, net['network']['id'],
arg_list=('port_security_enabled',
addr_pair.ADDRESS_PAIRS,),
port_security_enabled=True,
allowed_address_pairs=address_pairs)
port = self.deserialize(self.fmt, res)
print port
update_port = {'port': {psec.PORTSECURITY: False}}
# If plugin implements security groups we also need to remove
# the security group on port.
plugin_obj = NeutronManager.get_plugin()
if 'security-groups' in plugin_obj.supported_extension_aliases:
update_port['port']['security_groups'] = []
req = self.new_update_request('ports', update_port,
port['port']['id'])
res = req.get_response(self.api)
self.assertEqual(res.status_int, 409)
self._delete('ports', port['port']['id'])
示例7: test_update_network
def test_update_network(self):
plugin_obj = NeutronManager.get_plugin()
networks_req = {}
router_inst = RouterInstance()
network = {
'router:external': router_inst,
u'name': u'network1',
'admin_state_up': 'True',
'tenant_id': uuid.uuid4().hex.decode(),
'vpc:route_table': '',
'shared': False,
'port_security_enabled': True,
u'contrail:policys': [],
}
context_obj = Context(network['tenant_id'])
#create project
if not GlobalProjects:
project_name = 'admin'
GlobalProjects.append(MockProject(name=project_name))
networks_req[u'network'] = network
net_dict = plugin_obj.create_network(context_obj, networks_req)
net_id = net_dict.get('id')
# change one of the attribute and update the network
network['admin_state_up'] = 'False'
new_dict = plugin_obj.update_network(context_obj, net_id,
networks_req)
self.assertNotEqual(net_dict.get('admin_state_up'),
new_dict.get('admin_state_up'))
示例8: test_delete_subnet
def test_delete_subnet(self):
#First create virtual network without subnet and then
#create subnet to update given network.
plugin_obj = NeutronManager.get_plugin()
networks_req = {}
router_inst = RouterInstance()
network = {
'router:external': router_inst,
u'name': u'network1',
'admin_state_up': 'True',
'tenant_id': uuid.uuid4().hex.decode(),
'vpc:route_table': '',
'shared': False,
'port_security_enabled': True,
u'contrail:policys': [],
}
networks_req[u'network'] = network
context_obj = Context(network['tenant_id'])
#create project
if not GlobalProjects:
project_name = 'admin'
GlobalProjects.append(MockProject(name=project_name))
net = plugin_obj.create_network(context_obj, networks_req)
subnet_obj[u'subnet']['network_id'] = net['id']
subnet_dict = plugin_obj.create_subnet(context_obj, subnet_obj)
subnet_id = subnet_dict['id']
plugin_obj.delete_subnet(context_obj, subnet_id)
示例9: test_delete_network
def test_delete_network(self):
# First create the network and request to delete the same
plugin_obj = NeutronManager.get_plugin()
networks_req = {}
router_inst = RouterInstance()
network = {
'router:external': router_inst,
u'name': u'network1',
'admin_state_up': 'True',
'tenant_id': uuid.uuid4().hex.decode(),
'vpc:route_table': '',
'shared': False,
'port_security_enabled': True,
u'contrail:policys': [],
}
context_obj = Context(network['tenant_id'])
#create project
if not GlobalProjects:
project_name = 'admin'
GlobalProjects.append(MockProject(name=project_name))
networks_req[u'network'] = network
net_dict = plugin_obj.create_network(context_obj, networks_req)
net_id = net_dict.get('id')
plugin_obj.delete_network(context_obj, net_id)
mock_vnc_api_cls.virtual_network_delete.assert_called_once()
示例10: test_create_network
def test_create_network(self):
plugin_obj = NeutronManager.get_plugin()
networks_req = {}
router_inst = RouterInstance()
network = {
'router:external': router_inst,
u'name': u'network1',
'admin_state_up': 'True',
'tenant_id': uuid.uuid4().hex.decode(),
'vpc:route_table': '',
'shared': False,
'port_security_enabled': True,
u'contrail:policys': [],
}
networks_req[u'network'] = network
context_obj = Context(network['tenant_id'])
#create project
if not GlobalProjects:
project_name = 'admin'
GlobalProjects.append(MockProject(name=project_name))
net = plugin_obj.create_network(context_obj, networks_req)
if 'contrail:fq_name' not in net.keys():
assert False
else:
assert True
示例11: setUp
def setUp(self):
self.httpPatch = patch('httplib.HTTPConnection', create=True,
new=HTTPConnectionMock)
self.httpPatch.start()
test_l3_plugin.L3NatDBTestCase.setUp = new_L3_setUp
super(RouterDBTestCase, self).setUp()
self.plugin_obj = NeutronManager.get_plugin()
示例12: test_create_networks_bulk_emulated_plugin_failure
def test_create_networks_bulk_emulated_plugin_failure(self):
real_has_attr = hasattr
def fakehasattr(item, attr):
if attr.endswith('__native_bulk_support'):
return False
return real_has_attr(item, attr)
plugin_obj = NeutronManager.get_plugin()
orig = plugin_obj.create_network
#ensures the API choose the emulation code path
with mock.patch('__builtin__.hasattr',
new=fakehasattr):
with mock.patch.object(plugin_obj,
'create_network') as patched_plugin:
def side_effect(*args, **kwargs):
return self._do_side_effect(patched_plugin, orig,
*args, **kwargs)
patched_plugin.side_effect = side_effect
res = self._create_network_bulk(self.fmt, 2, 'test', True)
LOG.debug("response is %s" % res)
# We expect an internal server error as we injected a fault
self._validate_behavior_on_bulk_failure(
res,
'networks',
wexc.HTTPInternalServerError.code)
示例13: test_create_subnets_bulk_emulated_plugin_failure
def test_create_subnets_bulk_emulated_plugin_failure(self):
real_has_attr = hasattr
#ensures the API choose the emulation code path
def fakehasattr(item, attr):
if attr.endswith('__native_bulk_support'):
return False
return real_has_attr(item, attr)
with mock.patch('__builtin__.hasattr',
new=fakehasattr):
plugin_obj = NeutronManager.get_plugin()
orig = plugin_obj.create_subnet
with mock.patch.object(plugin_obj,
'create_subnet') as patched_plugin:
def side_effect(*args, **kwargs):
self._do_side_effect(patched_plugin, orig,
*args, **kwargs)
patched_plugin.side_effect = side_effect
with self.network() as net:
res = self._create_subnet_bulk(self.fmt, 2,
net['network']['id'],
'test')
# We expect an internal server error as we injected a fault
self._validate_behavior_on_bulk_failure(
res,
'subnets',
wexc.HTTPInternalServerError.code)
示例14: setUp
def setUp(self):
super(ProvidernetExtensionTestCase, self).setUp()
plugin = 'neutron.neutron_plugin_base_v2.NeutronPluginBaseV2'
# Ensure existing ExtensionManager is not used
extensions.PluginAwareExtensionManager._instance = None
# Save the global RESOURCE_ATTRIBUTE_MAP
self.saved_attr_map = {}
for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
self.saved_attr_map[resource] = attrs.copy()
# Update the plugin and extensions path
self.setup_coreplugin(plugin)
cfg.CONF.set_override('allow_pagination', True)
cfg.CONF.set_override('allow_sorting', True)
self._plugin_patcher = mock.patch(plugin, autospec=True)
self.plugin = self._plugin_patcher.start()
# Ensure Quota checks never fail because of mock
instance = self.plugin.return_value
instance.get_networks_count.return_value = 1
# Instantiate mock plugin and enable the 'provider' extension
NeutronManager.get_plugin().supported_extension_aliases = (
["provider"])
ext_mgr = ProviderExtensionManager()
self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
self.addCleanup(self._plugin_patcher.stop)
self.addCleanup(self._restore_attribute_map)
self.api = webtest.TestApp(router.APIRouter())
quota.QUOTAS._driver = None
cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
group='QUOTAS')
示例15: setUp
def setUp(self, plugin=None):
super(AllowedAddressPairTestCase, self).setUp()
# Check if a plugin supports security groups
plugin_obj = NeutronManager.get_plugin()
self._skip_port_security = ('port-security' not in
plugin_obj.supported_extension_aliases)