标签:ade erro load stack back yaml import plugins add
开发 命令格式如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author:luoahong import os,sys if __name__ = = "__main__" : os.environ.setdefault( "DJANGO_SETTINGS_MODULE" , "Stark.settings" ) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) #print(BASE_DIR) sys.path.append(BASE_DIR) from Arya.action_list import actions from Arya.backends.utils import ArgvManagement obj = ArgvManagement(sys.argv) |
1
2
3
4
5
6
7
8
|
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author:luoahong from Arya.plugins import cmd,state actions = { ‘cmd‘ : cmd.CMD, ‘state‘ :state.State } |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author:luoahong import sys from Arya import action_list import django django.setup() from Stark import settings from Arya import models class ArgvManagement( object ): ‘‘‘ 接收用户指令并分配到相应模块 ‘‘‘ def __init__( self ,argvs): self .argvs = argvs self .argv_parse() def help_msg( self ): print ( "Available modules:" ) for registered_module in action_list.actions: print ( " %s" % registered_module) exit() |
1
2
3
4
5
6
7
|
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author:luoahong from Arya.backends.base_module import BaseSaltModule class CMD(BaseSaltModule): print ( ‘in cmd module ‘ ) |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author:luoahong from Arya.backends.base_module import BaseSaltModule import os class State(BaseSaltModule): def load_state_files( self ,state_filename): from yaml import load, dump try : from yaml import CLoader as Loader, CDumper as Dumper except ImportError: from yaml import Loader, Dumper state_file_path = "%s/%s" % ( self .settings.SALT_CONFIG_FILES_DIR,state_filename) if os.path.isfile(state_file_path): with open (state_file_path) as f: data = load(f.read(), Loader = Loader) return data else : exit( "%s is not a valid yaml config file" % state_filename) |
saltstack主机管理项目:计主机管理项目命令分发器(三)
标签:ade erro load stack back yaml import plugins add
原文地址:https://www.cnblogs.com/luoahong/p/9419535.html