huaweidatacom.ac.ac_logicinterface (1.0.0) — module

Manages LogicInterface on HUAWEI iMaster NCE-Fabric Controller.

Authors: ZhiwenZhang (@maomao1995)

Install collection

Install with ansible-galaxy collection install huaweidatacom.ac:==1.0.0


Add to requirements.yml

  collections:
    - name: huaweidatacom.ac
      version: 1.0.0

Description

Manages LogicInterface on HUAWEI iMaster NCE-Fabric Controller(AC).

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create LogicInterface
  hosts: localhost
  serial: True
  vars:
    now_time: "{{ansible_date_time.date}} {{ansible_date_time.time}}"
    token_id: "{{lookup('file','/tmp/ansible-temp')}}"
  vars_prompt:
    - name: "logicinterface_name"
      prompt: "Please input logic interface name "
      private: no
    - name: "logicrouter_id"
      prompt: "Please input logic router id "
      private: no
    - name: "logicswitch_id"
      prompt: "Please input logic switch id "
      private: no
    - name: "logicsubnet_id"
      prompt: "Please input logic subnet id "
      private: no
  tasks:
    - name: check logicinterface_name is null
      fail:
        msg: "Create LogicInterface fail! logicinterface_name is null"
      when: logicinterface_name == ''
    - name: check logicrouter_id is null
      fail:
        msg: "Create LogicInterface fail! logicrouter_id is null"
      when: logicrouter_id == ''
    - name: check logicswitch_id is null
      fail:
        msg: "Create LogicInterface fail! logicswitch_id is null"
      when: logicswitch_id == ''
    - name: check logicsubnet_id is null
      fail:
        msg: "Create LogicInterface fail! logicsubnet_id is null"
      when: logicsubnet_id == ''
    - name: Create logicinterface "{{logicinterface_name}}"
      tags: create_logicinterface
      vars:
        logicinterface_info:
          id: "{{ansible_date_time.iso8601_micro | to_uuid}}"
          name: "{{logicinterface_name}}"
          interfaceType: "RouterInterface"
          logicRouterId: "{{logicrouter_id}}"
          logicSwitchId: "{{logicswitch_id}}"
          ip:
            subnetId: "{{logicsubnet_id}}"
          additional:
            producer: "default"
            createAt: "{{now_time}}"
            updateAt: "{{now_time}}"
        logicinterface_infos:
          interface: [ "{{logicinterface_info}}" ]
      uri:
        url: 'https://{{north_ip}}:{{north_port}}/controller/dc/v3/logicnetwork/interfaces'
        method: POST
        body: '{{logicinterface_infos}}'
        body_format: json
        validate_certs: False
        return_content: yes
        headers:
          X-ACCESS-TOKEN: "{{token_id}}"
          Accept: application/json
          Content_Type: application/json
        status_code: 204
      register: logicinterface_result
    - name: response from create logic interface
      debug:
        msg: "{{logicinterface_result}}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Query LogicInterface
  hosts: localhost
  serial: True
  vars:
    token_id: "{{lookup('file','/tmp/ansible-temp')}}"
  vars_prompt:
    - name: "logicinterface_id"
      prompt: "Please input the logic interface id that you want to query "
      private: no
  tasks:
    - name: qeury logicinterfaces
      tags: qeury_logicinterfaces
      when: logicinterface_id == ''
      uri:
        url: 'https://{{north_ip}}:{{north_port}}/controller/dc/v3/logicnetwork/interfaces'
        method: GET
        validate_certs: False
        return_content: yes
        headers:
          X-ACCESS-TOKEN: "{{token_id}}"
          Accept: application/json
          Content_Type: application/json
        status_code: 200
      register: logicinterfaces_result
      ignore_errors: yes
    - name: qeury logicinterface "{{logicinterface_id}}"
      tags: qeury_logicinterface
      when: logicinterface_id != ''
      uri:
        url: 'https://{{north_ip}}:{{north_port}}/controller/dc/v3/logicnetwork/interfaces/interface/{{logicinterface_id}}'
        method: GET
        validate_certs: False
        return_content: yes
        headers:
          X-ACCESS-TOKEN: "{{token_id}}"
          Accept: application/json
          Content_Type: application/json
        status_code: 200
      register: logicinterface_result
      ignore_errors: yes
    - name: response from get logicinterfaces
      when: logicinterface_id == ''
      debug:
        msg: "{{logicinterfaces_result.json.interface}}"
    - name: response from query a logicinterface
      when: logicinterface_id != ''
      debug:
        msg: "{{logicinterface_result.json.interface}}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete LogicInterface
  hosts: localhost
  serial: True
  vars:
    token_id: "{{lookup('file','/tmp/ansible-temp')}}"
  vars_prompt:
    - name: "logicinterface_id"
      prompt: "Please input the logic interface id that you want to delete "
      private: no
  tasks:
    - name: check logicinterface_id is null
      fail:
        msg: "Delete LogicInterface fail! logicinterface_id is null"
      when: logicinterface_id == ''
    - name: Delete logicinterface "{{logicinterface_id}}"
      tags: delete_logicinterface
      uri:
        url: 'https://{{north_ip}}:{{north_port}}/controller/dc/v3/logicnetwork/interfaces/interface/{{logicinterface_id}}'
        method: DELETE
        validate_certs: False
        return_content: yes
        headers:
          X-ACCESS-TOKEN: "{{token_id}}"
          Accept: application/json
          Content_Type: application/json
        status_code: 204
      register: logicinterface_result
      ignore_errors: yes
    - name: response from delete a logicinterface
      debug:
        msg: "{{logicinterface_result}}"

Inputs

    
logicrouter_id:
    description:
    - AC LogicRouter id.

logicsubnet_id:
    description:
    - AC LogicSubnet id.

logicswitch_id:
    description:
    - AC LogicSwitch id.

logicinterface_id:
    description:
    - AC LogicInterface id.

logicinterface_name:
    description:
    - AC LogicInterface name.