mirror of https://git.48k.eu/ogcli/
				
				
				
			Bring clients.py up to date with ogServer API
get_client_properties is not using a valid API resource to fetch
computer details. Use /client/info.
list_client_hardware is not building a valid payload. Drop
payload building using 'scope' as key and updates o that its
uses "{ client : ip }" scheme for specifying a client. This is the
standard way of specifying a client in ogServer.
			
			
				master
			
			
		
							parent
							
								
									015a43ac3a
								
							
						
					
					
						commit
						f6fa795803
					
				|  | @ -18,27 +18,26 @@ class OgClient(): | ||||||
| 	@staticmethod | 	@staticmethod | ||||||
| 	def list_client_hardware(rest, args): | 	def list_client_hardware(rest, args): | ||||||
| 		parser = argparse.ArgumentParser() | 		parser = argparse.ArgumentParser() | ||||||
| 		parser.add_argument('--scope-id', | 		parser.add_argument('--client', | ||||||
| 				    nargs=1, | 				    nargs=1, | ||||||
|  | 				    type=str, | ||||||
| 				    required=True, | 				    required=True, | ||||||
| 				    help='ID of the computer scope') | 				    help='client IP') | ||||||
| 		parsed_args = parser.parse_args(args) | 		parsed_args = parser.parse_args(args) | ||||||
| 
 | 
 | ||||||
| 		payload = {'scope': {'id': int(parsed_args.scope_id[0]), | 		payload = {'client': parsed_args.client} | ||||||
| 				     'type': 'computer'}} |  | ||||||
| 		r = rest.get('/hardware', payload=payload) | 		r = rest.get('/hardware', payload=payload) | ||||||
| 		print(r.json()) | 		print(r.json()) | ||||||
| 
 | 
 | ||||||
| 	@staticmethod | 	@staticmethod | ||||||
| 	def get_client_properties(rest, args): | 	def get_client_properties(rest, args): | ||||||
| 		parser = argparse.ArgumentParser() | 		parser = argparse.ArgumentParser() | ||||||
| 		parser.add_argument('--id', | 		parser.add_argument('--client', | ||||||
| 				    nargs=1, | 				    nargs=1, | ||||||
| 				    required=True, | 				    required=True, | ||||||
| 				    help='ID of the computer scope') | 				    help='client IP') | ||||||
| 		parsed_args = parser.parse_args(args) | 		parsed_args = parser.parse_args(args) | ||||||
| 
 | 
 | ||||||
| 		payload = {'scope': {'id': int(parsed_args.id[0]), | 		payload = {'client': parsed_args.client} | ||||||
| 				     'type': 'computer'}} | 		r = rest.get('/client/info', payload=payload) | ||||||
| 		r = rest.get('/client/properties', payload=payload) |  | ||||||
| 		print(r.json()) | 		print(r.json()) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue