Example #1
0
 def __init__(self, channel):
      RPMHeaderLoader.__init__(self)
      self.s = rpcServer.getServer()
      self.li = rhnAuth.getLoginInfo()
      self.channels = self.li['X-RHN-Auth-Channels']
      self.channel = channel
      print "i:", "RPMRHNLoader.__init__"
Example #2
0
 def __init__(self, channel):
     RPMHeaderLoader.__init__(self)
     self.s = rpcServer.getServer()
     self.li = rhnAuth.getLoginInfo()
     self.channels = self.li['X-RHN-Auth-Channels']
     self.channel = channel
     print "i:", "RPMRHNLoader.__init__"
Example #3
0
    def run(self, command=None, argv=None):
        # argv is the list of packages to install if any
        #print "Up2date run() command: ", command, "pkgs: ", argv
        action = command["action"]

        if command.has_key("channel"):
            rhnoptions.setOption("channel", command["channel"])
        if command.has_key("global_zone"):
            rhnoptions.setOption("global_zone", command["global_zone"])
        if command.has_key("admin"):
            rhnoptions.setOption("admin", command["admin"])
        if command.has_key("response"):
            rhnoptions.setOption("response", command["response"])

        rhnoptions.setOption("action", action)

        result = None
        if action in ("", "installall"):
            if action == "":
                pkgs = argv
            if action == "installall":
                pkgs = self.getRHNPackages(latest=True)
                pkgs = [str(x) for x in pkgs if not x.installed]
            import smart.commands.install as install
            opts = install.parse_options([])
            opts.args = pkgs
            opts.yes = True

            # Use a custom policy for breaking ties with patches.
            if command.has_key("act_native"):
                result = install.main(self._ctrl, opts,
                                      RHNSolarisGreedyPolicyInstall)
            else:
                result = install.main(self._ctrl, opts,
                                      RHNSolarisPolicyInstall)

        if action == "list":
            pkgs = self.getRHNPackages()
            print _("""
Name                                    Version        Rel
----------------------------------------------------------""")
            for pkg in pkgs:
                if pkg.installed: continue
                found = False
                for upgs in pkg.upgrades:
                    for prv in upgs.providedby:
                        for p in prv.packages:
                            if p.installed:
                                found = True
                if found:
                    parts = pkg.version.split("-")
                    version = parts[0]
                    release = "-".join(parts[1:])
                    print "%-40s%-15s%-20s" % (pkg.name, version, release)
        # bug 165383: run the packages command after an install
        if action in ("", "installall", "packages"):
            from rhn.client import rhnPackages
            import string

            pkglist = self.getPackages()

            pkgs = []

            #8/8/2005 wregglej 165046
            #make sure patches get refreshed by checking to see if they're installed
            #and placing them in the pkgs list.
            patchlist = []
            status, output = commands.getstatusoutput("showrev -p")
            if status == 0:
                if type(output) == type(""):
                    output = output.splitlines()
                for line in output:
                    # Patch: 190001-01 Obsoletes:  Requires:  Incompatibles:  Packages: Zpkg2, Zpkg1
                    if not line.startswith("Patch:"):
                        continue
                    parts = line.split()
                    patchlist.append("patch-solaris-" + parts[1] + "-1")

            for pkg in pkglist:
                if pkg.name.startswith("patch-solaris"):
                    matchname = pkg.name + "-" + pkg.version
                    for patchname in patchlist:
                        if string.find(matchname, patchname) > -1:
                            parts = string.split(pkg.version, "-")
                            version = parts[0]
                            revision = string.join(parts[1:]) or 1
                            arch = "sparc-solaris-patch"
                            pkgs.append(
                                (pkg.name, version, revision, "", arch))
                elif pkg.installed:
                    # We won't be listing patch clusters: once installed
                    # they are just patches
                    if pkg.name.startswith("patch-solaris"):
                        arch = "sparc-solaris-patch"
                    else:
                        arch = "sparc-solaris"
                    parts = string.split(pkg.version, "-")
                    version = string.join(parts[0:-1], "-")
                    revision = parts[-1] or 1
                    # bug 164540: removed hard-coded '0' epoch
                    pkgs.append((pkg.name, version, revision, "", arch))

            rhnPackages.refreshPackages(pkgs)

            # FIXME (20050415): Proper output method
            print "Package list refresh successful"
        if action == "hardware":
            from rhn.client import rhnHardware
            rhnHardware.updateHardware()
            # FIXME (20050415): Proper output method
            print "Hardware profile refresh successful"
        if action == "showall" or action == "show_available" \
                or action == "showall_with_channels" or action == "show_available_with_channels":
            # Show the latest of each package in RHN
            pkgs = self.getRHNPackages(latest=True)
            for pkg in pkgs:
                if action.startswith("show_available") and pkg.installed:
                    continue
                if action.endswith("_with_channels"):
                    channelName = ""
                    for (ldr, info) in pkg.loaders.items():
                        channel = ldr.getChannel()
                        if channel.getType() == "solaris-rhn":
                            channelLabel = info['baseurl'][6:-1]
                            break
                    print "%-40s%-30s" % (str(pkg), channelLabel)
                else:
                    print str(pkg)
        if action == "show_orphans":
            pkgs = self.getPackages()
            rhn_pkgs = self.getRHNPackages(reload=False)
            for pkg in pkgs:
                if pkg not in rhn_pkgs:
                    print str(pkg)
        if action == "get":
            import smart.commands.download as download
            opts = download.parse_options([])
            opts.args = argv
            opts.yes = True
            result = download.main(self._ctrl, opts)
        if action == "show_channels":
            serverSettings = ServerSettings()
            li = rhnAuth.getLoginInfo()
            channels = li.get('X-RHN-Auth-Channels')
            for channelInfo in channels:
                print channelInfo[0]

        return result
