def validate_integrity(self): invalid = {} # validate networks integrity invalid_networks = list(set(self.info['networks']) - set(self._get_all_networks_name())) if invalid_networks: invalid['networks'] = invalid_networks # validate storagepools integrity for disk in self.info['disks']: pool_uri = disk['pool']['name'] pool_name = pool_name_from_uri(pool_uri) if pool_name not in self._get_active_storagepools_name(): invalid['storagepools'] = [pool_name] # validate iso integrity # FIXME when we support multiples cdrom devices iso = self.info.get('cdrom') if iso: if os.path.exists(iso): st_mode = os.stat(iso).st_mode if not (stat.S_ISREG(st_mode) or stat.S_ISBLK(st_mode)): invalid['cdrom'] = [iso] elif not check_url_path(iso): invalid['cdrom'] = [iso] self.info['invalid'] = invalid return self.info
def validate_integrity(self): invalid = {} # validate networks integrity invalid_networks = list( set(self.info['networks']) - set(self._get_all_networks_name())) if invalid_networks: invalid['networks'] = invalid_networks # validate storagepools integrity for disk in self.info['disks']: pool_uri = disk['pool']['name'] pool_name = pool_name_from_uri(pool_uri) if pool_name not in self._get_active_storagepools_name(): invalid['storagepools'] = [pool_name] # validate iso integrity # FIXME when we support multiples cdrom devices iso = self.info.get('cdrom') if iso: if os.path.exists(iso): st_mode = os.stat(iso).st_mode if not (stat.S_ISREG(st_mode) or stat.S_ISBLK(st_mode)): invalid['cdrom'] = [iso] elif not check_url_path(iso): invalid['cdrom'] = [iso] self.info['invalid'] = invalid return self.info
def _is_iso_remote(self): if os.path.exists(self.path): st_mode = os.stat(self.path).st_mode if stat.S_ISREG(st_mode) or stat.S_ISBLK(st_mode): return False if check_url_path(self.path): return True raise IsoFormatError("KCHISO0001E", {'filename': self.path})
def _is_iso_remote(self): if os.path.exists(self.path): st_mode = os.stat(self.path).st_mode if stat.S_ISREG(st_mode) or stat.S_ISBLK(st_mode): return False if check_url_path(self.path): return True raise IsoFormatError('KCHISO0001E', {'filename': self.path})
def _get_disk_type(path): if check_url_path(path): return 'network' if not os.path.exists(path): raise InvalidParameter("KCHVMSTOR0003E", {'value': path}) # Check if path is a valid local path if os.path.isfile(path): return 'file' r_path = os.path.realpath(path) if stat.S_ISBLK(os.stat(r_path).st_mode): return 'block' raise InvalidParameter("KCHVMSTOR0003E", {'value': path})
def validate_integrity(self): invalid = {} # validate networks integrity networks = self.info.get('networks', []) invalid_networks = list( set(networks) - set(self._get_all_networks_name())) if invalid_networks: invalid['networks'] = invalid_networks # validate storagepools and image-based templates integrity for disk in self.info['disks']: if 'pool' in disk: pool_uri = disk['pool']['name'] pool_name = pool_name_from_uri(pool_uri) if pool_name not in self._get_active_storagepools_name(): invalid['storagepools'] = [pool_name] if disk.get("base") is None: continue if os.path.exists(disk.get("base")) is False: invalid['vm-image'] = disk["base"] # validate iso integrity # FIXME when we support multiples cdrom devices iso = self.info.get('cdrom') if iso: if os.path.exists(iso): st_mode = os.stat(iso).st_mode if not (stat.S_ISREG(st_mode) or stat.S_ISBLK(st_mode)): invalid['cdrom'] = [iso] elif not check_url_path(iso): invalid['cdrom'] = [iso] self.info['invalid'] = invalid return self.info
def validate_integrity(self): invalid = {} # validate networks integrity networks = self.info.get('networks', []) invalid_networks = list( set(networks) - set(self._get_all_networks_name())) if invalid_networks: invalid['networks'] = invalid_networks # validate storagepools and image-based templates integrity for disk in self.info['disks']: if 'pool' in disk: pool_uri = disk['pool']['name'] pool_name = pool_name_from_uri(pool_uri) if pool_name not in self._get_active_storagepools_name(): invalid['storagepools'] = [pool_name] if disk.get('base') is None: continue if os.path.exists(disk.get('base')) is False: invalid['vm-image'] = disk['base'] # validate iso integrity # FIXME when we support multiples cdrom devices iso = self.info.get('cdrom') if iso: if os.path.exists(iso): st_mode = os.stat(iso).st_mode if not (stat.S_ISREG(st_mode) or stat.S_ISBLK(st_mode)): invalid['cdrom'] = [iso] elif not check_url_path(iso): invalid['cdrom'] = [iso] self.info['invalid'] = invalid return self.info
def validate_integrity(self): invalid = {} # validate networks integrity networks = self.info.get("networks", []) invalid_networks = list(set(networks) - set(self._get_all_networks_name())) if invalid_networks: invalid["networks"] = invalid_networks # validate storagepools and image-based templates integrity for disk in self.info["disks"]: if "pool" in disk: pool_uri = disk["pool"]["name"] pool_name = pool_name_from_uri(pool_uri) if pool_name not in self._get_active_storagepools_name(): invalid["storagepools"] = [pool_name] if disk.get("base") is None: continue if os.path.exists(disk.get("base")) is False: invalid["vm-image"] = disk["base"] # validate iso integrity # FIXME when we support multiples cdrom devices iso = self.info.get("cdrom") if iso: if os.path.exists(iso): st_mode = os.stat(iso).st_mode if not (stat.S_ISREG(st_mode) or stat.S_ISBLK(st_mode)): invalid["cdrom"] = [iso] elif not check_url_path(iso): invalid["cdrom"] = [iso] self.info["invalid"] = invalid return self.info
def validate_distro(distro): if check_url_path(distro['path']): return distro['name']
def validate_distro(distro): if check_url_path(distro["path"]): return distro["name"]