Ejemplo n.º 1
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_instance_pool,
         instance_pool_id=self.module.params.get("instance_pool_id"),
     )
Ejemplo n.º 2
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_key_store,
         key_store_id=self.module.params.get("key_store_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_boot_volume,
         boot_volume_id=self.module.params.get("boot_volume_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_service_connector,
         service_connector_id=self.module.params.get(
             "service_connector_id"),
     )
Ejemplo n.º 5
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_network_source,
         network_source_id=self.module.params.get("network_source_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_drg_attachment,
         drg_attachment_id=self.module.params.get("drg_attachment_id"),
     )
Ejemplo n.º 7
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_auto_scaling_configuration,
         auto_scaling_configuration_id=self.module.params.get(
             "auto_scaling_configuration_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_ip_sec_connection,
         ipsc_id=self.module.params.get("ipsc_id"),
     )
 def get_fetch_func(self):
     return lambda **kwargs: oci_common_utils.call_with_backoff(
         self.client.get_work_request,
         self.operation_response.headers["opc-work-request-id"],
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_osn,
         blockchain_platform_id=self.module.params.get("blockchain_platform_id"),
         osn_id=self.module.params.get("osn_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_model_provenance,
         model_id=self.module.params.get("model_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_public_ip_pool,
         public_ip_pool_id=self.module.params.get("public_ip_pool_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_managed_instance,
         managed_instance_id=self.module.params.get("managed_instance_id"),
     )
def create_service_client(module,
                          service_client_class,
                          config=None,
                          client_kwargs=None):
    """
    Creates a service client using the common module options provided by the user.
    :param module: An AnsibleModule that represents user provided options for a Task
    :param service_client_class: A class that represents a client to an OCI Service
    :param client_kwargs: kwargs that would be passed to the client class
    :return: A fully configured client
    """
    config = config or get_oci_config(module, service_client_class)
    kwargs = client_kwargs or {}

    if "service_endpoint" in module.params.keys():
        kwargs["service_endpoint"] = module.params.get("service_endpoint")

    if _is_instance_principal_auth(module):
        kwargs["signer"] = _create_instance_principal_signer(module)

    if _is_delegation_token_auth(module):
        delegation_token_location = config.get("delegation_token_file")
        kwargs["signer"] = _create_instance_principal_signer(
            module, delegation_token_location)

    # XXX: Validate configuration -- this may be redundant, as all Client constructors perform a validation
    try:
        oci.config.validate_config(config, **kwargs)
    except oci.exceptions.InvalidConfig as ic:
        module.fail_json(
            msg="Invalid OCI configuration. Exception: {0}".format(str(ic)))

    # Create service client class (optionally with signer)
    client = service_client_class(config, **kwargs)

    # Redirect calls to home region for IAM service.
    do_not_redirect = module.params.get(
        "do_not_redirect_to_home_region",
        False) or os.environ.get("OCI_IDENTITY_DO_NOT_REDIRECT_TO_HOME_REGION")

    if service_client_class == IdentityClient and not do_not_redirect:

        if "tenancy" in config:
            tenancy_id = config["tenancy"]
        elif hasattr(kwargs.get("signer"), "tenancy_id"):
            # the instance principals signer has the tenancy ID from the certificate from the
            # local metadata service
            tenancy_id = kwargs.get("signer").tenancy_id
        else:
            module.fail_json(
                msg=
                "Could not identify tenancy OCID from config or local metadata service"
            )

        region_subscriptions = oci_common_utils.call_with_backoff(
            client.list_region_subscriptions, tenancy_id=tenancy_id).data

        # Replace the region for the client with the home region.
        home_regions = [
            rs.region_name for rs in region_subscriptions
            if rs.is_home_region is True
        ]
        if len(home_regions) == 0:
            module.fail_json(
                msg="Could not identify home region for this tenancy")

        home_region = home_regions[0]

        client.base_client.set_region(home_region)

    set_db_test_flag(client)

    return client
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_export,
         export_id=self.module.params.get("export_id"),
     )
Ejemplo n.º 16
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_protection_settings,
         waas_policy_id=self.module.params.get("waas_policy_id"),
     )
Ejemplo n.º 17
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_remote_peering_connection,
         remote_peering_connection_id=self.module.params.get(
             "remote_peering_connection_id"),
     )
Ejemplo n.º 18
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_autonomous_container_database,
         autonomous_container_database_id=self.module.params.get(
             "autonomous_container_database_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_catalog_private_endpoint,
         catalog_private_endpoint_id=self.module.params.get(
             "catalog_private_endpoint_id"),
     )
Ejemplo n.º 20
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_log_group,
         log_group_id=self.module.params.get("log_group_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_data_asset,
         catalog_id=self.module.params.get("catalog_id"),
         data_asset_key=self.module.params.get("data_asset_key"),
     )
Ejemplo n.º 22
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_application,
         application_id=self.module.params.get("application_id"),
     )
Ejemplo n.º 23
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_configuration,
         compartment_id=self.module.params.get("compartment_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_dedicated_vm_host,
         dedicated_vm_host_id=self.module.params.get(
             "dedicated_vm_host_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_http_monitor,
         monitor_id=self.module.params.get("monitor_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_cloud_vm_cluster,
         cloud_vm_cluster_id=self.module.params.get("cloud_vm_cluster_id"),
     )
Ejemplo n.º 27
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_certificate,
         certificate_id=self.module.params.get("certificate_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_nat_gateway,
         nat_gateway_id=self.module.params.get("nat_gateway_id"),
     )
Ejemplo n.º 29
0
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_identity_provider,
         identity_provider_id=self.module.params.get("identity_provider_id"),
     )
 def get_resource(self):
     return oci_common_utils.call_with_backoff(
         self.client.get_cross_connect_group,
         cross_connect_group_id=self.module.params.get(
             "cross_connect_group_id"),
     )