Esempio n. 1
0
    def _write_image_xml(self):
        xml = "<image>\n"

        name_attributes = ""
        if self.appliance_version:
            name_attributes += " version='%s'" % self.appliance_version
        if self.appliance_release:
            name_attributes += " release='%s'" % self.appliance_release
        xml += "  <name%s>%s</name>\n" % (name_attributes, self.name)
        xml += "  <domain>\n"
        # XXX don't hardcode - determine based on the kernel we installed for grub
        # baremetal vs xen
        xml += "    <boot type='hvm'>\n"
        xml += "      <guest>\n"
        xml += "        <arch>%s</arch>\n" % os.uname()[4]
        xml += "      </guest>\n"
        xml += "      <os>\n"
        xml += "        <loader dev='hd'/>\n"
        xml += "      </os>\n"

        i = 0
        for name in self.__disks.keys():
            xml += "      <drive disk='%s-%s.%s' target='hd%s'/>\n" % (
                self.name, name, self.__disk_format, chr(ord('a') + i))
            i = i + 1

        xml += "    </boot>\n"
        xml += "    <devices>\n"
        xml += "      <vcpu>%s</vcpu>\n" % self.vcpu
        xml += "      <memory>%d</memory>\n" % (self.vmem * 1024)
        for network in self.ks.handler.network.network:
            xml += "      <interface/>\n"
        xml += "      <graphics/>\n"
        xml += "    </devices>\n"
        xml += "  </domain>\n"
        xml += "  <storage>\n"

        if self.checksum is True:
            for name in self.__disks.keys():
                diskpath = "%s/%s-%s.%s" % (self._outdir, self.name, name,
                                            self.__disk_format)
                disk_size = os.path.getsize(diskpath)
                meter_ct = 0
                meter = progress.TextMeter()
                meter.start(size=disk_size,
                            text="Generating disk signature for %s-%s.%s" %
                            (self.name, name, self.__disk_format))
                xml += "    <disk file='%s-%s.%s' use='system' format='%s'>\n" % (
                    self.name, name, self.__disk_format, self.__disk_format)

                try:
                    import hashlib
                    m1 = hashlib.sha1()
                    m2 = hashlib.sha256()
                except:
                    import sha
                    m1 = sha.new()
                    m2 = None
                f = open(diskpath, "r")
                while 1:
                    chunk = f.read(65536)
                    if not chunk:
                        break
                    m1.update(chunk)
                    if m2:
                        m2.update(chunk)
                    meter.update(meter_ct)
                    meter_ct = meter_ct + 65536

                sha1checksum = m1.hexdigest()
                xml += """      <checksum type='sha1'>%s</checksum>\n""" % sha1checksum

                if m2:
                    sha256checksum = m2.hexdigest()
                    xml += """      <checksum type='sha256'>%s</checksum>\n""" % sha256checksum
                xml += "    </disk>\n"
        else:
            for name in self.__disks.keys():
                xml += "    <disk file='%s-%s.%s' use='system' format='%s'/>\n" % (
                    self.name, name, self.__disk_format, self.__disk_format)

        xml += "  </storage>\n"
        xml += "</image>\n"

        logging.debug("writing image XML to %s/%s.xml" %
                      (self._outdir, self.name))
        cfg = open("%s/%s.xml" % (self._outdir, self.name), "w")
        cfg.write(xml)
        cfg.close()
Esempio n. 2
0
remotekojisession = koji.ClientSession(REMOTEKOJIHUB)
localkojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA)

tag = 'f18-rebuild'

ignorelist = "Agda amtu aunit adobe-source-libraries acpid apmd apmud athcool bunny blktap biosdevname cpuid clean cabal-dev cmospwd cmucl compat-gcc-296 darktable dmidecode darcs dyninst dssi-vst efibootmgr edac-utils edb fedora-ksplice frysk florist firmware-addon-dell groonga ghc-aeson ghc-mwc-random gnu-efi ghc-ForSyDe ghc-Agda GtkAda gprbuild grub ghdl grub2 ghc-hakyll ghc-hamlet gnatcoll gpart gprolog ghc-vector ghc-hashtables ghc-parameterized-data ghc-shakespeare ghc-type-level i8kutils ibmasm imvirt infiniband-diags ioport iprutils ipw2100-firmware ipw2200-firmware ksplice latrace libbsr libipathverbs libseccomp librtas lightning lrmi libsmbios matreshka mactel-boot memtest86+ maxima microcode_ctl mkbootdisk mcelog mono-debugger msr-tools numactl numad openscada openni openni-primesense openalchemist pcc perftest pesign php-pecl-xhprof planets pmtools powerpc-utils powerpc-utils-papr ppc64-utils ps3-utils picprog pvs-sbcl perl-threads-tbb qperf rubygem-virt-p2v s3switch semantik sgabios sbcl syslinux seabios spicctrl stripesnoop spice-xpi sugar-tamtam superiotool svgalib sysprof system-config-boot spice tboot tbb unetbootin virt-v2v vrq wraplinux x86info xen xorg-x11-drv-openchrome xorg-x11-drv-neomagic xorg-x11-drv-geode xorg-x11-drv-vmware xorg-x11-drv-vmmouse xorg-x11-drv-intel yaboot zeromq-ada"

pkgs = remotekojisession.listPackages(tagID=tag, inherited=True)

# reduce the list to those that are not blocked and sort by package name
pkgs = sorted([pkg for pkg in pkgs if not pkg['blocked']],
              key=operator.itemgetter('package_name'))

print 'Checking %s packages...' % len(pkgs)

pg = progress.TextMeter()

for pkg in pkgs:
    if pkg['package_name'] in ignorelist:
        logging.debug("Ignored package: %s" % pkg['package_name'])
        continue
    if pkg['blocked']:
        logging.debug("Blocked pkg: %s" % pkg['package_name'])
        continue
    pkginfo = remotekojisession.listTagged(tag,
                                           inherit=False,
                                           package=pkg['package_name'])
    pkgindex = 0
    if len(pkginfo) > pkgindex:
        logging.info("got build %s" % pkginfo[pkgindex]['nvr'])
    elif len(pkginfo) == 1: