En la administración de SAS 9.4, la relación entre una biblioteca (SASLibrary) y su servidor de aplicaciones (como SASApp o SASSTP) se gestiona mediante la asociación de metadatos DeployedComponents. Este script es una herramienta administrativa potente para asignar bibliotecas de forma masiva, algo esencial durante migraciones de servidor o al escalar entornos con nuevos contextos de ejecución.
Type : MIXTE
El script no utiliza datos en el sentido tradicional (tablas SAS). Lee y modifica objetos (metadatos) directamente en el servidor de metadatos SAS. Los 'datos' fuente son las definiciones de los contextos de servidor y las bibliotecas SAS almacenadas en los metadatos.
| 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; |