Skip to content

Commit 4aa9c1c

Browse files
committed
adding up, down, create
Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>
1 parent 9289335 commit 4aa9c1c

File tree

8 files changed

+424
-113
lines changed

8 files changed

+424
-113
lines changed

scompose/client/__init__.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_parser():
5454
help='specify project name (defaults to $PWD)')
5555

5656
parser.add_argument("--project-directory", default=None,
57-
dest='project_dir', type=str,
57+
dest='working_dir', type=str,
5858
help='specify project working directory (defaults to compose file location)')
5959

6060
parser.add_argument("--env-file", default=None,
@@ -82,19 +82,21 @@ def get_parser():
8282
config = subparsers.add_parser("config",
8383
help="Validate and view the compose file")
8484

85-
# Create
85+
# Create (assumes built already)
8686

8787
create = subparsers.add_parser("create",
8888
help="create instances")
8989

90+
# Down
91+
9092
down = subparsers.add_parser("down",
9193
help="stop instances")
9294

9395
execute = subparsers.add_parser("exec",
94-
help="execute a command to a container")
96+
help="execute a command to an instance")
9597

9698
images = subparsers.add_parser("images",
97-
help="list images")
99+
help="list running instances")
98100

99101
kill = subparsers.add_parser("kill",
100102
help="kill instances")
@@ -106,22 +108,18 @@ def get_parser():
106108
help="list instances")
107109

108110
restart = subparsers.add_parser("restart",
109-
help="restart images")
111+
help="stop and start containers.")
110112

111113
rm = subparsers.add_parser("rm",
112114
help="remove non-running container images")
113115

114-
stop = subparsers.add_parser("stop",
115-
help="stop running containers")
116-
117116
up = subparsers.add_parser("up",
118117
help="build and start containers")
119118

120-
121-
# Add a context to relevant subparsers
122-
for sub in [config, build]:
123-
sub.add_argument('context', nargs=1,
124-
help='the context for the command (e.g., . means pwd)')
119+
# Add list of names
120+
for sub in [create, down, up]:
121+
sub.add_argument('names', nargs="?",
122+
help='the names of the instances to target')
125123

126124
return parser
127125

scompose/client/build.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,9 @@ def main(args, parser, extra):
3434
e.g. `folder_db`. If a Singularity recipe changes for a container folder,
3535
you can run "singularity-compose build" to rebuild it.
3636
'''
37-
working_dir = args.context
38-
if working_dir == ".":
39-
working_dir = os.getcwd()
40-
4137
# Initialize the project
4238
project = Project(filename=args.file,
4339
name=args.project_name,
44-
working_dir=working_dir,
4540
env_file=args.env_file)
4641

4742
# Builds any containers into folders

scompose/client/create.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'''
2+
3+
Copyright (C) 2019 Vanessa Sochat.
4+
5+
This program is free software: you can redistribute it and/or modify it
6+
under the terms of the GNU Affero General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or (at your
8+
option) any later version.
9+
10+
This program is distributed in the hope that it will be useful, but WITHOUT
11+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
13+
License for more details.
14+
15+
You should have received a copy of the GNU Affero General Public License
16+
along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
'''
19+
20+
from scompose.project import Project
21+
import logging
22+
import json
23+
import sys
24+
import os
25+
26+
27+
log = logging.getLogger(__name__)
28+
29+
def main(args, parser, extra):
30+
'''create one or more instances. If they don't exist, build first.
31+
32+
This will build and bring up one or more named instances, or if None
33+
are provided, we create all of them.
34+
'''
35+
# Initialize the project
36+
project = Project(filename=args.file,
37+
name=args.project_name,
38+
env_file=args.env_file)
39+
40+
# Create instances, and if none specified, create all
41+
project.create(args.names)

scompose/client/down.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'''
2+
3+
Copyright (C) 2019 Vanessa Sochat.
4+
5+
This program is free software: you can redistribute it and/or modify it
6+
under the terms of the GNU Affero General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or (at your
8+
option) any later version.
9+
10+
This program is distributed in the hope that it will be useful, but WITHOUT
11+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
13+
License for more details.
14+
15+
You should have received a copy of the GNU Affero General Public License
16+
along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
'''
19+
20+
from scompose.project import Project
21+
import logging
22+
import json
23+
import sys
24+
import os
25+
26+
27+
log = logging.getLogger(__name__)
28+
29+
def main(args, parser, extra):
30+
'''bring one or more instances down
31+
'''
32+
# Initialize the project
33+
project = Project(filename=args.file,
34+
name=args.project_name,
35+
env_file=args.env_file)
36+
37+
# Create instances, and if none specified, create all
38+
project.down(args.names)

scompose/client/up.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'''
2+
3+
Copyright (C) 2019 Vanessa Sochat.
4+
5+
This program is free software: you can redistribute it and/or modify it
6+
under the terms of the GNU Affero General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or (at your
8+
option) any later version.
9+
10+
This program is distributed in the hope that it will be useful, but WITHOUT
11+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
13+
License for more details.
14+
15+
You should have received a copy of the GNU Affero General Public License
16+
along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
'''
19+
20+
from scompose.project import Project
21+
import logging
22+
import json
23+
import sys
24+
import os
25+
26+
27+
log = logging.getLogger(__name__)
28+
29+
def main(args, parser, extra):
30+
'''bring up one or more instances. They must exist.
31+
32+
This will build and bring up one or more named instances, or if None
33+
are provided, we create all of them.
34+
'''
35+
# Initialize the project
36+
project = Project(filename=args.file,
37+
name=args.project_name,
38+
env_file=args.env_file)
39+
40+
# Create instances, and if none specified, create all
41+
project.up(args.names)

0 commit comments

Comments
 (0)