"src/pages/service_shop/zhfwDetail.vue" did not exist on "4b94e03211544f8de2820079ec053bbb858b9514"
Commit 682725a1 authored by chengaoxing's avatar chengaoxing

update : a new project

parents
#
# example: http://server.arcgis.com/en/server/latest/administer/linux/example-create-a-site.htm
# Note the example is for ArcGIS Server not Portal but the concepts are the same.
#
from __future__ import print_function
import sys
import os, time
import requests
import json
import argparse
# HTTPS calls will generate warnings about the self-signed certificate if you delete this.
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
class arcgis(object):
def __init__(self,**kwargs):
self.arcgishome = kwargs.get('arcgishome')
self.user = kwargs.get('user')
self.passwd = kwargs.get('passwd')
self.hostname = kwargs.get('hostname')
self.fullname = kwargs.get('fullname')
self.email = kwargs.get('email')
self.content = kwargs.get('content')
self.java_home = kwargs.get('java_home')
os.environ['JAVA_HOME']=self.java_home
def status_check(self):
uri = "https://%s:7443/arcgis/portaladmin/Status" % self.hostname
parameters = {
"f" : "json"
}
try:
response = requests.post(
uri,
data=parameters,
timeout=10,
verify=False
)
rj = json.loads(response.text)
status = rj["status"]
print("portal is in servering with status %s"%(status))
except Exception as e:
print("Failed to request the server %s with reason %s"%(uri,e))
return False
return True
def create_site(self):
defaultdir = "%s/portal/usr" % self.arcgishome
content_store_path = self.content
content_store = {
"type" : "FileSystem",
"provider" : "FileSystem",
"connectionString" : content_store_path
}
content_storeJSON = json.dumps(content_store)
parameters = {
"username" : self.user,
"password" : self.passwd,
"fullname" : self.fullname,
"email" : self.email,
"description" : "Administrator account created for APAAS",
"securityQuestionIdx" : 1,
"securityQuestionAns" : "Nothing",
"contentStore" : content_storeJSON,
"f" : "json"
}
uri = "https://%s:7443/arcgis/portaladmin/createNewSite" % self.hostname
try:
response = requests.post(
uri,
data=parameters,
timeout=500,
verify=False
)
if response and response.status_code != 200:
print("Server not available; code ", response.status_code)
err = json.loads(response.text).get('error',None)
if err is not None:
print("Some error happended when create the new site: \n %s \n"%(err))
return False
except Exception as e:
print("Error when post the requrest with reason :%s"%e)
timeout = True
return True
# ------------------------------------------------------------------------
if __name__ == "__main__":
# parser = argparse.ArgumentParser(description="""
# usage: python portalmanager.py arcgis_hme hostname, user,password [options]
# """
# )
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument("-a","--arcgishome", default="/arcgis",
help="The home path where arcgis portal installed, default is /arcgis")
parser.add_argument("-n","--hostname", default="arcgisportal",
help="The hostname where the server in ")
parser.add_argument("-u","--user", default="portaladmin",
help="the username to register amdin account, default is arcgis")
parser.add_argument("-p","--password", default="Aa123456",
help="the password to register amdin account, default is ABCD1234")
parser.add_argument("-c","--content", default=None,
help="the path to content store, defautl is $ARCGISHOME/portal/usr/arcgisportal")
parser.add_argument("-f","--fullname", default="PORTAL ADMIN",
help="the full name for admin user,default as APAAS CUSTOMER")
parser.add_argument("-e","--email", default="portaladmin@bd-apaas.com",
help="the email for admin user, defautl is user@bd-apaas.com")
parser.add_argument("-j","--javahome", default=None,
help="the email for admin user, defautl is user@bd-apaas.com")
args = parser.parse_args()
if args.content is None:
args.content = "{}/portal/usr/arcgisportal".format(args.arcgishome)
if args.javahome is None:
args.javahome = "{}/portal/framework/runtime/jre".format(args.arcgishome)
print("""
attempting to register a new user with information : {user}:{password}@{hostname};
the home path of arcgis was in {arcgishome};
and data was stored in default path {content};
user's ({user}) full name is {fullname} and email is {email}
""".format(user=args.user,password=args.password,arcgishome=args.arcgishome,
hostname=args.hostname,email=args.email,fullname=args.fullname,
content=args.content)
)
home = '/'+args.arcgishome.split('/')[-1],
user = args.user,
passwd = args.password,
hostname = args.hostname,
content = args.content,
fullname = args.fullname,
email = args.email
ag = arcgis(arcgishome = '/'+args.arcgishome.split('/')[-1],
user = args.user,
passwd = args.password,
hostname = args.hostname,
content = args.content,
fullname = args.fullname,
email = args.email,
java_home = args.javahome
)
if ag.create_site():
print("Success ...")
sys.exit(0)
else:
print("Failed to Create a new site")
sys.exit(1)
#
# example: http://server.arcgis.com/en/server/latest/administer/linux/example-create-a-site.htm
# Note the example is for ArcGIS Server not Portal but the concepts are the same.
#
from __future__ import print_function
import sys
import os, time
import requests
import json
# HTTPS calls will generate warnings about the self-signed certificate if you delete this.
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
class arcgis(object):
def __init__(self,arcgis_home,user,passwd):
self.arcgis_home = arcgis_home
self.user = user
self.passwd = passwd
self.hostname = ""
self.java_home = ""
def validateEnv(self):
'''
Validate the needed environment variables
'''
self.hostname = os.environ.get("ARCGIS_HOSTNAME","")
if self.hostname == "":
print("The Environment variable ARCGIS_HOSTNAME MUST be set, for example: gisportal.xxxxx.com")
return False
self.java_home = os.environ.get("JAVA_HOME","")
if self.java_home == "":
print("Warning : JAVA_HOME not be set, set to $ARCGIS_HOIME/portal/framwork/runtime/jre")
os.environ['JAVA_HOME']="$ARCGIS_HOME/portal/framework/runtime/jre"
return True
def status_check(self):
uri = "https://%s:7443/arcgis/portaladmin/Status" % self.hostname
parameters = {
"f" : "json"
}
try:
response = requests.post(
uri,
data=parameters,
timeout=10,
verify=False
)
rj = json.loads(response.text)
status = rj["status"]
print("portal is in servering with status %s"%(status))
except Exception as e:
print("Failed to request the server %s with reason %s"%(uri,e))
return False
return True
def create_site(self):
defaultdir = "%s/portal/usr" % self.arcgis_home
content_store_path = os.path.join(defaultdir,"content")
content_store = {
"type" : "FileSystem",
"provider" : "FileSystem",
"connectionString" : content_store_path
}
content_storeJSON = json.dumps(content_store)
parameters = {
"username" : self.user,
"password" : self.passwd,
"fullname" : "APAAS CUSTOMER",
"email" : "user@bd-apaas.com",
"description" : "Administrator account created for APAAS",
"securityQuestionIdx" : 1,
"securityQuestionAns" : "Nothing",
"contentStore" : content_storeJSON,
"f" : "json"
}
uri = "https://%s:7443/arcgis/portaladmin/createNewSite" % self.hostname
response = None
timeout = False
try:
response = requests.post(
uri,
data=parameters,
timeout=500,
verify=False
)
if response and response.status_code != 200:
print("Server not available; code ", response.status_code)
err = json.loads(response.text).get('error',None)
if err is not None:
print("Some error happended when create the new site: \n %s \n"%(err))
return False
except Exception as e:
print("Error when post the requrest with reason :%s"%e)
timeout = True
return True
# ------------------------------------------------------------------------
if __name__ == "__main__":
home = os.environ.get("ARCGIS_HOME","/arcgis")
user = os.environ.get("PORTAL_USER","portaladmin")
passwd = os.environ.get("PORTAL_PASSWORD","Aa123456")
ag = arcgis(home,user,passwd)
if ag.validateEnv():
if user == "portaladmin" or passwd == "Aa123456":
print("Warning: default Parameter will be used when create new site user: %s and password: %s"%(user,passwd))
if ag.create_site():
print("Create the new site Successfully")
sys.exit(0)
print("Failed to Create a new site")
sys.exit(1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment