当前位置: 首页>>代码示例>>Python>>正文


Python factory.PluginFactory类代码示例

本文整理汇总了Python中networkapi.plugins.factory.PluginFactory的典型用法代码示例。如果您正苦于以下问题:Python PluginFactory类的具体用法?Python PluginFactory怎么用?Python PluginFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PluginFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _remove_svi

def _remove_svi(equipment, vlan_num):
    equip_plugin = PluginFactory.factory(equipment)
    equip_plugin.connect()
    output = equip_plugin.remove_svi(vlan_num)
    equip_plugin.close()

    return output
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:7,代码来源:v1.py

示例2: _applyconfig

def _applyconfig(equipment, filename, equipment_access=None, source_server=None, port=22):
    """Apply configuration file on equipment

    Args:
            equipment: networkapi.equipamento.Equipamento()
            filename: relative file path from TFTPBOOT_FILES_PATH to apply in equipment
            equipment_access: networkapi.equipamento.EquipamentoAcesso() to use
            source_server: source TFTP server address
            port: ssh tcp port

    Returns:
            equipment output

    Raises:
    """

    if equipment.maintenance is True:
        return 'Equipment is in maintenance mode. No action taken.'

    if source_server is None:
        source_server = TFTP_SERVER_ADDR

    # TODO: Handle exceptions from the following methods and generate response
    # for the caller

    equip_plugin = PluginFactory.factory(equipment)
    equip_plugin.connect()
    equip_plugin.ensure_privilege_level()
    equip_output = equip_plugin.copyScriptFileToConfig(filename)
    equip_plugin.close()

    return equip_output
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:32,代码来源:facade.py

示例3: undeploy_neighbor_v6

def undeploy_neighbor_v6(neighbor_id):

    neighbor = NeighborV6.objects.get(id=neighbor_id)

    if not neighbor.created:
        raise exceptions.NeighborV6IsUndeployed(neighbor)

    locks_list = lock_resources_used_by_neighbor_v6(neighbor)

    try:
        get_created_neighbors_v4_shares_same_eqpt_and_peer(neighbor)
        get_created_neighbors_v6_shares_same_eqpt_and_peer(neighbor)

        eqpt = get_v6_equipment(neighbor)

        plugin = PluginFactory.factory(eqpt)
        plugin.bgp().undeploy_neighbor(neighbor)

        neighbor.deploy()

    except Exception as e:
        raise api_rest_exceptions.NetworkAPIException(str(e))

    finally:
        destroy_lock(locks_list)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:25,代码来源:facade.py

示例4: deploy_neighbor_v4

def deploy_neighbor_v4(neighbor_id):

    neighbor = NeighborV4.objects.get(id=neighbor_id)

    if neighbor.created:
        raise NeighborV4IsDeployed(neighbor)

    locks_list = lock_resources_used_by_neighbor_v4(neighbor)

    try:
        depl_v4 = get_created_neighbors_v4_shares_same_eqpt_and_peer(neighbor)
        depl_v6 = get_created_neighbors_v6_shares_same_eqpt_and_peer(neighbor)

        eqpt = get_v4_equipment(neighbor)

        plugin = PluginFactory.factory(eqpt)
        plugin.bgp().deploy_neighbor(neighbor)

        neighbor.deploy()

    except Exception as e:
        raise NetworkAPIException(str(e))

    finally:
        destroy_lock(locks_list)
开发者ID:pantuza,项目名称:GloboNetworkAPI,代码行数:25,代码来源:facade.py

示例5: __applyConfig

