Index: /branches/rel_avx_2_7_6/src/webui/webui/htdocs/new/src/avx/models/va/image/__init__.py
===================================================================
--- /branches/rel_avx_2_7_6/src/webui/webui/htdocs/new/src/avx/models/va/image/__init__.py	(revision 9242)
+++ /branches/rel_avx_2_7_6/src/webui/webui/htdocs/new/src/avx/models/va/image/__init__.py	(working copy)
@@ -428,15 +428,21 @@
                             import_cli = 'va image "%s" "%s" "%s" "%s"' % (instance.image_name, res_list[1], res_list[2], res_list[4])
                         else:
                             import_cli = 'va image "%s" "%s" "%s"' % (instance.image_name, res_list[1], res_list[2])
-                        result = self.cli.cmd(import_cli,
-                                            RegexParser('%s:((?!size:).)*?size:[\s\S]+' % instance.image_name, match_exception=CLICmdNormal, exclusive=True),
-                                            RegexParser('%s' % instance.image_name, unmatch_exception=CLICmdError, unmatch_msg=__('Failed to import the VA image.')),
-                                            BlankParser(nonblank_exception=CLICmdError, supplement=True),timeout=600.0)
+                        result = self.cli.cmd(import_cli, timeout=600.0)
+                        if "Invalid image file name" in result:
+                            cli_parse(result, RegexParser('Invalid image file name', match_exception=CLICmdError, match_msg=__('Invalid image file name! Allowed characters: "a-z", "A-Z", "0-9", ".", "_", "-"')))
+                        else:
+                            cli_parse(result,
+                                RegexParser('%s:((?!size:).)*?size:[\s\S]+' % instance.image_name, match_exception=CLICmdNormal, exclusive=True),
+                                BlankParser(blank_exception=CLICmdError, blank_msg=__('Failed to import the VA image.'), nonblank_exception=CLICmdError))
                 else:
-                    result = self.cli.cmd('va image "%s" "%s" "%s"' % (instance.image_name, image_url, instance.image_format),
-                                            RegexParser('%s:((?!size:).)*?size:[\s\S]+' % instance.image_name, match_exception=CLICmdNormal, exclusive=True),
-                                            RegexParser('%s' % instance.image_name, unmatch_exception=CLICmdError, unmatch_msg=__('Failed to import the VA image.')),
-                                            BlankParser(nonblank_exception=CLICmdError, supplement=True),timeout=600.0)
+                    result = self.cli.cmd('va image "%s" "%s" "%s"' % (instance.image_name, image_url, instance.image_format), timeout=600.0)
+                    if "Invalid image file name" in result:
+                        cli_parse(result, RegexParser('Invalid image file name', match_exception=CLICmdError, match_msg=__('Invalid image file name! Allowed characters: "a-z", "A-Z", "0-9", ".", "_", "-"')))
+                    else:
+                        cli_parse(result,
+                            RegexParser('%s:((?!size:).)*?size:[\s\S]+' % instance.image_name, match_exception=CLICmdNormal, exclusive=True),
+                            BlankParser(blank_exception=CLICmdError, blank_msg=__('Failed to import the VA image.'), nonblank_exception=CLICmdError))
             # there is no default metadata.
             else:
                 if "local" in instance.metadata_url:
@@ -453,10 +459,13 @@
                                 icon_path = res_list[0]
                             image_url = res_list[1]
                             im_format = res_list[2]
-                        result = self.cli.cmd('va image "%s" "%s" "%s" "%s"' % (instance.image_name, image_url, im_format, metadata_url),
-                                            RegexParser('%s:((?!size:).)*?size:[\s\S]+' % instance.image_name, match_exception=CLICmdNormal, exclusive=True),
-                                            RegexParser('%s' % instance.image_name, unmatch_exception=CLICmdError, unmatch_msg=__('Failed to import the VA image.')),
-                                            BlankParser(nonblank_exception=CLICmdError, supplement=True),timeout=600.0)
+                        result = self.cli.cmd('va image "%s" "%s" "%s" "%s"' % (instance.image_name, image_url, im_format, metadata_url), timeout=600.0)
+                        if "Invalid image file name" in result:
+                            cli_parse(result, RegexParser('Invalid image file name', match_exception=CLICmdError, match_msg=__('Invalid image file name! Allowed characters: "a-z", "A-Z", "0-9", ".", "_", "-"')))
+                        else:
+                            cli_parse(result,
+                                RegexParser('%s:((?!size:).)*?size:[\s\S]+' % instance.image_name, match_exception=CLICmdNormal, exclusive=True),
+                                BlankParser(blank_exception=CLICmdError, blank_msg=__('Failed to import the VA image.'), nonblank_exception=CLICmdError))
                     else:
                         raise ModelQueryException(CLICmdError(__('Please enter the metadata URL!')))
                 elif "manual" in instance.metadata_url:
