c7n-oci


Namec7n-oci JSON
Version 0.1.9 PyPI version JSON
download
home_pagehttps://cloudcustodian.io
SummaryCloud Custodian - OCI Support
upload_time2024-03-26 21:21:33
maintainerNone
docs_urlNone
authorCloud Custodian Project
requires_python<4.0,>=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # Cloud Custodian - OCI Support

This is a plugin to Cloud Custodian that adds OCI support.

## Install Cloud Custodian and OCI Plugin

The OCI provider must be installed as a separate package in addition to c7n.

    $ git clone https://github.com/cloud-custodian/cloud-custodian.git
    $ virtualenv custodian
    $ source custodian/bin/activate
    (custodian) $ pip install -e cloud-custodian/.
    (custodian) $ pip install -e cloud-custodian/tools/c7n_oci/.

## Write your first policy

Cloud Custodian policies are expressed in YAML and include the following:

* The type of resource to run the policy against
* Filters to narrow down the set of resources
* Actions to take on the filtered set of resources

Our first policy filters compute instance of a specific name, then adds the tag ``mark_deletion: true``.

Create a file named ``custodian.yml`` with the following content. Update ``display_name``,``compartment_id`` match an existing compute instance.

    policies:
        - name: filter-for-compute-name
          description: Filter for compute which matches the display name
          resource: oci.instance
          filters:
            - type: query
              params:
                compartment_id: 'ocid1.compartment.oc1..<unique_ID>'
            - type: value
              key: display_name
              value: test
          actions:
            - type: update_instance
              params:
                update_instance_details:
                    freeform_tags:
                        mark-for-deletion: 'true'

## Run your policy

    custodian run --output-dir=. custodian.yml

If successful, you should see output like the following on the command line::

    2023-05-25 18:15:53,132: custodian.oci.session:INFO Successfully authenticated user ...
    2023-05-25 18:16:01,118: custodian.policy:INFO policy:filter-for-compute-name resource:oci.instance region: count:1 time:7.98
    2023-05-25 18:16:05,474: custodian.oci.resources.compute:INFO Received status 200 for PUT:update_instance 9A14E2D68AC94772849C7534E10BC963/089249DEBA83A0BDA6050BFF759BCF49/38040CF37F356743B539E653B2DED1E0
    2023-05-25 18:16:05,483: custodian.policy:INFO policy:filter-for-compute-name action:updateinstance resources:1 execution_time:4.34

You can find a new ``filter-for-compute-name`` under --output-dir option value directory with a log and a ``resources.json`` file.

## Links
- [Getting Started](https://cloudcustodian.io/docs/oci/gettingstarted.html)
- [Example Scenarios](https://cloudcustodian.io/docs/oci/examples/index.html)

            

Raw data

            {
    "_id": null,
    "home_page": "https://cloudcustodian.io",
    "name": "c7n-oci",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Cloud Custodian Project",
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "# Cloud Custodian - OCI Support\n\nThis is a plugin to Cloud Custodian that adds OCI support.\n\n## Install Cloud Custodian and OCI Plugin\n\nThe OCI provider must be installed as a separate package in addition to c7n.\n\n    $ git clone https://github.com/cloud-custodian/cloud-custodian.git\n    $ virtualenv custodian\n    $ source custodian/bin/activate\n    (custodian) $ pip install -e cloud-custodian/.\n    (custodian) $ pip install -e cloud-custodian/tools/c7n_oci/.\n\n## Write your first policy\n\nCloud Custodian policies are expressed in YAML and include the following:\n\n* The type of resource to run the policy against\n* Filters to narrow down the set of resources\n* Actions to take on the filtered set of resources\n\nOur first policy filters compute instance of a specific name, then adds the tag ``mark_deletion: true``.\n\nCreate a file named ``custodian.yml`` with the following content. Update ``display_name``,``compartment_id`` match an existing compute instance.\n\n    policies:\n        - name: filter-for-compute-name\n          description: Filter for compute which matches the display name\n          resource: oci.instance\n          filters:\n            - type: query\n              params:\n                compartment_id: 'ocid1.compartment.oc1..<unique_ID>'\n            - type: value\n              key: display_name\n              value: test\n          actions:\n            - type: update_instance\n              params:\n                update_instance_details:\n                    freeform_tags:\n                        mark-for-deletion: 'true'\n\n## Run your policy\n\n    custodian run --output-dir=. custodian.yml\n\nIf successful, you should see output like the following on the command line::\n\n    2023-05-25 18:15:53,132: custodian.oci.session:INFO Successfully authenticated user ...\n    2023-05-25 18:16:01,118: custodian.policy:INFO policy:filter-for-compute-name resource:oci.instance region: count:1 time:7.98\n    2023-05-25 18:16:05,474: custodian.oci.resources.compute:INFO Received status 200 for PUT:update_instance 9A14E2D68AC94772849C7534E10BC963/089249DEBA83A0BDA6050BFF759BCF49/38040CF37F356743B539E653B2DED1E0\n    2023-05-25 18:16:05,483: custodian.policy:INFO policy:filter-for-compute-name action:updateinstance resources:1 execution_time:4.34\n\nYou can find a new ``filter-for-compute-name`` under --output-dir option value directory with a log and a ``resources.json`` file.\n\n## Links\n- [Getting Started](https://cloudcustodian.io/docs/oci/gettingstarted.html)\n- [Example Scenarios](https://cloudcustodian.io/docs/oci/examples/index.html)\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Cloud Custodian - OCI Support",
    "version": "0.1.9",
    "project_urls": {
        "Documentation": "https://cloudcustodian.io/docs/",
        "Homepage": "https://cloudcustodian.io",
        "Repository": "https://github.com/cloud-custodian/cloud-custodian"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b4c3ba4e65185949671f47acb895e04d81615aa9b3c55b0b50fd077c9abada1f",
                "md5": "89d4e468670c0b73dc4a4a37b68a4bfb",
                "sha256": "2c4ee9a48991f5561ace8ff17aed3271220a70e9f4ab788b57fd32589a7cf58e"
            },
            "downloads": -1,
            "filename": "c7n_oci-0.1.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "89d4e468670c0b73dc4a4a37b68a4bfb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 26758,
            "upload_time": "2024-03-26T21:21:33",
            "upload_time_iso_8601": "2024-03-26T21:21:33.203199Z",
            "url": "https://files.pythonhosted.org/packages/b4/c3/ba4e65185949671f47acb895e04d81615aa9b3c55b0b50fd077c9abada1f/c7n_oci-0.1.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-26 21:21:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cloud-custodian",
    "github_project": "cloud-custodian",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "c7n-oci"
}
        
Elapsed time: 0.22215s