def __applyConfig(equipment,filename, equipment_access=None,source_server=None,port=22):
	'''Apply configuration file on equipment

	Args:
		equipment: networkapi.equipamento.Equipamento()
		filename: relative file path from TFTPBOOT_FILES_PATH to apply in equipment
		equipment_access: networkapi.equipamento.EquipamentoAcesso() to use
		source_server: source TFTP server address
		port: ssh tcp port

	Returns:
		equipment output

	Raises:
	'''

	if equipment.maintenance == True:
		return "Equipment is in maintenance mode. No action taken."
		
	if source_server == None:
		source_server = TFTP_SERVER_ADDR
	
	equip_plugin = PluginFactory.factory(equipment)
	equip_plugin.connect()
	equip_plugin.ensure_privilege_level()
	equip_output = equip_plugin.copyScriptFileToConfig(filename)
	equip_plugin.close()

	return equip_output
开发者ID:andrewsmedina,项目名称:GloboNetworkAPI,代码行数:29,代码来源:facade.py

示例6: test_factory_bgp_undeploy_neighbor

    def test_factory_bgp_undeploy_neighbor(self):
        equipment = self._mock_equipment()
        plugin = PluginFactory.factory(equipment)

        neighbor = {}

        self.assertEqual(hasattr(plugin.bgp(neighbor), 'undeploy_neighbor'),
                         True)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:8,代码来源:test_cli.py

示例7: test_factory_bgp_deploy_prefix_list

    def test_factory_bgp_deploy_prefix_list(self):
        equipment = self._mock_equipment()
        plugin = PluginFactory.factory(equipment)

        neighbor = {}

        self.assertEqual(
            hasattr(plugin.bgp(neighbor), 'deploy_prefix_list'), True)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:8,代码来源:test_cli.py

示例8: remove_svi

def remove_svi(equipment, vlan_num):
    """Call function "remove_svi" of Plugin for model of equipment."""

    equip_plugin = PluginFactory.factory(equipment)
    equip_plugin.connect()
    output = equip_plugin.remove_svi(vlan_num)
    equip_plugin.close()

    return output
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:9,代码来源:utils.py

示例9: flush_flows

def flush_flows(env_id):
    """ Flushes flow from a environment without restore it """
    eqpts = get_controller_by_envid(env_id)
    for eqpt in eqpts:
        plugin = PluginFactory.factory(eqpt, env_id=env_id)
        try:
            plugin.flush_flows()
        except Exception as e:
            log.error(e)
            raise NetworkAPIException('Failed to flush Controller '
                                      'plugin. %s' % e)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:11,代码来源:facade.py

示例10: _prepare_apply_state

def _prepare_apply_state(pools, user=None):
    load_balance = dict()
    keys = list()

    for pool in pools:
        server_pool = ServerPool.objects.get(id=pool['id'])

        server_pool_members = server_pool.serverpoolmember_set.all()

        if pool['server_pool_members']:
            equips = _validate_pool_members_to_apply(pool, user)

            keys.append(sorted([str(eqpt.id) for eqpt in equips]))

            for e in equips:
                eqpt_id = str(e.id)
                equipment_access = EquipamentoAcesso.search(
                    equipamento=e.id
                )

                plugin = PluginFactory.factory(e)

                if not load_balance.get(eqpt_id):

                    load_balance[eqpt_id] = {
                        'plugin': plugin,
                        'access': equipment_access,
                        'pools': [],
                    }

                mbs = pool['server_pool_members']
                idx_mbs = [mb['id'] for mb in mbs]

                load_balance[eqpt_id]['pools'].append({
                    'id': server_pool.id,
                    'nome': server_pool.identifier,
                    'pools_members': [{
                        'id': pool_member.id,
                        'ip': pool_member.ip.ip_formated
                        if pool_member.ip else pool_member.ipv6.ip_formated,
                        'port': pool_member.port_real,
                        'member_status': mbs
                        [idx_mbs.index(pool_member.id)]['member_status']
                    } for pool_member in server_pool_members
                        if pool_member.id in idx_mbs]
                })
    # pools are in differents load balancers
    keys = [','.join(key) for key in keys]
    if len(list(set(keys))) > 1:
        raise Exception('Pools are in differents load balancers')

    return load_balance
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:52,代码来源:deploy.py

