From 71e8353820564b7a7961edf7e3ddb4476906f741 Mon Sep 17 00:00:00 2001 From: chengaoxing Date: Thu, 16 May 2019 12:01:58 +0800 Subject: [PATCH] update : update --- readme.md | 1 + src/portalmng.py | 35 ++++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/readme.md b/readme.md index e69de29..8b13789 100644 --- a/readme.md +++ b/readme.md @@ -0,0 +1 @@ + diff --git a/src/portalmng.py b/src/portalmng.py index f2ae75e..37b457c 100644 --- a/src/portalmng.py +++ b/src/portalmng.py @@ -52,7 +52,8 @@ class arcgis(object): return True def create_site(self): - + ##{"type":"fileStore","provider":"FileSystem","connectionString":"/arcgis/portal/usr/arcgisportal/content"} + ## defaultdir = "%s/portal/usr" % self.arcgishome content_store_path = self.content @@ -76,7 +77,6 @@ class arcgis(object): } uri = "https://%s:7443/arcgis/portaladmin/createNewSite" % self.hostname - print(uri) try: response = requests.post( uri, @@ -91,7 +91,11 @@ class arcgis(object): print("Some error happended when create the new site: \n %s \n"%(err)) return False 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: print("Error when post the requrest with reason :%s"%e) timeout = True @@ -107,6 +111,8 @@ if __name__ == "__main__": # """ # ) parser = argparse.ArgumentParser(add_help=True) + parser.add_argument("opt",type=str, choices=['createnewsite'] + help="optaions: createnewsite ...") 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", @@ -116,7 +122,7 @@ if __name__ == "__main__": 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") + help="the path to content store, defautl is $ARCGISHOME/portal/usr/arcgisportal/content") 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", @@ -126,6 +132,11 @@ if __name__ == "__main__": 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: args.content = "{}/portal/usr/arcgisportal".format(args.arcgishome) if args.javahome is None: @@ -145,7 +156,7 @@ if __name__ == "__main__": user = args.user, passwd = args.password, hostname = args.hostname, - content = args.content, + content = (args.content).rstrip('/'), fullname = args.fullname, email = args.email @@ -159,9 +170,11 @@ if __name__ == "__main__": java_home = args.javahome ) - if ag.create_site(): - print("Success ...") - sys.exit(0) - else: - print("Failed to Create a new site") - sys.exit(1) + if args.opt =="createnewsite": + print("Create a new admin site") + if ag.create_site(): + print("Succeed creating a admin account, visit : https://%s:7443/arcgis/home"%(args.hostname)) + sys.exit(0) + else: + print("Failed to Create a new site") + sys.exit(1) -- 2.26.0