Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding JSON APIs to the HTTP server #578

Merged
merged 5 commits into from
Jun 28, 2023

Conversation

mainframed
Copy link
Contributor

This change adds JSON APIs to the HTTP server similar to xml/rate but provides a lot more information in different/various API calls.

This request adds the following URLs:

  • cgi-bin/api/v1 - returns JSON with information about the APIs
  • cgi-bin/api/v1/cpus - Returns JSON with information about the CPUs
  • cgi-bin/api/v1/devices - Returns JSON with information about the configured devices
  • cgi-bin/api/v1/rates - Returns JSON with MIPS/IO
  • cgi-bin/api/v1/maxrates - Returns JSON with maxrates information
  • cgi-bin/api/v1/version - Returns JSON with version information
  • cgi-bin/api/v1/storage - Returns JSON with storage at an address ( a parameter, default 0) of fullword (a parameter, default 32) length
  • cgi-bin/api/v1/syslog - Returns JSON of the syslog, each line in an array. Can take two parameters: command - hercules commands, and msgcount - the number of lines to return.

For example (from zzsacard.bin):

http://localhost:8888/cgi-bin/api/v1/devices

{
	"devices": [{
		"devnum": "0009",
		"subchannel": "0000",
		"devclass": "CON",
		"devtype": "3215",
		"status": "open ",
		"assignment": "*syscons cmdpref(/) noprompt IO[0]"
	}, {
		"devnum": "000C",
		"subchannel": "0001",
		"devclass": "RDR",
		"devtype": "3505",
		"status": "",
		"assignment": "./util/zzsacard.bin intrq IO[0]"
	}, {
		"devnum": "000D",
		"subchannel": "0002",
		"devclass": "PCH",
		"devtype": "3525",
		"status": "open ",
		"assignment": "punch00d.txt ascii IO[0]"
	}, {
		"devnum": "000E",
		"subchannel": "0003",
		"devclass": "PRT",
		"devtype": "1403",
		"status": "open ",
		"assignment": "print00e.txt crlf IO[0]"
	}, {
		"devnum": "001F",
		"subchannel": "0004",
		"devclass": "DSP",
		"devtype": "3270",
		"status": "",
		"assignment": "* IO[0]"
	}]
}

http://localhost:8888/cgi-bin/api/v1/devices

