1. issues with renew slice using 1.3

issues with renew slice using 1.3

Home Forums FABRIC General Questions and Discussion issues with renew slice using 1.3

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2867
    Gregory Daues
    Participant

      When trying to use example code from

      https://github.com/fabric-testbed/jupyter-examples/blob/master/fabric_examples/fablib_api/renew_slice/renew_slice.ipynb

      end_date = (datetime.datetime.utcnow() + datetime.timedelta(days=6)).strftime(“%Y-%m-%d %H:%M:%S”)

      slice.renew(end_date)

       

      to renew a slice using 1.3 for fabrictestbed, fabrictestbed_extensions , I see an error

      Exception: Failed to renew slice: Status.INVALID_ARGUMENTS, Lease End Time 2022-09-13 15:52:03 should be in format: %Y-%m-%d %H:%M:%S %z

      Is there an updated code sample for renew slice ?    Handling the time zone in python datetime looks like it takes some special treatment.

       

       

      #2868
      Komal Thareja
      Participant

        Thank you for let us know! We will work on fixing the example. Please use the snippet below to renew the slice.
        Hope this helps!

         

        
        import datetime
        
        #Set end host to now plus 1 day
        now = datetime.now(timezone.utc)
        end_date = now + timedelta(days=6).strftime("%Y-%m-%d %H:%M:%S %z")
        
        try:
        slice = fablib.get_slice(name=slice_name)
        
        slice.renew(end_date)
        except Exception as e:
        print(f"Exception: {e}")
        
        #2878
        Gregory Daues
        Participant

          Thanks; I was able to get the renew slice to work with snippets along those lines.
          My scripting that worked looked something like

          import datetime
          from datetime import timedelta

          now = datetime.datetime.now(datetime.timezone.utc)
          end_date = (now + timedelta(days=6)).strftime(“%Y-%m-%d %H:%M:%S %z”)

          slice = fablib.get_slice(name=slice_name)
          slice.renew(end_date)

          where I imagine that can be cleaned up a bit.

        Viewing 3 posts - 1 through 3 (of 3 total)
        • You must be logged in to reply to this topic.