Skip to content

disk.py: add elements of ssh/https network disk#4083

Merged
Yingshun merged 1 commit intoavocado-framework:masterfrom
meinaLi:ssh_disk
Apr 28, 2025
Merged

disk.py: add elements of ssh/https network disk#4083
Yingshun merged 1 commit intoavocado-framework:masterfrom
meinaLi:ssh_disk

Conversation

@meinaLi
Copy link
Copy Markdown
Contributor

@meinaLi meinaLi commented Mar 18, 2025

  1. Add the new elements for disk source:
    • knownHosts
    • identity
    • ssl
    • readahead
    • timeout
    • cookies
  2. Add storage_use_nbdkit which can be used with ssh/https network disks in utils_config.py.

1. Add the new elements for disk source:
   - knownHosts
   - identity
   - ssl
   - readahead
   - timeout
   - cookies
2. Add storage_use_nbdkit which can be used with ssh/https network disks in utils_config.py.

Signed-off-by: meinaLi <meili@redhat.com>
@meinaLi meinaLi changed the title disk.py: add elements of ssh network disk disk.py: add elements of ssh/https network disk Mar 28, 2025
@meinaLi
Copy link
Copy Markdown
Contributor Author

meinaLi commented Mar 28, 2025

This update is related to autotest/tp-libvirt#6251 and autotest/tp-libvirt#6252.

@meinaLi
Copy link
Copy Markdown
Contributor Author

meinaLi commented Apr 8, 2025

@chloerh Please help review this PR, thanks.

Copy link
Copy Markdown
Contributor

@chloerh chloerh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good, could you please provide a result of setup_attrs() and fetch_attrs() which could be helpful, thanks!

@meinaLi
Copy link
Copy Markdown
Contributor Author

meinaLi commented Apr 15, 2025

The fetch_attrs() result for ssh network disk:

>>> from virttest.libvirt_xml.devices import disk
>>> disk_dev = disk.Disk()
>>> disk_dev.xml = """
... <disk type="network" device="disk">
...   <driver name="qemu" type="qcow2"/>
...   <source protocol="ssh" name="/var/lib/libvirt/images/test.qcow2">
...     <host name="[ssh_server_ip]" port="22"/>
...     <knownHosts path="/tmp/known_hosts"/>
...     <identity username="root" keyfile="/tmp/id_rsa"/>
...   </source>
...   <target dev="sdb" bus="scsi"/>
...   <address type='drive' controller='0' bus='0' target='0' unit='1'/>
... </disk>
... """
>>> disk_dev.fetch_attrs()
{'address': {'type_name': 'drive', 'attrs': {'type': 'drive', 'controller': '0', 'bus': '0', 'target': '0', 'unit': '1'}}, 'type_name': 'network', 'source': {'identity': [{'username': 'root', 'keyfile': '/tmp/id_rsa'}], 'knownhosts': '/tmp/known_hosts', 'attrs': {'protocol': 'ssh', 'name': '/var/lib/libvirt/images/test.qcow2'}, 'hosts': [{'name': '[ssh_server_ip]', 'port': '22'}]}, 'target': {'dev': 'sdb', 'bus': 'scsi'}, 'device': 'disk', 'driver': {'name': 'qemu', 'type': 'qcow2'}}

The setup_attrs() result for ssh network disk:

>>> disk_dev.setup_attrs(**disk_dict)
>>> disk_dev.xml
'/tmp/xml_utils_temp_80gk329h.xml'
# cat /tmp/xml_utils_temp_80gk329h.xml
<disk type="network" device="disk">
  <driver name="qemu" type="qcow2" />
  <target dev="sdb" bus="scsi" />
  <address type="drive" controller="0" bus="0" target="0" unit="1" /><source protocol="ssh" name="/var/lib/libvirt/images/test.qcow2">
    <knownHosts path="/tmp/known_hosts" />
    <identity username="root" keyfile="/tmp/id_rsa" /><host name="[ssh_server_ip]" port="22" /></source></disk>

@meinaLi
Copy link
Copy Markdown
Contributor Author

meinaLi commented Apr 15, 2025

The fetch_attrs() result for https network disk:

>>> disk_dev.xml = """
...     <disk type='network' device='disk'>
...       <driver name='qemu' type='raw'/>
...         <source protocol='https' name='/fedora/linux/releases/41/Workstation/x86_64/iso/Fedora-Server-netinst-x86_64-41-1.4.iso'>
...         <host name='insect.mm.fcix.net' port='443'/>
...         <ssl verify='yes'/>
...         <cookies>
...           <cookie name='vmware_soap_session'>&quot;314455dbd2eaafd7d76b3b7828f0a3e3956450f9&quot;</cookie>
...         </cookies>
...        <readahead size='1024'/>
...         <timeout seconds='1234'/>
...       </source>
...       <target dev='vdb' bus='virtio'/>
...       <readonly/>
...       <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
...     </disk>
... """
>>> disk_dev.fetch_attrs()
{'address': {'type_name': 'pci', 'attrs': {'type': 'pci', 'domain': '0x0000', 'bus': '0x07', 'slot': '0x00', 'function': '0x0'}}, 'type_name': 'network', 'source': {'cookies': {'cookie': '"314455dbd2eaafd7d76b3b7828f0a3e3956450f9"', 'cookie_name': 'vmware_soap_session'}, 'ssl': 'yes', 'attrs': {'protocol': 'https', 'name': '/fedora/linux/releases/41/Workstation/x86_64/iso/Fedora-Server-netinst-x86_64-41-1.4.iso'}, 'timeout': '1234', 'hosts': [{'name': 'insect.mm.fcix.net', 'port': '443'}], 'readahead': '1024'}, 'readonly': True, 'target': {'dev': 'vdb', 'bus': 'virtio'}, 'device': 'disk', 'driver': {'name': 'qemu', 'type': 'raw'}}
>>> 

The setup_attrs() result for https network disk:

>>> disk_dev.setup_attrs(**disk_dict)
>>> disk_dev.xml
'/tmp/xml_utils_temp__8fps0u8.xml'
>>> 
# cat /tmp/xml_utils_temp__8fps0u8.xml
<disk type="network" device="disk">
      <driver name="qemu" type="raw" />
        <target dev="vdb" bus="virtio" />
      <readonly />
      <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0" /><source protocol="https" name="/fedora/linux/releases/41/Workstation/x86_64/iso/Fedora-Server-netinst-x86_64-41-1.4.iso">
        <ssl verify="yes" />
        <readahead size="1024" />
        <timeout seconds="1234" />
      <cookies>
          <cookie name="vmware_soap_session">"314455dbd2eaafd7d76b3b7828f0a3e3956450f9"</cookie>
        </cookies><host name="insect.mm.fcix.net" port="443" /></source></disk>

@meinaLi meinaLi requested a review from chloerh April 15, 2025 02:29
Copy link
Copy Markdown
Contributor

@chloerh chloerh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Approved.

@meinaLi
Copy link
Copy Markdown
Contributor Author

meinaLi commented Apr 24, 2025

@Yingshun Can you help review this PR? It's related to tp-libvirt PR which is in reviewing. This one need to be merged early than others. Thanks.

@Yingshun Yingshun merged commit 9cbead0 into avocado-framework:master Apr 28, 2025
50 checks passed
@meinaLi meinaLi deleted the ssh_disk branch June 26, 2025 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants