mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-25 11:01:09 +00:00
Example for XCC cert scripting
This commit is contained in:
parent
6d2918ed45
commit
9180bab761
46
misc/getcsr.py
Normal file
46
misc/getcsr.py
Normal file
@ -0,0 +1,46 @@
|
||||
import argparse
|
||||
import io
|
||||
import gzip
|
||||
import pyghmi.redfish.command as cmd
|
||||
import os
|
||||
import sys
|
||||
|
||||
ap = argparse.ArgumentParser(description='Certificate Generate')
|
||||
ap.add_argument('xcc', help='XCC address')
|
||||
ap.add_argument('--country', help='Two Letter Country')
|
||||
ap.add_argument('--state', help='State or Province')
|
||||
ap.add_argument('--city', help='City or Locality')
|
||||
ap.add_argument('--org', help='Organization name')
|
||||
ap.add_argument('--name', help='Common/Host Name')
|
||||
args = ap.parse_args()
|
||||
|
||||
c = cmd.Command(args.xcc, os.environ['XCCUSER'], os.environ['XCCPASS'],
|
||||
verifycallback=lambda x: True)
|
||||
params = [
|
||||
'0', # 'serviceType'
|
||||
args.country,
|
||||
args.state,
|
||||
args.city,
|
||||
args.org,
|
||||
args.name,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
]
|
||||
wc = c.oem.wc
|
||||
rsp, status = wc.grab_json_response_with_status('/api/function', {'Sec_GenKeyAndCSR': ','.join(params)})
|
||||
rsp, status = wc.grab_json_response_with_status('/api/dataset', {'CSR_Format': '1'})
|
||||
rsp, status = wc.grab_json_response_with_status('/api/function', {'Sec_DownloadCSRANDCert': '0,4,0'})
|
||||
wc.request('GET', '/download/{0}'.format(rsp['FileName']))
|
||||
rsp = wc.getresponse()
|
||||
csr = rsp.read()
|
||||
if rsp.getheader('Content-Encoding', None) == 'gzip':
|
||||
csr = gzip.GzipFile(fileobj=io.BytesIO(csr)).read()
|
||||
print(csr)
|
||||
|
16
misc/installcert.py
Normal file
16
misc/installcert.py
Normal file
@ -0,0 +1,16 @@
|
||||
import argparse
|
||||
import pyghmi.redfish.command as cmd
|
||||
import os
|
||||
import sys
|
||||
|
||||
ap = argparse.ArgumentParser(description='Certificate Generate')
|
||||
ap.add_argument('xcc', help='XCC address')
|
||||
ap.add_argument('cert', help='Certificate in PEM format')
|
||||
args = ap.parse_args()
|
||||
|
||||
c = cmd.Command(args.xcc, os.environ['XCCUSER'], os.environ['XCCPASS'],
|
||||
verifycallback=lambda x: True)
|
||||
wc = c.oem.wc
|
||||
cert = open(args.cert, 'rb').read()
|
||||
res = wc.grab_json_response_with_status('/api/function', {'Sec_ImportCert': '0,1,0,0,,{0}'.format(cert)
|
||||
print(repr(res))
|
Loading…
Reference in New Issue
Block a user