Skip to content
This repository was archived by the owner on Oct 10, 2020. It is now read-only.

[merged] Implementing Atomic ps for DBus API#516

Closed
AmartC wants to merge 1 commit intoprojectatomic:masterfrom
AmartC:master
Closed

[merged] Implementing Atomic ps for DBus API#516
AmartC wants to merge 1 commit intoprojectatomic:masterfrom
AmartC:master

Conversation

@AmartC
Copy link
Contributor

@AmartC AmartC commented Aug 5, 2016

Atomic ps can now be called from tty or through the DBus API.

@AmartC AmartC force-pushed the master branch 3 times, most recently from 9cc7942 to eff1ce4 Compare August 5, 2016 14:56
@giuseppe
Copy link
Collaborator

giuseppe commented Aug 5, 2016

I needed these changes to get the tests passing:

I also included some other changes, like using JSON only for the dbus part, not inside the Ps class

diff --git a/Atomic/ps.py b/Atomic/ps.py
index 88b8a32..c43bbe5 100644
--- a/Atomic/ps.py
+++ b/Atomic/ps.py
@@ -11,7 +11,7 @@ class Ps(Atomic):

     def ps_tty(self):
         skull = (u"\u2620").encode('utf-8')
-        all_container_info = json.loads(self.ps())
+        all_container_info = self.ps()
         all_containers = []
         for each in all_container_info:
             if each["Type"] == "systemcontainer":
@@ -31,11 +31,11 @@ class Ps(Atomic):

                 image = each['Image']
                 command = each["Command"]
-                created = dateparse(ret['created']).strftime("%F %H:%M") # pylint: disable=no-member
+                created = created.strftime("%F %H:%M") # pylint: disable=no-member
                 container_info = {"type" : "systemcontainer", "container" : container,
                               "image" : image, "command" : command,
                               "created" : created, "status" : status,
-                              "runtime" : "runc", "vulnerabe" : each["vulnerable"]}
+                              "runtime" : "runc", "vulnerable" : each["vulnerable"]}

                 if self.args.filter:
                     if not self._filter_include_container(container_info):
@@ -132,7 +132,7 @@ class Ps(Atomic):
                 ret["vuln_info"] = dict()
             all_containers.append(ret)

-        return json.dumps(all_containers)
+        return all_containers

     def _filter_include_container(self, container_info):
         filterables = ["container", "image", "command", "created", "status", "runtime"]
diff --git a/atomic_dbus.py b/atomic_dbus.py
index 4e2cd7b..cbfa768 100755
--- a/atomic_dbus.py
+++ b/atomic_dbus.py
@@ -273,7 +273,7 @@ class atomic_dbus(slip.dbus.service.Object):
         ps.useTTY = False
         args = self.Args()
         ps.set_args(args)
-        return ps.ps()
+        return json.dumps(ps.ps())


 if __name__ == "__main__":
diff --git a/tests/integration/test_system_containers.sh b/tests/integration/test_system_containers.sh
index dbbd6e7..e1d87d0 100755
--- a/tests/integration/test_system_containers.sh
+++ b/tests/integration/test_system_containers.sh
@@ -68,19 +68,19 @@ trap teardown EXIT

 ${ATOMIC} --debug install --name=${NAME} --set=RECEIVER=${SECRET} --system oci:atomic-test-system

-${ATOMIC} ps > ps.out
+${ATOMIC} --debug ps --no-trunc > ps.out
 grep -q "test-system" ps.out
-${ATOMIC} ps --json > ps.out
+${ATOMIC} --debug ps --json > ps.out
 grep -q "test-system" ps.out
-${ATOMIC} ps --all > ps.out
+${ATOMIC} ps --all --no-trunc > ps.out
 grep -q "test-system" ps.out
 ${ATOMIC} ps --json --all > ps.out
 grep -q "test-system" ps.out
-${ATOMIC} ps --filter id=test-system > ps.out
+${ATOMIC} ps --no-trunc --filter id=test-system > ps.out
 grep -q "test-system" ps.out
 ${ATOMIC} ps --no-trunc > ps.out
 grep -q "test-system" ps.out
-${ATOMIC} ps --quiet > ps.out
+${ATOMIC} ps --no-trunc --quiet > ps.out
 grep -q "test-system" ps.out
 ${ATOMIC} ps -aq --no-trunc --filter id=test-system > ps.out
 grep -q "test-system" ps.out

@AmartC AmartC force-pushed the master branch 4 times, most recently from 04a2a15 to d2be6f6 Compare August 5, 2016 16:53
@giuseppe
Copy link
Collaborator

giuseppe commented Aug 5, 2016

@rh-atomic-bot r+ e75fc84

@rh-atomic-bot
Copy link

⌛ Testing commit e75fc84 with merge 6302409...

@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: giuseppe
Pushing 6302409 to master...

@rh-atomic-bot rh-atomic-bot changed the title Implementing Atomic ps for DBus API [merged] Implementing Atomic ps for DBus API Aug 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants