示例#1
0
def getChannels(force=None, label_whitelist=None, timeout=None):
    """ return rhnChannelList containing list of channel we are subscribed to """
    cfg = config.initUp2dateConfig()
    global selected_channels
    if not selected_channels and not force:
        selected_channels = rhnChannelList()
        s = rhnserver.RhnServer(timeout=timeout)

        if not up2dateAuth.getSystemId():
            raise up2dateErrors.NoSystemIdError(_("Unable to Locate SystemId"))

        up2dateChannels = s.up2date.listChannels(up2dateAuth.getSystemId())

        for chan in up2dateChannels:
            if label_whitelist and not label_whitelist.has_key(chan['label']):
                continue

            channel = rhnChannel(type='up2date', url=config.getServerlURL())
            for key in chan.keys():
                if key == "last_modified":
                    channel['version'] = chan['last_modified']
                else:
                    channel[key] = chan[key]
            selected_channels.addChannel(channel)

    if len(selected_channels.list) == 0:
        raise up2dateErrors.NoChannelsError(
            _("This system may not be updated until it is associated with a channel."
              ))

    return selected_channels
示例#2
0
def getChannels(force=None, label_whitelist=None):
    cfg = config.initUp2dateConfig()
    global selected_channels
    if not selected_channels and not force:
        selected_channels = rhnChannelList()
        s = rhnserver.RhnServer()

        if not up2dateAuth.getSystemId():
            raise up2dateErrors.NoSystemIdError(_("Unable to Locate SystemId"))

        up2dateChannels = s.up2date.listChannels(up2dateAuth.getSystemId())

        for chan in up2dateChannels:
            if label_whitelist and not label_whitelist.has_key(chan['label']):
                continue
                
            channel = rhnChannel(type = 'up2date', url = cfg["serverURL"])
            for key in chan.keys():
                if key == "last_modified":
                    channel['version'] = chan['last_modified']
                else:
                    channel[key] = chan[key]
            selected_channels.addChannel(channel)

    if len(selected_channels.list) == 0:
        raise up2dateErrors.NoChannelsError(_("This system may not be updated until it is associated with a channel."))

    return selected_channels
