In einer SAS 9.4-Umgebung ist die logische Verknüpfung zwischen einer SAS-Bibliothek und einem Anwendungsserver (z. B. SASApp oder SASSTP) über die Metadaten-Assoziation DeployedComponents definiert. Dieses Skript ist ein hervorragendes Administrationswerkzeug, um Bibliotheken massenhaft neuen Serverkontexten zuzuweisen – eine Aufgabe, die häufig bei Server-Migrationen oder der horizontalen Skalierung von Umgebungen anfällt.
Type : MIXTE
Das Skript verwendet keine Daten im traditionellen Sinne (SAS-Tabellen). Es liest und ändert Objekte (Metadaten) direkt auf dem SAS-Metadaten-Server. Die 'Quelldaten' sind die Definitionen der Serverkontexte und SAS-Bibliotheken, die in den Metadaten gespeichert sind.
| 1 | options |
| 2 | metaserver="my.sas.server" |
| 3 | metaport=8561 |
| 4 | metauser="sasadm @saspw" |
| 5 | metapass="password" |
| 6 | metarepository=Foundation |
| 7 | metaprotocol=Bridge; |
| 1 | DATA _null_; |
| 2 | |
| 3 | /* Initialize variables. */ |
| 4 | |
| 5 | LENGTH type id app_uri lib_uri $ 50; |
| 6 | call missing(of _character_); |
| 7 | |
| 8 | /* Define query for the Application Server Context */ |
| 9 | /* to add to the libraries and search for it. */ |
| 10 | |
| 11 | appobj="omsobj:ServerContext? @Name='SASSTP'"; |
| 12 | app_count=metadata_resolve(appobj,type,id); |
| 13 | |
| 14 | /* If no context matches this query, stop the program with an error. */ |
| 15 | |
| 16 | IF app_count <= 0 THEN DO; |
| 17 | put "ERROR: No application server context found matching query " appobj; |
| 18 | stop; |
| 19 | END; |
| 20 | ELSE DO; |
| 21 | |
| 22 | /* Extract the URI of the context if it exists. */ |
| 23 | |
| 24 | rc=metadata_getnobj(appobj,1,app_uri); |
| 25 | |
| 26 | /* Define the query for the libraries to be updated and search for them. */ |
| 27 | |
| 28 | libobj="omsobj:SASLibrary? @code_sas_json/RFValid.json contains '.'"; |
| 29 | lib_count=metadata_resolve(libobj,type,id); |
| 30 | |
| 31 | /* If no libraries match the query, stop the program with an error. */ |
| 32 | IF lib_count <= 0 THEN DO; |
| 33 | put "ERROR: No libraries found matching query " libobj; |
| 34 | stop; |
| 35 | END; |
| 36 | |
| 37 | /* If libraries are found, for each one append */ |
| 38 | /* the context to its list of associated contexts. */ |
| 39 | |
| 40 | ELSE DO n=1 to lib_count; |
| 41 | rc=metadata_getnobj(libobj,1,lib_uri); |
| 42 | rc=metadata_setassn(lib_uri,"DeployedComponents","Append",app_uri); |
| 43 | END; |
| 44 | END; |
| 45 | RUN; |