__metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import ( oci_config_utils, oci_common_utils, ) from ansible.module_utils import six try: from oci.mysql import WorkRequestsClient HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_mysql_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class MysqlDbSystemActionsHelperCustom: def get_action_desired_states(self, action): action_desired_states = super(MysqlDbSystemActionsHelperCustom, self).get_action_desired_states(action)
oci_common_utils, oci_config_utils, ) try: import oci from oci.announcements_service.models import AnnouncementsCollection from oci.announcements_service import AnnouncementsPreferencesClient from oci.util import to_dict HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_announcements_service_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger def utc_now(): return " " + str(datetime.utcnow()) + ": " def deserialize_response(data, base_client, class_type):
# Copyright (c) 2020 Oracle and/or its affiliates. # This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # Apache License v2.0 # See LICENSE.TXT for details. from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils logger = oci_common_utils.get_logger( "oci_compute_instance_agent_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class InstanceAgentCommandHelperCustom: # The create operation is not idempotent since it is valid to have multiple commands with the given # values and there is no way for us to distinguish if the user wants to create another or not. def get_matching_resource(self): return None # this method is being overwritten as the InstanceAgentCommandSummary model does not reurn back `id` field,
"""This module contains all the customisations for identity modules.""" from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils try: from oci.exceptions import ServiceError, MaximumWaitTimeExceeded HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_identity_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class ApiKeyHelperCustom: def get_create_model_dict_for_idempotence_check(self, create_model): model_dict = super( ApiKeyHelperCustom, self).get_create_model_dict_for_idempotence_check(create_model)
) from ansible_collections.oracle.oci.plugins.module_utils.oci_common_utils import ( pretty_print_json, ) import os try: from oci.exceptions import ServiceError, MaximumWaitTimeExceeded from oci.util import to_dict HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_resource_utils") def _debug(s): get_logger().debug(s) def get_logger(): return logger class OCIResourceCommonBase: """Base class for the Helper Classes to hold common code.""" def __init__(self, module, resource_type, service_client_class, namespace): self.module = module self.resource_type = resource_type
# See LICENSE.TXT for details. from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils try: from oci.exceptions import ServiceError HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_artifacts_custom_helpers") def get_logger(): return logger def _debug(s): get_logger().debug(s) class ContainerConfigurationHelperCustom: # container configuration does not have the module resourceId. # It has only update flow. So not considering the check for resourceId to check is_update def is_update(self): if not self.module.params.get("state") == "present":
# Copyright (c) 2020, 2021 Oracle and/or its affiliates. # This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # Apache License v2.0 # See LICENSE.TXT for details. from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils logger = oci_common_utils.get_logger("oci_data_science_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger try: from oci.util import to_dict from oci.exceptions import ServiceError HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False
NONE_WAITER_KEY = "NONE_WAITER_KEY" # Services where if no opc-work-request-id is returned we will fallback to waiting # via lifecycle state # This is something that ideally services should fix, but we want our modules to continue # working before that happens # If we can reliably determine that no opc-work-request returned indicates immediate completion # and no waiting is necessary then we can build that case into WorkRequestWaiter SERVICES_WHERE_WORK_REQUEST_WAITING_SHOULD_FALLBACK_TO_LIFECYCLE_WAITING = [ "database", "mysql", "resource_manager", "core", ] logger = oci_common_utils.get_logger("oci_wait_utils") def _debug(s): get_logger().debug(s) def get_logger(): return logger class Waiter: """Interface defining wait method""" def wait(self): raise NotImplementedError(
MissingPrivateKeyPassphrase, ConfigFileNotFound, ) from oci.auth.signers.resource_principals_signer import ( get_resource_principals_signer, ) from oci.identity.identity_client import IdentityClient from oci.database import DatabaseClient HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False agent_name = "Oracle-Ansible/" inventory_agent_name = "Oracle-Ansible-Inv/" logger = oci_common_utils.get_logger("oci_config_utils") def _debug(s): get_logger().debug(s) def get_logger(): return logger def get_oci_config(module, service_client_class=None): """Return the OCI configuration to use for all OCI API calls. The effective OCI configuration is derived by merging any overrides specified for configuration attributes through Ansible module options or environment variables. The order of precedence for deriving the effective configuration dict is: 1. If a config file is provided, use that to setup the initial config dict.
# Copyright (c) 2020, 2021 Oracle and/or its affiliates. # This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # Apache License v2.0 # See LICENSE.TXT for details. from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils logger = oci_common_utils.get_logger("oci_stream_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class StreamPoolHelperCustom: # Some attrs end with details and the get returns the same field without details # This case we should still match them for update and create def get_existing_resource_dict_for_idempotence_check( self, existing_resource): existing_resource_dict = super( StreamPoolHelperCustom, self).get_existing_resource_dict_for_idempotence_check(
__metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils try: import oci from oci.util import to_dict from oci.core import BlockstorageClient from oci.exceptions import ServiceError HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_blockstorage_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class BootVolumeBackupActionsHelperCustom: def is_action_necessary(self, action, resource, *args, **kwargs): if action.upper() == "COPY": # boot_volume_backup copied from another backup will have the source backup in source_boot_volume_backup_id # parameter. Use it to find if the copy already exists in the destination region.
# Copyright (c) 2020 Oracle and/or its affiliates. # This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # Apache License v2.0 # See LICENSE.TXT for details. from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils logger = oci_common_utils.get_logger("oci_cloud_guard_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class DetectorRecipeHelperCustom: # excluding the responder_rules param from being used in idempotency as the detector_rules object is # not getting converted to dict format by the method to_dict which causes the idempotency check # to fail and create another resource with the same attributes def get_exclude_attributes(self): exclude_attributes = super(DetectorRecipeHelperCustom, self).get_exclude_attributes() return exclude_attributes + [
# See LICENSE.TXT for details. from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils try: from oci.util import to_dict HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_blockchain_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class BlockchainPlatformHelperCustom: def get_exclude_attributes(self): exclude_attributes = super(BlockchainPlatformHelperCustom, self).get_exclude_attributes() # These attributes are used for authentication and not really representative of the resource itself except maybe
# Copyright (c) 2020, 2021 Oracle and/or its affiliates. # This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # Apache License v2.0 # See LICENSE.TXT for details. from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import ( oci_common_utils, oci_config_utils, ) logger = oci_common_utils.get_logger("oci_compute_management_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger try: import oci from oci.util import to_dict from oci.core import VirtualNetworkClient, ComputeClient, BlockstorageClient from oci.exceptions import ServiceError
from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils try: from oci.exceptions import ServiceError, MaximumWaitTimeExceeded from oci.util import to_dict HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_logging_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class LogHelperCustom: def get_get_fn(self): def get_fn(log_id): return self.client.get_log( log_id=log_id,
__metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import ( oci_common_utils, oci_config_utils, ) try: import oci HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_waas_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class WaasCertificateHelperCustom: def get_create_model_dict_for_idempotence_check(self, create_model): create_model_dict = super( WaasCertificateHelperCustom, self).get_create_model_dict_for_idempotence_check(create_model)
from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils try: from oci.analytics.models import ChangeAnalyticsInstanceNetworkEndpointDetails from oci.util import to_dict HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_analytics_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class AnalyticsInstanceHelperCustom: # exclude the attributes from the create model which are not present in the get model for idempotency check def get_exclude_attributes(self): exclude_attributes = super(AnalyticsInstanceHelperCustom, self).get_exclude_attributes()
# Copyright (c) 2020 Oracle and/or its affiliates. # This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # Apache License v2.0 # See LICENSE.TXT for details. from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils logger = oci_common_utils.get_logger("oci_data_catalog_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class DataCatalogDataAssetHelperCustom: # this resource does not use standard `id` or `resource_id` as identifier, it uses `key` or `data_asset_key`. # overriding this method due to naming mismatch in input parameter (data_asset_key) and output parameter (key) def get_get_model_from_summary_model(self, summary_model): return oci_common_utils.call_with_backoff( self.client.get_data_asset, catalog_id=self.module.params.get("catalog_id"), data_asset_key=summary_model.key,
from ansible_collections.oracle.oci.plugins.module_utils import ( oci_common_utils, oci_wait_utils, ) try: from oci.exceptions import ServiceError from oci.util import to_dict HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_database_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class AutonomousDatabaseHelperCustom: # get model doesn't return admin_password of existing database resources. Thus, excluding # admin_password for idempotency. def get_exclude_attributes(self): return super(AutonomousDatabaseHelperCustom, self).get_exclude_attributes() + [
AddedNetworkSecurityGroupSecurityRules, UpdatedNetworkSecurityGroupSecurityRules, BulkAddVirtualCircuitPublicPrefixesDetails, BulkDeleteVirtualCircuitPublicPrefixesDetails, ) from oci.core.models.get_public_ip_by_private_ip_id_details import ( GetPublicIpByPrivateIpIdDetails, ) from oci.core.models.get_public_ip_by_ip_address_details import ( GetPublicIpByIpAddressDetails, ) HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_network_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger class NetworkSecurityGroupSecurityRuleActionsHelperCustom: ADD_NETWORK_SECURITY_GROUP_SECURITY_RULES_ACTION = "add" UPDATE_NETWORK_SECURITY_GROUP_SECURITY_RULES_ACTION = "update" REMOVE_NETWORK_SECURITY_GROUP_SECURITY_RULES_ACTION = "remove"
__metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import ( oci_common_utils, oci_wait_utils, ) try: from oci.bds.models import RemoveAutoScalingConfigurationDetails HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False logger = oci_common_utils.get_logger("oci_bigdata_custom_helpers") def _debug(s): get_logger().debug(s) def get_logger(): return logger # BDS has a list of nodes. The update operation only updates the tags not the nodes. # If the user updates the nodes count and reruns, nothing will happen # because we exclude the nodes from the idempotency check. # Some node types can be updated using actions. class BdsInstanceHelperCustom: