Browse Source
* add getosixidentity.py * Add new tool that is in master to viya4_v1 (#73) * Viya4 v1 (#64) * add properties file * add get properties function * add get of properties to listreports * update listreports * fix * add insepct * test with foldertree * update properties * test export folder tree * exportfoldertree * make cli location and command dynamic * add imports * fix * add os * add all option * updates * update import packages * update import packages * a few more sas-viya changes * add function * showsetup * make targetname optional * update * update * Update sharedfunctions.py added get_valid_filename * Update snapshotreports.py * Update updatepreferences.py upped the limit on all users * Update INSTALL.md * Update INSTALL.md * Update application.properties Update the default cli name for Viya 3.x * (PSETRIAGE-1406) import notification templates (#70) This is to compensate for lack of notification template editor and template VLI to laod templates using template service. * PSETRIAGE-1406) import notification templates (#71) Some bug fixes * add getosixidentity.py (#72) Co-authored-by: Lori Small <lori.small@sas.com> * Update application.properties * add importcaslibs.py * addd +x * fix cass comment * fix tabs * update message * update message * message when no files * fix indent * Update importcaslibs.py * Update importcaslibs.py * +x * update * add comments to setup.py * updates to doc * +x * update readme * temporary set to sas-admin Co-authored-by: Lori Small <lori.small@sas.com>master
committed by
GitHub
5 changed files with 318 additions and 44 deletions
@ -0,0 +1,91 @@ |
|||
#!/usr/bin/python |
|||
# -*- coding: utf-8 -*- |
|||
# |
|||
# importcaslibs.py |
|||
# April 2021 |
|||
# |
|||
# Pass in a directory and this tool will import all the json files in the directory. It depends on the admin CLI |
|||
# The json files should be standard caslib definitions |
|||
# |
|||
# File format |
|||
#{ |
|||
#"attributes": { "active": false, "personal": false, "subDirs": false}, |
|||
#"description": "", |
|||
#"name": "Sales2", |
|||
# "path": "/tmp/sales", |
|||
# "scope": "global", |
|||
# "server": "cas-shared-default", |
|||
# "type": "PATH" |
|||
#} |
|||
# |
|||
# |
|||
# Change History |
|||
# |
|||
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved. |
|||
# |
|||
# Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. |
|||
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
|||
# |
|||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS |
|||
# OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. |
|||
# |
|||
# |
|||
# Import Python modules |
|||
import argparse, sys, subprocess, os, json |
|||
from sharedfunctions import callrestapi, getapplicationproperties |
|||
|
|||
# get cli location from properties |
|||
propertylist=getapplicationproperties() |
|||
|
|||
clidir=propertylist["sascli.location"] |
|||
cliexe=propertylist["sascli.executable"] |
|||
|
|||
clicommand=os.path.join(clidir,cliexe) |
|||
|
|||
# get input parameters |
|||
parser = argparse.ArgumentParser(description="Import JSON files that define path-based CASLIBS from directory. All json files in directory will be imported.") |
|||
parser.add_argument("-d","--directory", help="Directory that contains JSON caslib dfinition files to import",required='True') |
|||
parser.add_argument("-q","--quiet", help="Suppress the are you sure prompt.", action='store_true') |
|||
args= parser.parse_args() |
|||
basedir=args.directory |
|||
quietmode=args.quiet |
|||
|
|||
# get python version |
|||
version=int(str(sys.version_info[0])) |
|||
|
|||
# if the quiet mode flag is not passed then prompt to continue |
|||
if not quietmode: |
|||
|
|||
if version > 2: |
|||
areyousure=input("WARNING: Are you sure? (Y)") |
|||
else: |
|||
areyousure=raw_input("WARNING: Are you sure? (Y)") |
|||
else: |
|||
areyousure="Y" |
|||
|
|||
if areyousure.upper() =='Y': |
|||
|
|||
# check that directory exists |
|||
if os.path.isdir(basedir): |
|||
|
|||
# loop files in the directory |
|||
for filename in os.listdir( basedir ): |
|||
|
|||
# only process json files |
|||
if filename.lower().endswith('.json'): |
|||
command=clicommand+' cas caslibs create path --source-file '+os.path.join(basedir,filename) |
|||
print(command) |
|||
subprocess.call(command, shell=True) |
|||
|
|||
print("NOTE: Viya Caslib imported attempted from json file "+filename+" in directory "+basedir ) |
|||
|
|||
else: print("ERROR: Directory does not exist") |
|||
else: |
|||
print("NOTE: Operation cancelled") |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,80 @@ |
|||
#!/usr/bin/python |
|||
# -*- coding: utf-8 -*- |
|||
# |
|||
# importconfiguration.py |
|||
# April 2021 |
|||
# |
|||
# Pass in a directory and this tool will import all the json files in the directory. It depends on the admin CLI |
|||
# The json files should be standard viya configuration definitions |
|||
# |
|||
# |
|||
# Change History |
|||
# |
|||
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved. |
|||
# |
|||
# Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. |
|||
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
|||
# |
|||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS |
|||
# OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. |
|||
# |
|||
# |
|||
# Import Python modules |
|||
import argparse, sys, subprocess, os, json |
|||
from sharedfunctions import callrestapi, getapplicationproperties |
|||
|
|||
# get cli location from properties |
|||
propertylist=getapplicationproperties() |
|||
|
|||
clidir=propertylist["sascli.location"] |
|||
cliexe=propertylist["sascli.executable"] |
|||
|
|||
clicommand=os.path.join(clidir,cliexe) |
|||
|
|||
# get input parameters |
|||
parser = argparse.ArgumentParser(description="Import JSON files that update Viya configuration. All json files in directory will be imported.") |
|||
parser.add_argument("-d","--directory", help="Directory that contains JSON configuration definition files to import",required='True') |
|||
parser.add_argument("-q","--quiet", help="Suppress the are you sure prompt.", action='store_true') |
|||
args= parser.parse_args() |
|||
basedir=args.directory |
|||
quietmode=args.quiet |
|||
|
|||
# get python version |
|||
version=int(str(sys.version_info[0])) |
|||
|
|||
# if the quiet mode flag is not passed then prompt to continue |
|||
if not quietmode: |
|||
|
|||
if version > 2: |
|||
areyousure=input("WARNING: Are you sure? (Y)") |
|||
else: |
|||
areyousure=raw_input("WARNING: Are you sure? (Y)") |
|||
else: |
|||
areyousure="Y" |
|||
|
|||
if areyousure.upper() =='Y': |
|||
|
|||
# check that directory exists |
|||
if os.path.isdir(basedir): |
|||
|
|||
# loop files in the directory |
|||
for filename in os.listdir( basedir ): |
|||
|
|||
# only process json files |
|||
if filename.lower().endswith('.json'): |
|||
command=clicommand+' configuration configurations update --file '+os.path.join(basedir,filename) |
|||
print(command) |
|||
subprocess.call(command, shell=True) |
|||
|
|||
print("NOTE: Configuration import attempted from json file "+filename+" in directory "+basedir ) |
|||
|
|||
else: print("ERROR: Directory does not exist") |
|||
else: |
|||
print("NOTE: Operation cancelled") |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,73 @@ |
|||
#!/usr/bin/python |
|||
# -*- coding: utf-8 -*- |
|||
# |
|||
# setup.py |
|||
# December 2020 |
|||
# |
|||
# Updates the application.properties file with the location and name of the administration cli |
|||
# The default application properties stores the values for Viya 3.x |
|||
# This ensures bacward compatibility for Viya 3 users. |
|||
# |
|||
# sascli.location=/opt/sas/viya/home/bin/ |
|||
# sascli.executable=sas-admin |
|||
# |
|||
# The defaults for the function are the Viya 4 values |
|||
# |
|||
# sascli.location=/opt/sas/viya/home/bin/ |
|||
# sascli.executable=sas-viya |
|||
# |
|||
# As a result you only need to run setup.sh if you clone master and are using viya4 |
|||
# |
|||
# .setup.py will set the default values for Viya 4 |
|||
# OR |
|||
# ./setup.py --clilocation /opt/bin --cliexecutable sas-viya |
|||
# |
|||
# |
|||
# Copyright © 2018, SAS Institute Inc., Cary, NC, USA. All Rights Reserved. |
|||
# |
|||
# Licensed under the Apache License, Version 2.0 (the License); |
|||
# you may not use this file except in compliance with the License. |
|||
# You may obtain a copy of the License at |
|||
# |
|||
# http://www.apache.org/licenses/LICENSE-2.0 |
|||
# |
|||
# Unless required by applicable law or agreed to in writing, software |
|||
# distributed under the License is distributed on an "AS IS" BASIS, |
|||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
# See the License for the specific language governing permissions and |
|||
# limitations under the License. |
|||
# |
|||
# Import Python modules |
|||
|
|||
import argparse, sys, configparser, os, inspect |
|||
|
|||
from sharedfunctions import getapplicationproperties |
|||
from configobj import ConfigObj |
|||
|
|||
# get python version |
|||
version=int(str(sys.version_info[0])) |
|||
|
|||
# get input parameters |
|||
parser = argparse.ArgumentParser(description="Setup pyviyatools") |
|||
parser.add_argument("--clilocation", help="Enter the full path to the viya cli.",default="/opt/sas/viya/home/bin/") |
|||
parser.add_argument("--cliexecutable", help="Enter the name of the viya cli executable.", default="sas-viya") |
|||
args = parser.parse_args() |
|||
|
|||
clilocation=args.clilocation |
|||
cliexecutable=args.cliexecutable |
|||
|
|||
thepath=os.path.split(inspect.getsourcefile(lambda:0)) |
|||
install_dir=thepath[0] |
|||
prop_file=os.path.join(install_dir, "application.properties") |
|||
|
|||
print ("Note: updating "+prop_file) |
|||
|
|||
dict={"sascli.location":clilocation,"sascli.executable":cliexecutable} |
|||
|
|||
print("NOTE: configuration values set to ", dict ) |
|||
|
|||
config = ConfigObj(dict) |
|||
config.filename = prop_file |
|||
|
|||
config.write() |
|||
|
|||
Loading…
Reference in new issue