- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2018 03:00 AM
Hi,
I'm trying to automate as much as possible the deployment of MID servers to many branch environments. I have figured out how to get the MID server to deploy as a Windows service without requiring end user UI by preconfiguring the config files, but I end up with a new MID server entry in the instance that needs to be manually validated before it will work. Since these new MID servers could be deployed at all hours by a deployment script, I need the validation to happen automatically.
I can't find any mention of how to do this in the API reference. Is this something I'm missing or is there no way to automate this at all and it HAS to be done manually?
Thanks,
Mark.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2018 09:18 PM
Hi Mark,
To follow-up on what Arnoud wrote. I took a look at the MIDServerAjax script include that is called to validate a Mid Server from the UI.
If you add the code below to a scheduled job and set the job to run on a schedule of your choosing, you can make sure that any unvalidated Mid Servers get validated.
var mm = new MIDServerManage();
var gr = new GlideRecord("ecc_agent");
//search for mid servers that aren't validated
gr.addQuery("validated", false);
gr.query();
while(gr.next()){
mm.validate(gr.name);
}
Hope this helps.
Let me know if you have any questions.
Thanks,
Cody
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2018 01:26 AM
Thanks Cody, that's very helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2018 01:41 AM
This would be a security breach.
The validate step is there to be conscious in witch midserver your interacts with.
If you invalidate a server, it will revalidate when the job runs.
Dont use this in a business environment.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2018 08:43 AM
Hi Mark,
Arnoud makes a good point. If you use a scheduled job as I suggested, then any server you invalidated manually would be validated again the next time the job ran.
To address this you would need to add a way to identify servers that you have manually invalidated, so that you can write a query that excludes them from being revalidated when the job runs.
For example, you could add a true/false field to the Mid Server (ecc_agent) table. To continue, you could name the field No Auto Validate (u_no_auto_validate). Set it to false by default, and then set it to true when you manually invalidate a mid server.
The updated script in the scheduled job would look like this.
var mm = new MIDServerManage();
var gr = new GlideRecord("ecc_agent");
//search for mid servers that aren't validated
gr.addQuery("validated", false);
//add query to exclude servers that we don't want to auto validate
gr.addQuery("u_no_auto_validate", false);
gr.query();
while(gr.next()){
mm.validate(gr.name);
}
Again, thanks to Arnoud for identifying a security issue with the approach I suggested.
Let me know if you have any questions.
Thanks,
Cody