Published on :

Automatic Server Context Assignment (SAS 9 Metadata)

This code is also available in: Deutsch Español Français
Attention : This code requires administrator privileges.
This program is designed for a SAS© 9 environment (or a Viya environment connected to SAS© 9 metadata via the Bridge protocol). It connects to the metadata server, identifies the 'SASSTP' server context, and searches for libraries matching a specific query (the query identifier in the provided code contains an artifact ' @code_sas©_json/DataGridProvider.json' which appears to be a copy-paste or injection error, probably replacing a condition on ' @Name'). For each library found, it updates the metadata to associate the server context via the 'DeployedComponents' association.
Data Analysis

Type : EXTERNAL


The script does not use classic SAS tabular data. It queries and modifies the Metadata Repository via specialized DATA Step functions (metadata_resolve, metadata_getnobj, metadata_setassn).

1 Code Block
OPTIONS
Explanation :
Configuration of SAS 9 metadata server connection parameters (host, port, user, password, repository).
Copied!
1options
2 metaserver="meta.demo.sas.com"
3 metaport=8561
4 metauser="sasadm @saspw"
5 metapass="password"
6 metarepository=Foundation
7 metaprotocol=Bridge;
2 Code Block
DATA STEP
Explanation :
DATA _NULL_ step containing the business logic: querying the metadata server to find the application server URI, searching for target libraries, and assignment loop (adding the 'DeployedComponents' association with 'metadata_setassn').
Copied!
1DATA _null_;
2 LENGTH type id app_uri lib_uri $ 50;
3 call missing(of _character_);
4 
5 /* Recherche du contexte serveur SASSTP */
6 appobj="omsobj:ServerContext? @Name='SASSTP'";
7 app_count=metadata_resolve(appobj,type,id);
8 
9 IF app_count <= 0 THEN DO;
10 put "ERROR: No application server context found matching query " appobj;
11 stop;
12 END;
13 ELSE DO;
14 /* Récupération de l'URI du contexte */
15 rc=metadata_getnobj(appobj,1,app_uri);
16 
17 /* Recherche des bibliothèques cibles */
18 libobj="omsobj:SASLibrary? ..."; /* Partie corrompue dans l'entrée originale */
19 lib_count=metadata_resolve(libobj,type,id);
20 
21 IF lib_count <= 0 THEN DO;
22 put "ERROR: No libraries found matching query " libobj;
23 stop;
24 END;
25 ELSE DO n=1 to lib_count;
26 /* Boucle de mise à jour des métadonnées */
27 rc=metadata_getnobj(libobj,1,lib_uri);
28 rc=metadata_setassn(lib_uri,"DeployedComponents","Append",app_uri);
29 END;
30 END;
31RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Author: Greg Wootton Date: 16JUN2017