scale_computing.hypercore.api module – API interaction with Scale Computing HyperCore

Note

This module is part of the scale_computing.hypercore collection (version 1.6.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install scale_computing.hypercore.

To use it in a playbook, specify: scale_computing.hypercore.api.

New in scale_computing.hypercore 1.0.0

Synopsis

  • Perform a GET, POST, PATCH, DELETE, or PUT request on resource(s) from the given endpoint. The api module can be used to perform raw API calls whenever there is no suitable concrete module or role implementation for a specific task.

Parameters

Parameter

Comments

action

string / required

The action to perform.

Choices:

  • "post"

  • "patch"

  • "delete"

  • "get"

  • "post_list"

  • "put"

cluster_instance

dictionary

Scale Computing HyperCore instance information.

auth_method

string

Select login method. If not set, the value of the SC_AUTH_METHOD environment variable will be used.

Value local - username/password is verified by the HyperCore server (the local users).

Value oidc - username/password is verified by the configured OIDC provider.

Choices:

  • "local" ← (default)

  • "oidc"

host

string / required

The HyperCore instance URL.

If not set, the value of the SC_HOST environment variable will be used.

For example “https://10.1.2.3:443”.

password

string / required

Password used for authentication.

If not set, the value of the SC_PASSWORD environment variable will be used.

timeout

float

Timeout in seconds for the connection with the Scale Computing HyperCore API instance.

If not set, the value of the SC_TIMEOUT environment variable will be used.

username

string / required

Username used for authentication.

If not set, the value of the SC_USERNAME environment variable will be used.

data

dictionary

A Dict containing a data to be sent to HyperCore REST endpoint.

If action=patch, data we’re updating the resource with.

If action=get, data option is going to be ignored.

If action=post the resource will be created from the data.

If action=delete, data option is going to be ignored.

If action=post_list, data will be send as list instead of dict.

endpoint

string / required

The raw endpoint that we want to perform post, patch or delete operation on.

source

string

added in scale_computing.hypercore 1.1.0

Source of the file to upload.

Notes

Note

  • check_mode is not supported.

Examples

- name: Create a VM with specified data
  scale_computing.hypercore.api:
    action: post
    cluster_instance:
      host: "https://0.0.0.0"
      username: admin
      password: admin
    endpoint: /rest/v1/VirDomain
    data:
      dom:
        name: XLAB-jc1
        tags: Xlab,jc1,us1
        mem: 512100100
        numVCPU: 2
        blockDevs:
          - type: VIRTIO_DISK
            capacity: 8100100100
            name: jc1-disk-0
        netDevs:
          - type: RTL8139
            vlan: 0
            connected: true
      options:
        attachGuestToolsISO: true
  register: result

- name: Retrieve all VMs
  scale_computing.hypercore.api:
    action: get
    cluster_instance:
      host: https://0.0.0.0
      username: admin
      password: admin
    endpoint: /rest/v1/VirDomain
  register: result

- name: Retrieve a specific VM
  scale_computing.hypercore.api:
    action: get
    cluster_instance:
      host: https://0.0.0.0
      username: admin
      password: admin
    endpoint: /rest/v1/VirDomain/0cdcdc95-ef66-461c-82a3-79ce03704981
  register: result

- name: Delete a VM
  scale_computing.hypercore.api:
    action: delete
    cluster_instance:
      host: https://0.0.0.0
      username: admin
      password: admin
    endpoint: /rest/v1/VirDomain/0fc7fe1f-2039-42c4-a2ad-945bccbe18b2
  register: result

- name: Clone a VM from snapshot
  scale_computing.hypercore.api:
    action: post
    cluster_instance:
      host: https://0.0.0.0
      username: admin
      password: admin
    endpoint: /rest/v1/VirDomain/17a23be5-9cf2-4d79-b02f-b2a0cb29a0f7/clone
    data:
      template:
        name: XLAB-jc1
        description: ""
        tags: Xlab,jc1,us1
  register: result

- name: Patch (an existing) record
  scale_computing.hypercore.api:
    action: post
    cluster_instance:
      host: https://0.0.0.0
      username: admin
      password: admin
    endpoint: /rest/v1/VirDomain/17a23be5-9cf2-4d79-b02f-b2a0cb29a0f7
    data:
      dom:
        name: XLAB-jc1-updated
        tags: Xlab,jc1,us1,updated-tag
        mem: 512100100
        numVCPU: 2
        blockDevs:
          - type: VIRTIO_DISK
            capacity: 8100100100
            name: jc1-disk-0-updated
        netDevs:
          - type: RTL8139
            vlan: 0
            connected: true
      options:
        attachGuestToolsISO: true
  register: result

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

record

dictionary

In case of action=get, list of records from the specified endpoint. Exact content depend on called API endpoint.

In case of action=post, action=patch or action=delete, usually the task tag dictionary, returned from the HyperCore API. If task tag is returned, the module internally waits on returned task tag to be finished.

Returned: success

Sample: {"createdUUID": "51e6d073-7566-4273-9196-58720117bd7f", "taskTag": 359}

Authors

  • Tjaž Eržen (@tjazsch)