Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

How to fetch current date & time on F5 using F5 Python SDK

How to fetch current date & time on F5 using F5 Python SDK ?

I am getting some data through https://localhost/mgmt/tm/sys/clock
I tried the following without luck,

mgmt = ManagementRoot('F5-IP', "UserName", "Passwd")
_f5_date_time = mgmt.tm.sys.clock.load()
print _f5_date_time
0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

The clock endpoint hasn't been added yet to the SDK, but if you open an issue on GitHub I'll get it added in the next release.

0
Comments on this Answer
Comment made 13-Feb-2018 by Jason Rahm

So this will look like this:

t = Stats(b.tm.sys.clock.load())
t.stat['fullDate']['description']
u'2018-02-13T17:49:49Z'
0
Comment made 22-Jun-2018 by Saran 57

Hi Jason,

I am now able to fetch the date & time as below.
Is it the right way to fetch time & Date through SDK ?

_f5_date_time = mgmt.tm.sys.clock.load()
print _f5_date_time.entries['https://localhost/mgmt/tm/sys/clock/0']['nestedStats']['entries']['fullDate']['description']

**Output**
2018-06-22T10:23:09Z

I got the following at the same time through TMSH

(tmos)# show sys clock
----------------------------
Sys::Clock
----------------------------
Fri Jun 22 05:23:09 CDT 2018

(tmos)#

I am unable to get the Time Zone and also there is a time difference.

2018-06-22T10:23:09Z          --> Fetched using python SDK.     
Fri Jun 22 05:23:09 CDT 2018  --> Via TMSH at the same time.    

Three Questions:
1) Is it the right way to fetch Date & Time using F5 Python SDK ?
2) Why is there a Time difference between SDK & TMSH outputs ?
3) How to get Time Zone via SDK ?

0
Comment made 22-Jun-2018 by Jason Rahm

the sdk pushes the zulu time, the local system tmsh calls adjust for your big-ip timezone settings. You can read/modify your timezone settings on big-ip at /tm/sys/ntp with the timezone attribute:

{
    "kind": "tm:sys:ntp:ntpstate",
    "selfLink": "https://localhost/mgmt/tm/sys/ntp?ver=13.1.0.5",
    "timezone": "America/Chicago",
    "restrictReference": {
        "link": "https://localhost/mgmt/tm/sys/ntp/restrict?ver=13.1.0.5",
        "isSubcollection": true
    }
}
0
Comment made 22-Jun-2018 by Saran 57

Thank You Jason,

Is there a better way to fetch Date & Time other than the below ?

mgmt.tm.sys.clock.load().entries['https://localhost/mgmt/tm/sys/clock/0']['nestedStats']['entries']['fullDate']['description']
0
Comment made 22-Jun-2018 by Jason Rahm

the way I showed you in my first comment above would be simpler

0
Comment made 23-Jun-2018 by Saran 57

Thank You Jason

0