mirror of
https://github.com/tlsnotary/pagesigner-oracles.git
synced 2026-01-08 22:47:57 -05:00
aws_query: fix output
This commit is contained in:
20
aws_query.py
20
aws_query.py
@@ -5,13 +5,13 @@ import hashlib
|
||||
from urllib import parse
|
||||
|
||||
if len(sys.argv) != 6:
|
||||
print ('Output HTTPS GET links in JSON to be used to check the oracle status')
|
||||
print ('Outputs HTTPS GET links in JSON to be used to check the oracle status')
|
||||
print ('The default availability zone is ec2.us-east-1.amazonaws.com')
|
||||
print ('Usage: ami-id instance-id volume-id AWS-ID AWS-secret')
|
||||
print('Where:')
|
||||
print('ami-id is the AMI from which the instance was launched,')
|
||||
print('instance-id is the notary server instance, and')
|
||||
print('volume-id is the volume attached to it.')
|
||||
print ('Where:')
|
||||
print ('ami-id is the AMI from which the instance was launched,')
|
||||
print ('instance-id is the notary server instance, and')
|
||||
print ('volume-id is the volume attached to it.')
|
||||
exit(0)
|
||||
|
||||
common_args = [('Expires=2030-01-01'), ('SignatureMethod=HmacSHA256'), ('SignatureVersion=2')]
|
||||
@@ -21,8 +21,10 @@ instance_id = sys.argv[2]
|
||||
volume_id = sys.argv[3]
|
||||
key = sys.argv[4]
|
||||
secret = sys.argv[5]
|
||||
output = ''
|
||||
|
||||
def makeurl(args, endpoint, abbr):
|
||||
global output
|
||||
# sorting is essential, otherwise AWS will refuse the signature
|
||||
args.sort()
|
||||
argstr = ''
|
||||
@@ -34,10 +36,10 @@ def makeurl(args, endpoint, abbr):
|
||||
base64str = base64.b64encode(mhmac.digest()).strip().decode('utf-8')
|
||||
urlenc_sig = parse.quote_plus(base64str)
|
||||
final_string='https://'+endpoint+'/?'+argstr+'&Signature='+urlenc_sig
|
||||
print ('"' + final_string + '",', end = '')
|
||||
output += '"' + final_string + '",'
|
||||
|
||||
print('The JSON below is an input for URLFetcher:')
|
||||
print('[', end = '')
|
||||
output += '['
|
||||
args = []
|
||||
args.extend(common_args)
|
||||
args.append('Action=DescribeInstances')
|
||||
@@ -105,4 +107,6 @@ args.append('ImageId.1='+ami_id)
|
||||
args.append('AWSAccessKeyId='+key)
|
||||
args.append('Version=2014-10-01')
|
||||
makeurl(args, availability_zone, 'DImg')
|
||||
print(']')
|
||||
output = output[:-1]
|
||||
output += ']'
|
||||
print(output)
|
||||
Reference in New Issue
Block a user