| @@ 162-202 (lines=41) @@ | ||
| 159 | def _parse_certificates(self, value): |
|
| 160 | self.certificates = value |
|
| 161 | ||
| 162 | def handle_end(self): |
|
| 163 | """Handle the end of the section.""" |
|
| 164 | tmpl = "%s missing for the %s addon" |
|
| 165 | ||
| 166 | # check provided data |
|
| 167 | if not self.content_type: |
|
| 168 | raise KickstartValueError(tmpl % ("content-type", self.name)) |
|
| 169 | ||
| 170 | if self.content_type != "scap-security-guide" and not self.content_url: |
|
| 171 | raise KickstartValueError(tmpl % ("content-url", self.name)) |
|
| 172 | ||
| 173 | if not self.profile_id: |
|
| 174 | self.profile_id = "default" |
|
| 175 | ||
| 176 | if self.content_type in ("rpm", "archive") and not self.content_path: |
|
| 177 | msg = "Path to the XCCDF file has to be given if content in RPM "\ |
|
| 178 | "or archive is used" |
|
| 179 | raise KickstartValueError(msg) |
|
| 180 | ||
| 181 | if self.content_type == "rpm" and not self.content_url.endswith(".rpm"): |
|
| 182 | msg = "Content type set to RPM, but the content URL doesn't end "\ |
|
| 183 | "with '.rpm'" |
|
| 184 | raise KickstartValueError(msg) |
|
| 185 | ||
| 186 | if self.content_type == "archive": |
|
| 187 | supported_archive = any( |
|
| 188 | self.content_url.endswith(arch_type) |
|
| 189 | for arch_type in common.SUPPORTED_ARCHIVES |
|
| 190 | ) |
|
| 191 | if not supported_archive: |
|
| 192 | msg = "Unsupported archive type of the content "\ |
|
| 193 | "file '%s'" % self.content_url |
|
| 194 | raise KickstartValueError(msg) |
|
| 195 | ||
| 196 | # do some initialization magic in case of SSG |
|
| 197 | if self.content_type == "scap-security-guide": |
|
| 198 | if not common.ssg_available(): |
|
| 199 | msg = "SCAP Security Guide not found on the system" |
|
| 200 | raise KickstartValueError(msg) |
|
| 201 | ||
| 202 | self.content_path = common.SSG_DIR + common.SSG_CONTENT |
|
| 203 | ||
| 204 | def __str__(self): |
|
| 205 | """Generate the kickstart representation. |
|
| @@ 241-284 (lines=44) @@ | ||
| 238 | msg = "Unknown item '%s' for %s addon" % (line, self.name) |
|
| 239 | raise KickstartParseError(msg) |
|
| 240 | ||
| 241 | def finalize(self): |
|
| 242 | """ |
|
| 243 | The finalize method that is called when the end of the %addon section |
|
| 244 | (the %end line) is reached. It means no more kickstart data will come. |
|
| 245 | ||
| 246 | """ |
|
| 247 | ||
| 248 | tmpl = "%s missing for the %s addon" |
|
| 249 | ||
| 250 | # check provided data |
|
| 251 | if not self.content_type: |
|
| 252 | raise KickstartValueError(tmpl % ("content-type", self.name)) |
|
| 253 | ||
| 254 | if self.content_type != "scap-security-guide" and not self.content_url: |
|
| 255 | raise KickstartValueError(tmpl % ("content-url", self.name)) |
|
| 256 | ||
| 257 | if not self.profile_id: |
|
| 258 | self.profile_id = "default" |
|
| 259 | ||
| 260 | if self.content_type in ("rpm", "archive") and not self.content_path: |
|
| 261 | msg = "Path to the XCCDF file has to be given if content in RPM "\ |
|
| 262 | "or archive is used" |
|
| 263 | raise KickstartValueError(msg) |
|
| 264 | ||
| 265 | if self.content_type == "rpm" and not self.content_url.endswith(".rpm"): |
|
| 266 | msg = "Content type set to RPM, but the content URL doesn't end "\ |
|
| 267 | "with '.rpm'" |
|
| 268 | raise KickstartValueError(msg) |
|
| 269 | ||
| 270 | if self.content_type == "archive": |
|
| 271 | supported_archive = any(self.content_url.endswith(arch_type) |
|
| 272 | for arch_type in SUPPORTED_ARCHIVES) |
|
| 273 | if not supported_archive: |
|
| 274 | msg = "Unsupported archive type of the content "\ |
|
| 275 | "file '%s'" % self.content_url |
|
| 276 | raise KickstartValueError(msg) |
|
| 277 | ||
| 278 | # do some initialization magic in case of SSG |
|
| 279 | if self.content_type == "scap-security-guide": |
|
| 280 | if not common.ssg_available(): |
|
| 281 | msg = "SCAP Security Guide not found on the system" |
|
| 282 | raise KickstartValueError(msg) |
|
| 283 | ||
| 284 | self.content_path = common.SSG_DIR + common.SSG_CONTENT |
|
| 285 | ||
| 286 | @property |
|
| 287 | def content_defined(self): |
|