Xin chào ! Nếu đây là lần đầu tiên bạn đến với diễn đàn, xin vui lòng danh ra một phút bấm vào đây để đăng kí và tham gia thảo luận cùng VnPro.

Announcement

Collapse
No announcement yet.

Cơ bản về YANG cho DEVNET

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cơ bản về YANG cho DEVNET

    YAML Basics for DevNet
    YAML is a human-readable structured data format which stands for Stands for Yet Another Markup Language or now YAML Ain’t Markup Language, depending on where you look The official documentation page states the latter.

    Goals of YAML
    • Data serialization standard for programming languages.
    • Human-readable structured data format.
    • Portable between programming languages.
    • Consistent model.
    • Expressive and extensible.
    • Easy to implement and use.
    A quick overview of YAML
    • Writable and readable.
    • Case sensitive
    • Files end in .yaml or .yml
    • Spaces are used instead of tabs (because various tools treat tabs differently)
    • Indentation is used for structure
    • Colons separate key-value pairs
    • Dashes create bullet lists
    • The start of a YAML file begins with three dashes
    Data structures:
    • Mappings (hashes/dictionaries)
    • Sequences (arrays/lists)
    • Scalars (strings/numbers)
    Working with Blocks
    Block collections use indentation for scope and begin each entry on its new line. Block sequences use a dash and space to indicate each entry. Mappings use a colon and space to mark a key-value pair.
    To create a comment, you must use a hash tag.
    Sequence
    A sequence entry will be denoted by a dash -.

    - netsw-idf-01
    - netsw-idf-02
    - netsw-idf-03
    Scalar
    A scalar is just a single value. They can be strings, numbers, Boolean, or null values.

    # scalars can be quoted
    “GigabitEthernet1/0/1”

    # scalars can also be unquoted
    GigabitEthernet1/0/2
    Mapping Scalars to Sequences
    Also creates an array.

    routers:
    - rtr-idf-01
    - rtr-idf-02
    switches:
    - netsw-idf-01
    - netsw-idf-02
    Sample Inventory in YAML
    —--
    sites:
    - name: san-jose # This is a comment. Begin block 1.
    hosts:
    - hostname: r1
    host: 192.168.1.1
    os: cisco_ios
    - hostname: sw1
    host: 192.168.1.5
    os: cisco_ios
    - hostname: sw2
    host: 192.168.1.6
    os: junos

    - name: san-diego # This is a comment. Begin block 2.
    hosts:
    - hostname: r2
    host: 192.168.2.1
    os: cisco_ios
    - hostname: sw1
    host: 192.168.2.5
    os: cisco_ios
    Have we created a list or a dictionary? List items which is a dictionary.
    Here’s a sample YAML script used to configure a VLAN on a Cisco switch.
    ---
    - hosts: cisco
    connection: network_cli
    tasks:
    - nxos_vlan:
    vlan_id: 10
    name: STORAGE


    Đặng Quang Minh, CCIEx2#11897 (Enterprise Infrastructure, Wireless), DEVNET, CCSI#31417

    Email : dangquangminh@vnpro.org
    https://www.facebook.com/groups/vietprofessional/
Working...
X