Add Time based Auto Scaling and Power On/Off operations to OCI in under 5 minutes!

By | August 23, 2020

Would you like the schedule (based on time) Power On/Off and/or Scaling operations for your OCI resources? Well that is very easily possible with my Auto Scaling Script!

The Script supports:

  • Compute VMs: On/Off
  • Instance Pools: On/Off and Scaling (# of instances)
  • Database VMs: On/Off
  • Database Baremetal Servers: Scaling (# of CPUs)
  • Autonomous Databases: On/Off and Scaling (# of CPUs)
  • Oracle Digital Assistant: On/Off
  • Oracle Analytics Cloud: On/Off and Scaling (between 2-8 oCPU and 10-12 oCPU)
  • Oracle Integration Service: On/Off

If you want to implement this in your OCI environment, I have made a very simple instruction video:

You can also find full instructions on the github repository:

https://github.com/AnykeyNL/OCI-AutoScale

9 thoughts on “Add Time based Auto Scaling and Power On/Off operations to OCI in under 5 minutes!

  1. Tushar

    Hi,
    Have created dynamic group and policy as per the video but still I am facing issue while creating name space:-
    [opc@tushar-autostart OCI-AutoScale]$ python3 CreateNameSpaces.py
    Logged in as: Instance Principle/comvivamfs3 @ ap-mumbai-1
    Creating Namespace Schedule
    Traceback (most recent call last):
    File “CreateNameSpaces.py”, line 58, in
    response = identity.create_tag_namespace(create_tag_namespace_details=details).data
    File “/usr/local/lib/python3.6/site-packages/oci/identity/identity_client.py”, line 2388, in create_tag_namespace
    response_type=”TagNamespace”)
    File “/usr/local/lib/python3.6/site-packages/oci/base_client.py”, line 256, in call_api
    return self.request(request)
    File “/usr/local/lib/python3.6/site-packages/oci/base_client.py”, line 377, in request
    self.raise_service_error(request, response)
    File “/usr/local/lib/python3.6/site-packages/oci/base_client.py”, line 547, in raise_service_error
    original_request=request)
    oci.exceptions.ServiceError: {‘opc-request-id’: ‘8EA34C5766EF405A9E260C392069C631/B08B839C3B22E31CDAA023F3533C81C0/42F259C26D6D9C93E51A5D4F31E8F967’, ‘code’: ‘NotAllowed’, ‘message’: ‘Please go to your home region fra to execute CREATE, UPDATE and DELETE operations.’, ‘status’: 403}

    Reply
    1. richard Post author

      Hi, is ap-mumbai your home region? The CreateNameSpaces calls can only be made to the home region. I will try to fix this week to automatically select the home region, no matter where you run the script from, but for now, run the script in an instance in your home region, or manually create the tag namespace and keys.

      Reply
      1. Tushar

        Hi Sir,

        No, Frankfurt is the home region. I have configured on Frankfurt. Its configured on Home region successfully. Thanks.
        But the thing is, scale up/down is not working other than the home region.
        How I can manage the scale up/down other than the home region?

        Reply
        1. richard Post author

          The script should find all resources across all enabled regions. Just keep in mind from a hour-of-the-day perspective, it is looking at the time of day of where the script is running, not where the resource is located.

          If you have created a resource in an other region with the schedule tag, do you see it in the output of the script come by?

          Reply
          1. Tushar

            Yes, I have configured the python script in Frankfurt and Tag the resource of Mumbai & Frankfurt both region. But Its working for Frankfurt only.
            Even when I am running it manually using “paython3 AutoScaleALL.py”. Its not considering the Mumbai related resources in the output of script and resource are not scaling down.

  2. Paul

    Hello Richard,

    [opc@compins01 OCI-AutoScale]$ python3 CreateNameSpaces.py
    Traceback (most recent call last):
    File “CreateNameSpaces.py”, line 11, in
    import oci
    ModuleNotFoundError: No module named ‘oci’

    Did I forget a step? Do I need to make a copy of config_example with my own OCIDs?

    Reply
    1. richard Post author

      did you run the “pip3 install oci” command?
      You are missing the OCI library

      Reply
      1. Paul

        Got it working on a fresh new Compute Instance. I re-used an old one – my mistake.

        Reply
        1. richard Post author

          Super! Enjoy the script. Hope it can help to make savings ๐Ÿ™‚

          Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.