From 8051c02d247681201dd56af65fa1f563094adaaa Mon Sep 17 00:00:00 2001 From: Andy Fiddaman Date: Mon, 22 Aug 2022 11:51:18 +0000 Subject: [PATCH] Add network tests for illumos --- cloudinit/distros/illumos.py | 7 +++++-- test/README | 3 +++ test/cloud-init/meta-data | 2 ++ test/cloud-init/meta-data~ | 2 ++ test/cloud-init/network-config | 14 ++++++++++++++ test/cloud-init/user-data | 20 ++++++++++++++++++++ test/cloud-init/user-data~ | 16 ++++++++++++++++ test/cloud-init/vendor-data | 0 test/cloudinit | 1 + 9 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 test/README create mode 100644 test/cloud-init/meta-data create mode 100644 test/cloud-init/meta-data~ create mode 100644 test/cloud-init/network-config create mode 100644 test/cloud-init/user-data create mode 100644 test/cloud-init/user-data~ create mode 100644 test/cloud-init/vendor-data create mode 120000 test/cloudinit diff --git a/cloudinit/distros/illumos.py b/cloudinit/distros/illumos.py index 85d808aa3e9..018eca28ba5 100644 --- a/cloudinit/distros/illumos.py +++ b/cloudinit/distros/illumos.py @@ -58,7 +58,7 @@ def manage_service(self, action, service): cmd = ['svcs', '-H', '-o', 'state', service] try: (out, err) = subp.subp(cmd, capture=True) - except ProcessExecutionError: + except subp.ProcessExecutionError: # Pass back to caller raise @@ -71,7 +71,7 @@ def manage_service(self, action, service): # Callers do not actually check the exit status unless # distro.uses_systemd() is True but exit code 3 would mean # 'not running', so we use that. - raise ProcessExecutionError( + raise subp.ProcessExecutionError( cmd=cmd, stdout=out, stderr=err, exit_code=3 ) @@ -285,5 +285,8 @@ def apply_locale(self, locale, out_fn=None): def set_timezone(self, tz): self._update_init('TZ', tz) + def chpasswd(self, plist_in: list, hashed: bool): + for name, password in plist_in: + self.set_passwd(name, password, hashed=hashed) # vim:ts=4:sw=4:et:fdm=marker diff --git a/test/README b/test/README new file mode 100644 index 00000000000..cb2b6310048 --- /dev/null +++ b/test/README @@ -0,0 +1,3 @@ + +zadm set citest cloud-init=http://172.27.10.254/cloudinit/ + diff --git a/test/cloud-init/meta-data b/test/cloud-init/meta-data new file mode 100644 index 00000000000..78c08ae193f --- /dev/null +++ b/test/cloud-init/meta-data @@ -0,0 +1,2 @@ +instance-id: 40d84db8-bf08-48b9-c347-fb436d131bb1 +local-hostname: test diff --git a/test/cloud-init/meta-data~ b/test/cloud-init/meta-data~ new file mode 100644 index 00000000000..78c08ae193f --- /dev/null +++ b/test/cloud-init/meta-data~ @@ -0,0 +1,2 @@ +instance-id: 40d84db8-bf08-48b9-c347-fb436d131bb1 +local-hostname: test diff --git a/test/cloud-init/network-config b/test/cloud-init/network-config new file mode 100644 index 00000000000..7c86d6f7f7d --- /dev/null +++ b/test/cloud-init/network-config @@ -0,0 +1,14 @@ +ethernets: + bob3: + addresses: + - 10.0.0.5/25 + gateway4: 10.0.0.127 + match: + macaddress: 02:08:20:7c:68:7a + nameservers: + addresses: + - 1.1.1.1 + - 9.9.9.9 + search: omnios.org + set-name: bob3 +version: 2 diff --git a/test/cloud-init/user-data b/test/cloud-init/user-data new file mode 100644 index 00000000000..75c104ab31d --- /dev/null +++ b/test/cloud-init/user-data @@ -0,0 +1,20 @@ +#cloud-config +chpasswd: + expire: false +disable_root: false +hostname: test +password: $6$SEeDRaFR$CI8Y/wfMXioIWlrtTLs75iOA4m/./1Vu78d5Plhk6N/T.yctR/s8ojMIjIhyIJB8lwYJAlQXi5GBuh4O0gjY5/ +ssh-pwauth: true +ssh_authorized_keys: +- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKi3Xy6qla2g7wH5b1t+6nDi99D/Unl9Hqpi7j4acP8s + cinit +users: +- default +- name: root + ssh_authorized_keys: + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKi3Xy6qla2g7wH5b1t+6nDi99D/Unl9Hqpi7j4acP8s + cinit +packages: + - system/cpuid + - [system/pciutils, 3.7.0] +package_reboot_if_required: false diff --git a/test/cloud-init/user-data~ b/test/cloud-init/user-data~ new file mode 100644 index 00000000000..6827117c521 --- /dev/null +++ b/test/cloud-init/user-data~ @@ -0,0 +1,16 @@ +#cloud-config +chpasswd: + expire: false +disable_root: false +hostname: test +password: $6$SEeDRaFR$CI8Y/wfMXioIWlrtTLs75iOA4m/./1Vu78d5Plhk6N/T.yctR/s8ojMIjIhyIJB8lwYJAlQXi5GBuh4O0gjY5/ +ssh-pwauth: true +ssh_authorized_keys: +- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKi3Xy6qla2g7wH5b1t+6nDi99D/Unl9Hqpi7j4acP8s + cinit +users: +- default +- name: root + ssh_authorized_keys: + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKi3Xy6qla2g7wH5b1t+6nDi99D/Unl9Hqpi7j4acP8s + cinit diff --git a/test/cloud-init/vendor-data b/test/cloud-init/vendor-data new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/cloudinit b/test/cloudinit new file mode 120000 index 00000000000..992a1c2a4ea --- /dev/null +++ b/test/cloudinit @@ -0,0 +1 @@ +cloud-init \ No newline at end of file