How to use the genie.conf.base.cli.CliConfigBuilder function in genie

To help you get started, we’ve selected a few genie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / te / iosxe / te.py View on Github external
def build_config(self, apply=True, attributes=None, unconfig=False):
                attributes = AttributesHelper(self, attributes)
                configurations = CliConfigBuilder(unconfig=unconfig)
        
                # TODO
                pass

                return str(configurations)
github CiscoTestAutomation / genielibs / src / conf / igmp / nxos / igmp.py View on Github external
def build_config(self, apply=True, attributes=None, unconfig=False,
                             **kwargs):
                assert not kwargs, kwargs
                attributes = AttributesHelper(self, attributes)
                configurations = CliConfigBuilder(unconfig=unconfig)

                # global_max_groups -- not supported on nxos

                with configurations.submode_context(
                    attributes.format('vrf context {vrf_id}' if 
                            self.vrf_id != 'default' else '', force=True)):
                    if unconfig and attributes.iswildcard and self.vrf_id != 'default':
                        configurations.submode_unconfig()

                    # Ssm Attributes under vrf level config
                    for ssm, attributes2 in attributes.sequence_values('ssm', sort=True):
                        if unconfig:
                            configurations.append_block(ssm.build_unconfig(
                                apply=False, attributes=attributes2, **kwargs))
                        else:
                            configurations.append_block(ssm.build_config(
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / ldp / iosxe / ldp.py View on Github external
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
                assert not apply
                attributes = AttributesHelper(self, attributes)
                configurations = CliConfigBuilder(unconfig=unconfig)

                # iosxe: mpls ldp router-id {interface.name}
                # iosxe: mpls ldp router-id vrf xxx {interface.name}
                if self.vrf_name == 'default':
                    configurations.append_line(attributes.format('mpls ldp router-id {router_id.name}'))
                else:
                    configurations.append_line(attributes.format('mpls ldp router-id vrf {vrf_name} {router_id.name}',force=True))

                # iosxe : mpls ldp session protection ...
                if self.vrf_name == 'default':
                    if attributes.value('session_protection'):
                        if attributes.value('session_protection_for_acl') and attributes.value('session_protection_dur'):
                            configurations.append_line(attributes.format('mpls ldp session protection for '\
                                                '{session_protection_for_acl.name} {session_protection_dur}'))

                        elif attributes.value('session_protection_for_acl'):
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / interface / iosxe / interface.py View on Github external
def build_config(self, apply=True, attributes=None, unconfig=False,
                     **kwargs):
        assert not kwargs
        attributes = AttributesHelper(self, attributes)
        configurations = CliConfigBuilder(unconfig=unconfig)

        with self._build_config_create_interface_submode_context(configurations):
            self._build_config_interface_submode(configurations=configurations, attributes=attributes, unconfig=unconfig)

        if apply:
            if configurations:
                self.device.configure(configurations, fail_invalid=True)
        else:
            return CliConfig(device=self.device, unconfig=unconfig,
                             cli_config=configurations)
github CiscoTestAutomation / genielibs / src / conf / igmp / nxos / igmp_group.py View on Github external
def build_config(self, apply=True, attributes=None, unconfig=False,
                     **kwargs):
        assert not kwargs, kwargs
        attributes = AttributesHelper(self, attributes)
        configurations = CliConfigBuilder(unconfig=unconfig)

        # ===================================
        # join_group
        # join_group_source_addr
        # static_group
        # static_group_source_addr
        # ===================================

        if attributes.value('join_group'):

            cmd_str = 'ip igmp join-group {join_group}'

            # build up configuration string
            if attributes.value('join_group_source_addr') and \
               attributes.value('join_group_source_addr') != '*':
                cmd_str += ' source {join_group_source_addr}'
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / interface / nxos / interface.py View on Github external
Create a Interface obj

            >>> eth = Interface(name='ethernet3/1')

            assign configurable attributes to the interface obj

            >>> eth.description = 'ethernet3/1'
            >>> eth.shutdown = False

            Build configuration

            >>> configuration = eth.build_config()
        """
        assert not kwargs, kwargs
        attributes = AttributesHelper(self, attributes)
        configurations = CliConfigBuilder(unconfig=unconfig)

        with self._build_config_create_interface_submode_context(\
            configurations):
            self._build_config_interface_submode(\
                    configurations=configurations, \
                    attributes=attributes, unconfig=unconfig)

        if apply:
            if configurations:
                self.device.configure(configurations, fail_invalid=True)
        else:
            return CliConfig(device=self.device, unconfig=unconfig,
                             cli_config=configurations)
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / ldp / iosxe / ldp.py View on Github external
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
            attributes = AttributesHelper(self, attributes)
            configurations = CliConfigBuilder(unconfig=unconfig)

            if attributes.iswildcard:
                # iosxe : mpls label protocol ldp
                configurations.append_line('mpls label protocol ldp', \
                                            unconfig_cmd = 'default mpls label protocol')

                # iosxe : mpls ip
                configurations.append_line('mpls ip', \
                                            unconfig_cmd = 'default mpls ip')


            # iosxe : no mpls ip
            if attributes.value('shutdown'):
                configurations.append_line('no mpls ip', \
                                            unconfig_cmd = 'mpls ip')
github CiscoTestAutomation / genielibs / src / conf / igmp / iosxr / igmp.py View on Github external
def build_config(self, apply=True, attributes=None, unconfig=False,
                         **kwargs):
            assert not kwargs, kwargs
            attributes = AttributesHelper(self, attributes)
            configurations = CliConfigBuilder(unconfig=unconfig)

            # iosxr: router igmp (config-igmp)
            with configurations.submode_context('router igmp'):
                if unconfig and attributes.iswildcard:
                    configurations.submode_unconfig()
 
                # VrfAttributes
                for sub, attributes2 in attributes.mapping_values('vrf_attr',
                        sort=True, keys=self.vrf_attr):
                            configurations.append_block(
                                sub.build_config(apply=False,
                                                 attributes=attributes2,
                                                 unconfig=unconfig))            
            
            if apply:
                if configurations:
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / lisp / iosxe / lisp.py View on Github external
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
                        assert not apply
                        attributes = AttributesHelper(self, attributes)
                        configurations = CliConfigBuilder(unconfig=unconfig)

                        # +- DeviceAttributes
                        #   +- RouterInstanceAttributes
                        #     +- ExtranetAttributes
                        #       +- InstanceIdAttributes
                        #         +- EidRecordProviderAttributes
                        # --------------------------------------
                        # Add EidRecordProviderAttributes configurations under InstanceIdAttributes
                        for sub, attributes2 in attributes.mapping_values('eid_record_provider_attr', 
                                                                          sort=True, 
                                                                          keys=self.eid_record_provider_attr):
                            configurations.append_block(
                                sub.build_config(apply=False,
                                                 attributes=attributes2,
                                                 unconfig=unconfig,
                                                 instance_id=self.extranet_inst_id))