@@ -504,10 +513,13 @@
                     except Exception, e:
                         destination.close()
                         raise ModelQueryException(CLICmdError(__('Failed to write the Metadata file: %s' % e)))
-                    result = self.cli.cmd('va image "%s" "%s" "%s" "%s"' % (instance.image_name, image_url, im_format, 'file://metadata.ini'),
-                                            RegexParser('%s:((?!size:).)*?size:[\s\S]+' % instance.image_name, match_exception=CLICmdNormal, exclusive=True),
-                                            RegexParser('%s' % instance.image_name, unmatch_exception=CLICmdError, unmatch_msg=__('Failed to import the VA image.')),
-                                            BlankParser(nonblank_exception=CLICmdError, supplement=True),timeout=600.0)
+                    result = self.cli.cmd('va image "%s" "%s" "%s" "%s"' % (instance.image_name, image_url, im_format, 'file://metadata.ini'), timeout=600.0)
+                    if "Invalid image file name" in result:
+                        cli_parse(result, RegexParser('Invalid image file name', match_exception=CLICmdError, match_msg=__('Invalid image file name! Allowed characters: "a-z", "A-Z", "0-9", ".", "_", "-"')))
+                    else:
+                        cli_parse(result,
+                            RegexParser('%s:((?!size:).)*?size:[\s\S]+' % instance.image_name, match_exception=CLICmdNormal, exclusive=True),
+                            BlankParser(blank_exception=CLICmdError, blank_msg=__('Failed to import the VA image.'), nonblank_exception=CLICmdError))
                 else:
                     if instance.metadata_url["md_url"]:
                         is_docker_image = False
@@ -528,10 +540,13 @@
                                 icon_path = res_list[0]
                             image_url = res_list[1]
                             im_format = res_list[2]
-                        result = self.cli.cmd('va image "%s" "%s" "%s" "%s"' % (instance.image_name, image_url, im_format, url),
-                                            RegexParser('%s:((?!size:).)*?size:[\s\S]+' % instance.image_name, match_exception=CLICmdNormal, exclusive=True),
-                                            RegexParser('%s' % instance.image_name, unmatch_exception=CLICmdError, unmatch_msg=__('Failed to import the VA image.')),
-                                            BlankParser(nonblank_exception=CLICmdError, supplement=True),timeout=600.0)
+                        result = self.cli.cmd('va image "%s" "%s" "%s" "%s"' % (instance.image_name, image_url, im_format, url), timeout=600.0)
+                        if "Invalid image file name" in result:
+                            cli_parse(result, RegexParser('Invalid image file name', match_exception=CLICmdError, match_msg=__('Invalid image file name! Allowed characters: "a-z", "A-Z", "0-9", ".", "_", "-"')))
+                        else:
+                            cli_parse(result,
+                                RegexParser('%s:((?!size:).)*?size:[\s\S]+' % instance.image_name, match_exception=CLICmdNormal, exclusive=True),
+                                BlankParser(blank_exception=CLICmdError, blank_msg=__('Failed to import the VA image.'), nonblank_exception=CLICmdError))
                     else:
                         raise ModelQueryException(CLICmdError(__('Please enter the metadata URL!')))
 
@@ -550,8 +565,11 @@
                     shutil.rmtree(IMAGE_CUSTOM_ICON + each_pk["image_name"])
                 if os.path.exists(IMAGE_CUSTOM_ICON_PATH + each_pk["image_name"]):
                     shutil.rmtree(IMAGE_CUSTOM_ICON_PATH + each_pk["image_name"])
-                result = self.cli.cmd('no va image "%s"' % each_pk["image_name"],
-                                  BlankParser(nonblank_exception=CLICmdError, supplement=True))
+                result = self.cli.cmd('no va image "%s"' % each_pk["image_name"])
+                if "Invalid image file name" in result:
+                    cli_parse(result, RegexParser('Invalid image file name', match_exception=CLICmdError, match_msg=__('Invalid image file name! Allowed characters: "a-z", "A-Z", "0-9", ".", "_", "-"')))
+                elif result:
+                    cli_parse(result, BlankParser(nonblank_exception=CLICmdError, supplement=True))
             mark_expire_all(getVAImageNumber)
             return
 
