示例#1
0
def patchClusterInstall(pkgs):
    print "Installing patch cluster: ", pkgs

    import smart.commands.install as install

    inst_pkgs = []
    for (pkg, data) in pkgs:
        inst_pkgs.append("%s-%s-%s" % (pkg[0], pkg[1], pkg[2]))

    ctrl = init()
    opts = install.parse_options([])
    opts.args = inst_pkgs
    opts.yes = True

    try:
        install.main(ctrl, opts)
        refresh_list()
    except Exception, e:
        msg = "Patch cluster install failed"
        if e.args:
            msg += ": %s"
            msg %= str(e.args[0])
        data = {'version': 0, 'name' : 'solarispkgs.patchClusterInstall'}
        # FIXME (20050613): What is the proper return value here?
        return (102, msg, data)
示例#2
0
def install(pkgs):
    print "Installing packages %s" % pkgs
    import smart.commands.install as install

    inst_pkgs = []
    for (pkg, data) in pkgs:
        inst_pkgs.append("%s-%s-%s" % (pkg[0], pkg[1], pkg[2]))
        if data.has_key('answerfile'):
            # FIXME (20050426): Handle answer file
            pass

    ctrl = init()
    opts = install.parse_options([])
    opts.args = inst_pkgs
    opts.yes = True

    try:
        install.main(ctrl, opts)
        refresh_list()
    except Exception, e:
        msg = "Package install failed"
        if e.args:
            msg += ": %s"
            msg %= str(e.args[0])
        data = {'version': 0, 'name' : 'solarispkgs.install'}
        return (101, msg, data)
示例#3
0
def install(pkgs):
    print "Installing packages %s" % pkgs
    import smart.commands.install as install

    inst_pkgs = []
    for (pkg, data) in pkgs:
        inst_pkgs.append("%s-%s-%s" % (pkg[0], pkg[1], pkg[2]))
        if data.has_key('answerfile'):
            # FIXME (20050426): Handle answer file
            pass

    ctrl = init()
    opts = install.parse_options([])
    opts.args = inst_pkgs
    opts.yes = True

    try:
        install.main(ctrl, opts)
        refresh_list()
    except Exception, e:
        msg = "Package install failed"
        if e.args:
            msg += ": %s"
            msg %= str(e.args[0])
        data = {'version': 0, 'name': 'solarispkgs.install'}
        return (101, msg, data)
示例#4
0
def patchClusterInstall(pkgs):
    print "Installing patch cluster: ", pkgs

    import smart.commands.install as install

    inst_pkgs = []
    for (pkg, data) in pkgs:
        inst_pkgs.append("%s-%s-%s" % (pkg[0], pkg[1], pkg[2]))

    ctrl = init()
    opts = install.parse_options([])
    opts.args = inst_pkgs
    opts.yes = True

    try:
        install.main(ctrl, opts)
        refresh_list()
    except Exception, e:
        msg = "Patch cluster install failed"
        if e.args:
            msg += ": %s"
            msg %= str(e.args[0])
        data = {'version': 0, 'name': 'solarispkgs.patchClusterInstall'}
        # FIXME (20050613): What is the proper return value here?
        return (102, msg, data)
def main(argv=None):
    if argv is None:
        argv = sys.argv
    try:
        try:
            opts, args = getopt.getopt(argv[1:], "ho:v", ["help", "output="])
        except getopt.error, msg:
            raise Usage(msg)
    
        # option processing
        for option, value in opts:
            if option == "-v":
                verbose = True
            if option in ("-h", "--help"):
                raise Usage(help_message)
            if option in ("-o", "--output"):
                output = value

        smart_ctrl = SmartCtrlr()
#        smart_ctrl.reloadChannels(caching=NEVER)
        
#        print smart_ctrl.getChannels()
#        print smart_ctrl._cache._loaders
#        print smart_ctrl._cache.getPackages()
        smart.sysconf.set("remove-packages", False)
        print smart.sysconf
        opts = install.parse_options(['Package2'])
        install.main(smart_ctrl, opts)
示例#6
0
def patchInstall(pkgs, keepBackup=None):
    print "Installing patches %s" % pkgs

    import smart.commands.install as install

    inst_pkgs = []
    for (pkg, data) in pkgs:
        inst_pkgs.append("%s-%s-%s" % (pkg[0], pkg[1], pkg[2]))

    ctrl = init()
    opts = install.parse_options([])
    opts.args = inst_pkgs
    opts.yes = True

    try:
        install.main(ctrl, opts)
        refresh_list()
    except Exception, e:
        msg = "Patch install failed"
        if e.args:
            msg += ": %s"
            msg %= str(e.args[0])
        data = {'version': 0, 'name' : 'solarispkgs.patchInstall'}
        return (102, msg, data)
示例#7
0
def patchInstall(pkgs, keepBackup=None):
    print "Installing patches %s" % pkgs

    import smart.commands.install as install

    inst_pkgs = []
    for (pkg, data) in pkgs:
        inst_pkgs.append("%s-%s-%s" % (pkg[0], pkg[1], pkg[2]))

    ctrl = init()
    opts = install.parse_options([])
    opts.args = inst_pkgs
    opts.yes = True

    try:
        install.main(ctrl, opts)
        refresh_list()
    except Exception, e:
        msg = "Patch install failed"
        if e.args:
            msg += ": %s"
            msg %= str(e.args[0])
        data = {'version': 0, 'name': 'solarispkgs.patchInstall'}
        return (102, msg, data)
示例#8
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
示例#9
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