def update_db_home(db_client, module, db_home_id): result = dict() db_home = oci_utils.get_existing_resource( db_client.get_db_home, module, db_home_id=db_home_id) if db_home is None: raise ClientError(Exception("No DB Home with id " + db_home_id + " is found for update")) last_patch_history_entry_id = db_home.last_patch_history_entry_id input_version_dict = module.params.get('patch_details', None) update_db_home_details = UpdateDbHomeDetails() version_changed, patch_details = oci_db_utils.is_version_changed( db_client.get_db_home_patch_history_entry, db_client.get_db_home_patch, db_home.db_version, input_version_dict, last_patch_history_entry_id, db_home_id=db_home_id) if version_changed: update_db_home_details.db_version = patch_details result = oci_utils.update_and_wait(resource_type='db_home', update_fn=db_client.update_db_home, kwargs_update={ 'db_home_id': db_home_id, 'update_db_home_details': update_db_home_details}, client=db_client, get_fn=db_client.get_db_home, get_param='db_home_id', module=module) else: result['db_home'] = to_dict(db_home) result['changed'] = False return result
def update_db_system(db_client, module, db_system_id): result = dict() changed = False db_system = oci_utils.get_existing_resource( db_client.get_db_system, module, db_system_id=module.params.get("db_system_id")) if db_system is None: raise ClientError( Exception("No DB System with id " + db_system_id + " is found for update")) existing_ssh_public_keys = db_system.ssh_public_keys last_patch_history_entry_id = db_system.last_patch_history_entry_id purge_ssh_public_keys = module.params.get("purge_ssh_public_keys") delete_ssh_public_keys = module.params.get("delete_ssh_public_keys") update_db_system_details = UpdateDbSystemDetails() primitive_attributes = [ "cpu_core_count", "data_storage_size_in_gbs", "freeform_tags", "defined_tags", ] for attribute in primitive_attributes: changed = oci_utils.check_and_update_attributes_if_changed( update_db_system_details, attribute, module.params.get(attribute, None), getattr(db_system, attribute), changed, ) input_ssh_public_keys = create_ssh_public_keys( module.params.get("ssh_public_keys", None)) ssh_public_keys_changed = False if input_ssh_public_keys is not None: ( ssh_public_keys, ssh_public_keys_changed, ) = oci_utils.get_component_list_difference( input_ssh_public_keys, existing_ssh_public_keys, purge_ssh_public_keys, delete_ssh_public_keys, ) if ssh_public_keys_changed: update_db_system_details.ssh_public_keys = ssh_public_keys input_version_dict = module.params.get("version", None) version_changed, patch_details = oci_db_utils.is_version_changed( db_client.get_db_system_patch_history_entry, db_client.get_db_system_patch, db_system.version, input_version_dict, last_patch_history_entry_id, db_system_id=db_system_id, ) if version_changed: update_db_system_details.version = patch_details changed = changed or ssh_public_keys_changed or version_changed if changed: result = oci_utils.update_and_wait( resource_type="db_system", update_fn=db_client.update_db_system, kwargs_update={ "db_system_id": db_system_id, "update_db_system_details": update_db_system_details, }, client=db_client, get_fn=db_client.get_db_system, get_param="db_system_id", module=module, ) else: result["db_system"] = to_dict(db_system) result["changed"] = False return result
def update_db_system(db_client, module, db_system_id): result = dict() changed = False db_system = oci_utils.get_existing_resource( db_client.get_db_system, module, db_system_id=module.params.get('db_system_id')) if db_system is None: raise ClientError( Exception("No DB System with id " + db_system_id + " is found for update")) primitive_attributes = [ 'cpu_core_count', 'data_storage_size_in_gbs', 'freeform_tags', 'defined_tags' ] existing_ssh_public_keys = db_system.ssh_public_keys last_patch_history_entry_id = db_system.last_patch_history_entry_id purge_ssh_public_keys = module.params.get('purge_ssh_public_keys') update_db_system_details = UpdateDbSystemDetails() for attribute in primitive_attributes: changed = oci_utils.check_and_update_attributes( update_db_system_details, attribute, module.params.get(attribute, None), getattr(db_system, attribute), changed) input_ssh_public_keys = create_ssh_public_keys( module.params.get('ssh_public_keys', None)) ssh_public_keys_changed = False if input_ssh_public_keys is not None: ssh_public_keys, ssh_public_keys_changed = oci_utils.get_component_list_difference( input_ssh_public_keys, existing_ssh_public_keys, purge_ssh_public_keys) if ssh_public_keys_changed: update_db_system_details.ssh_public_keys = ssh_public_keys else: update_db_system_details.ssh_public_keys = existing_ssh_public_keys input_version_dict = module.params.get('version', None) version_changed, patch_details = oci_db_utils.is_version_changed( db_client.get_db_system_patch_history_entry, db_client.get_db_system_patch, db_system.version, input_version_dict, last_patch_history_entry_id, db_system_id=db_system_id) if version_changed: update_db_system_details.version = patch_details changed = changed or ssh_public_keys_changed or version_changed if changed: result = oci_utils.update_and_wait( resource_type='db_system', update_fn=db_client.update_db_system, kwargs_update={ 'db_system_id': db_system_id, 'update_db_system_details': update_db_system_details }, client=db_client, get_fn=db_client.get_db_system, get_param='db_system_id', module=module) else: result['db_system'] = to_dict(db_system) result['changed'] = False return result