File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 1+ import os
12from logging import Logger
23
34import oci
1011
1112def get_compute_client ():
1213 logger .info ("entering get_compute_client" )
13- config = oci .config .from_file ()
14- return oci .core .ComputeClient (config )
14+ config = oci .config .from_file (
15+ profile_name = os .getenv ("OCI_CONFIG_PROFILE" , oci .config .DEFAULT_PROFILE )
16+ )
17+
18+ private_key = oci .signer .load_private_key_from_file (config ["key_file" ])
19+ token_file = config ["security_token_file" ]
20+ token = None
21+ with open (token_file , "r" ) as f :
22+ token = f .read ()
23+ signer = oci .auth .signers .SecurityTokenSigner (token , private_key )
24+ return oci .core .ComputeClient (config , signer = signer )
1525
1626
1727@mcp .tool
Original file line number Diff line number Diff line change 1+ import os
12from logging import Logger
23
34import oci
910
1011
1112def get_networking_client ():
12- # Assumes you have ~/.oci/config with [DEFAULT] set up
13- config = oci .config .from_file ("~/.oci/config" )
14- return oci .core .VirtualNetworkClient (config )
13+ config = oci .config .from_file (
14+ profile_name = os .getenv ("OCI_CONFIG_PROFILE" , oci .config .DEFAULT_PROFILE )
15+ )
16+ private_key = oci .signer .load_private_key_from_file (config ["key_file" ])
17+ token_file = config ["security_token_file" ]
18+ token = None
19+ with open (token_file , "r" ) as f :
20+ token = f .read ()
21+ signer = oci .auth .signers .SecurityTokenSigner (token , private_key )
22+ return oci .core .VirtualNetworkClient (config , signer = signer )
1523
1624
1725@mcp .tool
You can’t perform that action at this time.
0 commit comments