Example #4
0
    def run(self, command=None, argv=None):
        # argv is the list of packages to install if any
        #print "Up2date run() command: ", command, "pkgs: ", argv
        action = command["action"]

        if command.has_key("channel"):
            rhnoptions.setOption("channel", command["channel"])
        if command.has_key("global_zone"):
            rhnoptions.setOption("global_zone", command["global_zone"])
        if command.has_key("admin"):
            rhnoptions.setOption("admin", command["admin"])
        if command.has_key("response"):
            rhnoptions.setOption("response", command["response"])


        rhnoptions.setOption("action", action)

        result = None
        if action in ("", "installall"):
            if action == "":
                pkgs = argv
            if action == "installall":
                pkgs = self.getRHNPackages(latest=True)
                pkgs = [str(x) for x in pkgs if not x.installed]
            import smart.commands.install as install
            opts = install.parse_options([])
            opts.args = pkgs
            opts.yes = True

            # Use a custom policy for breaking ties with patches.
            if command.has_key("act_native"):
                result = install.main(self._ctrl, opts, RHNSolarisGreedyPolicyInstall)
            else:
                result = install.main(self._ctrl, opts, RHNSolarisPolicyInstall)

        if action == "list":
            pkgs = self.getRHNPackages()
            print _("""
Name                                    Version        Rel
----------------------------------------------------------""")
            for pkg in pkgs:
                if pkg.installed: continue
                found = False
                for upgs in pkg.upgrades:
                    for prv in upgs.providedby:
                        for p in prv.packages:
                            if p.installed:
                                found = True
                if found:
                    parts = pkg.version.split("-")
                    version = parts[0]
                    release = "-".join(parts[1:])
                    print "%-40s%-15s%-20s" % (pkg.name, version, release)
        # bug 165383: run the packages command after an install
        if action in ("", "installall", "packages"):
            from rhn.client import rhnPackages
            import string

            pkglist = self.getPackages()

            pkgs = []

            #8/8/2005 wregglej 165046
            #make sure patches get refreshed by checking to see if they're installed
            #and placing them in the pkgs list.
            patchlist = []
            status, output = commands.getstatusoutput("showrev -p")
            if status == 0:
                if type(output) == type(""):
                    output = output.splitlines()
                for line in output:
                    # Patch: 190001-01 Obsoletes:  Requires:  Incompatibles:  Packages: Zpkg2, Zpkg1
                    if not line.startswith("Patch:"):
                        continue
                    parts = line.split()
                    patchlist.append("patch-solaris-" + parts[1] + "-1")

            for pkg in pkglist:
                if pkg.name.startswith("patch-solaris"):
                    matchname = pkg.name + "-" + pkg.version
                    for patchname in patchlist:
                        if string.find(matchname, patchname) > -1:
                            parts = string.split(pkg.version, "-")
                            version = parts[0]
                            revision = string.join(parts[1:]) or 1
                            arch = "sparc-solaris-patch"
                            pkgs.append((pkg.name, version, revision, "", arch))
                elif pkg.installed:
                    # We won't be listing patch clusters: once installed
                    # they are just patches
                    if pkg.name.startswith("patch-solaris"):
                        arch = "sparc-solaris-patch"
                    else:
                        arch = "sparc-solaris"
                    parts = string.split(pkg.version, "-")
                    version = string.join(parts[0:-1], "-")
                    revision = parts[-1] or 1
                    # bug 164540: removed hard-coded '0' epoch
                    pkgs.append((pkg.name, version, revision, "", arch))

            rhnPackages.refreshPackages(pkgs)

            # FIXME (20050415): Proper output method
            print "Package list refresh successful"
        if action == "hardware":
            from rhn.client import rhnHardware
            rhnHardware.updateHardware()
            # FIXME (20050415): Proper output method
            print "Hardware profile refresh successful"
        if action == "showall" or action == "show_available" \
                or action == "showall_with_channels" or action == "show_available_with_channels":
            # Show the latest of each package in RHN
            pkgs = self.getRHNPackages(latest=True)
            for pkg in pkgs:
                if action.startswith("show_available") and pkg.installed: continue
                if action.endswith("_with_channels"):
                    channelName = ""
                    for (ldr,info) in pkg.loaders.items():
                        channel = ldr.getChannel()
                        if channel.getType() == "solaris-rhn":
                            channelLabel = info['baseurl'][6:-1]
                            break
                    print "%-40s%-30s" % (str(pkg), channelLabel)
                else:
                    print str(pkg)
        if action == "show_orphans":
            pkgs = self.getPackages()
            rhn_pkgs = self.getRHNPackages(reload=False)
            for pkg in pkgs:
                if pkg not in rhn_pkgs:
                    print str(pkg)
        if action == "get":
            import smart.commands.download as download
            opts = download.parse_options([])
            opts.args = argv
            opts.yes = True
            result = download.main(self._ctrl, opts)
        if action == "show_channels":
            serverSettings = ServerSettings()
            li = rhnAuth.getLoginInfo()
            channels = li.get('X-RHN-Auth-Channels')
            for channelInfo in channels:
                print channelInfo[0]

        return result