neoave / mrack

Multicloud use-case based multihost async provisioner for CIs and testing during development
Apache License 2.0
12 stars 14 forks source link

feat(Beaker): Add parsing of hostRequires to the job #145

Closed Tiboris closed 3 years ago

Tiboris commented 3 years ago

mrack now supports the hostRequires in the host metadata or default in provisioning config yaml.

NOTE CASE MATTERS:

The hostRequires for the host should look like following:

hostRequires:
  or:
    - hostname:
        _value: foo1.bar.baz.com
        _op: "="
    - hostname:
        _value: foo2.bar.baz.com
        _op: "="
  and:
    - system:
        memory:
          _value: 8000
          _op: ">"
    - arch:
        _value: x86_64
        _op: "="
    - system_type:
        _value: Machine
        _op: "="
    - key_value:
        _key: HVM
        _value: 1
        _op: "="
    - disk:
        size:
          _value: 137438953472
          _op: ">"

Which will result into following xml for the job specification:

<hostRequires>
  <or>
    <hostname value="foo1.bar.baz.com" op="="/>
    <hostname value="foo2.bar.baz.com" op="="/>
  </or>
  <and>
    <system>
      <memory value="8000" op="&gt;"/>
    </system>
    <arch value="x86_64" op="="/>
    <system_type value="Machine" op="="/>
    <key_value key="HVM" value="1" op="="/>
    <disk>
      <size value="137438953472" op="&gt;"/>
    </disk>
  </and>
</hostRequires>

and such requirement will be uploaded to the beaker hub and schedule a job with this requirements.

Signed-off-by: Tibor Dudlák tdudlak@redhat.com

spoore1 commented 3 years ago

FYI, latest update worked for my use case:

Metadata:

        provider: beaker
        beaker:
          hostRequires:
            _force: "somehostname"

Beaker job xml:

      <hostRequires force="somehostname"/>
pvoborni commented 3 years ago

Hi, thanks for the PR. Mostly looks good to me. It would be good to include also unit tests for _req_to_bkr_job method with several variations of prov config and host metadata - testing multiple cases.