Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Commit

Permalink
Enhancement to manageags files to support portal security handler
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMillerGIS committed Jun 25, 2015
1 parent fed4ec6 commit d61228c
Show file tree
Hide file tree
Showing 10 changed files with 654 additions and 183 deletions.
90 changes: 70 additions & 20 deletions src/arcrest/manageags/_clusters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from .._abstract.abstract import BaseAGSServer
import json
from parameters import ClusterProtocol
from ..security.security import ArcGISTokenSecurityHandler,AGOLTokenSecurityHandler, PortalTokenSecurityHandler, OAuthSecurityHandler, PortalServerSecurityHandler

########################################################################
class Clusters(BaseAGSServer):
"""
Expand Down Expand Up @@ -39,9 +41,13 @@ def __init__(self, url,
def __init(self):
""" populates server admin information """
params = {
"f" : "json",
"token" : self._securityHandler.token
"f" : "json"
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
json_dict = self._do_get(url=self._url,
param_dict=params,
proxy_url=self._proxy_url,
Expand Down Expand Up @@ -85,12 +91,16 @@ def createCluster(self, clusterName, machineNames="", tcpClusterPort=None):
"""
url = self._url + "/create"
params = {
"token" : self._securityHandler.token,
"f" : "json",
"clusterName" : clusterName,
"machineNames" : machineNames,
"tcpClusterPort" : tcpClusterPort
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
return self._do_post(url=url,
param_dict=params,
proxy_url=self._proxy_url,
Expand All @@ -105,9 +115,13 @@ def getAvailableMachines(self):
"""
url = self._url + "/getAvailableMachines"
params = {
"f" : "json",
"token" : self._securityHandler.token
"f" : "json"
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
return self._do_get(url=url,
param_dict=params,
proxy_url=self._proxy_url,
Expand Down Expand Up @@ -152,9 +166,13 @@ def __init__(self, url, securityHandler, proxy_url=None, proxy_port=None,
def __init(self):
""" populates server admin information """
params = {
"f" : "json",
"token" : self._securityHandler.token
"f" : "json"
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
json_dict = self._do_get(url=self._url,
param_dict=params,
proxy_url=self._proxy_url,
Expand Down Expand Up @@ -234,9 +252,13 @@ def start(self):
operation reports an error.
"""
params = {
"f" : "json",
"token" : self._securityHandler.token
"f" : "json"
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
url = self._url + "/start"
return self._do_post(url=url,
param_dict=params,
Expand All @@ -251,9 +273,13 @@ def stop(self):
be reached, then this operation reports an error.
"""
params = {
"f" : "json",
"token" : self._securityHandler.token
"f" : "json"
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
url = self._url + "/stop"
return self._do_post(url=url,
param_dict=params,
Expand All @@ -268,9 +294,13 @@ def delete(self):
also stopped. Deleting a cluster does not delete your GIS services.
"""
params = {
"f" : "json",
"token" : self._securityHandler.token
"f" : "json"
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
url = self._url + "/delete"
return self._do_post(url=url,
param_dict=params,
Expand All @@ -286,9 +316,13 @@ def servicesInCluster(self):
This resource was added at ArcGIS 10.1 Service Pack 1.
"""
params = {
"f" : "json",
"token" : self._securityHandler.token
"f" : "json"
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
url = self._url + "/services"
return self._do_post(url=url,
param_dict=params,
Expand All @@ -306,9 +340,13 @@ def machinesInCluster(self):
"""
url = self._url + "/machines"
params = {
"f" : "json",
"token" : self._securityHandler.token
"f" : "json"
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
return self._do_get(url=url,
param_dict=params,
proxy_url=self._proxy_url,
Expand All @@ -328,9 +366,13 @@ def addMachinesToCluster(self, machineNames):
url = self._url + "/machines/add"
params = {
"f" : "json",
"token" : self._securityHandler.token,
"machineNames" : machineNames
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
return self._do_post(url=url,
param_dict=params,
proxy_url=self._proxy_url,
Expand All @@ -349,9 +391,13 @@ def removeMachinesFromCluster(self,
url = self._url + "/machines/remove"
params = {
"f" : "json",
"token" : self._securityHandler.token,
"machineNames" : machineNames
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
return self._do_post(url=url,
param_dict=params,
proxy_url=self._proxy_url,
Expand All @@ -368,9 +414,13 @@ def editProtocol(self, clusterProtocolObj):
url = self._url + "/editProtocol"
params = {
"f" : "json",
"token" : self._securityHandler.token,
"clusterProtocol" : str(clusterProtocolObj)
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token
return self._do_post(url=url,
param_dict=params,
proxy_url=self._proxy_url,
Expand Down
Loading

0 comments on commit d61228c

Please sign in to comment.