| @@ 204-245 (lines=42) @@ | ||
| 201 | ||
| 202 | self.content_path = common.SSG_DIR + common.SSG_CONTENT |
|
| 203 | ||
| 204 | def __str__(self): |
|
| 205 | """Generate the kickstart representation. |
|
| 206 | ||
| 207 | What should end up in the resulting kickstart file, |
|
| 208 | i.e. string representation of the stored data. |
|
| 209 | ||
| 210 | :return: a string |
|
| 211 | """ |
|
| 212 | if not self.profile_id: |
|
| 213 | return "" |
|
| 214 | ||
| 215 | ret = "%%addon %s" % self.name |
|
| 216 | ret += "\n%s" % key_value_pair("content-type", self.content_type) |
|
| 217 | ||
| 218 | if self.content_url: |
|
| 219 | ret += "\n%s" % key_value_pair("content-url", self.content_url) |
|
| 220 | ||
| 221 | if self.datastream_id: |
|
| 222 | ret += "\n%s" % key_value_pair("datastream-id", self.datastream_id) |
|
| 223 | ||
| 224 | if self.xccdf_id: |
|
| 225 | ret += "\n%s" % key_value_pair("xccdf-id", self.xccdf_id) |
|
| 226 | ||
| 227 | if self.content_path and self.content_type != "scap-security-guide": |
|
| 228 | ret += "\n%s" % key_value_pair("content-path", self.content_path) |
|
| 229 | ||
| 230 | if self.cpe_path: |
|
| 231 | ret += "\n%s" % key_value_pair("cpe-path", self.cpe_path) |
|
| 232 | ||
| 233 | if self.tailoring_path: |
|
| 234 | ret += "\n%s" % key_value_pair("tailoring-path", self.tailoring_path) |
|
| 235 | ||
| 236 | ret += "\n%s" % key_value_pair("profile", self.profile_id) |
|
| 237 | ||
| 238 | if self.fingerprint: |
|
| 239 | ret += "\n%s" % key_value_pair("fingerprint", self.fingerprint) |
|
| 240 | ||
| 241 | if self.certificates: |
|
| 242 | ret += "\n%s" % key_value_pair("certificates", self.certificates) |
|
| 243 | ||
| 244 | ret += "\n%end\n\n" |
|
| 245 | return ret |
|
| 246 | ||
| 247 | ||
| 248 | class OSCAPKickstartSpecification(KickstartSpecification): |
|
| @@ 109-149 (lines=41) @@ | ||
| 106 | ||
| 107 | self.content_bringer = content_discovery.ContentBringer(self) |
|
| 108 | ||
| 109 | def __str__(self): |
|
| 110 | """ |
|
| 111 | What should end up in the resulting kickstart file, i.e. string |
|
| 112 | representation of the stored data. |
|
| 113 | ||
| 114 | """ |
|
| 115 | ||
| 116 | if self.dry_run or not self.profile_id: |
|
| 117 | # the addon was run in the dry run mode, omit it from the kickstart |
|
| 118 | return "" |
|
| 119 | ||
| 120 | def key_value_pair(key, value, indent=4): |
|
| 121 | return "%s%s = %s" % (indent * " ", key, value) |
|
| 122 | ||
| 123 | ret = "%%addon %s" % self.name |
|
| 124 | ret += "\n%s" % key_value_pair("content-type", self.content_type) |
|
| 125 | ||
| 126 | if self.content_url: |
|
| 127 | ret += "\n%s" % key_value_pair("content-url", self.content_url) |
|
| 128 | if self.datastream_id: |
|
| 129 | ret += "\n%s" % key_value_pair("datastream-id", self.datastream_id) |
|
| 130 | if self.xccdf_id: |
|
| 131 | ret += "\n%s" % key_value_pair("xccdf-id", self.xccdf_id) |
|
| 132 | if self.content_path and self.content_type != "scap-security-guide": |
|
| 133 | ret += "\n%s" % key_value_pair("content-path", self.content_path) |
|
| 134 | if self.cpe_path: |
|
| 135 | ret += "\n%s" % key_value_pair("cpe-path", self.cpe_path) |
|
| 136 | if self.tailoring_path: |
|
| 137 | ret += "\n%s" % key_value_pair("tailoring-path", |
|
| 138 | self.tailoring_path) |
|
| 139 | ||
| 140 | ret += "\n%s" % key_value_pair("profile", self.profile_id) |
|
| 141 | ||
| 142 | if self.fingerprint: |
|
| 143 | ret += "\n%s" % key_value_pair("fingerprint", self.fingerprint) |
|
| 144 | ||
| 145 | if self.certificates: |
|
| 146 | ret += "\n%s" % key_value_pair("certificates", self.certificates) |
|
| 147 | ||
| 148 | ret += "\n%end\n\n" |
|
| 149 | return ret |
|
| 150 | ||
| 151 | def _parse_content_type(self, value): |
|
| 152 | value_low = value.lower() |
|