02-cmdb acquisition Asset function plug-in development | CMDB

Source: Internet
Author: User

#__init__.py fromConfImportSettingsdefPack (): Response= {}     forKvinchsettings. Plugins.items ():Importimportlib M_path,classname= V.rsplit ('.', Maxsplit=1) M=Importlib.import_module (m_path) CLS=getattr (m,classname) response[k]=CLS (). Execute ()returnResponse
#base.py fromConfImportSettingsclassBaseplugin (object):def __init__(self): mode_list= ['SSH','Salt',"Agent"]        ifSettings. MODEinchMode_list:self.mode=settings. MODEElse:            RaiseException ('configuration File Error')    defssh (self,cmd):Pass    defAgent (self,cmd):Pass    defSalt (self,cmd):Pass    defShell_cmd (self,cmd):ifSelf.mode = ='SSH': Ret=self.ssh (cmd)elifSelf.mode = ='Salt': Ret=self.salt (cmd)Else: Ret=self.agent (cmd)returnretdefExecute (self): ret= Self.shell_cmd ('View Platform Commands')        ifRET = ='win':            returnself.windows ()elifRET = ='Linux':            returnSelf.linux ()Else:            RaiseException ('support for Windows and Linux only')    defLinux (self):RaiseException ('....')    defwindows (self):RaiseException ('....')
#disk.py from. baseImportBasepluginclassDiskplugin (baseplugin):defwindows (self): output= Self.shell_cmd ('ipconfig')        returnOutputdefLinux (self): output= Self.shell_cmd ('ifconfig')        returnOutput#mem.py from. baseImportBasepluginclassMemplugin (baseplugin):defwindows (self): output= Self.shell_cmd ('asdf')        #Regular Expressions        returnOutputdefLinux (self): output= Self.shell_cmd ('asdf')        #Regular Expressions        returnOutput#nic.py from. baseImportBasepluginclassNicplugin (baseplugin):defwindows (self): output= Self.shell_cmd ('asdf')        #Regular Expressions        returnOutputdefLinux (self): output= Self.shell_cmd ('asdf')        #Regular Expressions        returnOutput
# settings.py " Agent " # Salt,ssh

02-cmdb acquisition Asset function plug-in development | CMDB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.