Skip to content

Instantly share code, notes, and snippets.

@HauptJ
Created March 28, 2020 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HauptJ/57e2d1ce2dfbb80a836894d32f06da86 to your computer and use it in GitHub Desktop.
Save HauptJ/57e2d1ce2dfbb80a836894d32f06da86 to your computer and use it in GitHub Desktop.
OVH API Re-Imaging Script
#!/usr/bin/env python3
import ovh
import json
import argparse
def reimage(ovhClient, ovhServerName, sshKeyName, hostName, ovhTemplateName, useDistribKernel=False):
result = ovhClient.post(
'/dedicated/server/'+ ovhServerName + '/install/start',
details={
"noRaid":False,
"sshKeyName":sshKeyName,
"language":"en",
"useSpla":False,
"diskGroupId": 1,
"resetHwRaid":False,
"customHostname":hostName,
"installSqlServer":False,
"useDistribKernel":useDistribKernel
},
templateName=ovhTemplateName,
)
return result
def printResult(result):
print(json.dumps(result, indent=4))
def client():
# create a client instance using configuration in ovh.conf
ovhClient = ovh.Client()
return ovhClient
def main(argv):
option = ''
ovhServerName = ''
sshKeyName = ''
sshKeyName = ''
hostName = ''
ovhTemplateName = ''
useDistribKernel = 'true'
parser = argparse.ArgumentParser()
parser.add_argument()
# Function return output
ovhClient = client()
if(option == "reinstall"):
result = reimage(ovhClient, ovhServerName, sshKeyName, hostName, ovhTemplateName, useDistribKernel)
printResult(result)
else:
print("Invalid option paramater passed in.")
if __name__== "__main__":
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment