本文整理汇总了Python中f5_openstack_agent.lbaasv2.drivers.bigip.service_adapter.ServiceModelAdapter.get_folder_name方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceModelAdapter.get_folder_name方法的具体用法?Python ServiceModelAdapter.get_folder_name怎么用?Python ServiceModelAdapter.get_folder_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类f5_openstack_agent.lbaasv2.drivers.bigip.service_adapter.ServiceModelAdapter
的用法示例。
在下文中一共展示了ServiceModelAdapter.get_folder_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: L2ServiceBuilder
# 需要导入模块: from f5_openstack_agent.lbaasv2.drivers.bigip.service_adapter import ServiceModelAdapter [as 别名]
# 或者: from f5_openstack_agent.lbaasv2.drivers.bigip.service_adapter.ServiceModelAdapter import get_folder_name [as 别名]
#.........这里部分代码省略.........
if tagged:
vlanid = network['provider:segmentation_id']
else:
vlanid = 0
vlan_name = "vlan-" + \
str(interface).replace(".", "-") + \
"-" + str(vlanid)
if len(vlan_name) > 15:
vlan_name = 'vlan-tr-' + str(vlanid)
return vlan_name
def assure_bigip_network(self, bigip, network):
# Ensure bigip has configured network object
if not network:
LOG.error(' assure_bigip_network: '
'Attempted to assure a network with no id..skipping.')
return
if network['id'] in bigip.assured_networks:
return
if network['id'] in self.conf.common_network_ids:
LOG.debug(' assure_bigip_network: '
'Network is a common global network... skipping.')
return
LOG.debug(" assure_bigip_network network: %s" % str(network))
start_time = time()
if self.is_common_network(network):
network_folder = 'Common'
else:
network_folder = self.service_adapter.get_folder_name(
network['tenant_id']
)
# setup all needed L2 network segments
if network['provider:network_type'] == 'flat':
self._assure_device_network_flat(network, bigip, network_folder)
elif network['provider:network_type'] == 'vlan':
self._assure_device_network_vlan(network, bigip, network_folder)
elif network['provider:network_type'] == 'vxlan':
self._assure_device_network_vxlan(network, bigip, network_folder)
elif network['provider:network_type'] == 'gre':
self._assure_device_network_gre(network, bigip, network_folder)
else:
error_message = 'Unsupported network type %s.' \
% network['provider:network_type'] + \
' Cannot setup network.'
LOG.error(error_message)
raise f5ex.InvalidNetworkType(error_message)
bigip.assured_networks.append(network['id'])
if time() - start_time > .001:
LOG.debug(" assure bigip network took %.5f secs" %
(time() - start_time))
def _assure_device_network_flat(self, network, bigip, network_folder):
# Ensure bigip has configured flat vlan (untagged)
interface = self.interface_mapping['default']
vlanid = 0
# Do we have host specific mappings?
net_key = network['provider:physical_network']
if net_key + ':' + bigip.hostname in \
self.interface_mapping:
示例2: L2ServiceBuilder
# 需要导入模块: from f5_openstack_agent.lbaasv2.drivers.bigip.service_adapter import ServiceModelAdapter [as 别名]
# 或者: from f5_openstack_agent.lbaasv2.drivers.bigip.service_adapter.ServiceModelAdapter import get_folder_name [as 别名]
#.........这里部分代码省略.........
vlanid = 0
if net_type == "flat":
interface_name = str(interface).replace(".", "-")
if (len(interface_name) > 15):
LOG.warn(
"Interface name is greater than 15 chars in length")
vlan_name = "flat-%s" % (interface_name)
else:
vlan_name = "vlan-%d" % (vlanid)
return vlan_name
def assure_bigip_network(self, bigip, network):
# Ensure bigip has configured network object
if not network:
LOG.error('assure_bigip_network: '
'Attempted to assure a network with no id..skipping.')
return
if network['id'] in bigip.assured_networks:
return
if network['id'] in self.conf.common_network_ids:
LOG.debug('assure_bigip_network: '
'Network is a common global network... skipping.')
return
LOG.debug("assure_bigip_network network: %s" % str(network))
start_time = time()
if self.is_common_network(network):
network_folder = 'Common'
else:
network_folder = self.service_adapter.get_folder_name(
network['tenant_id']
)
# setup all needed L2 network segments
if network['provider:network_type'] == 'flat':
network_name = self._assure_device_network_flat(
network, bigip, network_folder)
elif network['provider:network_type'] == 'vlan':
network_name = self._assure_device_network_vlan(
network, bigip, network_folder)
elif network['provider:network_type'] == 'vxlan':
network_name = self._assure_device_network_vxlan(
network, bigip, network_folder)
elif network['provider:network_type'] == 'gre':
network_name = self._assure_device_network_gre(
network, bigip, network_folder)
elif network['provider:network_type'] == 'opflex':
raise f5_ex.NetworkNotReady(
"Opflex network segment definition required")
else:
error_message = 'Unsupported network type %s.' \
% network['provider:network_type'] + \
' Cannot setup network.'
LOG.error(error_message)
raise f5_ex.InvalidNetworkType(error_message)
bigip.assured_networks[network['id']] = network_name
if time() - start_time > .001:
LOG.debug(" assure bigip network took %.5f secs" %
(time() - start_time))
def _assure_device_network_flat(self, network, bigip, network_folder):