MCPcopy Index your code
hub / github.com/saltstack/salt / install

Method install

salt/utils/win_update.py:763–883  ·  view source on GitHub ↗

Install the updates passed in the updates collection. Load the updates collection using the ``search`` or ``available`` functions. If the updates need to be downloaded, use the ``download`` function. Args: updates (Updates): An instance

(self, updates)

Source from the content-addressed store, hash-verified

761 return ret
762
763 def install(self, updates):
764 """
765 Install the updates passed in the updates collection. Load the updates
766 collection using the ``search`` or ``available`` functions. If the
767 updates need to be downloaded, use the ``download`` function.
768
769 Args:
770
771 updates (Updates):
772 An instance of the Updates class containing a the updates to be
773 installed.
774
775 Returns:
776 dict: A dictionary containing the results of the installation
777
778 Code Example:
779
780 .. code-block:: python
781
782 import salt.utils.win_update
783 wua = salt.utils.win_update.WindowsUpdateAgent()
784
785 # install KB3195454
786 updates = wua.search('KB3195454')
787 results = wua.download(updates)
788 results = wua.install(updates)
789 """
790 # Check for empty list
791 if updates.count() == 0:
792 ret = {"Success": False, "Updates": "Nothing to install"}
793 return ret
794
795 installer = self._session.CreateUpdateInstaller()
796 self._session.ClientApplicationID = "Salt: Install Update"
797 with salt.utils.winapi.Com():
798 install_list = win32com.client.Dispatch("Microsoft.Update.UpdateColl")
799
800 ret = {"Updates": {}}
801
802 # Check for updates that aren't already installed
803 for update in updates.updates:
804
805 # Define uid to keep the lines shorter
806 uid = update.Identity.UpdateID
807 ret["Updates"][uid] = {}
808 ret["Updates"][uid]["Title"] = update.Title
809 ret["Updates"][uid]["AlreadyInstalled"] = bool(update.IsInstalled)
810
811 # Make sure the update has actually been installed
812 if not salt.utils.data.is_true(update.IsInstalled):
813 log.debug("To Be Installed: %s", uid)
814 log.debug("\tTitle: %s", update.Title)
815 install_list.Add(update)
816
817 # Check the install list
818 if install_list.Count == 0:
819 ret = {"Success": True, "Updates": "Nothing to install"}
820 return ret

Callers 5

getFunction · 0.95
listFunction · 0.95
installFunction · 0.95
installedFunction · 0.95
uptodateFunction · 0.95

Calls 6

ComMethod · 0.80
debugMethod · 0.80
countMethod · 0.45
AddMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected