Skip to content

Commit f9a97ab

Browse files
Bugfixes
1 parent ca12a68 commit f9a97ab

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

etc/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ port = 6379
3030
# Devportal helper
3131
[devportal]
3232
host = "devportal"
33-
port = 5000
33+
port = 5001
3434
uri = "/v1/devportal"
3535

3636
# Staged configuration for NGINX Management Suite

src/Contrib/DevPortal.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313

1414

1515
def buildDevPortal(openapischema):
16-
response = requests.post(f"http://{NcgConfig.config['devportal']['host']}:"
17-
f"{NcgConfig.config['devportal']['port']}{NcgConfig.config['devportal']['uri']}",
18-
headers={'Content-Type': 'application/json'}, data=openapischema)
16+
try:
17+
response = requests.post(f"http://{NcgConfig.config['devportal']['host']}:"
18+
f"{NcgConfig.config['devportal']['port']}{NcgConfig.config['devportal']['uri']}",
19+
headers={'Content-Type': 'application/json'}, data=openapischema)
20+
except Exception as e:
21+
return 400, ""
1922

2023
return response.status_code, json.loads(response.text)
2124

@@ -32,6 +35,9 @@ def createDevPortal(locationDeclaration: dict):
3235
apiSchemaString = Contrib.MiscUtils.yaml_to_json(apiSchemaString)
3336

3437
status, devportalJSON = buildDevPortal(openapischema=apiSchemaString)
35-
devportalHTML = base64.b64encode(bytes(devportalJSON['devportal'], 'utf-8')).decode('utf-8')
38+
if status == 200:
39+
devportalHTML = base64.b64encode(bytes(devportalJSON['devportal'], 'utf-8')).decode('utf-8')
40+
else:
41+
devportalHTML = ""
3642

37-
return 200, devportalHTML
43+
return status, devportalHTML

src/V3_CreateConfig.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ def createconfig(declaration: ConfigDeclaration, apiversion: str, runfromautosyn
152152
status, devPortalHTML = (
153153
Contrib.DevPortal.createDevPortal(locationDeclaration=loc))
154154

155+
if status != 200:
156+
return {"status_code": 400,
157+
"message": {"status_code": status, "message":
158+
{"code": status, "content": f"Developer Portal creation failed for {loc['apigateway']['openapi_schema']}"}}}
159+
155160
### Add optional API Developer portal HTML files
156161
# devPortalHTML
157162
newAuxFile = {'contents': devPortalHTML, 'name': NcgConfig.config['nms']['devportal_dir'] +
@@ -443,8 +448,13 @@ def createconfig(declaration: ConfigDeclaration, apiversion: str, runfromautosyn
443448
print(f'Configuration [{configUid}] changed, publishing to NMS')
444449

445450
# Retrieve instance group uid
446-
ig = requests.get(url=f'{nmsUrl}/api/platform/v1/instance-groups', auth=(nmsUsername, nmsPassword),
447-
verify=False)
451+
try:
452+
ig = requests.get(url=f'{nmsUrl}/api/platform/v1/instance-groups', auth=(nmsUsername, nmsPassword),
453+
verify=False)
454+
except Exception as e:
455+
return {"status_code": 400,
456+
"message": {"status_code": 400,
457+
"message": {"code": 400, "content": f"Can't connect to {nmsUrl}"}}}
448458

449459
if ig.status_code != 200:
450460
try:

src/V3_NginxConfigDeclaration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111

1212
class OutputConfigMap(BaseModel, extra=Extra.forbid):
13-
name: str = ""
13+
name: str = "nginx-config"
1414
namespace: Optional[str] = ""
15-
filename: str = ""
15+
filename: str = "nginx-config.conf"
1616

1717

1818
class OutputHttp(BaseModel, extra=Extra.forbid):

0 commit comments

Comments
 (0)