diff options
Diffstat (limited to 'scripts/lib/mic/conf.py')
| -rw-r--r-- | scripts/lib/mic/conf.py | 58 |
1 files changed, 1 insertions, 57 deletions
diff --git a/scripts/lib/mic/conf.py b/scripts/lib/mic/conf.py index b850d80520..1fe6edd724 100644 --- a/scripts/lib/mic/conf.py +++ b/scripts/lib/mic/conf.py | |||
| @@ -20,7 +20,7 @@ import ConfigParser | |||
| 20 | 20 | ||
| 21 | from mic import msger | 21 | from mic import msger |
| 22 | from mic import kickstart | 22 | from mic import kickstart |
| 23 | from mic.utils import misc, runner, proxy, errors | 23 | from mic.utils import misc, runner, errors |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | def get_siteconf(): | 26 | def get_siteconf(): |
| @@ -55,8 +55,6 @@ class ConfigMgr(object): | |||
| 55 | "pack_to": None, | 55 | "pack_to": None, |
| 56 | "name_prefix": None, | 56 | "name_prefix": None, |
| 57 | "name_suffix": None, | 57 | "name_suffix": None, |
| 58 | "proxy": None, | ||
| 59 | "no_proxy": None, | ||
| 60 | "copy_kernel": False, | 58 | "copy_kernel": False, |
| 61 | "install_pkgs": None, | 59 | "install_pkgs": None, |
| 62 | "repourl": {}, | 60 | "repourl": {}, |
| @@ -104,16 +102,6 @@ class ConfigMgr(object): | |||
| 104 | for sec, vals in self.DEFAULTS.iteritems(): | 102 | for sec, vals in self.DEFAULTS.iteritems(): |
| 105 | setattr(self, sec, vals) | 103 | setattr(self, sec, vals) |
| 106 | 104 | ||
| 107 | def __set_siteconf(self, siteconf): | ||
| 108 | try: | ||
| 109 | self.__siteconf = siteconf | ||
| 110 | self._parse_siteconf(siteconf) | ||
| 111 | except ConfigParser.Error, error: | ||
| 112 | raise errors.ConfigError("%s" % error) | ||
| 113 | def __get_siteconf(self): | ||
| 114 | return self.__siteconf | ||
| 115 | _siteconf = property(__get_siteconf, __set_siteconf) | ||
| 116 | |||
| 117 | def __set_ksconf(self, ksconf): | 105 | def __set_ksconf(self, ksconf): |
| 118 | if not os.path.isfile(ksconf): | 106 | if not os.path.isfile(ksconf): |
| 119 | msger.error('Cannot find ks file: %s' % ksconf) | 107 | msger.error('Cannot find ks file: %s' % ksconf) |
| @@ -124,50 +112,6 @@ class ConfigMgr(object): | |||
| 124 | return self.__ksconf | 112 | return self.__ksconf |
| 125 | _ksconf = property(__get_ksconf, __set_ksconf) | 113 | _ksconf = property(__get_ksconf, __set_ksconf) |
| 126 | 114 | ||
| 127 | def _parse_siteconf(self, siteconf): | ||
| 128 | if not siteconf: | ||
| 129 | return | ||
| 130 | |||
| 131 | if not os.path.exists(siteconf): | ||
| 132 | msger.warning("cannot read config file: %s" % siteconf) | ||
| 133 | return | ||
| 134 | |||
| 135 | parser = ConfigParser.SafeConfigParser() | ||
| 136 | parser.read(siteconf) | ||
| 137 | |||
| 138 | for section in parser.sections(): | ||
| 139 | if section in self.DEFAULTS: | ||
| 140 | getattr(self, section).update(dict(parser.items(section))) | ||
| 141 | |||
| 142 | # append common section items to other sections | ||
| 143 | for section in self.DEFAULTS.keys(): | ||
| 144 | if section != "common": | ||
| 145 | getattr(self, section).update(self.common) | ||
| 146 | |||
| 147 | # check and normalize the scheme of proxy url | ||
| 148 | if self.create['proxy']: | ||
| 149 | m = re.match('^(\w+)://.*', self.create['proxy']) | ||
| 150 | if m: | ||
| 151 | scheme = m.group(1) | ||
| 152 | if scheme not in ('http', 'https', 'ftp', 'socks'): | ||
| 153 | msger.error("%s: proxy scheme is incorrect" % siteconf) | ||
| 154 | else: | ||
| 155 | msger.warning("%s: proxy url w/o scheme, use http as default" | ||
| 156 | % siteconf) | ||
| 157 | self.create['proxy'] = "http://" + self.create['proxy'] | ||
| 158 | |||
| 159 | proxy.set_proxies(self.create['proxy'], self.create['no_proxy']) | ||
| 160 | |||
| 161 | # bootstrap option handling | ||
| 162 | self.set_runtime(self.create['runtime']) | ||
| 163 | if isinstance(self.bootstrap['packages'], basestring): | ||
| 164 | packages = self.bootstrap['packages'].replace('\n', ' ') | ||
| 165 | if packages.find(',') != -1: | ||
| 166 | packages = packages.split(',') | ||
| 167 | else: | ||
| 168 | packages = packages.split() | ||
| 169 | self.bootstrap['packages'] = packages | ||
| 170 | |||
| 171 | def _parse_kickstart(self, ksconf=None): | 115 | def _parse_kickstart(self, ksconf=None): |
| 172 | if not ksconf: | 116 | if not ksconf: |
| 173 | return | 117 | return |
