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:
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}
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.
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?
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?
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.
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?
did you run the “pip3 install oci” command?
You are missing the OCI library
Got it working on a fresh new Compute Instance. I re-used an old one – my mistake.
Super! Enjoy the script. Hope it can help to make savings ๐
Richard, thank you for this great gift to the community; I plan to make very good use of it and save lots of $$$.
I’ve been using it successfully for “AnyDay/Weekday” tags, but I’m having trouble getting the specific day of the week tag (i.e. Monday, Tuesday, etc.) to work. Is it a known issue, or am I mis-configured somehow ?
When used alone, I get “not correct amount of hours”
When used with more general WeekDay/AnyDay tags, it seems to not be overruling as expected.
Schedule
Tuesday
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0
Checking: ccca – Instance
Error with schedule of ccca – , not correct amount of hours
WeekDay
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0
Tuesday
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Checking: ccca – Instance (on a Tuesday)
– Active schedule for ccca : 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,[0],0,0,1,0,0
“A specific day of the week tag (ie. Monday) overrules all other tags.”
Hi, if I look at both WeekDay and Tuesday schedule, they have the same number for the current hour. The last 6th number are both a 0.
Maybe you clock is running in a different timezone then you expect it to be?
You can see, based on the [ ] which element is being used.
ok, I will double check on the timezone for the double schedule, but why do I get
โnot correct amount of hoursโ with any of the named weekdays when used by themselves ?
I’m pretty sure I have 24 numbers (have recounted, and have cut/paste from a working AnyDay string.
This is the schedule I’m trying now to shutdown at 5pm Friday and startup first thing on Monday
(does it look reasonable?)
Schedule.WeekDay: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Schedule.Friday: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
Schedule.Weekend: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Looks perfectly fine. will investigate.
I think the problem has been fixed, the specific day check was one tab to much indented. Please refresh the code and all should be good. If not, let me know ๐
I count 24 as well ๐ I will check. I am working on the script any way this weekend, as I am also adding support for load balancer scaling and exadata. Finally convinced oracle to provide me with exadata ๐
HI Richard, thanks for your VDO and github link. I find this is useful. However, i’ve been observing some ‘off’ time delayed. For instance,
WeekDay : 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0
-> I want it to on at 10am, and off at 3pm.
but it is on at 10am and off at 5pm.
Anything I need to correct it?
Appreciate your help on this.
Any thoughts on this one?
Thank You
[opc@autoscalertaskscheduler OCI-AutoScale]$ sudo python3 CreateNameSpaces.py
Logged in as: Instance Principle/philipsradoncoci @ phx
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/lib/python3.6/site-packages/oci/identity/identity_client.py”, line 2388, in create_tag_namespace
response_type=”TagNamespace”)
File “/usr/lib/python3.6/site-packages/oci/base_client.py”, line 260, in call_api
return self.request(request)
File “/usr/lib/python3.6/site-packages/oci/base_client.py”, line 375, in request
self.raise_service_error(request, response)
File “/usr/lib/python3.6/site-packages/oci/base_client.py”, line 545, in raise_service_error
original_request=request)
oci.exceptions.ServiceError: {‘opc-request-id’: ’50BD1EB02CFE4BF9B878DA0D6B06CEE6/0E1EFB9D015C9E88202A3471C2DE5A8F/18BFEB2110145331558DE23FAC438E05′, ‘code’: ‘NotAuthorizedOrNotFound’, ‘message’: ‘Authorization failed or requested resource not found’, ‘status’: 404}
[opc@autoscalertaskscheduler OCI-AutoScale]$
Does this dynamic group has the permissions to create a namespace definition?
Hi Richard,
I have this for the Policy
allow dynamic-group SchedulePermissions to manage all-resources in tenancy
Hi Richard,
It seems like this doesn’t work for Bare Metal machines.
I was able to get it to work with Virtual Machines.
Thoughts?
Thank you
Correct. You always have to pay for BM servers, no matter if your turn them on or off. So that is why the auto scale script does not support them.
Richard,
This is great tool! We have been using it on our Windows compute instances, and our VM ASM DB Systems. We recently started using it on LVM (vs ASM) based DB Systems, and the database start up is not working properly. It is not turning on all the listener services, in particular the service for the pdb. I’m curious what commands are used to turn on and off the db and db systems.
sounds more like a bug ๐ Did you file an service request for this?