def updateHardware(): s = rpcServer.getServer() hardwareList = hardware.Hardware() s.registration.refresh_hw_profile(up2dateAuth.getSystemId(), hardwareList)
def refresh_list(cache_only=None): if cache_only: return (0, "no-ops for caching", {}) # read all hardware in hardwareList = hardware.Hardware() s = rpcServer.getServer() if argVerbose > 1: print "Called refresh_hardware" try: s.registration.refresh_hw_profile(up2dateAuth.getSystemId(), hardwareList) except: print "ERROR: sending hardware database for System Profile" return (12, "Error refreshing system hardware", {}) return (0, "hardware list refreshed", {})
def main(self): if self.options.serverUrl: rhnreg.cfg.set("serverURL", self.options.serverUrl) if self.options.sslCACert: rhnreg.cfg.set("sslCACert", self.options.sslCACert) if not (self.options.activationkey or (self.options.username and self.options.password)): print _("A username and password are required "\ "to register a system.") sys.exit(-1) if rhnreg.registered() and not self.options.force: print _( "This system is already registered. Use --force to override") sys.exit(-1) rhnreg.getCaps() if not self.options.nopackages: getArch = 0 if rhnreg.cfg['supportsExtendedPackageProfile']: getArch = 1 packageList = pkgUtils.getInstalledPackageList(getArch=getArch) else: packageList = [] hardwareList = hardware.Hardware() if self.options.profilename: profilename = self.options.profilename else: profilename = RegisterKsCli.__generateProfileName(hardwareList) other = {} if self.options.systemorgid: other['org_id'] = self.options.systemorgid # Try to get the virt uuid and put it in "other". (virt_uuid, virt_type) = rhnreg.get_virt_info() if not virt_uuid is None: other['virt_uuid'] = virt_uuid other['virt_type'] = virt_type # If specified, send up the EUS channel label for subscription. if self.options.use_eus_channel: if self.options.activationkey: print _( "Usage of --use-eus-channel option with --activationkey is not supported. Please use username and password instead." ) sys.exit(-1) if not rhnreg.server_supports_eus(): print _( "The server you are registering against does not support EUS." ) sys.exit(-1) channels = rhnreg.getAvailableChannels(self.options.username, self.options.password) other['channel'] = channels['default_channel'] try: systemId = rhnreg.registerSystem(self.options.username, self.options.password, profilename, self.options.activationkey, other) except (up2dateErrors.AuthenticationTicketError, up2dateErrors.RhnUuidUniquenessError, up2dateErrors.CommunicationError, up2dateErrors.AuthenticationOrAccountCreationError): e = sys.exc_info()[1] print "%s" % e.errmsg sys.exit(1) # collect hardware info, inluding hostname if not self.options.nohardware: rhnreg.sendHardware(systemId, hardwareList) if not self.options.nopackages: rhnreg.sendPackages(systemId, packageList) if self.options.contactinfo: print _( "Warning: --contactinfo option has been deprecated. Please login to the server web user Interface and update your contactinfo. " ) # write out the new id if isinstance(systemId, unicode): rhnreg.writeSystemId(unicode.encode(systemId, 'utf-8')) else: rhnreg.writeSystemId(systemId) # assume successful communication with server # remember to save the config options rhnreg.cfg.save() # Send virtualization information to the server. We must do this # *after* writing out the system id. if not self.options.novirtinfo: rhnreg.sendVirtInfo(systemId) # do this after writing out system id, bug #147513 if not self.options.norhnsd: rhnreg.startRhnsd() try: present, conf_changed = rhnreg.pluginEnable() if not present: sys.stderr.write( rhncli.utf8_encode( _("Warning: %s is not present, could not enable it.") % PM_PLUGIN_NAME)) except IOError: e = sys.exc_info()[1] sys.stderr.write( rhncli.utf8_encode( _("Warning: Could not open %s\n%s is not enabled.\n") % (PM_PLUGIN_CONF, PM_PLUGIN_NAME) + e.errmsg)) RegisterKsCli.__runRhnCheck(self.options.verbose)
def main(self): if self.options.serverUrl: rhnreg.cfg.set("serverURL", self.options.serverUrl) if self.options.sslCACert: rhnreg.cfg.set("sslCACert", self.options.sslCACert) if not (self.options.activationkey or (self.options.username and self.options.password)): print _("A username and password are required "\ "to register a system.") sys.exit(-1) if rhnreg.registered() and not self.options.force: print _("This system is already registered. Use --force to override") sys.exit(-1) rhnreg.getCaps() if not self.options.nopackages: getArch = 0 if rhnreg.cfg['supportsExtendedPackageProfile']: getArch = 1 packageList = pkgUtils.getInstalledPackageList(getArch=getArch) else: packageList = [] hardwareList = hardware.Hardware() if self.options.profilename: profilename = self.options.profilename else: profilename = RegisterKsCli.__generateProfileName(hardwareList) other = {} if self.options.systemorgid: other['org_id'] = self.options.systemorgid # Try to get the virt uuid and put it in "other". (virt_uuid, virt_type) = rhnreg.get_virt_info() if not virt_uuid is None: other['virt_uuid'] = virt_uuid other['virt_type'] = virt_type # If specified, send up the EUS channel label for subscription. if self.options.use_eus_channel: if self.options.activationkey: print _("Usage of --use-eus-channel option with --activationkey is not supported. Please use username and password instead.") sys.exit(-1) if not rhnreg.server_supports_eus(): print _("The server you are registering against does not support EUS.") sys.exit(-1) channels = rhnreg.getAvailableChannels(self.options.username, self.options.password) other['channel'] = channels['default_channel'] try: if self.options.activationkey: systemId = rhnreg.registerSystem(token = self.options.activationkey, profileName = profilename, other = other) else: systemId = rhnreg.registerSystem(self.options.username, self.options.password, profilename, other = other) except (up2dateErrors.AuthenticationTicketError, up2dateErrors.RhnUuidUniquenessError, up2dateErrors.CommunicationError, up2dateErrors.AuthenticationOrAccountCreationError), e: print "%s" % e.errmsg sys.exit(1)
def __init__(self, screen, tui): self.screen = screen self.tui = tui size = snack._snack.size() #get the virtualization uuid and set it to other. (virt_uuid, virt_type) = rhnreg.get_virt_info() if not virt_uuid is None: self.tui.other['virt_uuid'] = virt_uuid self.tui.other['virt_type'] = virt_type # read all hardware in tui.hardware = hardware.Hardware() toplevel = snack.GridForm(screen, sstr(HARDWARE_WINDOW), 1, 7) text = snack.TextboxReflowed(70, sstr(HARDWARE_WINDOW_DESC1)) toplevel.add(text, 0, 0, anchorLeft = 1) grid = snack.Grid(2, 2) label = snack.Label(sstr(_("Profile name:"))) grid.setField(label, 0, 0, padding = (0, 0, 1, 0), anchorRight = 1) self.profileEntry = snack.Entry(40) grid.setField(self.profileEntry, 1, 0, anchorLeft = 1) toplevel.add(grid, 0, 1, anchorLeft = 1) if tui.includeHardware: self.hardwareButton = snack.Checkbox(sstr(HARDWARE_WINDOW_CHECKBOX), isOn = 1) else: self.hardwareButton = snack.Checkbox(sstr(HARDWARE_WINDOW_CHECKBOX)) toplevel.add(self.hardwareButton, 0, 2, padding = (0, 1, 0, 0), anchorLeft = 1) label = snack.Label(sstr(DESELECT)) toplevel.add(label, 0, 3, anchorLeft = 1, padding = (0, 0, 0, 1)) grid = snack.Grid(4, 3) hardware_text = '' hardware_text += _("Version: ") + sstr(up2dateUtils.getVersion()) + " " self.versionLabel = snack.Label(sstr(_("Version: "))) grid.setField(self.versionLabel, 0, 0, padding = (0, 0, 1, 0), anchorLeft = 1) self.versionLabel2 = snack.Label(sstr(up2dateUtils.getVersion())) grid.setField(self.versionLabel2, 1, 0, anchorLeft = 1) hardware_text += _("CPU model: ") for hw in tui.hardware: if hw['class'] == 'CPU': hardware_text += hw['model'] +"\n" hardware_text += _("Hostname: ") for hw in tui.hardware: if hw['class'] == 'NETINFO': unicode_hostname = idn_puny_to_unicode(hw['hostname']) hardware_text += unicode_hostname + "\n" if tui.profileName != "": self.profileEntry.set(tui.profileName) else: self.profileEntry.set(sstr(unicode_hostname)) hardware_text += _("CPU speed: ") for hw in tui.hardware: if hw['class'] == 'CPU': hardware_text += _("%d MHz") % hw['speed'] + " " hardware_text += _("IP Address: ") for hw in tui.hardware: if hw['class'] == 'NETINFO': if hw['ipaddr']: hardware_text += hw['ipaddr'] + " " elif hw['ip6addr']: hardware_text += hw['ip6addr'] + " " hardware_text += _("Memory: ") for hw in tui.hardware: if hw['class'] == 'MEMORY': hardware_text += _("%s megabytes") % hw['ram'] tb = snack.TextboxReflowed(80, sstr(hardware_text)) toplevel.add(tb, 0, 4) self.additionalHWLabel = snack.TextboxReflowed(size[0]-10, sstr(HARDWARE_WINDOW_DESC2)) toplevel.add(self.additionalHWLabel, 0, 5, padding = (0, 1, 0, 0), anchorLeft = 1) # BUTTON BAR self.bb = snack.ButtonBar(screen, [(sstr(NEXT), "next"), (sstr(BACK), "back"), (sstr(CANCEL), "cancel")]) toplevel.add(self.bb, 0, 6, padding = (0, 1, 0, 0), growx = 1) self.g = toplevel