Revision 823bfa49
b/lib/hypervisor/hv_base.py | ||
---|---|---|
62 | 62 |
_FILE_CHECK = (utils.IsNormAbsPath, "must be an absolute normalized path", |
63 | 63 |
os.path.isfile, "not found or not a file") |
64 | 64 |
|
65 |
# must be a file or a URL |
|
66 |
_FILE_OR_URL_CHECK = (utils.IsNormAbsPathOrURL, |
|
67 |
"must be an absolute normalized path or a URL", |
|
68 |
lambda x: os.path.isfile(x) or |
|
69 |
re.match(r'(https?|ftp)://', x), |
|
70 |
"not found or not a file or URL") |
|
71 |
|
|
65 | 72 |
# must be a directory |
66 | 73 |
_DIR_CHECK = (utils.IsNormAbsPath, "must be an absolute normalized path", |
67 | 74 |
os.path.isdir, "not found or not a directory") |
... | ... | |
75 | 82 |
# nice wrappers for users |
76 | 83 |
REQ_FILE_CHECK = (True, ) + _FILE_CHECK |
77 | 84 |
OPT_FILE_CHECK = (False, ) + _FILE_CHECK |
85 |
REQ_FILE_OR_URL_CHECK = (True, ) + _FILE_OR_URL_CHECK |
|
86 |
OPT_FILE_OR_URL_CHECK = (False, ) + _FILE_OR_URL_CHECK |
|
78 | 87 |
REQ_DIR_CHECK = (True, ) + _DIR_CHECK |
79 | 88 |
OPT_DIR_CHECK = (False, ) + _DIR_CHECK |
80 | 89 |
NET_PORT_CHECK = (True, lambda x: x > 0 and x < 65535, "invalid port number", |
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
164 | 164 |
constants.HV_VNC_X509: hv_base.OPT_DIR_CHECK, |
165 | 165 |
constants.HV_VNC_X509_VERIFY: hv_base.NO_CHECK, |
166 | 166 |
constants.HV_VNC_PASSWORD_FILE: hv_base.OPT_FILE_CHECK, |
167 |
constants.HV_CDROM_IMAGE_PATH: hv_base.OPT_FILE_CHECK, |
|
167 |
constants.HV_CDROM_IMAGE_PATH: hv_base.OPT_FILE_OR_URL_CHECK,
|
|
168 | 168 |
constants.HV_BOOT_ORDER: |
169 | 169 |
hv_base.ParamInSet(True, constants.HT_KVM_VALID_BO_TYPES), |
170 | 170 |
constants.HV_NIC_TYPE: |
... | ... | |
567 | 567 |
|
568 | 568 |
iso_image = hvp[constants.HV_CDROM_IMAGE_PATH] |
569 | 569 |
if iso_image: |
570 |
options = ',format=raw,media=cdrom' |
|
570 |
options = ',media=cdrom' |
|
571 |
if not re.match(r'(https?|ftp)://', iso_image): |
|
572 |
options = "%s,format=raw" % options |
|
571 | 573 |
if boot_cdrom: |
572 | 574 |
kvm_cmd.extend(['-boot', 'd']) |
573 | 575 |
if disk_type != constants.HT_DISK_IDE: |
b/lib/utils/io.py | ||
---|---|---|
23 | 23 |
""" |
24 | 24 |
|
25 | 25 |
import os |
26 |
import re |
|
26 | 27 |
import logging |
27 | 28 |
import shutil |
28 | 29 |
import tempfile |
... | ... | |
441 | 442 |
return os.path.normpath(path) == path and os.path.isabs(path) |
442 | 443 |
|
443 | 444 |
|
445 |
def IsNormAbsPathOrURL(path): |
|
446 |
"""Check whether a path is absolute and normalized, or |
|
447 |
an HTTP URL. |
|
448 |
|
|
449 |
""" |
|
450 |
return IsNormAbsPath(path) or re.match(r'(https?|ftp)://', path) |
|
451 |
|
|
452 |
|
|
444 | 453 |
def PathJoin(*args): |
445 | 454 |
"""Safe-join a list of path components. |
446 | 455 |
|
Also available in: Unified diff