dellemc.enterprise_sonic.sonic_api (2.4.0) — module

Manages REST operations on devices running Enterprise SONiC

| "added in version" 1.0.0 of dellemc.enterprise_sonic"

Authors: Abirami N (@abirami-n)

This plugin has a corresponding action plugin.

Install collection

Install with ansible-galaxy collection install dellemc.enterprise_sonic:==2.4.0


Add to requirements.yml

  collections:
    - name: dellemc.enterprise_sonic
      version: 2.4.0

Description

Manages REST operations on devices running Enterprise SONiC Distribution by Dell Technologies. This module provides an implementation for working with SONiC REST operations in a deterministic way.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Checks that you can connect (GET) to a page and it returns a status 200
  dellemc.enterprise_sonic.sonic_api:
    url: data/openconfig-interfaces:interfaces/interface=Ethernet60
    method: "GET"
    status_code: 200
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Appends data to an existing interface using PATCH and verifies if it returns status 204
  dellemc.enterprise_sonic.sonic_api:
    url: data/openconfig-interfaces:interfaces/interface=Ethernet60/config/description
    method: "PATCH"
    body: {"openconfig-interfaces:description": "Eth-60"}
    status_code: 204
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Deletes an associated IP address using DELETE and verifies if it returns status 204
  dellemc.enterprise_sonic.sonic_api:
    url: >
      data/openconfig-interfaces:interfaces/interface=Ethernet64/subinterfaces/subinterface=0/
      openconfig-if-ip:ipv4/addresses/address=1.1.1.1/config/prefix-length
    method: "DELETE"
    status_code: 204
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Adds a VLAN network instance using PUT and verifies if it returns status 204
  dellemc.enterprise_sonic.sonic_api:
    url: data/openconfig-network-instance:network-instances/network-instance=Vlan100/
    method: "PUT"
    body: {"openconfig-network-instance:network-instance": [{"name": "Vlan100","config": {"name": "Vlan100"}}]}
    status_code: 204
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Adds a prefix-set to a routing policy using POST and verifies if it returns 201
  dellemc.enterprise_sonic.sonic_api:
        url: data/openconfig-routing-policy:routing-policy/defined-sets/prefix-sets/prefix-set=p1
        method: "POST"
        body: {"openconfig-routing-policy:config": {"name": "p1","mode": "IPV4" }}
        status_code: 201

Inputs

    
url:
    description:
    - The HTTP path of the request after 'restconf/'.
    required: true
    type: path

body:
    description:
    - The body of the HTTP request/response to the web service which contains the payload.
    type: raw

method:
    choices:
    - GET
    - PUT
    - POST
    - PATCH
    - DELETE
    description:
    - The HTTP method of the request or response. Must be a valid method accepted by the
      service that handles the request.
    required: true
    type: str

status_code:
    description:
    - A list of valid, numeric, HTTP status codes that signifies the success of a request.
    elements: int
    required: true
    type: list

Outputs

msg:
  description: The HTTP error message from the request.
  returned: HTTP Error
  type: str
response:
  description: The response at the network device end for the REST call which contains
    the status code.
  returned: always
  sample:
    response:
    - 204
    - ? ''
      : null
  type: list