BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sathya66
Barite | Level 11

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
gwootton
SAS Super FREQ

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

View solution in original post

3 REPLIES 3
gwootton
SAS Super FREQ

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
sathya66
Barite | Level 11

Thanks for this

I am looking for protocal, port and  hostname so what about the Host Name?

gwootton
SAS Super FREQ
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)
--
Greg Wootton | Principal Systems Technical Support Engineer

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 3346 views
  • 2 likes
  • 2 in conversation