Saltstack Study notes-12th: Saltstack Web Interface

Source: Internet
Author: User
Tags saltstack


Saltstack has its own Python-developed web interface Halite, the benefit is based on Python, can work seamlessly with the salt API, to determine the more obvious, the need to personalize the Web interface to customize the will be more troublesome, If you like to experience this interface, you can refer to the following article http://rfyiamcool.blog.51cto.com/1030776/1275443/


I am using another python+php for web development, the specific tools are described in one of my other articles, where we re-introduce the entire development


First, we introduce the PHP and Python communication tools


Ppython (download) There are always three files: php_python.py, process.py, php_python.php


PHP_PYTHON.PY: Is the main program of Ppython, startup will open a process waiting for port communication

process.py: is a Ppython handler that will return the result after executing the command passed by PHP.

php_python.php: A call interface provided to PHP, which is processed by the file delivery command to Python and accepts the processed return result


A simple test Ppython


11 Simple test Python

#!/usr/bin/python#coding=utf-8import commands;d EF ls_home (): S,r=commands.getstatusoutput ("ls ~/"); Return ("%s"% (r));

Note: Write the above code to test.py and php_python.py in the same directory


2 A simple PHP call to the Python function file, test.php

<?phpimport Php_python.php;echo Ppython ("Test::ls_home");? >


3 Start the Ppython and test

# Start Ppython

Python php_python.py


#测试刚刚的小程序

PHP test.php


Note: Under normal circumstances, you can display the user directory files, if the five information, or error, consider whether it is a port problem, PHP and Python through 5100 port to communicate, you need to open a local 5100 port firewall.


More complex tests, introducing Saltstack


1 Modify the above test.py

#!/usr/bin/python#coding=utf-8#coding = utf-8import osimport salt.keyimport salt.clientconf= '/etc/salt/master ' opts =    Salt.config.master_config (conf) # # # # #def key (PAR) using a reverse injection method: Global opts; return eval (PAR);d EF Client (PAR): return eval (PAR);


2 Modify the above test.php file

<?phpimport php_python.php;## shows Keyecho Ppython waiting for authentication ("Test::key", "Salt.key.Key (opts). List_keys ()");? >


3 reboot Php_python.py:ctrl+c stop and re-execute Python php_python.py boot.


4 test the command as above, execute: PHP test.php


Note: This has been implemented in the concatenation of the Salt and PHP, PHP uses the same command format as the Python API format, the command implementation of the file test.py using anti-injection method to invoke the command, and return the results to the PHP file for display.


Just one more word.


Since you can make a programming call to PHP, and the format of the command is the same as the Salt API format, you can simply do PHP Web programming display, here are a few I use php+extjs+ppyton+saltstack development of the management background


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/39/00/wKioL1O1KXqQRRh1AAYRXXHcykc493.jpg "style=" float: none; "title=" 1.jpg "alt=" Wkiol1o1kxqqrrh1aayrxxhcykc493.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/39/00/wKiom1O1KarTT3PwAATsBXq5_yE020.jpg "style=" float: none; "title=" 2.jpg "alt=" Wkiom1o1kartt3pwaatsbxq5_ye020.jpg "/>




This article is from the "Nano Dragon" blog, please be sure to keep this source http://arlen.blog.51cto.com/7175583/1434135

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.