Auto Start / Stop Compute Instances

By | January 3, 2019

I have extended the library of scripts for automatic scheduling. There was already a script to auto Scale BM Database and ATP/ADW instances. New is the autoOnOff script for compute instances.

Based on a pre-defined tag in the namespace “Schedule” you can now automatically power on or off compute instances. This will not delete any of the data, but just powers the VM instance on or off. When compute instances are powered off, this will be done by a “softstop”, this means the instance will gracefully shutdown by sending a shutdown command to the operating system.

You can find the script here:

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

59 thoughts on “Auto Start / Stop Compute Instances

  1. Manu

    Hello,

    I have one question: you run this script connected on the db system with putty(as it seems in youtube video you have for autoscalling) or you run it from the shell on your laptop with oci cli configured?

    Thank you

    Reply
    1. richard Post author

      Hi,in principle you can run the script from anywhere as long as it can connect to the API service from OCI.

      Reply
  2. Manu

    Thank you for the answer.
    I have managed to succesfully run the script from a docker image, at works perfectly for normal instances but it doesn’t seems to work on DB System, where I am trying to stop/start a node.:(

    Reply
    1. Manu

      I was trying starting/stopping DBS, ATP and ADW but except normal instance I was unsuccesfull

      Reply
    2. richard Post author

      Database Instances can not be stopped. You can start/stop autonomous services, but this different API call then needed for a compute instance.

      Reply
    3. AK

      Hi,
      Could you please share DockerFile for this setup ? i am trying build Image.

      Reply
  3. Pingback: Autoscaling Options in OCI

  4. Maxime

    Hello
    Thank you for your work !
    A little mistake in the README, WeekDay is written, but the script is checking for Weekday

    Reply
  5. AK

    Hi,
    i wouldnt find Tag namespace Schedule, how do i create it?

    Reply
  6. Daniel Dueñas

    Hi, I’m trying to use your script but i have an error, could you please help me?
    It get my regions, then I get this error:

    Traceback (most recent call last):
    File “AutoScaleCompute.py”, line 132, in
    response = oci.pagination.list_call_get_all_results(ComputeClient.list_insta
    nces,compartment_id=compartment.id)
    File “C:\Python\Python37-32\lib\site-packages\oci\pagination\pagination_utils.
    py”, line 203, in list_call_get_all_results
    for response in list_call_get_all_results_generator(list_func_ref, ‘response
    ‘, *list_func_args, **list_func_kwargs):
    File “C:\Python\Python37-32\lib\site-packages\oci\pagination\pagination_utils.
    py”, line 271, in list_call_get_all_results_generator
    call_result = retry.DEFAULT_RETRY_STRATEGY.make_retrying_call(list_func_ref,
    *list_func_args, **list_func_kwargs)
    File “C:\Python\Python37-32\lib\site-packages\oci\retry\retry.py”, line 271, i
    n make_retrying_call
    return func_ref(*func_args, **func_kwargs)
    File “C:\Python\Python37-32\lib\site-packages\oci\core\compute_client.py”, lin
    e 4452, in list_instances
    response_type=”list[Instance]”)
    File “C:\Python\Python37-32\lib\site-packages\oci\base_client.py”, line 229, i
    n call_api
    response = self.request(request)
    File “C:\Python\Python37-32\lib\site-packages\oci\base_client.py”, line 352, i
    n request
    self.raise_service_error(request, response)
    File “C:\Python\Python37-32\lib\site-packages\oci\base_client.py”, line 522, i
    n raise_service_error
    original_request=request)
    oci.exceptions.ServiceError: {‘opc-request-id’: ‘Some code’, ‘code’: ‘N
    otAuthorizedOrNotFound’, ‘message’: ‘Authorization failed or requested resource
    not found.’, ‘status’: 404}

    Reply
    1. richard Post author

      Hi,

      Looks like an authorization issue. Are you trying to do this as an admin user? If not, what policies do you have set for the user?

      Reply
      1. Daniel Dueñas

        Yes i have admin Privileges, i think is because i only have permission on one region and are 3 on the list, because it fails checking one that i dont use

        Reply
        1. richard Post author

          If you just want to go thru one region, change this part of the code:

          regions = identity.list_region_subscriptions(config[“tenancy”]).data
          regionnames = “”
          for region in regions:
          regionnames = regionnames + region.region_name + ” “

          Reply
          1. Daniel Dueñas

            Now, I have this error

            C:\Start-Stop OCI>C:\Python\Python37-32\python.exe AutoScaleCompute.py on
            File “AutoScaleCompute.py”, line 93
            regionnames = regionnames + region.region_name + ” ”
            ^
            IndentationError: expected an indented block

          2. Daniel Dueñas

            The previous error is corrected, but still passing through the other regions, where should i put that part of code?

          3. richard Post author

            Sorry, I assumed you understood python. I will later send you modified code for single region.

  7. Daniel Dueñas

    I already made that only check the region that i have, but the error still showing
    What permission my account need? because I have Administrator privileges so i don’t know why is the error

    Reply
    1. richard Post author

      I see you are using the AutoScaleCompute script, can you try the AutoScaleAll script, this script does not use list request for most resources, but the search feature.

      Reply
      1. Daniel Dueñas

        I still have the error, i really dont know whats wrong

        2019-09-30 16:34:56,389 Day of week: Monday – Current hour: 16
        2019-09-30 16:34:56,405 2019-09-30 21:34:56.405503: Request: POST https://query
        .us-ashburn-1.oraclecloud.com/20180409/resources
        2019-09-30 16:34:56,826 2019-09-30 21:34:56.826704: Request: GET https://identi
        ty.us-ashburn-1.oraclecloud.com/20160918/compartments/
        2019-09-30 16:34:56,967 2019-09-30 21:34:56.967104: Request: GET https://identi
        ty.us-ashburn-1.oraclecloud.com/20160918/compartments/
        2019-09-30 16:34:57,169 2019-09-30 21:34:57.169905: Request: GET https://iaas.u
        s-ashburn-1.oraclecloud.com/20160918/instancePools
        Traceback (most recent call last):
        File “AutoScaleAll.py”, line 124, in
        pools = pool.list_instance_pools(compartment_id=c.id).data
        File “C:\Python\Python37-32\lib\site-packages\oci\core\compute_management_clie
        nt.py”, line 1885, in list_instance_pools
        response_type=”list[InstancePoolSummary]”)
        File “C:\Python\Python37-32\lib\site-packages\oci\base_client.py”, line 229, i
        n call_api
        response = self.request(request)
        File “C:\Python\Python37-32\lib\site-packages\oci\base_client.py”, line 352, i
        n request
        self.raise_service_error(request, response)
        File “C:\Python\Python37-32\lib\site-packages\oci\base_client.py”, line 522, i
        n raise_service_error
        original_request=request)
        oci.exceptions.ServiceError: {‘opc-request-id’: ‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX’, ‘code’: ‘N
        otAuthorizedOrNotFound’, ‘message’: ‘Authorization failed or requested resource
        not found.’, ‘status’: 404}

        Reply
        1. richard Post author

          Not everything is covered by the Search API call, in this case it is saying you can not list Instance Pools. I really think this is a policy issue on your side.

          Do you have admin rights in the whole account, including root compartment, or just have admin rights on a compartment?

          Reply
  8. ibra

    Hello Richard,

    First thanks alot for your great work.

    We are planning to save money by shutting down the compute instances only during weekends.
    i have two questions :
    Oracle: (“Stopping an instance using the instance’s OS does not stop billing for that instance. If you stop an instance this way, be sure to also stop it from the Console or API.”)

    1- your script is using the API calls right ?
    2- your code including both ( auto scale up/down & start/stop ) but we need to use only the start/stop instances is there any concerns by running the whole code or you can share the compute instance part only.

    Thank again.
    Regards
    Ibra

    Reply
    1. richard Post author

      Hi,
      Yes the script uses the official OCI APIs, so when it turns of an instance, it actually stops the billing for it.
      For compute instances you can use the 0 value for turning off and 1 for turning on.

      In the script you can also configure how you want to shutdown the instance; hard stop or soft stop.

      Reply
  9. pete

    Hello Richard,
    Nice work !

    I only have rights in the specific compartment hence i have authorization problem.

    python3 CreateNameSpaces.py
    /usr/lib/python3.6/site-packages/oci/packages/cryptography/hazmat/bindings/openssl/binding.py:179: CryptographyDeprecationWarning: OpenSSL version 1.0.2 is no longer supported by the OpenSSL project, please upgrade. The next version of cryptography will completely remove support for it.
    utils.CryptographyDeprecationWarning,
    Traceback (most recent call last):
    File “CreateNameSpaces.py”, line 41, in
    compartment = identity.get_compartment(compartment_id=SearchCompID).data
    File “/usr/lib/python3.6/site-packages/oci/identity/identity_client.py”, line 4321, in get_compartment
    response_type=”Compartment”)
    File “/usr/lib/python3.6/site-packages/oci/base_client.py”, line 263, in call_api
    return self.request(request)
    File “/usr/lib/python3.6/site-packages/oci/base_client.py”, line 384, in request
    self.raise_service_error(request, response)
    File “/usr/lib/python3.6/site-packages/oci/base_client.py”, line 554, in raise_service_error
    original_request=request)
    oci.exceptions.ServiceError: {‘opc-request-id’: ’61C6B65047FD488D90947C2078F2E9F1/67088E35729DDF2A02F850B1EB7DC25A/7090E69470055A284ADED3531975B2A6′, ‘code’: ‘NotAuthorizedOrNotFound’, ‘message’: ‘Authorization failed or requested resource not found’, ‘status’: 404}

    Would you be able to post the code for specific compartment access scenario ?

    Reply
    1. richard Post author

      Can you create the namespaces manually using the OCI Web Console?

      Reply
  10. Mario

    Richard, how you deal with the service limit for compute simultaneous startup? Thanks.

    Reply
    1. richard Post author

      The script re-tries call when the API limit is reached.

      Reply
  11. Mike Turner

    Richard –
    Nice work I was up and running quickly with your instructions.
    I would like to try to use the notifications to push email, I created the Topic in OCI and put the Topic OCI ID in the scrtipt, but it does not send nay notifications.

    Is there something else I have to do? I assumed it used the notifications service so I did not create an email domain or anything in OCI. I just subscribed and verified by subscription in the notification service.

    Reply
  12. MS Mahmood

    Hi Richard,
    Can you please share the names of REST APIs Which are related to start and stop of an instance. Also I need to know the name of REST API which can be used to change the shape of instance from small to large or large to small actually want to resize it. Thanks

    Reply
  13. Marvin

    Hi Richard,

    Great solution. I have deployed this on a group of our test servers but have noticed some strange behaviour
    We are using EDT timezone with the following tags

    Schedule.Friday: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0
    Schedule.Saturday: 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

    However, the instances are rebooting at midnight Thursday/Friday

    I have tested and change the tag to below but the error persists.
    Schedule.Friday: *,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0

    Any possible ideas of what might be causing this?

    Reply
  14. liz hall

    Richard,

    we have been using your scripts for a year. Saving us lots of money! We tried this, but found that there was a quick on/off for 2 hours. We don’t see what is incorrect.

    VM turned off Sunday for 2 hours. Then back on Sunday hrough Friday 0400. Shut down at Friday for 3 minutes, then backup till the expected Friday shutdown.

    Our VM is Eastern timezone.

    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
    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
    Sunday
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1
    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

    Reply
  15. alessandro

    HI,
    one question :

    is there a version on windows VM?

    thanks for support

    Reply
  16. Trevor North

    Would this also work for stopping compute nodes of ExaCC ?

    And a more general question – does OCI provide a way to run these scripts without needing to access a command shell i.e. is there some scheduling tool built into OCI (or maybe a template for one using e.g. OCI functions) that can make API calls at set times ?

    I guess we can setup a linux VM that has the cli tools installed and can be run from an enterprise scheduler to run such API calls but would be nice if there was an existing native OCI solution for this since it should be a common thing e.g. shutting down VM instances that are tagged such as non prod.

    Thanks in advance

    Reply
  17. Derrick M

    For the tag value, does the first position indicate the midnight hour? or the 1:00 AM hour?

    Reply
  18. Mario

    Hi Richard, I’m new to OCI and would like to know why only hourly start/stop and not, for ex. 15 or 5 minutes?
    Thank you!

    Reply
    1. richard Post author

      Welcome to OCI 🙂 Hope you will have a good and fun experience. The approach of any time is certainly possible, but think would require a different style of implementation of the script. for instance accept crontab like tags. I will have a look at this how difficult that would be to implement.

      Reply
      1. Mario

        Hey! Thank you for your prompt reply!

        I found out that we already use your (great, great) script but I was asked to implement some kind of schedule/script that would be able, at least, to start/stop a VM on a 15 min basis (hh:00, hh:15, hh:30, hh45).

        Any hint besides crontab like tags (as it seams quite hard to parse)? We don’t need resource auto scaling, only start/stop VMs.

        As like previous questions in this blog, (I’m sorry for all these questions – newbie here) but do you think, in my case, that it would be possible to call an OCI REST API, say from a VM or even an external scheduler, to issue a VM start/stop? (I found this https://support.oracle.com/epmos/faces/DocumentDisplay?id=2476404.1). At first glance, is any inconvenience by using it?

        Thank you very much!

        Reply
      2. Mario

        Thank you for your prompt reply!

        Just wondering if it would be possible/simple to change the script a little bit to use the following tag syntax:
        0,0,0,0,0,0,0,0,[min](4:16)*,*,*,*,*,*,*,*,0,0,0,0,0,0,0,0 (or something similar), where [min] is the minute of that hour. Another example:
        0,0,0,0,0,0,0,0,[30]1,*,*,*,*,*,*,*,0,0,0,0,0,0,0,0

        Thank you

        Reply
        1. richard Post author

          It is not that simple. while the format of the tag could work, currently the script is based on running it once an hour and then take actions hat fall in that hour.

          With minute base tags, you would need to run the script every minute (not efficient) and make sure it completes within that minute as well.

          To support minute based scheduling, the actual way of triggering / running the script would need to change.

          Reply
  19. Surya

    Hello Richard,

    First of all, I would like to express my gratitude for your incredible efforts. However, I am currently encountering the following error and would greatly appreciate your assistance in resolving it.

    # python3 AutoScaleALL.py

    ##########################################################################################
    # Running Auto Scale #
    ##########################################################################################
    Traceback (most recent call last):
    File “AutoScaleALL.py”, line 1566, in
    config, signer = OCIFunctions.create_signer(cmd.config_profile, cmd.is_instance_principals, cmd.is_delegation_token)
    File “/home/crif-gt-devops/surya/OCI-AutoScale/OCIFunctions.py”, line 61, in create_signer
    (config_profile if config_profile else oci.config.DEFAULT_PROFILE)
    File “/usr/lib/python3.6/site-packages/oci/config.py”, line 107, in from_file
    raise ConfigFileNotFound(“Could not find config file at {}, please follow the instructions in the link to setup the config file https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm“.format(expanded_file_location))
    oci.exceptions.ConfigFileNotFound: Could not find config file at /root/.oci/config, please follow the instructions in the link to setup the config file https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm

    Reply
    1. richard Post author

      the error states that no config file exists. did you configure the oci cli authentication? where are you trying to run this script? if you are running via cloud shell, add the paramater -dt

      Reply
  20. Surya

    I apologize, sir, for not configuring OCI CLI authentication. Could you please provide me with the steps to set it up?

    Regards,
    Surya

    Reply
    1. richard Post author

      just run: oci setup config
      during the wizard let it create the keys for you. then upload the public key to your user profile in OCI as API key.

      Reply
  21. Surya

    Hi Sir,
    i am facing following error

    ##########################################################################################
    # Running Auto Scale #
    ##########################################################################################
    Starts at 2023-06-21 22:10:32

    Connecting to Identity Service…
    Traceback (most recent call last):
    File “AutoScaleALL.py”, line 1575, in
    tenancy = identity.get_tenancy(config[“tenancy”]).data
    File “/usr/lib/python3.6/site-packages/oci/identity/identity_client.py”, line 7896, in get_tenancy
    api_reference_link=api_reference_link)
    File “/usr/lib/python3.6/site-packages/oci/retry/retry.py”, line 308, in make_retrying_call
    response = func_ref(*func_args, **func_kwargs)
    File “/usr/lib/python3.6/site-packages/oci/base_client.py”, line 485, in call_api
    response = self.request(request, allow_control_chars, operation_name, api_reference_link)
    File “/usr/lib/python3.6/site-packages/circuitbreaker.py”, line 52, in wrapper
    return self.call(function, *args, **kwargs)
    File “/usr/lib/python3.6/site-packages/circuitbreaker.py”, line 67, in call
    result = func(*args, **kwargs)
    File “/usr/lib/python3.6/site-packages/oci/base_client.py”, line 632, in request
    self.raise_service_error(request, response, service_code, message, operation_name, api_reference_link, target_service, request_endpoint, client_version, timestamp, deserialized_data)
    File “/usr/lib/python3.6/site-packages/oci/base_client.py”, line 801, in raise_service_error
    deserialized_data=deserialized_data)
    oci.exceptions.ServiceError: {‘target_service’: ‘identity’, ‘status’: 401, ‘code’: ‘NotAuthenticated’, ‘opc-request-id’: ’26B634072D0C4E3D866C522F829399A2/C778DEC58A95E1D08EC08173E3F69CA9/129230CB5BE29796F2FE21468462436D’, ‘message’: ‘The required information to complete authentication was not provided or was incorrect.’, ‘operation_name’: ‘get_tenancy’, ‘timestamp’: ‘2023-06-21T16:40:32.387646+00:00’, ‘client_version’: ‘Oracle-PythonSDK/2.93.1’, ‘request_endpoint’: ‘GET https://identity.ap-mumbai-1.oci.oraclecloud.com/20160918/tenancies/ocid1.tenancy.oc1..aaaaaaaa75wuiujbxk35dlgqe27i6wjmcm3l4rmi35uxvfa3ie5n2pqlnxaq’, ‘logging_tips’: ‘To get more info on the failing request, refer to https://docs.oracle.com/en-us/iaas/tools/python/latest/logging.html for ways to log the request/response details.’, ‘troubleshooting_tips’: “See https://docs.oracle.com/iaas/Content/API/References/apierrors.htm#apierrors_401__401_notauthenticated for more information about resolving this error. Also see https://docs.oracle.com/iaas/api/#/en/identity/20160918/Tenancy/GetTenancy for details on this operation’s requirements. If you are unable to resolve this identity issue, please contact Oracle support and provide them this full error message.”}

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “AutoScaleALL.py”, line 1600, in
    raise RuntimeError(“\nError connecting to Identity Service – ” + str(e))
    RuntimeError:
    Error connecting to Identity Service – {‘target_service’: ‘identity’, ‘status’: 401, ‘code’: ‘NotAuthenticated’, ‘opc-request-id’: ’26B634072D0C4E3D866C522F829399A2/C778DEC58A95E1D08EC08173E3F69CA9/129230CB5BE29796F2FE21468462436D’, ‘message’: ‘The required information to complete authentication was not provided or was incorrect.’, ‘operation_name’: ‘get_tenancy’, ‘timestamp’: ‘2023-06-21T16:40:32.387646+00:00’, ‘client_version’: ‘Oracle-PythonSDK/2.93.1’, ‘request_endpoint’: ‘GET https://identity.ap-mumbai-1.oci.oraclecloud.com/20160918/tenancies/ocid1.tenancy.oc1..aaaaaaaa75wuiujbxk35dlgqe27i6wjmcm3l4rmi35uxvfa3ie5n2pqlnxaq’, ‘logging_tips’: ‘To get more info on the failing request, refer to https://docs.oracle.com/en-us/iaas/tools/python/latest/logging.html for ways to log the request/response details.’, ‘troubleshooting_tips’: “See https://docs.oracle.com/iaas/Content/API/References/apierrors.htm#apierrors_401__401_notauthenticated for more information about resolving this error. Also see https://docs.oracle.com/iaas/api/#/en/identity/20160918/Tenancy/GetTenancy for details on this operation’s requirements. If you are unable to resolve this identity issue, please contact Oracle support and provide them this full error message.”}

    regards,
    Surya

    Reply
    1. richard Post author

      Error is still about authentication. Did you upload the public key to your OCI Profile in the API section?

      Reply
      1. Surya

        Sorry Sir,
        Can you share the complete process. if you have any blog plz share with me.

        Regards,
        Surya

        Reply
  22. Pingback: OCI CLI, across multiple regions – Jason Lester – Oracle DBA, Architect and more

  23. John Kent

    Hi Richard
    In the README it says
    – If this is the first time you are using the Autoscaling script, go to the OCI-Autoscale directory and run the following command:
    – python3 CreateNameSpaces.py -ip

    But when I ran this I got a 404 error.
    oci.exceptions.ServiceError: {‘target_service’: ‘identity’, ‘status’: 404, ‘code’: ‘NotAuthorizedOrNotFound’, ‘opc-request-id’: ‘6EA2D7401BC347A7AD0761C5488EC594/5A0186FBF0E7068C068E852EBC7A6D28/68ECAA771EEFC617823B48CF9C400B86’, ‘message’: ‘Authorization failed or requested resource not found.’, ‘operation_name’: ‘create_tag_namespace’, ‘timestamp’: ‘2023-11-20T11:22:31.161111+00:00’, ‘client_version’: ‘Oracle-PythonSDK/2.93.1’, ‘request_endpoint’: ‘POST https://identity.uk-london-1.oci.oraclecloud.com/20160918/tagNamespaces‘, ‘logging_tips’: ‘To get more info on the failing request, refer to https://docs.oracle.com/en-us/iaas/tools/python/latest/logging.html for ways to log the request/response details.’, ‘troubleshooting_tips’:

    I noticed that in the video you didn’t use -ip, I tried this and it worked
    [opc@auto-scheduling-server OCI-AutoScale]$ python3 CreateNameSpaces.py
    Starts at 2023-11-23 12:02:20

    Connecting to Identity Service…

    Tenant Name : silverlinksoftware
    Tenant Id : ocid1.tenancy.oc1..aaaaaaaas3k6ddclddbv25elaxm47nnlw6kcekawg6hzyyxgpyhaq3ulgm7q
    Home Region : uk-london-1
    Creating Namespace Schedule
    Creating keys Schedule
    Key AnyDay is created
    Key WeekDay is created
    Key Weekend is created
    Key Monday is created
    Key Tuesday is created
    Key Wednesday is created
    Key Thursday is created
    Key Friday is created
    Key Saturday is created
    Key Sunday is created
    Key DayOfMonth is created

    Also in order to get the crontab working I had to remove the -ip

    Original doesn’t work
    58 * * * * python3 /home/opc/OCI-AutoScale/AutoScaleALL.py -a Down -ip
    01 * * * * python3 /home/opc/OCI-AutoScale/AutoScaleALL.py -a Up -ip
    Now
    58 * * * * python3 /home/opc/OCI-AutoScale/AutoScaleALL.py -a Down
    01 * * * * python3 /home/opc/OCI-AutoScale/AutoScaleALL.py -a Up
    All appears to work now.

    Do you think this is due to a problem in my OCI setup?

    Many thanks for any help
    John

    Reply
  24. John Kent

    Hi Richard
    In the README it says
    – If this is the first time you are using the Autoscaling script, go to the OCI
    -Autoscale directory and run the following command:
    – python3 CreateNameSpaces.py -ip

    But when I do I get a 404 error as follows
    oci.exceptions.ServiceError: {‘target_service’: ‘identity’, ‘status’: 404, ‘code’: ‘NotAuthorizedOrNotFound’, ‘opc-request-id’: ‘6EA2D7401BC347A7AD0761C5488EC594/5A0186FBF0E7068C068E852EBC7A6D28/68ECAA771EEFC617823B48CF9C400B86’, ‘message’: ‘Authorization failed or requested resource not found.’, ‘operation_name’: ‘create_tag_namespace’, ‘timestamp’: ‘2023-11-20T11:22:31.161111+00:00’, ‘client_version’: ‘Oracle-PythonSDK/2.93.1’, ‘request_endpoint’: ‘POST https://identity.uk-london-1.oci.oraclecloud.com/20160918/tagNamespaces‘, ‘logging_tips’: ‘To get more info on the failing request, refer to https://docs.oracle.com/en-us/iaas/tools/python/latest/logging.html for ways to log the request/response details.’, ‘troubleshooting_tips’:

    In the video I think that you run it without the -ip, and when I do the same it runs as follows
    [opc@auto-scheduling-server OCI-AutoScale]$ python3 CreateNameSpaces.py
    Starts at 2023-11-23 12:02:20

    Connecting to Identity Service…

    Tenant Name : silverlinksoftware
    Tenant Id : ocid1.tenancy.oc1..aaaaaaaas3k6ddclddbv25elaxm47nnlw6kcekawg6hzyyxgpyhaq3ulgm7q
    Home Region : uk-london-1
    Creating Namespace Schedule
    Creating keys Schedule
    Key AnyDay is created
    Key WeekDay is created
    Key Weekend is created
    Key Monday is created
    Key Tuesday is created
    Key Wednesday is created
    Key Thursday is created
    Key Friday is created
    Key Saturday is created
    Key Sunday is created
    Key DayOfMonth is created

    Namespace and keys for scheduling have been created
    [opc@auto-scheduling-server OCI-AutoScale]$

    In addition in order for the cron to work I have to remove -ip
    This does not work
    58 * * * * python3 /home/opc/OCI-AutoScale/AutoScaleALL.py -a Down -ip
    01 * * * * python3 /home/opc/OCI-AutoScale/AutoScaleALL.py -a Up -ip
    But this does.
    58 * * * * python3 /home/opc/OCI-AutoScale/AutoScaleALL.py -a Down
    01 * * * * python3 /home/opc/OCI-AutoScale/AutoScaleALL.py -a Up

    Could this be a problem in my OCI setup?

    Thanks for any help.

    Regards
    John

    Reply
    1. richard Post author

      I think the createnamespace script does not support instanceprinciple authentication, just normal OCI (config file / ssh key) authentication, hence the script with -ip does not work.

      Reply

Leave a Reply to pete Cancel 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.