From a0375d387fe2e5a626905212b137cbca9aed71e8 Mon Sep 17 00:00:00 2001 From: Stacy Smith Date: Wed, 26 Jul 2017 15:36:41 -0600 Subject: [PATCH 1/3] Add vmhost parameter to SW.install() to support upgrading the VM Host. Initial support for upgrading vmhost. --- lib/jnpr/junos/utils/sw.py | 97 ++++++++++++++++++++++++++------------ 1 file changed, 68 insertions(+), 29 deletions(-) diff --git a/lib/jnpr/junos/utils/sw.py b/lib/jnpr/junos/utils/sw.py index 3605f20c7..c31176d0a 100644 --- a/lib/jnpr/junos/utils/sw.py +++ b/lib/jnpr/junos/utils/sw.py @@ -192,17 +192,27 @@ def put(self, package, remote_path='/var/tmp', progress=None): # pkgadd - used to perform the 'request system software add ...' # ------------------------------------------------------------------------- - def pkgadd(self, remote_package, **kvargs): + def pkgadd(self, remote_package, vmhost=False, **kvargs): """ - Issue the 'request system software add' command on the package. - The "no-validate" options is set by default. If you want to validate - the image, do that using the specific :meth:`validate` method. Also, - if you want to reboot the device, suggest using the :meth:`reboot` - method rather ``reboot=True``. + Issue the RPC equivalent of the 'request system software add' command + or the 'request vmhost software add' command on the package. + If vhmhost=False, the RPC is used and the + The "no-validate" options is set. If you want to validate + the image, do that using the specific :meth:`validate` method. + If vmhost=True, the RPC is used. + + If you want to reboot the device, invoke the :meth:`reboot` method + after installing the software rather than passing the ``reboot=True`` + parameter. :param str remote_package: The file-path to the install package on the remote (Junos) device. + + :param bool vhmhost: + (Optional) A boolean indicating if this is a software update of the + vhmhost. The default is ``vmhost=False``. + :param dict kvargs: Any additional parameters to the 'request' command can be passed within **kvargs**, following the RPC syntax @@ -211,18 +221,23 @@ def pkgadd(self, remote_package, **kvargs): .. warning:: Refer to the restrictions listed in :meth:`install`. """ - if isinstance(remote_package, (list, tuple)) and self._mixed_VC: - args = dict(no_validate=True, set=remote_package) + if vmhost is False: + if isinstance(remote_package, (list, tuple)) and self._mixed_VC: + args = dict(no_validate=True, set=remote_package) + else: + args = dict(no_validate=True, package_name=remote_package) + args.update(kvargs) + rsp = self.rpc.request_package_add(**args) else: - args = dict(no_validate=True, package_name=remote_package) - args.update(kvargs) + rsp = self.rpc.request_vmhost_package_add( + package_name=remote_package, + **kvargs) - rsp = self.rpc.request_package_add(**args) return self._parse_pkgadd_response(rsp) - # ------------------------------------------------------------------------- - # pkgaddNSSU - used to perform NSSU upgrade - # ------------------------------------------------------------------------- + # ------------------------------------------------------------------------- + # pkgaddNSSU - used to perform NSSU upgrade + # ------------------------------------------------------------------------- def pkgaddNSSU(self, remote_package, **kvargs): """ @@ -241,17 +256,32 @@ def pkgaddNSSU(self, remote_package, **kvargs): # pkgaddISSU - used to perform ISSU upgrade # ------------------------------------------------------------------------- - def pkgaddISSU(self, remote_package, **kvargs): + def pkgaddISSU(self, remote_package, vmhost=False, **kvargs): """ - Issue the 'request system software nonstop-upgrade' command on the - package. + Issue the RPC equivalent of the + 'request system software in-service-upgrade' command + or the 'request vmhost software in-service-upgrade' command on the + package. If vhmhost=False, the + RPC is used. If vmhost=True, the + RPC is used. :param str remote_package: The file-path to the install package on the remote (Junos) device. + + + :param bool vhmhost: + (Optional) A boolean indicating if this is a software update of the + vhmhost. The default is ``vmhost=False``. """ - rsp = self.rpc.request_package_in_service_upgrade( - package_name=remote_package, **kvargs) + if vmhost is False: + rsp = self.rpc.request_package_in_service_upgrade( + package_name=remote_package, + **kvargs) + else: + rsp = self.rpc.request_vmhost_package_in_service_upgrade( + package_name=remote_package, + **kvargs) return self._parse_pkgadd_response(rsp) def _parse_pkgadd_response(self, rsp): @@ -596,7 +626,7 @@ def install(self, package=None, pkg_set=None, remote_path='/var/tmp', no_copy=False, issu=False, nssu=False, timeout=1800, cleanfs_timeout=300, checksum_timeout=300, checksum_algorithm='md5', force_copy=False, all_re=True, - **kwargs): + vmhost=False, **kwargs): """ Performs the complete installation of the **package** that includes the following steps: @@ -747,6 +777,10 @@ def myprogress(dev, report): all Routing Engines of the Junos device. When ``False`` if the only preform the software install on the current Routing Engine. + :param bool vhmhost: + (Optional) A boolean indicating if this is a software update of the + vhmhost. The default is ``vmhost=False``. + :param kwargs **kwargs: (Optional) Additional keyword arguments are passed through to the "package add" RPC. @@ -816,15 +850,20 @@ def _progress(report): if len(remote_pkg_set) == 1: remote_package = remote_pkg_set[0] # validate can't be used in the case of a Mixed VC - if validate is True and self._mixed_VC is False: - _progress( - "validating software against current config," - " please be patient ...") - v_ok = self.validate(remote_package, issu, nssu, - dev_timeout=timeout) - - if v_ok is not True: - return v_ok + # With vmhost=True, validate is handled in the package add. + if validate is True: + if self._mixed_VC is False and vmhost is not True: + _progress( + "validating software against current config," + " please be patient ...") + v_ok = self.validate(remote_package, issu, nssu, + dev_timeout=timeout) + if v_ok is not True: + return v_ok + else: + if vmhost is True: + # Need to pass the no_validate option via kwargs. + kwargs.update({'no_validate': True}) if issu is True: _progress( From ac127989d7fdc8fcfd16f4ee88a596b70ab2db72 Mon Sep 17 00:00:00 2001 From: Stacy Smith Date: Thu, 27 Jul 2017 13:49:17 -0600 Subject: [PATCH 2/3] Forgot to pass new vmhost parameter to pkg add functions. --- lib/jnpr/junos/utils/sw.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/jnpr/junos/utils/sw.py b/lib/jnpr/junos/utils/sw.py index c31176d0a..d60b4214e 100644 --- a/lib/jnpr/junos/utils/sw.py +++ b/lib/jnpr/junos/utils/sw.py @@ -869,6 +869,7 @@ def _progress(report): _progress( "ISSU: installing software ... please be patient ...") return self.pkgaddISSU(remote_package, + vmhost=vmhost, dev_timeout=timeout, **kwargs) elif nssu is True: _progress( @@ -880,6 +881,7 @@ def _progress(report): _progress("installing software ... please be patient ...") add_ok = self.pkgadd( remote_package, + vmhost = vmhost, dev_timeout=timeout, **kwargs) return add_ok @@ -898,6 +900,7 @@ def _progress(report): "be patient ...".format(vc_id)) ok &= self.pkgadd( remote_package, + vmhost=vmhost, member=vc_id, dev_timeout=timeout, **kwargs) @@ -910,6 +913,7 @@ def _progress(report): "installing software on RE0 ... please be patient ...") ok &= self.pkgadd( remote_package, + vmhost = vmhost, re0=True, dev_timeout=timeout, **kwargs) @@ -917,6 +921,7 @@ def _progress(report): "installing software on RE1 ... please be patient ...") ok &= self.pkgadd( remote_package, + vmhost = vmhost, re1=True, dev_timeout=timeout, **kwargs) @@ -924,7 +929,10 @@ def _progress(report): elif len(remote_pkg_set) > 1 and self._mixed_VC: _progress("installing software ... please be patient ...") - add_ok = self.pkgadd(remote_pkg_set, dev_timeout=timeout, **kwargs) + add_ok = self.pkgadd(remote_pkg_set, + vmhost=vmhost, + dev_timeout=timeout, + **kwargs) return add_ok # ------------------------------------------------------------------------- From 1c9446bd13d5419a980a2a2c1b276fbba3d324ba Mon Sep 17 00:00:00 2001 From: Stacy Smith Date: Wed, 16 Aug 2017 10:55:34 -0600 Subject: [PATCH 3/3] PEP8 cleanup and unit tests. --- lib/jnpr/junos/utils/sw.py | 22 +- .../rpc-reply/request-vmhost-package-add.xml | 246 ++++++++++++++++++ tests/unit/utils/test_sw.py | 28 +- 3 files changed, 282 insertions(+), 14 deletions(-) create mode 100644 tests/unit/utils/rpc-reply/request-vmhost-package-add.xml diff --git a/lib/jnpr/junos/utils/sw.py b/lib/jnpr/junos/utils/sw.py index d60b4214e..907d2bcff 100644 --- a/lib/jnpr/junos/utils/sw.py +++ b/lib/jnpr/junos/utils/sw.py @@ -679,21 +679,21 @@ def install(self, package=None, pkg_set=None, remote_path='/var/tmp', to reboot the device. :param str package: - Either the full file path to the install package tarball on the local - (PyEZ host's) filesystem OR a URL (from the target device's - perspcective) from which the device retrieves installed. When the + Either the full file path to the install package tarball on the local + (PyEZ host's) filesystem OR a URL (from the target device's + perspcective) from which the device retrieves installed. When the value is a URL, then the :no_copy: and :remote_path: values are unused. The acceptable formats for a URL value may be found at: https://www.juniper.net/documentation/en_US/junos/topics/concept/junos-software-formats-filenames-urls.html :param list pkg_set: - A list/tuple of :package: values which will be installed on a mixed VC - setup. + A list/tuple of :package: values which will be installed on a mixed + VC setup. :param str remote_path: If the value of :package: or :pkg_set: is a file path on the local - (PyEZ host's) filesystem, then the image is copied from the local - filesystem to the :remote_path: directory on the target Junos + (PyEZ host's) filesystem, then the image is copied from the local + filesystem to the :remote_path: directory on the target Junos device. The default is ``/var/tmp``. If the value of :package: or :pkg_set: is a URL, then the value of :remote_path: is unused. @@ -729,7 +729,7 @@ def myprogress(dev, report): directory of the target Junos device. When the value of :no_copy: is ``False`` (the default), then the package is copied from the local PyEZ host to the :remote_path: directory of the target Junos device. - If the value of :package: or :pkg_set: is a URL, then the value of + If the value of :package: or :pkg_set: is a URL, then the value of :no_copy: is unused. :param bool issu: @@ -881,7 +881,7 @@ def _progress(report): _progress("installing software ... please be patient ...") add_ok = self.pkgadd( remote_package, - vmhost = vmhost, + vmhost=vmhost, dev_timeout=timeout, **kwargs) return add_ok @@ -913,7 +913,7 @@ def _progress(report): "installing software on RE0 ... please be patient ...") ok &= self.pkgadd( remote_package, - vmhost = vmhost, + vmhost=vmhost, re0=True, dev_timeout=timeout, **kwargs) @@ -921,7 +921,7 @@ def _progress(report): "installing software on RE1 ... please be patient ...") ok &= self.pkgadd( remote_package, - vmhost = vmhost, + vmhost=vmhost, re1=True, dev_timeout=timeout, **kwargs) diff --git a/tests/unit/utils/rpc-reply/request-vmhost-package-add.xml b/tests/unit/utils/rpc-reply/request-vmhost-package-add.xml new file mode 100644 index 000000000..be3ab1127 --- /dev/null +++ b/tests/unit/utils/rpc-reply/request-vmhost-package-add.xml @@ -0,0 +1,246 @@ + + + Junos Validation begin. Procedure will take few minutes. + Initializing... + Verified os-libs-10-x86-64-20170607 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting os-libs-10-x86-64-20170607.351421_builder_stable_10 + Verified os-runtime-x86-64-20170607 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting os-runtime-x86-64-20170607.351421_builder_stable_10 + Verified os-zoneinfo-x86-64-20170607 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting os-zoneinfo-x86-64-20170607.351421_builder_stable_10 + Verified os-libs-compat32-10-x86-64-20170607 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting os-libs-compat32-10-x86-64-20170607.351421_builder_stable_10 + Verified os-compat32-x86-64-20170607 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting os-compat32-x86-64-20170607.351421_builder_stable_10 + Verified py-base-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting py-base-x86-32-20170630.054423_builder_junos_151_f6_s7 + Verified os-vmguest-x86-64-20170607 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting os-vmguest-x86-64-20170607.351421_builder_stable_10 + Verified os-crypto-x86-64-20170607 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting os-crypto-x86-64-20170607.351421_builder_stable_10 + Verified junos-net-prd-x86-64-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting junos-net-prd-x86-64-20170630.054423_builder_junos_151_f6_s7 + Verified junos-modules-x86-64-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting junos-modules-x86-64-20170630.054423_builder_junos_151_f6_s7 + Verified junos-libs-compat32-x86-64-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting junos-libs-compat32-x86-64-20170630.054423_builder_junos_151_f6_s7 + Verified junos-runtime-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting junos-runtime-x86-32-20170630.054423_builder_junos_151_f6_s7 + Verified junos-platform-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting junos-platform-x86-32-20170630.054423_builder_junos_151_f6_s7 + Verified junos-libs-x86-64-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting junos-libs-x86-64-20170630.054423_builder_junos_151_f6_s7 + Verified junos-dp-crypto-support-mtx-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting junos-dp-crypto-support-mtx-x86-32-20170630.054423_builder_junos_151_f6_s7 + Verified junos-daemons-x86-64-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting junos-daemons-x86-64-20170630.054423_builder_junos_151_f6_s7 + Verified jservices-voice-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-ssl-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-sfw-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-rpm-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-ptsp-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-nat-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-mss-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-mobile-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-llpdf-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-jflow-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-ipsec-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-idp-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-hcm-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-crypto-base-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-cpcd-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-cos-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-bgf-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-appid-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-alg-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jservices-aacl-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Verified jpfe-common-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting jpfe-common-x86-32-20170630.054423_builder_junos_151_f6_s7 + Verified jdocs-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting jdocs-x86-32-20170630.054423_builder_junos_151_f6_s7 + Verified fips-mode-x86-32-20170630 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Mounting fips-mode-x86-32-20170630.054423_builder_junos_151_f6_s7 + Hardware Database regeneration succeeded + Validating against /config/juniper.conf.gz + mgd: commit complete + Validation succeeded + + + + + + + hup + + + + Verified junos-vmhost-install-ptx-x86-64-15.1F6-S7.2 signed by PackageProductionEc_2017 method ECDSA256+SHA256 + Copied the config and other data to the aux disk. + Transfer junos-host-upgrade.sh + Transfer Done + Transfer /packages/db/pkginst.69723/junos-vmhost-install*.tgz + Transfer Done + Starting upgrade ... + Preparing for upgrade... + /tmp/pkg-QWC/unpack/install/ + tar --directory=/tmp/pkg-QWC/unpack/install/ -xvf /tmp/install.tgz + ./ + ./vm/ + ./vm/re_fpga-1.0-0.x86_64.rpm + ./vm/vsmartd-1.0-0.x86_64.rpm + ./vm/grub.cfg.ngre + ./vm/resild-1.0-0.x86_64.rpm + ./vm/note + ./junos/ + ./junos/junos-mtre-install.sh + ./junos/junos-mtre-upgrade.sh + ./vmhost/ + ./vmhost/vmhost-x86_64-15.1F6-S7-20170608_0128_builder.img.gz + ./vmhost/README + ./vmhost-core-x86_64-15.1F6-S7-20170608_0128_builder.tgz + ./vmhost-version.sh + ./vmhost-pkgs-version + ./hostd/ + ./hostd/jhost_core-1.0-1706080443.x86_64.rpm + ./hostd/vehostd-note.txt + ./hostd/vehostd-ovp-install.sh + ./vmhost-version + ./scripts/ + ./scripts/mount-usb-img.sh + ./scripts/target-scripts/ + ./scripts/target-scripts/mk-mtre-rollback.sh + ./scripts/target-scripts/savelog + ./scripts/target-scripts/mk-mtre-zeroize.sh + ./scripts/target-scripts/vmhost-partition.inc + ./scripts/target-scripts/02setmac.sh + ./scripts/target-scripts/S05rootunion.sh + ./scripts/target-scripts/S05ovprootrwS.sh + ./scripts/target-scripts/S05ovprootrw.sh + ./scripts/target-scripts/vmhost-kdump.inc + ./scripts/target-scripts/mtre-ssd-version.sh + ./scripts/target-scripts/mk-mtre-partition.sh + ./scripts/target-scripts/vmhost-kdump-configure + ./scripts/target-scripts/vmhost-kdump-process.sh + ./scripts/target-scripts/mtre-ssd-snapshot.sh + ./scripts/target-scripts/01vehostd_setup.sh + ./scripts/target-scripts/gt-mtre-version.sh + ./scripts/target-scripts/platfom_specific_init + ./scripts/target-scripts/mtre-ssd-zeroize.sh + ./scripts/target-scripts/S05rootunionS.sh + ./scripts/target-scripts/mk-mtre-snapshot.sh + ./scripts/target-scripts/03boot_info.sh + ./scripts/target-scripts/vmhost-misc.inc + ./scripts/target-scripts/01boot_setup.sh + ./scripts/target-scripts/vmhost-kdump-input.sh + ./scripts/target-scripts/mtre-ssd-rollback.sh + ./scripts/target-scripts/S08jhostrpminstall.sh + ./scripts/target-scripts/vmhost_version_get_major.sh + ./scripts/target-scripts/vmhost-kdump-usb-format.sh + ./scripts/target-scripts/00read_only_root.sh + ./scripts/target-scripts/S04modutilsPost.sh + ./scripts/target-scripts/00junos_setup.sh + ./scripts/target-scripts/rc.local + ./scripts/mk-mtre-partition.sh + ./scripts/ddimage + ./scripts/mtre-installer.sh + ./scripts/mtre-ssd-installer.sh + ./scripts/mk-mtre-upgrade.sh + ./scripts/ssd-ovp-installer.sh + ./scripts/grub.cfg.ngre + ./scripts/mk-part-mtre-install.sh + ./scripts/mtre-ssd-upgrade.sh + ./bin/ + ./bin/telnet.netkit + junos/ + junos/junos-install-x86-64-15.1F6-S7.2.img.gz + /tmp/pkg-QWC/unpack/install// + sh /tmp/pkg-QWC/unpack/install///scripts/mtre-ssd-upgrade.sh /tmp/pkg-QWC/unpack/install// + Current root details, Device sda, Label: jrootb_P, Partition: sda4 + Copying /tmp/pkg-QWC/unpack/install///vmhost/vmhost-x86_64-15.1F6-S7-20170608_0128_builder.img.gz to tmp dir: /tmp/install-31a ... + Testing /tmp/install-31a/vmhost-x86_64-15.1F6-S7-20170608_0128_builder.img.gz for compression ... + Uncompressing Linux: /tmp/install-31a/vmhost-x86_64-15.1F6-S7-20170608_0128_builder.img.gz ... + Image details + ============= + image: '/tmp/install-31a/vmhost-x86_64-15.1F6-S7-20170608_0128_builder.img' + size: 1998585856 bytes + modified: 2017-08-16 16:39:22.462996193 +0200 + type: x86 boot sector + + Finding alternate root for upgrade + Upgrading software on jrootp_P ... + Inputs: jrootp_P p /dev/sda /tmp/install-31a/vmhost-x86_64-15.1F6-S7-20170608_0128_builder.img P /tmp/pkg-QWC/unpack/install// + + Mounting images and device in preparation for upgrade... + USBIMG_BOOT_OFFSET: 1048576, USBIMG_BOOT_SIZELIMIT: 134217728, USBIMG_ROOT_OFFSET: 135266304, USBIMG_ROOT_SIZELIMIT: 1863319552 + Cleaning target ROOTFS jrootp_P + Copying ROOTFS files... + Upgrading administrative Junos context ... + Testing /tmp/partdisk-cfO/jlvmjunosfs/Current.p/junos-install-x86-64-15.1F6-S7.2.img.gz for compression ... + Uncompressing Junos: /tmp/partdisk-cfO/jlvmjunosfs/Current.p/junos-install-x86-64-15.1F6-S7.2.img.gz ... + Done with Junos Upgrade + Upgrading hostd content ... + ./ + ./rasdaemon_install.sh + ./i40e_pkg_install.sh + ./resild_install.sh + ./jhost_core-1.0-1706080443.x86_64.rpm + ./re_fpga-1.0-0.x86_64.rpm + ./i40e_pkg-1.0-0.x86_64.rpm + ./bios_pkg-1.0-0.x86_64.rpm + ./vsmartd-1.0-0.x86_64.rpm + ./monit_install.sh + ./vmhost-version.sh + ./vmhost-version + ./vmhost-firmware-x86_64-15.1F6-S7-20170608_0128_builder.tar + ./vsmartd_install.sh + ./rasdaemon-0.5.6-1.x86_64.rpm + ./bios_pkg_install.sh + ./vehostd_install.sh + ./resild-1.0-0.x86_64.rpm + ./monit-5.12.2-1.x86_64.rpm + ./re_fpga_install.sh + Copying /tmp/partdisk-cfO/unpack/jhost_core-1.0-1706080443.x86_64.rpm to /tmp/partdisk-cfO/jrootfs/hostd ... + Installing Hostd image jhost_core-1.0-1706080443.x86_64.rpm ... + rpm -ivh --prefix=/tmp/partdisk-cfO/jrootfs/ --nodeps --dbpath=/tmp/partdisk-cfO/jrootfs//var/lib/rpm /tmp/partdisk-cfO/unpack/jhost_core-1.0-1706080443.x86_64.rpm + Preparing... ################################################## + jhost_core ################################################## + Please wait while configuration is in progress... + Installation successful... + Done with hostd Install + rpm -ivh --prefix=/tmp/partdisk-cfO/jrootfs --nodeps --dbpath=/tmp/partdisk-cfO/jrootfs/var/lib/rpm /tmp/partdisk-cfO/unpack/re_fpga-1.0-0.x86_64.rpm + Preparing... ################################################## + preparing install ... + re_fpga ################################################## + adding module to kernel... + rpm -ivh --prefix=/tmp/partdisk-cfO/jrootfs --nodeps --dbpath=/tmp/partdisk-cfO/jrootfs/var/lib/rpm /tmp/partdisk-cfO/unpack/vsmartd-1.0-0.x86_64.rpm + Preparing... ################################################## + preparing install ... + vsmartd ################################################## + adding module to kernel... + rpm -ivh --prefix=/tmp/partdisk-cfO/jrootfs --nodeps --dbpath=/tmp/partdisk-cfO/jrootfs/var/lib/rpm /tmp/partdisk-cfO/unpack/resild-1.0-0.x86_64.rpm + Preparing... ################################################## + preparing install ... + resild ################################################## + adding module to kernel... + rpm -ivh --prefix=/tmp/partdisk-cfO/jrootfs --nodeps --dbpath=/tmp/partdisk-cfO/jrootfs/var/lib/rpm /tmp/partdisk-cfO/unpack/rasdaemon-0.5.6-1.x86_64.rpm + Preparing... ################################################## + rasdaemon ################################################## + Installing Monit image monit-5.12.2-1.x86_64.rpm ... + rpm -ivh --prefix=/tmp/partdisk-cfO/jrootfs/ --nodeps --dbpath=/tmp/partdisk-cfO/jrootfs//var/lib/rpm /tmp/partdisk-cfO/unpack/monit-5.12.2-1.x86_64.rpm + Preparing... ################################################## + monit ################################################## + Installation successful... + Done with Monit Install... + Target kernel version: 3.10.79-ovp-rt74-WR6.0.0.20_preempt-rt + Creating moint points for JUNOSFS and VMFS: /junos, /vm + Updating boot partition... + Upgrade complete. + Cmos Write successfull + Cmos Write successfull for Boot_retry + Cmos Write successfull for Boot_retry + ... upgrade complete. + A REBOOT IS REQUIRED TO LOAD THIS SOFTWARE CORRECTLY. + Use the 'request vmhost reboot' command to reboot the system. + + 0 + diff --git a/tests/unit/utils/test_sw.py b/tests/unit/utils/test_sw.py index 4f3521150..1e3d7d364 100644 --- a/tests/unit/utils/test_sw.py +++ b/tests/unit/utils/test_sw.py @@ -170,7 +170,7 @@ def test_sw_install_url_in_pkg_set(self, mock_md5, mock_execute): mock_md5.return_value = '96a35ab371e1ca10408c3caecdbd8a67' mock_execute.side_effect = self._mock_manager self.sw.put = MagicMock() - self.sw._mixed_VC=True + self.sw._mixed_VC = True self.assertTrue(self.sw.install( pkg_set=['safecopy.tgz', 'safecopy.tgz', 'ftp://server/path/test.tgz'])) @@ -485,6 +485,12 @@ def test_sw_remote_checksum_sha256(self, mock_execute): self.sw.remote_checksum(package, algorithm='sha256'), '27bccf64babe4ea6687d3461e6d724d165aa140933e77b582af615dad4f02170') + def test_sw_remote_checksum_unknown_alg(self): + self.assertRaises(ValueError, + self.sw.remote_checksum, + 'foo.tgz', + algorithm='foo') + @patch('jnpr.junos.Device.execute') def test_sw_safe_copy(self, mock_execute): mock_execute.side_effect = self._mock_manager @@ -615,8 +621,14 @@ def test_sw_install_multi_vc_mode_disabled(self, mock_pkgadd): sw = self.get_sw() sw.install(package='abc.tgz', no_copy=True) self.assertFalse(sw._multi_VC) - calls = [call('/var/tmp/abc.tgz', dev_timeout=1800, re0=True), - call('/var/tmp/abc.tgz', dev_timeout=1800, re1=True)] + calls = [call('/var/tmp/abc.tgz', + dev_timeout=1800, + vmhost=False, + re0=True), + call('/var/tmp/abc.tgz', + dev_timeout=1800, + re1=True, + vmhost=False)] mock_pkgadd.assert_has_calls(calls) @patch('jnpr.junos.utils.sw.SW.pkgadd') @@ -672,6 +684,12 @@ def test_sw_install_mixed_vc_ValueError(self, mock_pkgadd): def test_sw_install_mixed_vc_TypeError(self, mock_pkgadd): self.assertRaises(TypeError, self.sw.install, cleanfs=False) + @patch('jnpr.junos.Device.execute') + def test_sw_install_vmhost(self, mock_execute): + mock_execute.side_effect = self._mock_manager + package = 'test.tgz' + self.assertTrue(self.sw.install(package, no_copy=True, vmhost=True)) + @patch('jnpr.junos.Device.execute') def test_sw_install_kwargs_force_host(self, mock_execute): self.sw.install('file', no_copy=True, force_host=True) @@ -863,3 +881,7 @@ def _mock_manager(self, *args, **kwargs): return self._read_file('request-reboot-at.xml') else: return self._read_file(args[0].tag + '.xml') + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(TestSW) + unittest.TextTestRunner(verbosity=2).run(suite)