Commit 71e83538 authored by chengaoxing's avatar chengaoxing

update : update

parent 83343971
...@@ -52,7 +52,8 @@ class arcgis(object): ...@@ -52,7 +52,8 @@ class arcgis(object):
return True return True
def create_site(self): def create_site(self):
##{"type":"fileStore","provider":"FileSystem","connectionString":"/arcgis/portal/usr/arcgisportal/content"}
##
defaultdir = "%s/portal/usr" % self.arcgishome defaultdir = "%s/portal/usr" % self.arcgishome
content_store_path = self.content content_store_path = self.content
...@@ -76,7 +77,6 @@ class arcgis(object): ...@@ -76,7 +77,6 @@ class arcgis(object):
} }
uri = "https://%s:7443/arcgis/portaladmin/createNewSite" % self.hostname uri = "https://%s:7443/arcgis/portaladmin/createNewSite" % self.hostname
print(uri)
try: try:
response = requests.post( response = requests.post(
uri, uri,
...@@ -91,7 +91,11 @@ class arcgis(object): ...@@ -91,7 +91,11 @@ class arcgis(object):
print("Some error happended when create the new site: \n %s \n"%(err)) print("Some error happended when create the new site: \n %s \n"%(err))
return False return False
else: else:
print("Response : %s" % (response.text)) #Response : {"status":"success","recheckAfterSeconds":20}
resp = json.loads(response.text)
if resp.get('status',None) != 'success':
print("Warning: Fail to create a new site. Information : %s"%(response.text))
return False
except Exception as e: except Exception as e:
print("Error when post the requrest with reason :%s"%e) print("Error when post the requrest with reason :%s"%e)
timeout = True timeout = True
...@@ -107,6 +111,8 @@ if __name__ == "__main__": ...@@ -107,6 +111,8 @@ if __name__ == "__main__":
# """ # """
# ) # )
parser = argparse.ArgumentParser(add_help=True) parser = argparse.ArgumentParser(add_help=True)
parser.add_argument("opt",type=str, choices=['createnewsite']
help="optaions: createnewsite ...")
parser.add_argument("-a","--arcgishome", default="/arcgis", parser.add_argument("-a","--arcgishome", default="/arcgis",
help="The home path where arcgis portal installed, default is /arcgis") help="The home path where arcgis portal installed, default is /arcgis")
parser.add_argument("-n","--hostname", default="arcgisportal", parser.add_argument("-n","--hostname", default="arcgisportal",
...@@ -116,7 +122,7 @@ if __name__ == "__main__": ...@@ -116,7 +122,7 @@ if __name__ == "__main__":
parser.add_argument("-p","--password", default="Aa123456", parser.add_argument("-p","--password", default="Aa123456",
help="the password to register amdin account, default is ABCD1234") help="the password to register amdin account, default is ABCD1234")
parser.add_argument("-c","--content", default=None, parser.add_argument("-c","--content", default=None,
help="the path to content store, defautl is $ARCGISHOME/portal/usr/arcgisportal") help="the path to content store, defautl is $ARCGISHOME/portal/usr/arcgisportal/content")
parser.add_argument("-f","--fullname", default="PORTAL ADMIN", parser.add_argument("-f","--fullname", default="PORTAL ADMIN",
help="the full name for admin user,default as APAAS CUSTOMER") help="the full name for admin user,default as APAAS CUSTOMER")
parser.add_argument("-e","--email", default="portaladmin@bd-apaas.com", parser.add_argument("-e","--email", default="portaladmin@bd-apaas.com",
...@@ -126,6 +132,11 @@ if __name__ == "__main__": ...@@ -126,6 +132,11 @@ if __name__ == "__main__":
args = parser.parse_args() args = parser.parse_args()
if args.opt != 'createnewsite':
print("unsupported options, aviable is : createnewsite ")
print(args.print_help())
sys.exit(2)
if args.content is None: if args.content is None:
args.content = "{}/portal/usr/arcgisportal".format(args.arcgishome) args.content = "{}/portal/usr/arcgisportal".format(args.arcgishome)
if args.javahome is None: if args.javahome is None:
...@@ -145,7 +156,7 @@ if __name__ == "__main__": ...@@ -145,7 +156,7 @@ if __name__ == "__main__":
user = args.user, user = args.user,
passwd = args.password, passwd = args.password,
hostname = args.hostname, hostname = args.hostname,
content = args.content, content = (args.content).rstrip('/'),
fullname = args.fullname, fullname = args.fullname,
email = args.email email = args.email
...@@ -159,8 +170,10 @@ if __name__ == "__main__": ...@@ -159,8 +170,10 @@ if __name__ == "__main__":
java_home = args.javahome java_home = args.javahome
) )
if args.opt =="createnewsite":
print("Create a new admin site")
if ag.create_site(): if ag.create_site():
print("Success ...") print("Succeed creating a admin account, visit : https://%s:7443/arcgis/home"%(args.hostname))
sys.exit(0) sys.exit(0)
else: else:
print("Failed to Create a new site") print("Failed to Create a new site")
......
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