示例#3
0
    def __init__(self, screen, tui):

        if not rhnreg.registered() or tui.test:
            raise WindowSkipException()

        self.screen = screen
        self.tui = tui
        size = snack._snack.size()

        systemIdXml = rpclib.xmlrpclib.loads(up2dateAuth.getSystemId())
        oldUsername = systemIdXml[0][0]['username']
        oldsystemId = systemIdXml[0][0]['system_id']

        toplevel = snack.GridForm(self.screen,
                                  SYSTEM_ALREADY_SETUP.encode('utf-8'), 1, 2)
        self.bb = snack.ButtonBar(self.screen,
                                  [(YES_CONT.encode('utf-8'), "next"),
                                   (NO_CANCEL.encode('utf-8'), "exit")])
        toplevel.add(self.bb, 0, 1, growx=1)

        tb = snack.Textbox(
            size[0] - 30, size[1] - 20,
            (SYSTEM_ALREADY_REGISTERED + "\n\n" + _("Spacewalk Location:") +
             " " + convert_url_from_pune(self.tui.serverURL) + "\n" +
             _("Login:"******" " + oldUsername + "\n" + _("System ID:") + " " +
             oldsystemId + "\n\n" + SYSTEM_ALREADY_REGISTERED_CONT +
             "\n").encode('utf-8'), 1, 1)
        toplevel.add(tb, 0, 0, padding=(0, 0, 0, 1))

        self.g = toplevel
示例#4
0
文件: tui.py 项目: kidaa30/spacewalk
    def __init__(self, screen, tui):

        if not rhnreg.registered() or tui.test:
            raise WindowSkipException()

        self.screen = screen
        self.tui = tui
        size = snack._snack.size()

        systemIdXml = rpclib.xmlrpclib.loads(up2dateAuth.getSystemId())
        oldUsername = systemIdXml[0][0]['username']
        oldsystemId = systemIdXml[0][0]['system_id']

        toplevel = snack.GridForm(self.screen, SYSTEM_ALREADY_SETUP.encode('utf-8'), 1, 2)
        self.bb = snack.ButtonBar(self.screen,
                                  [(YES_CONT.encode('utf-8'), "next"),
                                   (NO_CANCEL.encode('utf-8'), "exit")])
        toplevel.add(self.bb, 0, 1, growx = 1)

        tb = snack.Textbox(size[0]-30, size[1]-20,
                            (SYSTEM_ALREADY_REGISTERED + "\n\n"
                            + _("Spacewalk Location:") + " " + convert_url_from_puny(self.tui.serverURL) + "\n"
                            + _("Login:"******" " + oldUsername + "\n"
                            + _("System ID:") + " " + oldsystemId + "\n\n"
                            + SYSTEM_ALREADY_REGISTERED_CONT + "\n").encode('utf-8'),
                            1, 1)
        toplevel.add(tb, 0, 0, padding = (0, 0, 0, 1))

        self.g = toplevel
示例#5
0
def getChannelDetails():

    channels = []
    sourceChannels = getChannels()

    useRhn = None
    for sourceChannel in sourceChannels.channels():
        if sourceChannel["type"] == "up2date":
            useRhn = 1

    if useRhn:
        s = rpcServer.getServer()
        up2dateChannels = rpcServer.doCall(s.up2date.listChannels, up2dateAuth.getSystemId())

    for sourceChannel in sourceChannels.channels():
        if sourceChannel["type"] != "up2date":
            # FIMXE: kluge since we dont have a good name, maybe be able to fix
            sourceChannel["name"] = sourceChannel["label"]
            sourceChannel["description"] = "%s channel %s from  %s" % (
                sourceChannel["type"],
                sourceChannel["label"],
                sourceChannel["url"],
            )
            channels.append(sourceChannel)
            continue

        if useRhn:
            for up2dateChannel in up2dateChannels:
                if up2dateChannel["label"] != sourceChannel["label"]:
                    continue
                for key in up2dateChannel.keys():
                    sourceChannel[key] = up2dateChannel[key]
                channels.append(sourceChannel)

    return channels
示例#6
0
def updateHardware():
    s = rpcServer.getServer()


    hardwareList = hardware.Hardware()
    s.registration.refresh_hw_profile(up2dateAuth.getSystemId(),
                                          hardwareList)
示例#7
0
def getChannelDetails():

    channels = []
    sourceChannels = getChannels()

    useRhn = None
    for sourceChannel in sourceChannels.channels():
        if sourceChannel['type'] == "up2date":
            useRhn = 1

    if useRhn:
        s = rpcServer.getServer()
        up2dateChannels = rpcServer.doCall(s.up2date.listChannels,
                                           up2dateAuth.getSystemId())

    for sourceChannel in sourceChannels.channels():
        if sourceChannel['type'] != 'up2date':
            # FIMXE: kluge since we dont have a good name, maybe be able to fix
            sourceChannel['name'] = sourceChannel['label']
            sourceChannel['description'] = "%s channel %s from  %s" % (
                sourceChannel['type'], sourceChannel['label'],
                sourceChannel['url'])
            channels.append(sourceChannel)
            continue

        if useRhn:
            for up2dateChannel in up2dateChannels:
                if up2dateChannel['label'] != sourceChannel['label']:
                    continue
                for key in up2dateChannel.keys():
                    sourceChannel[key] = up2dateChannel[key]
                channels.append(sourceChannel)

    return channels
示例#8
0
def getAdvisoryInfo(pkg, warningCallback=None):
    log = up2dateLog.initLog()
    cfg = config.initUp2dateConfig()
    # no errata for non rhn use
    if not cfg['useRhn']:
        return None

    s = rpcServer.getServer()

    ts = transaction.initReadOnlyTransaction()
    mi = ts.dbMatch('Providename', pkg[0])
    if not mi:
        return None

    # odd,set h to last value in mi. mi has to be iterated
    # to get values from it...
    h = None
    for h in mi:
        break

    info = None

    # in case of package less errata that somehow apply
    if h:
        try:
            pkgName = "%s-%s-%s" % (h['name'], h['version'], h['release'])
            log.log_me("getAdvisoryInfo for %s" % pkgName)
            info = rpcServer.doCall(s.errata.getPackageErratum,
                                    up2dateAuth.getSystemId(), pkg)
        except rpclib.Fault, f:
            if warningCallback:
                warningCallback(f.faultString)
            return None
示例#9
0
def subscribeChannels(channels, username, passwd):
    s = rpcServer.getServer()
    try:
        channels = rpcServer.doCall(s.up2date.subscribeChannels, up2dateAuth.getSystemId(), channels, username, passwd)
    except rpclib.Fault, f:
        if f.faultCode == -36:
            raise up2dateErrors.PasswordError(f.faultString)
        else:
            raise up2dateErrors.CommunicationError(f.faultString)
示例#10
0
def updatePackageProfile(timeout=None):
    """ get a list of installed packages and send it to rhnServer """
    log = up2dateLog.initLog()
    log.log_me("Updating package profile")
    packages = pkgUtils.getInstalledPackageList(getArch=1)
    s = rhnserver.RhnServer(timeout=timeout)
    if not s.capabilities.hasCapability('xmlrpc.packages.extended_profile', 2):
        # for older satellites and hosted - convert to old format
        packages = convertPackagesFromHashToList(packages)
    s.registration.update_packages(up2dateAuth.getSystemId(), packages)
示例#11
0
def updatePackageProfile():
    """ get a list of installed packages and send it to rhnServer """
    log = up2dateLog.initLog()
    log.log_me("Updating package profile")
    packages = pkgUtils.getInstalledPackageList(getArch=1)
    s = rhnserver.RhnServer()
    if not s.capabilities.hasCapability('xmlrpc.packages.extended_profile', 2):
        # for older satellites and hosted - convert to old format
        packages = convertPackagesFromHashToList(packages)
    s.registration.update_packages(up2dateAuth.getSystemId(), packages)
示例#12
0
def unsubscribeChannels(channels, username, passwd):
    s = rpcServer.getServer()
    try:
        channels = rpcServer.doCall(s.up2date.unsubscribeChannels,
                                    up2dateAuth.getSystemId(), channels,
                                    username, passwd)
    except rpclib.Fault, f:
        if f.faultCode == -36:
            raise up2dateErrors.PasswordError(f.faultString)
        else:
            raise up2dateErrors.CommunicationError(f.faultString)
示例#13
0
    def getHeader(self, pkg, lite = None,
                  msgCallback = None, progressCallback = None):
        hdr = None

        try:
            ret = self.s.up2date.header(up2dateAuth.getSystemId(), pkg)
        except KeyboardInterrupt:
            raise up2dateErrors.CommunicationError("Connection aborted by the user")
        except (socket.error, socket.sslerror), e:
            if len(e.args) > 1:
                raise up2dateErrors.CommunicationError(e.args[1])
            else:
                raise up2dateErrors.CommunicationError(e.args[0])
示例#14
0
def getAdvisoryInfo(pkg, warningCallback=None):
    log = up2dateLog.initLog()
    cfg = config.initUp2dateConfig()
    # no errata for non rhn use
    if not cfg['useRhn']:
        return None
        
    s = rpcServer.getServer()

    ts = transaction.initReadOnlyTransaction()
    mi = ts.dbMatch('Providename', pkg[0])
    if not mi:
	return None

    # odd,set h to last value in mi. mi has to be iterated
    # to get values from it...
    h = None
    for h in mi:
        break

    info = None

    # in case of package less errata that somehow apply
    if h:
        try:
            pkgName = "%s-%s-%s" % (h['name'],
                                h['version'],
                                h['release'])
            log.log_me("getAdvisoryInfo for %s" % pkgName)
            info = rpcServer.doCall(s.errata.getPackageErratum,
                                    up2dateAuth.getSystemId(),
                                    pkg)
        except rpclib.Fault, f:
            if warningCallback:
                warningCallback(f.faultString)
            return None
示例#15
0
def unsubscribeChannels(channels, username, passwd):
    s = rhnserver.RhnServer()
    return s.up2date.unsubscribeChannels(up2dateAuth.getSystemId(), channels,
                                         username, passwd)
示例#16
0
def unsubscribeChannels(channels,username,passwd):
    s = rhnserver.RhnServer()
    s.up2date.unsubscribeChannels(up2dateAuth.getSystemId(), channels,
        username, passwd)