-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/issue-398
- Loading branch information
Showing
4 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env python3 | ||
# Little wrapper to output flavor pretty description | ||
# from a CGI form with flavor | ||
# | ||
# (c) Kurt Garloff <kurt@garloff.de>, 11/2023 | ||
# SPDX-License-Identifier: CC-BY-SA-4.0 | ||
""" | ||
flavor-form.py | ||
CGI script to get passed flavor from a html form (GET) | ||
and parses it according to SCS flavor naming. | ||
It returns an error (sometimes with a useful error message) | ||
or a human-readable description of the flavor. | ||
""" | ||
|
||
# import os | ||
import sys | ||
import re | ||
# import traceback | ||
# TODO: Replace cgi by urllib, cgi is deprecated | ||
import cgi | ||
|
||
|
||
class TestForm: | ||
"Class for testing via cmd line" | ||
def __init__(self, fnm): | ||
self.value = fnm | ||
|
||
|
||
def parse_form(form): | ||
"output pretty description from SCS flavor name" | ||
import importlib | ||
fnmd = importlib.import_module("flavor-name-describe") | ||
fnm = "" | ||
try: | ||
fnm = form["flavor"].value | ||
except KeyError: | ||
pass | ||
print('\t<br/>\n\t<FORM ACTION="/cgi-bin/flavor-form.py" METHOD="GET">') | ||
print(f'\t Flavor name: <INPUT TYPE="text" NAME="flavor" SIZE=24 VALUE="{fnm}"/>') | ||
print('\t <INPUT TYPE="submit" VALUE="Submit"/>') | ||
# print(' <INPUT TYPE="reset" VALUE="Clear"/>\n</FORM>') | ||
print('\t</FORM>') | ||
if fnm: | ||
print("\t<br/><b>Flavor</b>") | ||
try: | ||
fnmd.main((fnm,)) | ||
except (TypeError, NameError, KeyError) as exc: | ||
print(f"\tERROR<br/>\n\t{exc}") | ||
|
||
|
||
def parse_generate(form): | ||
"input details to generate SCS flavor name" | ||
print("\tNot implemented yet as webform, use") | ||
print('\t<tt><a href="https://github.com/SovereignCloudStack/standards/blob/main/Tests/iaas/flavor-naming/flavor-name-check.py">flavor-name-check.py</a> -i</tt>') | ||
|
||
|
||
def main(argv): | ||
"Entry point for cgi flavor parsing" | ||
print("Content-Type: text/html\n") | ||
form = cgi.FieldStorage() | ||
# For testing | ||
if len(argv) > 0: | ||
form = {"flavor": TestForm(argv[0])} | ||
find_parse = re.compile(r'^[ \t]*<!\-\-FLAVOR\-FORM: PARSE\-\->[ \t]*$') | ||
find_generate = re.compile(r'^[ \t]*<!\-\-FLAVOR\-FORM: GENERATE\-\->[ \t]*$') | ||
with open("page/index.html", "r", encoding='utf-8') as infile: | ||
for line in infile: | ||
print(line, end='') | ||
if find_parse.match(line): | ||
parse_form(form) | ||
elif find_generate.match(line): | ||
parse_generate(form) | ||
|
||
|
||
if __name__ == "__main__": | ||
main(sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta property="og:locale" content="en" /> | ||
<meta name="description" content="Sovereign Cloud Stack combines the best of cloud computing in one unified standard. One standards are the SCS flavor names and this page is about parsing and generating SCS flavor names." /> | ||
<link rel="canonical" href="https://flavors.scs.community/" /> | ||
<meta property="og:url" content="https://flavors.scs.community/" /> | ||
<meta property="og:site_name" content="Sovereign Cloud Stack Flavors" /> | ||
<!-- Favicon --> | ||
<link rel="apple-touch-icon" sizes="180x180" href="/assets/scs-apple-icon.png" /> | ||
<link rel="icon" type="image/png" sizes="32x32" href="/assets/scs-favicon-32.png" /> | ||
<link rel="icon" type="image/png" sizes="16x16" href="/assets/scs-favicon-16.png" /> | ||
</head> | ||
<body> | ||
<h1>SCS flavor name parser and generator</h1> | ||
<h2>SCS flavor name parser</h2> | ||
<!--FLAVOR-FORM: PARSE--> | ||
<h2>SCS flavor name generator</h2> | ||
<!--FLAVOR-FORM: GENERATE--> | ||
<h2>References</h2> | ||
<ul> | ||
<li><a href="https://scs.community/">SCS homepage</a></li> | ||
<li><a href="https://docs.scs.community/">SCS docs pages</a></li> | ||
<li><a href="https://docs.scs.community/standards">SCS standards</a></li> | ||
<li><a href="https://docs.scs.community/standards/iaas/scs-0100">SCS flavor naming standard</a></li> | ||
<li><a href="https://github.com/SovereignCloudStack/standards/blob/main/Drafts/flavor-naming-strategy.md">SCS flavor naming rationale</a></li> | ||
<li><a href="https://github.com/SovereignCloudStack/standards/tree/main/Tests/iaas/flavor-naming">SCS flavor naming tools</a></li> | ||
</ul> | ||
</body> | ||
</html> |