Skip to content

Commit 00eef49

Browse files
author
lijianguo
committed
feat(ps):add ps:stop/start command
1 parent 49ce4ae commit 00eef49

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

rootfs/api/models/app.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,12 @@ def scale(self, user, structure): # noqa
498498

499499
def stop(self, user, types): # noqa
500500
"""scale containers which types contained down """
501+
rs_zero = []
502+
for _ in types:
503+
if not self.structure.get(_, 0):
504+
rs_zero.append(_)
505+
if rs_zero:
506+
raise DryccException("process {} replicas is zero".format(",".join(rs_zero))) # noqa
501507

502508
if self.release_set.filter(failed=False).latest().build is None:
503509
raise DryccException('No build associated with this release')
@@ -542,6 +548,13 @@ def start(self, user, types): # noqa
542548
if self.release_set.filter(failed=False).latest().build is None:
543549
raise DryccException('No build associated with this release')
544550

551+
rs_zero = []
552+
for _ in types:
553+
if not self.structure.get(_, 0):
554+
rs_zero.append(_)
555+
if rs_zero:
556+
raise DryccException("process {} replicas is zero".format(",".join(rs_zero))) # noqa
557+
545558
structure = {}
546559
for k, v in self.structure.items():
547560
if k in types:

rootfs/api/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def list(self, *args, **kwargs):
342342
if _ not in exist_pod_type:
343343
data.append({"type": _,
344344
"replicas": 0,
345-
"state": "stopped"})
345+
"state": "started"})
346346

347347
# # fake out pagination for now
348348
pagination = {'results': data, 'count': len(data)}

0 commit comments

Comments
 (0)