forked from uncloud/uncloud
Move all files to _etc_based
This commit is contained in:
parent
10f09c7115
commit
3cf3439f1c
116 changed files with 1 additions and 0 deletions
38
uncloud_etcd_based/uncloud/cli/image.py
Normal file
38
uncloud_etcd_based/uncloud/cli/image.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import requests
|
||||
|
||||
from uncloud.cli.helper import make_request
|
||||
from uncloud.common.parser import BaseParser
|
||||
|
||||
|
||||
class ImageParser(BaseParser):
|
||||
def __init__(self):
|
||||
super().__init__('image')
|
||||
|
||||
def create(self, **kwargs):
|
||||
p = self.subparser.add_parser('create', **kwargs)
|
||||
p.add_argument('--name', required=True)
|
||||
p.add_argument('--uuid', required=True)
|
||||
p.add_argument('--image-store', required=True, dest='image_store')
|
||||
|
||||
def list(self, **kwargs):
|
||||
self.subparser.add_parser('list', **kwargs)
|
||||
|
||||
|
||||
parser = ImageParser()
|
||||
arg_parser = parser.arg_parser
|
||||
|
||||
|
||||
def main(**kwargs):
|
||||
subcommand = kwargs.pop('image_subcommand')
|
||||
if not subcommand:
|
||||
arg_parser.print_help()
|
||||
else:
|
||||
data = None
|
||||
request_method = requests.post
|
||||
if subcommand == 'list':
|
||||
subcommand = 'list-public'
|
||||
request_method = requests.get
|
||||
elif subcommand == 'create':
|
||||
data = kwargs
|
||||
|
||||
make_request('image', subcommand, data=data, request_method=request_method)
|
||||
Loading…
Add table
Add a link
Reference in a new issue