I have written a python script (and an ansible playbook due to not being able to make the script work, but that's a different story) whose purpose is to perform a switchover within a mongodb replica set that is managed by ops manager, version 3.6. I have two sites, 3 servers in one site and 2 sites in the other, and what that script does basically is sent a PUT request to edit the automation configuration of the replica set and, depending on which site given, change the wanted server's priority to 2 while leaving the others at 1 and adding arbiters then deleting them if necessary. For now the purpose is just to change the priority with the put request to try and make it work, here is what the PUT request looks like:
data = {"replicaSets": [
{
"_id"_: "PP_ATLAS",
"members": [
{
"_id": 2,
"host": "*servername*",
"priority": 2,
},
{
"_id": 3,
"host": "*servername*",
},
{
"_id": 4,
"host": "*servername*",
}
]
}
],
}
headers = {'Content-Type': 'application/json'}
js = requests.put(url, auth=HTTPDigestAuth (MMS_User, MMS_API), data=json.dumps(data), headers=headers, verify=False)
MMS_User and MMS_API are the identification tokens used in order to access the ops manager, also known as MMS.
When I attempt this (the script requests a server name to switchover to as an argument), I recieve:
{"detail":"Invalid automation config: Process *servername that was given as an argument* referenced in one or more deployment items but not found in configuration.","error":400,"errorCode":null,"parameters":null,"reason":"Bad Request"}
400
The servername that was given as an argument is what it says, not the actual quote "servername that was given as an argument".