X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=modules%2Flibjuju%2Fjuju%2Funit.py;h=e8ecd960687a42191c8ada84ac21eeb2e52937f5;hp=fc597bf15ed57e48729176b497366487381f7e16;hb=d238b03584451451ffcea345ffc5d02c657003bd;hpb=68858c1915122c2dbc8999a5cd3229694abf5f3a diff --git a/modules/libjuju/juju/unit.py b/modules/libjuju/juju/unit.py index fc597bf..e8ecd96 100644 --- a/modules/libjuju/juju/unit.py +++ b/modules/libjuju/juju/unit.py @@ -1,6 +1,6 @@ import logging -from dateutil.parser import parse as parse_date +import pyrfc3339 from . import model from .client import client @@ -21,7 +21,7 @@ class Unit(model.ModelEntity): """Get the time when the `agent_status` was last updated. """ - return parse_date(self.safe_data['agent-status']['since']) + return pyrfc3339.parse(self.safe_data['agent-status']['since']) @property def agent_status_message(self): @@ -42,7 +42,7 @@ class Unit(model.ModelEntity): """Get the time when the `workload_status` was last updated. """ - return parse_date(self.safe_data['workload-status']['since']) + return pyrfc3339.parse(self.safe_data['workload-status']['since']) @property def workload_status_message(self): @@ -122,7 +122,8 @@ class Unit(model.ModelEntity): """Run command on this unit. :param str command: The command to run - :param int timeout: Time to wait before command is considered failed + :param int timeout: Time, in seconds, to wait before command is + considered failed :returns: A :class:`juju.action.Action` instance. """ @@ -131,6 +132,10 @@ class Unit(model.ModelEntity): log.debug( 'Running `%s` on %s', command, self.name) + if timeout: + # Convert seconds to nanoseconds + timeout = int(timeout * 1000000000) + res = await action.Run( [], command, @@ -144,7 +149,7 @@ class Unit(model.ModelEntity): """Run an action on this unit. :param str action_name: Name of action to run - :param \*\*params: Action parameters + :param **params: Action parameters :returns: A :class:`juju.action.Action` instance. Note that this only enqueues the action. You will need to call @@ -182,7 +187,8 @@ class Unit(model.ModelEntity): :param str destination: Remote destination of transferred files :param str user: Remote username :param bool proxy: Proxy through the Juju API server - :param str scp_opts: Additional options to the `scp` command + :param scp_opts: Additional options to the `scp` command + :type scp_opts: str or list """ await self.machine.scp_to(source, destination, user=user, proxy=proxy, scp_opts=scp_opts) @@ -195,7 +201,8 @@ class Unit(model.ModelEntity): :param str destination: Local destination of transferred files :param str user: Remote username :param bool proxy: Proxy through the Juju API server - :param str scp_opts: Additional options to the `scp` command + :param scp_opts: Additional options to the `scp` command + :type scp_opts: str or list """ await self.machine.scp_from(source, destination, user=user, proxy=proxy, scp_opts=scp_opts)