Example #1
0
 def check_license_sig(self, filename):
     p = createProcess(self,
             ('/usr/bin/gpg', '--homedir', self.gpg_homedir, filename),
             stderr=PIPE, locale=False)
     retcode = p.wait()
     if retcode != 0:
         raise NuConfError(LICENSE_BAD_SIG,
                           'Bad signature for activation key.')
Example #2
0
    def get_id(self, padding=True):
        """Return this appliance unique identifier"""
        try:
            p = createProcess(self, ("ifconfig", "eth0"),
                    stdout=PIPE, locale=False)
            line = p.stdout.readline()
            retcode = p.wait()
            if retcode != 0:
                raise NuConfError(
                    LICENSE_GETID_ERROR,
                    tr('Could not get the unique identifier.'))

            fields = line.strip().split()
            id_str = fields[4].replace(':', '')
            if padding:
                return "%015d" % int(id_str, 16)
            else:
                return "%d" % int(id_str, 16)
        except:
            raise NuConfError(
                LICENSE_GETID_ERROR,
                tr('Could not get the unique identifier.'))