☑ This topic is solved.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 11-02-2022 10:21 AM
(3936 views)
Hi all,
I am changing the infernal and external connections manually, is there a way we can do it via code?
https://documentation.sas.com/doc/en/bicdc/9.4/bimtag/n1s9ty2ykoxyr5n1ikt28hcjwuuz.htm
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I wrote this program a while ago that updated the port/protocol for these, so it would find any with http/7980 and updated to https/8343, but you could update other attributes as well:
/* ---------------------------------------- [ reset_protocol.sas ] ---------------------------------------- *
* The purpose of this program is to locate web connection info defined in Metadata and update the protocol *
* and port. *
* Author: Greg Wootton Date: 26SEP2019 *
* Note: This is experimental. Use at your own risk. *
* -------------------------------------------------------------------------------------------------------- */
/* Define macro variables for Metadata connection information and the protocols and ports that need changing.*/
%let metaserve=meta.demo.sas.com;
%let metaport=8561;
%let userid=sasadm@saspw;
%let pass=password;
%let oldprotocol='http';
%let newprotocol='https';
%let oldport='7980';
%let newport='8343';
/*End edit. */
/* Define Metadata connection information. */
options metaserver="&metaserve"
metaport=&metaport
metaprotocol='bridge'
metauser="&userid"
metapass="&pass"
metarepository='Foundation'
metaconnect='NONE'
;
/* Take an ad-hoc Metadata backup. */
PROC METAOPERATE ACTION=refresh options="<BACKUP COMMENT='METAOPERATE backup'/>" noautopause;
RUN;
/* Define a search that only returns objects defined with the old protocol and port. */
%let query="omsobj:TCPIPConnection?@CommunicationProtocol=&oldprotocol and @Port=&oldport";
/* For each, change the protocol to the new one. */
data _null_;
length type id uri $ 50 ;
call missing (of _character_);
count=metadata_resolve(&query,type,id);
put "NOTE: Found " count "connections to update.";
if count > 0 then do n=1 to count;
rc=metadata_getnobj(&query,n,uri);
rc=metadata_setattr(uri,"CommunicationProtocol",&newprotocol);
rc=metadata_setattr(uri,"Port",&newport);
end;
run;
--
Greg Wootton | Principal Systems Technical Support Engineer
Greg Wootton | Principal Systems Technical Support Engineer
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I wrote this program a while ago that updated the port/protocol for these, so it would find any with http/7980 and updated to https/8343, but you could update other attributes as well:
/* ---------------------------------------- [ reset_protocol.sas ] ---------------------------------------- *
* The purpose of this program is to locate web connection info defined in Metadata and update the protocol *
* and port. *
* Author: Greg Wootton Date: 26SEP2019 *
* Note: This is experimental. Use at your own risk. *
* -------------------------------------------------------------------------------------------------------- */
/* Define macro variables for Metadata connection information and the protocols and ports that need changing.*/
%let metaserve=meta.demo.sas.com;
%let metaport=8561;
%let userid=sasadm@saspw;
%let pass=password;
%let oldprotocol='http';
%let newprotocol='https';
%let oldport='7980';
%let newport='8343';
/*End edit. */
/* Define Metadata connection information. */
options metaserver="&metaserve"
metaport=&metaport
metaprotocol='bridge'
metauser="&userid"
metapass="&pass"
metarepository='Foundation'
metaconnect='NONE'
;
/* Take an ad-hoc Metadata backup. */
PROC METAOPERATE ACTION=refresh options="<BACKUP COMMENT='METAOPERATE backup'/>" noautopause;
RUN;
/* Define a search that only returns objects defined with the old protocol and port. */
%let query="omsobj:TCPIPConnection?@CommunicationProtocol=&oldprotocol and @Port=&oldport";
/* For each, change the protocol to the new one. */
data _null_;
length type id uri $ 50 ;
call missing (of _character_);
count=metadata_resolve(&query,type,id);
put "NOTE: Found " count "connections to update.";
if count > 0 then do n=1 to count;
rc=metadata_getnobj(&query,n,uri);
rc=metadata_setattr(uri,"CommunicationProtocol",&newprotocol);
rc=metadata_setattr(uri,"Port",&newport);
end;
run;
--
Greg Wootton | Principal Systems Technical Support Engineer
Greg Wootton | Principal Systems Technical Support Engineer
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for this
I am looking for protocal, port and hostname so what about the Host Name?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The hostname attribute is "HostName" so you could similarly modify the query to look for your desired HostName and add a metadata_setattr call to update it.
For example:
%let oldhost='old.example.com';
%let newhost='new.example.com';
...
%let query="omsobj:TCPIPConnection?@CommunicationProtocol=&oldprotocol and @Port=&oldport and @HostName=&oldhost";
...
rc=metadata_setattr(uri,"HostName",&newhost)
For example:
%let oldhost='old.example.com';
%let newhost='new.example.com';
...
%let query="omsobj:TCPIPConnection?@CommunicationProtocol=&oldprotocol and @Port=&oldport and @HostName=&oldhost";
...
rc=metadata_setattr(uri,"HostName",&newhost)
--
Greg Wootton | Principal Systems Technical Support Engineer
Greg Wootton | Principal Systems Technical Support Engineer