<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    vmtemplate.py has a function that checks template integrity
    (validate_integrity), that check template and if found some
    parameters invalid, warn the user.<br>
    <br>
    Today, the function is not verifying disks. I'll do it. Just want to
    make sure i'm checking all kind:<br>
    <br>
    Here is the function:<br>
    <br>
    <small><small>    def validate_integrity(self):<br>
                invalid = {}<br>
                # validate networks integrity<br>
                invalid_networks = list(set(self.info['networks']) -<br>
                                       
        set(self._get_all_networks_name()))<br>
                if invalid_networks:<br>
                    invalid['networks'] = invalid_networks<br>
        <br>
                # validate storagepools and integrity<br>
                for disk in self.info['disks']:<br>
                    pool_uri = disk['pool']['name']<br>
                    pool_name = pool_name_from_uri(pool_uri)<br>
                    if pool_name not in
        self._get_active_storagepools_name():<br>
                        invalid['storagepools'] = [pool_name]<br>
        <br>
                    if os.path.exists(disk["base"])<br>
        <br>
                # validate iso integrity<br>
                # FIXME when we support multiples cdrom devices<br>
                iso = self.info.get('cdrom')<br>
                if iso:<br>
                    if os.path.exists(iso):<br>
                        st_mode = os.stat(iso).st_mode<br>
                        if not (stat.S_ISREG(st_mode) or
        stat.S_ISBLK(st_mode)):<br>
                            invalid['cdrom'] = [iso]<br>
                    elif not check_url_path(iso):<br>
                        invalid['cdrom'] = [iso]<br>
        <br>
                self.info['invalid'] = invalid<br>
        <br>
                return self.info</small></small><br>
    <br>
    I just need to get the loop "<small><small># validate storagepools
        and integrity<big><big>"  and add a checking:<br>
                    # validate storagepools and integrity<br>
                    for disk in self.info['disks']:<br>
                        pool_uri = disk['pool']['name']<br>
                        pool_name = pool_name_from_uri(pool_uri)<br>
                        if pool_name not in
            self._get_active_storagepools_name():<br>
                            invalid['storagepools'] = [pool_name]<br>
            +<br>
            +     if not os.path.exists(disk.get("base")):<br>
            +         invalid["disks"] = disk</big></big><br>
        <big><big>+ <br>
            <br>
            I guess this way i can validate disks on dir storagepools,
            and nfs. But, what about netboot and other kind?<br>
          </big></big><br>
        <br>
      </small></small>
    <pre class="moz-signature" cols="72">-- 

Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems &amp; Technology Group
Phone : +55 19 2132 7878
<a class="moz-txt-link-abbreviated" href="mailto:ramonn@br.ibm.com">ramonn@br.ibm.com</a> </pre>
  </body>
</html>