def validate_input(self, page, errors):
     if page is SELECT_POOL_PAGE:
         if self.get_selected_pool() is not None:
             return True
         else:
             errors.append("You must select a storage pool.")
     elif page is VOLUME_NAME_PAGE:
         if utils.string_is_not_blank(self.__name.value()):
             return True
         else:
             errors.append(
                 "Storage object name can only contain alphanumeric, '_', '.', or '-' characters."
             )
     elif page is VOLUME_FORMAT_PAGE:
         if self.__formats.current() is not None:
             return True
         else:
             errors.append("You must select a volume format.")
     elif page is MAX_CAPACITY_PAGE:
         if utils.string_is_not_blank(self.__capacity.value()):
             if utils.string_is_not_blank(self.__allocation.value()):
                 capacity = int(self.__capacity.value())
                 allocation = int(self.__allocation.value())
                 if capacity > 0:
                     if capacity <= self.__config.get_pool().info()[3] / (
                             1024**2):
                         if allocation >= 0:
                             if allocation <= capacity:
                                 return True
                             else:
                                 errors.append(
                                     "Allocation cannot exceed the maximum capacity."
                                 )
                         else:
                             errors.append(
                                 "The allocation must be greater than or equal to 0."
                             )
                     else:
                         errors.append(
                             "The maximum capacity cannot exceed the storage pool size."
                         )
                 else:
                     errors.append(
                         "The capacity must be greater than zero.")
             else:
                 errors.append("An allocation value must be entered.")
         else:
             errors.append("A maximum volume capacity must be entered.")
     elif page is CONFIRM_PAGE:
         return True
     return False
Exemple #2
0
 def validate_input(self, page, errors):
     if page is POOL_NAME_PAGE:
         if utils.string_is_not_blank(self.__name.value()):
             if self.get_libvirt().storage_pool_exists(self.__name.value()):
                 errors.append("Name '%s' already in use by another pool." %
                               self.__name.value())
             else:
                 return True
         else:
             errors.append(
                 "Storage object name must be a string between 0 and 50 characters."
             )
     elif page is POOL_DETAILS_PAGE:
         result = True
         if self.__config.needs_target_path():
             if utils.string_is_not_blank(self.__target_path.value()):
                 if self.__target_path.value()[0:1] is not '/':
                     errors.append("'%s' is not an absolute path." %
                                   self.__target_path.value())
                     result = False
             else:
                 errors.append("You must enter a target path.")
                 result = False
         if self.__config.needs_format():
             if self.__formats.getSelection() is None:
                 errors.append("You must select a pool format.")
                 result = False
         if self.__config.needs_hostname():
             if not utils.string_is_not_blank(self.__hostname.value()):
                 errors.append("You must enter a hostname.")
                 result = False
         if self.__config.needs_source_path():
             if utils.string_is_not_blank(self.__source_path.value()):
                 if self.__config.source_must_be_absolute():
                     if self.__source_path.value()[0:1] is not '/':
                         errors.append("'%s' is not an absolute path." %
                                       self.__source_path.value())
                         result = False
             else:
                 errors.append("You must enter a source path.")
                 result = False
         return result
     elif page is CONFIRM_PAGE:
         return True
     return False
 def validate_input(self, page, errors):
     if page is SELECT_POOL_PAGE:
         if self.get_selected_pool() is not None:
             return True
         else:
             errors.append("You must select a storage pool.")
     elif page is VOLUME_NAME_PAGE:
         if utils.string_is_not_blank(self.__name.value()):
             return True
         else:
             errors.append("Storage object name can only contain alphanumeric, '_', '.', or '-' characters.")
     elif page is VOLUME_FORMAT_PAGE:
         if self.__formats.current() is not None:
             return True
         else:
             errors.append("You must select a volume format.")
     elif page is MAX_CAPACITY_PAGE:
         if utils.string_is_not_blank(self.__capacity.value()):
             if utils.string_is_not_blank(self.__allocation.value()):
                 capacity = int(self.__capacity.value())
                 allocation = int(self.__allocation.value())
                 if capacity > 0:
                     if capacity <= self.__config.get_pool().info()[3] / (1024 ** 2):
                         if allocation >= 0:
                             if allocation <= capacity:
                                 return True
                             else:
                                 errors.append("Allocation cannot exceed the maximum capacity.")
                         else:
                             errors.append("The allocation must be greater than or equal to 0.")
                     else:
                         errors.append("The maximum capacity cannot exceed the storage pool size.")
                 else:
                     errors.append("The capacity must be greater than zero.")
             else:
                 errors.append("An allocation value must be entered.")
         else:
             errors.append("A maximum volume capacity must be entered.")
     elif page is CONFIRM_PAGE:
         return True
     return False
 def validate_input(self, page, errors):
     if   page is POOL_NAME_PAGE:
         if utils.string_is_not_blank(self.__name.value()):
             if self.get_libvirt().storage_pool_exists(self.__name.value()):
                 errors.append("Name '%s' already in use by another pool." % self.__name.value())
             else:
                 return True
         else:
             errors.append("Storage object name must be a string between 0 and 50 characters.")
     elif page is POOL_DETAILS_PAGE:
         result = True
         if self.__config.needs_target_path():
             if utils.string_is_not_blank(self.__target_path.value()):
                 if self.__target_path.value()[0:1] is not '/':
                     errors.append("'%s' is not an absolute path." % self.__target_path.value())
                     result = False
             else:
                 errors.append("You must enter a target path.")
                 result = False
         if self.__config.needs_format():
             if self.__formats.getSelection() is None:
                 errors.append("You must select a pool format.")
                 result = False
         if self.__config.needs_hostname():
             if not utils.string_is_not_blank(self.__hostname.value()):
                 errors.append("You must enter a hostname.")
                 result = False
         if self.__config.needs_source_path():
             if utils.string_is_not_blank(self.__source_path.value()):
                 if self.__config.source_must_be_absolute():
                     if self.__source_path.value()[0:1] is not '/':
                         errors.append("'%s' is not an absolute path." % self.__source_path.value())
                         result = False
             else:
                 errors.append("You must enter a source path.")
                 result = False
         return result
     elif page is CONFIRM_PAGE:
         return True
     return False