示例11: setUp

    def setUp(self):
        # Must chose the equipment with the right version running on docker
        # Beryllium
        self.equipment = Equipamento.objects.filter(id=10).uniqueResult()
        # Nitrogen
        #self.equipment = Equipamento.objects.filter(id=11).uniqueResult()

        self.equipment_access = EquipamentoAcesso.objects.filter(id=1).uniqueResult()
        self.utils.set_controller_endpoint(self.equipment_access)

        self.odl = PluginFactory.factory(self.equipment)

        self.flow_key = "flow-node-inventory:flow"
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:13,代码来源:test_generic_odl_plugin.py

示例12: insert_flow

def insert_flow(env_id, data, user_id):
    eqpts = get_controller_by_envid(env_id)
    plugins = []
    for eqpt in eqpts:
        plugins.append(PluginFactory.factory(eqpt, env_id=env_id))
    try:
        return async_add_flow.apply_async(
            args=[plugins, user_id, data], queue='napi.odl_flow'
        )
    except Exception as e:
        log.error(e)
        raise NetworkAPIException('Failed to insert flow(s) '
                                  'plugin. %s' % e)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:13,代码来源:facade.py

示例13: update_flows

def update_flows(env_id, data, user_id):
    """ Call equipment plugin to asynchronously flush the environment """
    eqpts = get_controller_by_envid(env_id)
    plugins = []
    for eqpt in eqpts:
        plugins.append(PluginFactory.factory(eqpt, env_id=env_id))

    try:
        return async_flush_environment.apply_async(
            args=[plugins, user_id, data], queue='napi.odl_flow'
        )
    except Exception as e:
        log.error(e)
        raise NetworkAPIException('Failed to flush flow(s) '
                                  'from environment: %s \n%s' % (env_id, e))
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:15,代码来源:facade.py

示例14: delete_flow

def delete_flow(env_id, flow_id, user_id):
    """ Deletes one flow by id using the async task """

    eqpts = get_controller_by_envid(env_id)

    plugins = []
    for eqpt in eqpts:
        plugins.append(PluginFactory.factory(eqpt, env_id=env_id))

    try:
        return async_delete_flow.apply_async(
            args=[plugins, user_id, flow_id], queue='napi.odl_flow'
        )
    except Exception as err:
        log.error(err)
        raise NetworkAPIException('Failed to delete flow with error: %s' % err)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:facade.py

示例15: create_v3

    def create_v3(self, vip_port_map):
        # save port

        facade_eqpt = get_app('api_equipment', 'facade')

        self.vip_request = VipRequest.get_by_pk(
            vip_port_map.get('vip_request'))
        self.port = vip_port_map.get('port')

        eqpts = facade_eqpt.get_eqpt_by_envvip(
            self.vip_request.environmentvip.id)
        if eqpts:
            plugin = PluginFactory.factory(eqpts[0])
            identifier = plugin.get_name_eqpt(
                self.vip_request, vip_port_map['port'])
            self.identifier = identifier

        self.save()

        # L4 Protocol
        opt = VipRequestPortOptionVip()
        opt_map = {
            'vip_request_port': self.id,
            'optionvip': vip_port_map['options']['l4_protocol']
        }
        opt.create_v3(opt_map)

        # L7 Protocol
        opt = VipRequestPortOptionVip()
        opt_map = {
            'vip_request_port': self.id,
            'optionvip': vip_port_map['options']['l7_protocol']
        }
        opt.create_v3(opt_map)

        # Pools
        for pool in vip_port_map.get('pools'):
            pool_map = {
                'vip_request_port': self.id,
                'server_pool': pool.get('server_pool'),
                'optionvip': pool.get('l7_rule'),
                'val_optionvip': pool.get('l7_value'),
                'order': pool.get('order')
            }
            pl = VipRequestPortPool()
            pl.create_v3(pool_map)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:46,代码来源:models.py


注:本文中的networkapi.plugins.factory.PluginFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。