mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
Remove libvirt/virt content (#14)
This content has been moved to: https://github.com/ansible-collections/libvirt
This commit is contained in:
parent
8532c595fd
commit
0ffe9fa6c4
22 changed files with 0 additions and 2416 deletions
|
@ -1,6 +0,0 @@
|
|||
shippable/posix/group1
|
||||
skip/aix
|
||||
skip/freebsd
|
||||
skip/osx
|
||||
needs/privileged
|
||||
destructive
|
|
@ -1,9 +0,0 @@
|
|||
<network>
|
||||
<name>foobar</name>
|
||||
<forward mode='nat'/>
|
||||
<ip address='192.168.125.1' netmask='255.255.255.0'>
|
||||
<dhcp>
|
||||
<range start='192.168.125.2' end='192.168.125.254'/>
|
||||
</dhcp>
|
||||
</ip>
|
||||
</network>
|
|
@ -1,85 +0,0 @@
|
|||
---
|
||||
- include_vars: '{{ item }}'
|
||||
with_first_found:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_version}}.yml"
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version}}.yml"
|
||||
- "{{ ansible_distribution }}.yml"
|
||||
- "default.yml"
|
||||
|
||||
- block:
|
||||
- name: Install libvirt packages
|
||||
package:
|
||||
name: "{{ virt_net_packages }}"
|
||||
|
||||
- name: Start libvirt
|
||||
service:
|
||||
name: libvirtd
|
||||
state: started
|
||||
|
||||
- name: Define the foobar network
|
||||
virt_net:
|
||||
command: define
|
||||
name: foobar
|
||||
xml: '{{ lookup("file", "foobar.xml") }}'
|
||||
|
||||
- name: Define the foobar network (again)
|
||||
virt_net:
|
||||
command: define
|
||||
name: foobar
|
||||
xml: '{{ lookup("file", "foobar.xml") }}'
|
||||
register: second_virt_net_define
|
||||
|
||||
- name: Start the default network
|
||||
virt_net:
|
||||
uri: qemu:///system
|
||||
command: start
|
||||
name: foobar
|
||||
|
||||
- name: Start the default network (again)
|
||||
virt_net:
|
||||
uri: qemu:///system
|
||||
command: start
|
||||
name: foobar
|
||||
register: second_virt_net_start
|
||||
|
||||
- name: Get facts for default network
|
||||
virt_net:
|
||||
uri: qemu:///system
|
||||
command: facts
|
||||
name: foobar
|
||||
register: virt_net_facts
|
||||
|
||||
- name: Destroy the foobar network
|
||||
virt_net:
|
||||
command: destroy
|
||||
name: foobar
|
||||
|
||||
- name: Undefine the foobar network
|
||||
virt_net:
|
||||
command: undefine
|
||||
name: foobar
|
||||
register: second_virt_net_define
|
||||
|
||||
- name: Undefine the foobar network (again)
|
||||
virt_net:
|
||||
command: undefine
|
||||
name: foobar
|
||||
register: second_virt_net_undefine
|
||||
|
||||
- name: Ensure the second calls return "unchanged"
|
||||
assert:
|
||||
that:
|
||||
- "second_virt_net_start is not changed"
|
||||
- "second_virt_net_define is not changed"
|
||||
- "second_virt_net_undefine is not changed"
|
||||
|
||||
always:
|
||||
- name: Stop libvirt
|
||||
service:
|
||||
name: libvirtd
|
||||
state: stopped
|
||||
|
||||
- name: Remove only the libvirt packages
|
||||
package:
|
||||
name: "{{ virt_net_packages|select('match', '.*libvirt.*')|list }}"
|
||||
state: absent
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
virt_net_packages:
|
||||
- libvirt-daemon
|
||||
- libvirt-daemon-system
|
||||
- python-libvirt
|
||||
- python-lxml
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
virt_net_packages:
|
||||
- libvirt
|
||||
- libvirt-daemon
|
||||
- python3-libvirt
|
||||
- python3-lxml
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
virt_net_packages:
|
||||
- libvirt
|
||||
- libvirt-daemon
|
||||
- libvirt-python
|
||||
- python-lxml
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
virt_net_packages:
|
||||
- libvirt
|
||||
- libvirt-daemon
|
||||
- python3-libvirt
|
||||
- python3-lxml
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
virt_net_packages:
|
||||
- libvirt-daemon
|
||||
- python-libvirt
|
||||
- python-lxml
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
virt_net_packages:
|
||||
- libvirt-daemon
|
||||
- python-libvirt
|
||||
- python-lxml
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
virt_net_packages:
|
||||
- libvirt-daemon
|
||||
- libvirt-daemon-system
|
||||
- python-libvirt
|
||||
- python-lxml
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
virt_net_packages:
|
||||
- libvirt-daemon
|
||||
- python-libvirt
|
||||
- python-lxml
|
|
@ -1,69 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright: (c) 2019, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
import pytest
|
||||
|
||||
from ansible_collections.community.general.plugins.modules.cloud.misc import virt_net
|
||||
|
||||
from ansible_collections.community.general.tests.unit.compat import mock
|
||||
|
||||
|
||||
virt_net.libvirt = None
|
||||
virt_net.HAS_VIRT = True
|
||||
|
||||
|
||||
class DummyNetwork():
|
||||
def __init__(self, name, isActive=True):
|
||||
self._name = name
|
||||
self._isActive = isActive
|
||||
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
def isActive(self):
|
||||
return self._isActive
|
||||
|
||||
|
||||
class DummyLibvirtConn():
|
||||
def __init__(self):
|
||||
self._network = [
|
||||
DummyNetwork("inactive_net", isActive=False),
|
||||
DummyNetwork("active_net", isActive=True)]
|
||||
|
||||
def listNetworks(self):
|
||||
return [i.name() for i in self._network]
|
||||
|
||||
def networkLookupByName(self, name):
|
||||
for i in self._network:
|
||||
if i.name() == name:
|
||||
return i
|
||||
|
||||
def listDefinedNetworks(self):
|
||||
return []
|
||||
|
||||
|
||||
class DummyLibvirt():
|
||||
VIR_ERR_NETWORK_EXIST = 'VIR_ERR_NETWORK_EXIST'
|
||||
|
||||
@classmethod
|
||||
def open(cls, uri):
|
||||
return DummyLibvirtConn()
|
||||
|
||||
class libvirtError(Exception):
|
||||
def __init__(self):
|
||||
self.error_code
|
||||
|
||||
def get_error_code(self):
|
||||
return self.error_code
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dummy_libvirt(monkeypatch):
|
||||
monkeypatch.setattr(virt_net, 'libvirt', DummyLibvirt)
|
||||
return DummyLibvirt
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def virt_net_obj(dummy_libvirt):
|
||||
return virt_net.VirtNetwork('qemu:///nowhere', mock.MagicMock())
|
|
@ -1,30 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright: (c) 2019, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
from ansible_collections.community.general.tests.unit.compat import mock
|
||||
|
||||
|
||||
def test_virt_net_create_already_active(virt_net_obj, dummy_libvirt):
|
||||
virt_net_obj.conn.create = mock.Mock()
|
||||
assert virt_net_obj.create("active_net") is None
|
||||
virt_net_obj.conn.create.assert_not_called()
|
||||
|
||||
|
||||
def test_virt_net_recreate(virt_net_obj, dummy_libvirt):
|
||||
virt_net_obj.conn.create = mock.Mock()
|
||||
dummy_libvirt.libvirtError.error_code = 'VIR_ERR_NETWORK_EXIST'
|
||||
virt_net_obj.conn.create.side_effect = dummy_libvirt.libvirtError
|
||||
assert virt_net_obj.create("active_net") is None
|
||||
|
||||
|
||||
def test_virt_stop_ignore_inactive(virt_net_obj):
|
||||
virt_net_obj.conn.destroy = mock.Mock()
|
||||
virt_net_obj.stop('inactive_net')
|
||||
virt_net_obj.conn.destroy.assert_not_called()
|
||||
|
||||
|
||||
def test_virt_stop_active(virt_net_obj, monkeypatch):
|
||||
virt_net_obj.conn.destroy = mock.Mock()
|
||||
virt_net_obj.stop('active_net')
|
||||
virt_net_obj.conn.destroy.assert_called_with('active_net')
|
Loading…
Add table
Add a link
Reference in a new issue