{
	"cpus": [{
		"cpuid": "CPU0000",
		"online": true,
		"mode": "ESA/390",
		"percent": 0,
		"PSW": "030A0000800078DC",
		"general_registers": {
			"GR0": "00000000",
			"GR1": "0004FFFF",
			"GR2": "00000000",
			"GR3": "00000000",
			"GR4": "00000000",
			"GR5": "00000000",
			"GR6": "00000000",
			"GR7": "00000000",
			"GR8": "00000000",
			"GR9": "00000000",
			"GR10": "00001000",
			"GR11": "00002000",
			"GR12": "800078DA",
			"GR13": "00000000",
			"GR14": "00000000",
			"GR15": "00000000"
		},
		"control_registers": {
			"CR0": "00000840",
			"CR1": "00000000",
			"CR2": "00000000",
			"CR3": "00000000",
			"CR4": "00000000",
			"CR5": "00000000",
			"CR6": "80000000",
			"CR7": "00000000",
			"CR8": "00000000",
			"CR9": "00000000",
			"CR10": "00000000",
			"CR11": "00000000",
			"CR12": "00000000",
			"CR13": "00000000",
			"CR14": "C2000000",
			"CR15": "00000000"
		},
		"access_registers": {
			"AR0": "00000000",
			"AR1": "00000000",
			"AR2": "00000000",
			"AR3": "00000000",
			"AR4": "00000000",
			"AR5": "00000000",
			"AR6": "00000000",
			"AR7": "00000000",
			"AR8": "00000000",
			"AR9": "00000000",
			"AR10": "00000000",
			"AR11": "00000000",
			"AR12": "00000000",
			"AR13": "00000000",
			"AR14": "00000000",
			"AR15": "00000000"
		}
	}, {
		"cpuid": "CPU0001",
		"online": false,
		"mode": "z/Arch",
		"percent": 0,
		"PSW": "00000000000000000000000000000000",
		"general_registers": {
			"GR0": "0000000000000000",
			"GR1": "0000000000000000",
			"GR2": "0000000000000000",
			"GR3": "0000000000000000",
			"GR4": "0000000000000000",
			"GR5": "0000000000000000",
			"GR6": "0000000000000000",
			"GR7": "0000000000000000",
			"GR8": "0000000000000000",
			"GR9": "0000000000000000",
			"GR10": "0000000000000000",
			"GR11": "0000000000000000",
			"GR12": "0000000000000000",
			"GR13": "0000000000000000",
			"GR14": "0000000000000000",
			"GR15": "0000000000000000"
		},
		"control_registers": {
			"CR0": "0000000000000060",
			"CR1": "0000000000000000",
			"CR2": "0000000000000000",
			"CR3": "0000000000000000",
			"CR4": "0000000000000000",
			"CR5": "0000000000000000",
			"CR6": "0000000000000000",
			"CR7": "0000000000000000",
			"CR8": "0000000000000000",
			"CR9": "0000000000000000",
			"CR10": "0000000000000000",
			"CR11": "0000000000000000",
			"CR12": "0000000000000000",
			"CR13": "0000000000000000",
			"CR14": "00000000C2000000",
			"CR15": "0000000000000000"
		},
		"access_registers": {
			"AR0": "00000000",
			"AR1": "00000000",
			"AR2": "00000000",
			"AR3": "00000000",
			"AR4": "00000000",
			"AR5": "00000000",
			"AR6": "00000000",
			"AR7": "00000000",
			"AR8": "00000000",
			"AR9": "00000000",
			"AR10": "00000000",
			"AR11": "00000000",
			"AR12": "00000000",
			"AR13": "00000000",
			"AR14": "00000000",
			"AR15": "00000000"
		}
	}]
}

http://localhost:8888/cgi-bin/api/v1/syslog?msgcount=15

{
	"command": "",
	"msgcount": 15,
	"syslog": 
                         [
                             "HHC00100I Thread id 00007f76fd8cd640, prio 0, name 'rubato_thread' started", 
                             "HHC01024I Waiting for console connections on port 13270", 
                             "HHC01603I ipl c", 
                             "HHC00811I Processor CP00: architecture mode ESA/390",  
                             "HHC00801I Processor CP00: Operand exception interruption code 0015 ilc 4", 
                             "HHC02324I PSW=00081000800005E4 INST=B2343000     STSCH 0(3)                   store_subchannel", 
                             "HHC02326I R:00007E88:K:06=00000000 00010009 80000080 0000FF80  ................", 
                             "HHC02269I GR00=00000000 GR01=00050000 GR02=00000000 GR03=00007E88", 
                             "HHC02269I GR04=00000148 GR05=00000000 GR06=000005D2 GR07=00000000", 
                             "HHC02269I GR08=000A0000 GR09=DEAD0001 GR10=00001000 GR11=00002000", 
                             "HHC02269I GR12=00000000 GR13=00000000 GR14=80000390 GR15=00000000", 
                             "HHC02271I CR00=00000840 CR01=00000000 CR02=00000000 CR03=00000000", 
                             "HHC02271I CR04=00000000 CR05=00000000 CR06=80000000 CR07=00000000", 
                             "HHC02271I CR08=00000000 CR09=00000000 CR10=00000000 CR11=00000000", 
                             "HHC02271I CR12=00000000 CR13=00000000 CR14=C2000000 CR15=00000000", 
                             ""
                        ]
}

Also included is the addition of the javascript mimetype.

Copy link
Member

@Fish-Git Fish-Git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! Very nice! Thanks!

@Fish-Git Fish-Git merged commit ebd74c0 into SDL-Hercules-390:develop Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants