Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
ab62bfca
Commit
ab62bfca
authored
Mar 04, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修改一些bug
parent
7833fc8c
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
93 additions
and
72 deletions
+93
-72
README.md
README.md
+57
-44
forms.py
apps/assets/forms.py
+3
-0
idc_create_update.html
apps/assets/templates/assets/idc_create_update.html
+3
-3
idc_list.html
apps/assets/templates/assets/idc_list.html
+1
-1
system_user_list.html
apps/assets/templates/assets/system_user_list.html
+1
-1
task.py
apps/ops/models/task.py
+2
-2
_celery_tasks.py
apps/ops/tasks/_celery_tasks.py
+3
-3
ansible_api.py
apps/ops/utils/ansible_api.py
+10
-7
_nav.html
apps/templates/_nav.html
+0
-2
group.py
apps/users/models/group.py
+8
-4
config_example.py
config_example.py
+2
-2
run_server.py
run_server.py
+1
-1
make_migrations.sh
utils/make_migrations.sh
+2
-2
No files found.
README.md
View file @
ab62bfca
// Jumpserver //
~ Jumpserver是什么?
Jumpserver是一款开源的跳板机(堡垒机)产品, 主要使用Python,Django开发
他实现了跳板机(堡垒机)的主要功能,删减、优化了传统堡垒机,致力于为互联网
运维提供服务
~ 版本依赖
*
Python 2.7
## Jumpserver
Jumpserver是一款开源的跳板机产品,主要使用Python,Django开发
### 开发环境
*
Python 2.7 # 开发时需考虑兼容Python3
*
Django 1.10
~ 快速开始
```
pip install -r requirements.txt # Install pip module
yum -y install `cat rpm_requirements.txt` # Install rpm package
cp config_example.py config.py # Prepaire config from example config
cd apps && python manage.py makemigrations # Make migrations for django
python manage.py migrate # Migrate ORM to database
python manage.py loaddata init # Init some data
python manage.py loaddata fake # Generake some fake data
yum -y install redis && service redis start # Or install redis docker
python manage.py runserver 0.0.0.0:80 # Run it
```
~ 文档
*
[
项目结构描述
](
https://code.jumpserver.org/jumpserver/jumpserver/blob/master/docs/project_structure.md
)
*
[
Python代码规范
](
https://code.jumpserver.org/jumpserver/jumpserver/blob/master/docs/python_style_guide.md
)
*
[
API设计规范
](
https://code.jumpserver.org/jumpserver/jumpserver/blob/master/docs/api_style_guide.md
)
*
[
表结构
](
https://code.jumpserver.org/Jumpserver/jumpserver/wikis/table-structure
)
### 安装
1.
安装依赖库
```
$ cd requirements
$ sudo yum -y install `cat rpm_requirements.txt` # CentOS/RedHat
$ sudo apt-get install `cat deb_requirements.txt` # Ubuntu/Debian
```
2.
安装Python依赖包
```
# 请自行安装 Python2.7 和 pip, 以下运行是以python2.7和pip2.7开始
$ pip2.7 install -r requirements.txt -i https://pypi.doubanio.com/simple
# MacOS
$ pip2.7 install -r requirements.txt -i https://pypi.doubanio.com/simple --user
```
3.
配置文件
```
$ cd ..
$ cp config_example.py config.py
```
配置项 参考 config.py
4.
初始化数据库
```
# cd utils
# sh make_migrations.sh
# sh init_db.sh
```
5.
依赖redis
```
$ yum -y install redis
$ service redis start # Run docker or redis-server &
```
6.
启动
```
$ python2.7 run_server.py
```
### 开发者文档
*
[
项目结构描述
](
https://github.com/jumpserver/jumpserver/blob/dev/docs/project_structure.md
)
*
[
Python代码规范
](
https://github.com/jumpserver/jumpserver/blob/dev/docs/python_style_guide.md
)
*
[
API设计规范
](
https://github.com/jumpserver/jumpserver/blob/dev/docs/api_style_guide.md
)
apps/assets/forms.py
View file @
ab62bfca
...
...
@@ -121,6 +121,9 @@ class IDCForm(forms.ModelForm):
'extranet'
:
forms
.
Textarea
(
attrs
=
{
'placeholder'
:
'IP段之间用逗号隔开,如:201.1.32.1/24,202.2.32.1/24'
})
}
help_texts
=
{
'name'
:
'* required'
}
class
AdminUserForm
(
forms
.
ModelForm
):
...
...
apps/assets/templates/assets/idc_create_update.html
View file @
ab62bfca
...
...
@@ -47,9 +47,9 @@
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-
5
"
>
<button
class=
"btn btn-
white"
type=
"reset"
>
重置
</button>
<button
class=
"btn btn-primary"
type=
"submit"
>
提交
</button>
<div
class=
"col-sm-4 col-sm-offset-
2
"
>
<button
class=
"btn btn-
default"
type=
"reset"
>
{% trans 'Reset' %}
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
{% trans 'Submit' %}
</button>
</div>
</div>
</form>
...
...
apps/assets/templates/assets/idc_list.html
View file @
ab62bfca
...
...
@@ -32,7 +32,7 @@
<option
value=
"delete"
>
{% trans 'Delete selected' %}
</option>
</select>
<div
class=
"input-group-btn pull-left"
style=
"padding-left: 5px;"
>
<button
id=
'btn_bulk_update'
style=
"height: 32px;"
class=
"btn btn-sm btn-
warning
"
>
<button
id=
'btn_bulk_update'
style=
"height: 32px;"
class=
"btn btn-sm btn-
primary
"
>
{% trans 'Submit' %}
</button>
</div>
...
...
apps/assets/templates/assets/system_user_list.html
View file @
ab62bfca
...
...
@@ -32,7 +32,7 @@
<option
value=
"update"
>
{% trans 'Update selected' %}
</option>
</select>
<div
class=
"input-group-btn pull-left"
style=
"padding-left: 5px;"
>
<button
id=
'btn_bulk_update'
style=
"height: 32px;"
class=
"btn btn-sm btn-
warning
"
>
<button
id=
'btn_bulk_update'
style=
"height: 32px;"
class=
"btn btn-sm btn-
primary
"
>
{% trans 'Submit' %}
</button>
</div>
...
...
apps/ops/models/task.py
View file @
ab62bfca
...
...
@@ -30,8 +30,8 @@ class Task(models.Model):
return
[]
def
run
(
self
):
from
ops.utils.ansible_api
import
ADHocRunner
,
Config
conf
=
Config
()
from
ops.utils.ansible_api
import
ADHocRunner
,
Options
conf
=
Options
()
gather_facts
=
"yes"
if
self
.
is_gather_facts
else
"no"
play_source
=
{
"name"
:
"Ansible Play"
,
...
...
apps/ops/tasks/_celery_tasks.py
View file @
ab62bfca
...
...
@@ -3,12 +3,12 @@ from __future__ import absolute_import, unicode_literals
from
celery
import
shared_task
from
common
import
celery_app
from
ops.utils.ansible_api
import
Config
,
ADHocRunner
from
ops.utils.ansible_api
import
Options
,
ADHocRunner
@shared_task
(
name
=
"get_asset_hardware_info"
)
def
get_asset_hardware_info
(
task_name
,
task_uuid
,
*
assets
):
conf
=
Config
()
conf
=
Options
()
play_source
=
{
"name"
:
"Get host hardware information"
,
"hosts"
:
"default"
,
...
...
@@ -24,7 +24,7 @@ def get_asset_hardware_info(task_name, task_uuid, *assets):
@shared_task
(
name
=
"asset_test_ping_check"
)
def
asset_test_ping_check
(
task_name
,
task_uuid
,
*
assets
):
conf
=
Config
()
conf
=
Options
()
play_source
=
{
"name"
:
"Test host connection use ping"
,
"hosts"
:
"default"
,
...
...
apps/ops/utils/ansible_api.py
View file @
ab62bfca
...
...
@@ -20,7 +20,7 @@ from ansible.plugins.callback import CallbackBase
from
ops.models
import
TaskRecord
,
AnsiblePlay
,
AnsibleTask
,
AnsibleHostResult
__all__
=
[
"ADHocRunner"
,
"
Config
"
]
__all__
=
[
"ADHocRunner"
,
"
Options
"
]
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -30,7 +30,7 @@ class AnsibleError(StandardError):
pass
class
Config
(
object
):
class
Options
(
object
):
"""Ansible运行时配置类, 用于初始化Ansible的一些默认配置.
"""
def
__init__
(
self
,
verbosity
=
None
,
inventory
=
None
,
listhosts
=
None
,
subset
=
None
,
module_paths
=
None
,
extra_vars
=
None
,
...
...
@@ -93,7 +93,8 @@ class Config(object):
class
InventoryMixin
(
object
):
"""提供生成Ansible inventory对象的方法
"""
提供生成Ansible inventory对象的方法
"""
def
gen_inventory
(
self
):
...
...
@@ -313,7 +314,8 @@ class PlayBookRunner(InventoryMixin):
"""用于执行AnsiblePlaybook的接口.简化Playbook对象的使用.
"""
def
__init__
(
self
,
config
,
palybook_path
,
playbook_var
,
become_pass
,
*
hosts
,
**
group_vars
):
def
__init__
(
self
,
config
,
palybook_path
,
playbook_var
,
become_pass
,
*
hosts
,
**
group_vars
):
"""
:param config: Config实例
...
...
@@ -392,7 +394,8 @@ class PlayBookRunner(InventoryMixin):
class
ADHocRunner
(
InventoryMixin
):
"""ADHoc接口
"""
ADHoc接口
"""
def
__init__
(
self
,
play_data
,
config
=
None
,
*
hosts
,
**
group_vars
):
"""
...
...
@@ -408,7 +411,7 @@ class ADHocRunner(InventoryMixin):
tasks=[dict(action=dict(module='service', args={'name': 'vsftpd', 'state': 'restarted'}), async=async, poll=poll)]
)
"""
self
.
options
=
config
if
config
!=
None
else
Config
()
self
.
options
=
config
if
config
!=
None
else
Options
()
# 设置verbosity级别, 及命令行的--verbose选项
self
.
display
=
Display
()
...
...
@@ -482,7 +485,7 @@ class ADHocRunner(InventoryMixin):
def
test_run
():
conf
=
Config
()
conf
=
Options
()
assets
=
[
{
"name"
:
"192.168.1.119"
,
...
...
apps/templates/_nav.html
View file @
ab62bfca
...
...
@@ -50,8 +50,6 @@
</a>
<ul
class=
"nav nav-second-level"
>
<li
id=
"task"
><a
href=
"{% url 'ops:page-task-list' %}"
>
{% trans 'Task' %}
</a></li>
<li
id=
"sudo"
><a
href=
"{% url 'ops:page-sudo-list' %}"
>
{% trans 'Sudo' %}
</a></li>
<li
id=
"cron"
><a
href=
"{% url 'ops:page-cron-list' %}"
>
{% trans 'Cron' %}
</a></li>
</ul>
</li>
...
...
apps/users/models/group.py
View file @
ab62bfca
...
...
@@ -14,7 +14,8 @@ from common.mixins import NoDeleteModelMixin
__all__
=
[
'UserGroup'
]
class
UserGroup
(
NoDeleteModelMixin
,
Group
):
class
UserGroup
(
NoDeleteModelMixin
):
name
=
models
.
CharField
(
max_length
=
128
,
verbose_name
=
_
(
'Name'
))
comment
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
)
created_by
=
models
.
CharField
(
max_length
=
100
)
...
...
@@ -34,9 +35,12 @@ class UserGroup(NoDeleteModelMixin, Group):
@classmethod
def
initial
(
cls
):
group
,
created
=
cls
.
objects
.
get_or_create
(
name
=
'Default'
,
created_by
=
'System'
,
comment
=
'Default user group for all user'
)
default_group
=
cls
.
objects
.
filter
(
name
=
'Default'
)
if
not
default_group
:
group
=
cls
(
name
=
'Default'
,
created_by
=
'System'
,
comment
=
'Default user group'
)
group
.
save
()
else
:
group
=
default_group
[
0
]
return
group
@classmethod
...
...
config_example.py
View file @
ab62bfca
...
...
@@ -99,8 +99,8 @@ class DevelopmentConfig(Config):
EMAIL_PORT
=
465
EMAIL_HOST_USER
=
'ask@jumpserver.org'
EMAIL_HOST_PASSWORD
=
'xfDf4x1n'
EMAIL_USE_SSL
=
True
# If port is 465, set True
EMAIL_USE_TLS
=
False
# If port is 587, set True
EMAIL_USE_SSL
=
True
EMAIL_USE_TLS
=
False
EMAIL_SUBJECT_PREFIX
=
'[Jumpserver] '
SITE_URL
=
'http://localhost:8080'
...
...
run_server.py
View file @
ab62bfca
...
...
@@ -23,7 +23,7 @@ def start_django():
http_port
=
CONFIG
.
HTTP_LISTEN_PORT
or
'8080'
os
.
chdir
(
apps_dir
)
print
(
'start django'
)
subprocess
.
call
(
'python ./manage.py runserver
%
s:
%
s'
%
(
http_host
,
http_port
),
shell
=
True
)
subprocess
.
call
(
'python
2.7
./manage.py runserver
%
s:
%
s'
%
(
http_host
,
http_port
),
shell
=
True
)
def
start_celery
():
...
...
utils/make_migrations.sh
View file @
ab62bfca
#!/bin/bash
#
python ../apps/manage.py makemigrations
python
2.7
../apps/manage.py makemigrations
python ../apps/manage.py migrate
python
2.7
../apps/manage.py migrate
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment