コード例 #1
0
	def __init__(self):
		config = {}
		try:
			signer = Config.signer
			self.identity = IdentityClient(config=config, signer=signer)
			self.compartment_id = Config.tenancy_id
		except Exception:
			config = Config.config
			self.identity = IdentityClient(config)
			self.compartment_id = config["tenancy"]
		
		self.compartments = list()
		self.availability_domain_list = list()
		self.update_ads()
コード例 #2
0
 def set_connect(self, secret_data):
     self.identity_client = IdentityClient(secret_data)
     self.database_client = DatabaseClient(secret_data)
     self.disk_client = BlockstorageClient(secret_data)
     self.compute_client = ComputeClient(secret_data)
     self.compute_management_client = ComputeManagementClient(secret_data)
     self.virtual_network_client = VirtualNetworkClient(secret_data)
     self.load_balancer_client = LoadBalancerClient(secret_data)
     self.network_load_balancer_client = NetworkLoadBalancerClient(secret_data)
コード例 #3
0
ファイル: oci_wrapper.py プロジェクト: snafuz/oci-api-server
    def __init__(self, json_config=None):

        if json_config:
            self.config = from_file(profile_name=json_config.get("profile"))
        else:
            self.config = from_file()

        self._identity_client = IdentityClient(self.config)
        self._compute_client = ComputeClient(self.config)
        self._network_client = VirtualNetworkClient(self.config)
コード例 #4
0
ファイル: utils.py プロジェクト: bbhunt-2020/Canivete
def oracle_connect_service(service, credentials, region_name=None):
    try:
        if service == 'identity':
            return IdentityClient(credentials.config)
        else:
            print_exception('Service %s not supported' % service)
            return None

    except Exception as e:
        print_exception(e)
        return None
コード例 #5
0
	def __init__(self,tenancy_name):
		config = Config(tenancy_name)
		self.config = config.config
		self.compartment_id = self.config['tenancy']
		self.fingerprint = self.config['fingerprint']
		self.key_file = self.config["key_file"]
		self.admin_user_id = self.config["user"]
		self.identity = IdentityClient(self.config)
		self.users = list()
		self.list_users()
		self.compartments = list()
		self.availability_domains = list()
		self.store_compartments()
		self.list_availability_domains()
コード例 #6
0
    def authenticate(self, profile=None, **kwargs):

        try:

            config = from_file(profile_name=profile)
            compartment_id = config["tenancy"]

            # Get the current user
            identity = IdentityClient(config)
            identity.get_user(config["user"]).data

            return OracleCredentials(config, compartment_id)

        except Exception as e:
            raise AuthenticationException(e)
コード例 #7
0
    def authenticate(self, profile=None, **kwargs):

        try:

            # Set logging level to error for libraries as otherwise generates a lot of warnings
            logging.getLogger('oci').setLevel(logging.ERROR)

            config = from_file(profile_name=profile)

            # Get the current user
            identity = IdentityClient(config)
            identity.get_user(config["user"]).data

            return OracleCredentials(config)

        except Exception as e:
            raise AuthenticationException(e)
コード例 #8
0
 def handle(self, *args, **options):
     from oci.identity import IdentityClient
     config = oci.config.from_file()
     identity = IdentityClient(config)
     from oci.identity.models import CreateGroupDetails
     request = CreateGroupDetails()
     compartment_id = config["tenancy"]
     request.compartment_id = compartment_id
     request.name = "my-test-group"
     request.description = "Created with the Python SDK"
     group = identity.create_group(request)
     from oci.identity.models import CreateUserDetails
     request = CreateUserDetails()
     request.compartment_id = compartment_id
     request.name = "my-test-user"
     request.description = "Created with the Python SDK"
     user = identity.create_user(request)
     from oci.identity.models import AddUserToGroupDetails
     request = AddUserToGroupDetails()
     request.group_id = group.data.id
     request.user_id = user.data.id
     response = identity.add_user_to_group(request)
     print(response.status)
コード例 #9
0
    exit(1)

if not os.path.exists('.oci/oci_api_key.pem'):
    logging.error("File .oci/oci_api_key.pem missing!")
    exit(1)

if not os.path.exists('.oci/oci_api_key_public.pem'):
    logging.error("File .oci/oci_api_key_public.pem missing!")
    exit(1)

logging.info("Loading configuration from .oci")
config = from_file(file_location=".oci/config")
logging.info("Validating configuration from .oci")
validate_config(config)

identity = IdentityClient(config)
tenant_compartment_id = config["tenancy"]

logging.info("Retrieving all compartments")
compartments = getCompartmentRecurse(identity, tenant_compartment_id)
logging.debug(compartments)

if compartments.get(newCompartmentName) is not None:
    logging.error("Compartment already exists!")
    sendMail(newCompartmentOwner, "Subscription already exists",
             "Subscription %s already exists!" % newCompartmentName)
    exit(2)

newCompartmentNameParts = newCompartmentName.split('-')
newCompartmentParent = compartments[newCompartmentNameParts[1].lower()]
コード例 #10
0
import oci
from oci.identity import IdentityClient
from oci.core import VirtualNetworkClient, ComputeClient
from app.oci_config import get_configuration, get_compartment_scope, get_vcn_scope

config = get_configuration()
identity_client = IdentityClient(config)
compute_client = ComputeClient(config)
network_client = VirtualNetworkClient(config)


def get_oci_user():
    user = identity_client.get_user(config["user"]).data
    return user


def get_compute_instances_details():

    try:
        response = compute_client.list_instances(
            compartment_id=get_compartment_scope())
        return response.data
    except Exception as e:
        return {"problem encountered": e.__repr__()}


def get_compute_instances_status():

    try:
        response = {}
        instance_responses = compute_client.list_instances(
コード例 #11
0
 def __init__(self, credentials: OracleCredentials):
     self._credentials = credentials
     self._client = IdentityClient(self._credentials.config)
コード例 #12
0
 def identity(self, region=None):    
     try:
         return IdentityClient(self.config)
     except oci.exceptions.ClientError as err:
         print(err, file=sys.stderr)
         sys.exit(1)