Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
1dd03a4
moved old/
tomoyk May 24, 2022
731a02f
add gitignore
tomoyk May 24, 2022
d870d87
recreate project
tomoyk May 24, 2022
12605f2
add requirements and README
tomoyk May 24, 2022
a1d3404
fix config filename
tomoyk May 24, 2022
c78a46b
replaced Dockerfile
tomoyk May 24, 2022
8bb1e7d
renamed hosts.yaml.example
tomoyk May 24, 2022
a338c5c
static fileへのサポートを追加
tomoyk May 24, 2022
8391335
spectureへの対応を追加
tomoyk May 24, 2022
4804773
add ignore target
tomoyk May 24, 2022
1dbf01f
del old files
tomoyk May 24, 2022
72cb4ef
大規模修正
tomoyk May 24, 2022
5e605a2
微修正
tomoyk May 24, 2022
be36ca6
変数名と引数に型を追加
tomoyk May 25, 2022
45d46cd
Config読み込みを切り出し
tomoyk May 25, 2022
2f31499
connect.pyからアプリケーション依存コードをmain.pyに移動
tomoyk May 25, 2022
6d365aa
configパーサーの実装を修正
tomoyk May 25, 2022
2296460
classとfuncを移動
tomoyk May 25, 2022
3b224af
型アノテーションを追加
tomoyk May 25, 2022
91eca58
importを整理,get_vm_detailをリファクタリング
tomoyk May 25, 2022
c0c668d
トップを動く状態にした
tomoyk May 25, 2022
d2b851a
古いコードを削除
tomoyk May 25, 2022
602f2b4
微修正
tomoyk May 25, 2022
630f537
classをリファクタリング
tomoyk May 26, 2022
ae79aae
fix paramiko client and dataclass schema
tomoyk May 26, 2022
4e65f7c
MongoDBにデータをストアする実装を追加
tomoyk May 26, 2022
9770889
add 'updated_at'
tomoyk May 26, 2022
286a57b
commentout in connecter
tomoyk May 26, 2022
7b7f84b
merge conncter.py and crawler.py
tomoyk May 26, 2022
646edaa
moved dashboard assets
tomoyk May 26, 2022
874c15c
ログと例外処理を追加
tomoyk May 27, 2022
f164593
fix error reading
tomoyk May 27, 2022
3c1e9bc
例外処理の追加と認証情報の処理を追加
tomoyk May 27, 2022
1e4cf55
renamed dataclass
tomoyk May 27, 2022
2374cc1
fix dashboard
tomoyk May 27, 2022
4fc817c
autopep8
tomoyk May 27, 2022
51eb5b4
moved mongo_ipv4_codec
tomoyk May 27, 2022
b727873
moved load_config
tomoyk May 27, 2022
56a67b1
moved connecter
tomoyk May 27, 2022
e810f5c
moved tools and refactoring
tomoyk May 27, 2022
99150bf
renamed crawler -> main
tomoyk May 27, 2022
7cb4e1a
moved hosts.yml
tomoyk May 27, 2022
5a6f5cd
refactoring vim_cmd_parser
tomoyk May 27, 2022
a72b25e
importを並び替え
tomoyk May 27, 2022
a5e64e7
fix dashboard
tomoyk May 27, 2022
c945a96
fix template
tomoyk May 27, 2022
fd0996f
update girignore
tomoyk May 27, 2022
decdaa1
VM詳細の取得を追加
tomoyk May 27, 2022
e0d8f17
fix dataclass
tomoyk May 27, 2022
0b24a5d
mongoのIPv4対応を削除
tomoyk May 28, 2022
4d1b168
fix slack notify
tomoyk May 28, 2022
8f8671b
remove unsed codes
tomoyk May 28, 2022
fd5ef4f
refactoring import
tomoyk May 28, 2022
0ff8399
fix default value uptime
tomoyk May 28, 2022
d2d544b
add single vm page
tomoyk May 28, 2022
48d4a68
fix detail ui
tomoyk May 28, 2022
95c00e1
fix top UI
tomoyk May 28, 2022
f2b8584
fix detail UI
tomoyk May 28, 2022
acd2a42
add footer
tomoyk May 28, 2022
f986069
add wrapper and margin
tomoyk May 28, 2022
810a1ab
fix UI
tomoyk May 28, 2022
528079d
add sort
tomoyk May 28, 2022
aa793de
renamed menu items
tomoyk May 28, 2022
2e770b0
FIX UI
tomoyk May 28, 2022
d9dd118
fix UI
tomoyk May 28, 2022
9c9d367
add large spec mask
tomoyk May 28, 2022
5e9f6cf
READMEを書いたよ
tomoyk May 28, 2022
547b2aa
delete files
tomoyk May 28, 2022
e5ca24b
delete conncter
tomoyk May 28, 2022
6f227cc
moved example hosts.yml
tomoyk May 28, 2022
c6e8f9a
fix crawler a little
tomoyk May 28, 2022
d6e064b
add updating power with rpc call
tomoyk May 28, 2022
5799542
fix exception on detail.html
tomoyk May 28, 2022
d88e35c
fix load_config relative path import
tomoyk May 28, 2022
0a44e25
add 'executor'
tomoyk May 28, 2022
474d191
move import
tomoyk May 28, 2022
afb8afd
renamed
tomoyk May 28, 2022
6c2f065
add error handling
tomoyk May 28, 2022
75b548a
fix a little
tomoyk May 28, 2022
01b0c34
moved and delete
tomoyk May 28, 2022
6e36d56
update docs about architecture
tomoyk May 29, 2022
34e4e02
update README
tomoyk May 29, 2022
f3cfe61
add Feature
tomoyk May 29, 2022
3c8f667
fix typo
tomoyk May 29, 2022
2292a7e
add poling interval on crawler
tomoyk May 29, 2022
8affedb
renamed command result
tomoyk May 29, 2022
d085a25
add power management with javascript
tomoyk May 29, 2022
54b59dd
add hide ssh command on noipaddress
tomoyk May 29, 2022
06c3f66
add subPage navigation
tomoyk May 29, 2022
3f88f68
add inivisible class
tomoyk May 29, 2022
36abc7e
delete validate_machine_req
tomoyk May 30, 2022
443497c
add create_vm() on exectutor
tomoyk May 30, 2022
4826daf
fix esxi-console link
tomoyk May 30, 2022
6914a45
update vm create form
tomoyk May 30, 2022
08bed70
add config schema
tomoyk May 30, 2022
522fc34
fix creation form
tomoyk May 30, 2022
a3979ea
add esxi_nodes
tomoyk May 30, 2022
00596d1
update main tag
tomoyk May 30, 2022
3c52e3f
fix a little
tomoyk May 30, 2022
414d7b7
add menu item
tomoyk May 30, 2022
d73464c
fix create vm endpoint
tomoyk May 30, 2022
06072e9
リファクタリング
tomoyk May 30, 2022
5c51e6b
fix a bug
tomoyk May 30, 2022
c86221d
delete portgroup option
tomoyk May 30, 2022
f5453f2
delete portgroup in dashboard
tomoyk May 30, 2022
ed3052b
fix javascript schema
tomoyk May 30, 2022
50c7491
fix UI in vm creating
tomoyk May 30, 2022
edd40ad
add client.close()
tomoyk May 30, 2022
8a1c491
add filtering deleted VM
tomoyk May 30, 2022
6197043
fix a bug on long processing time
tomoyk May 30, 2022
8f9723e
add env vars for threshold
tomoyk May 30, 2022
2001158
add envvars in executor
tomoyk May 30, 2022
7a42054
add EXECUTOR env vars
tomoyk May 30, 2022
5b9633c
add Environment Vars
tomoyk May 30, 2022
77f0060
update example ISO
tomoyk May 30, 2022
8412844
fix undefined var
tomoyk May 30, 2022
c03ba3d
fix README Table
tomoyk May 30, 2022
5346a93
add requirements.txt
tomoyk May 30, 2022
0e5cde2
create symlink and Dockerfile
tomoyk May 30, 2022
91d068d
delete symlinks
tomoyk May 30, 2022
45148a2
add library package
tomoyk May 31, 2022
f270221
split packages
tomoyk May 31, 2022
6f74a43
add black
tomoyk May 31, 2022
58f61b8
apply black
tomoyk May 31, 2022
05c836e
add black
tomoyk May 31, 2022
fa04778
apply black
tomoyk May 31, 2022
035a61b
delete unused import
tomoyk May 31, 2022
4891e2e
add flake8
tomoyk May 31, 2022
a9b6417
add DEVGUIDE
tomoyk May 31, 2022
b19a7bf
split requirements.txt
tomoyk May 31, 2022
90b1d03
fix by isort
tomoyk May 31, 2022
68ae508
remove annotation
tomoyk May 31, 2022
941b214
update demo.gif
tomoyk May 31, 2022
2fb74cf
remove image width
tomoyk May 31, 2022
91f6804
add optional parameters: hosts.yml
tomoyk May 31, 2022
5c2935b
renamed hosts example
tomoyk May 31, 2022
3397747
moved file and renaed file
tomoyk May 31, 2022
520fe93
create docs
tomoyk May 31, 2022
5f7c0e2
delete files
tomoyk May 31, 2022
a564f09
update README
tomoyk May 31, 2022
7eae6d9
removed doc
tomoyk May 31, 2022
5f0dfa1
fix config file
tomoyk May 31, 2022
359256c
fix Dockerfile
tomoyk May 31, 2022
c194f95
add CI
tomoyk May 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/image-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
push:
branches:
- master

jobs:
build-and-push:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
strategy:
matrix:
target:
[
"crawler",
"dashboard",
"executor",
]
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set image tag for master
run: |
COMMITID=$(git rev-parse --short ${{ github.sha }} | cut -c1-7)
CUR_BRANCH=$(git symbolic-ref --short HEAD)
echo "DOCKER_TAG=${CUR_BRANCH}-${COMMITID}" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ${{ matrix.target }}/Dockerfile
push: true
tags: ghcr.io/cdsl-research/ecoman/${{ matrix.target }}:${{ env.DOCKER_TAG }}
136 changes: 133 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,133 @@
hosts.yaml
env/**
__pycache__/**
hosts.yml
id_rsa*


# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
16 changes: 0 additions & 16 deletions Dockerfile

This file was deleted.

102 changes: 47 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,67 @@
# ECoMan - Easy Computer Manager
# ECoMan

## How to run
ECoMan is a tool for supporting virtual machine management on VMware ESXi.
It provides administrators to view virtual machine lists with web user interface.

Setup venv
<img src="assets/demo.gif">

```
python3 -m venv env
. env/bin/activate
pip installl -r requirements.txt
```
## Feature

Configure esxi-node credentials on hosts.yaml
- View virtual machine lists over multiple ESXi Nodes
- Create a virtual machine via Web UI
- Set power status via Web UI
- Emphasize several machines which have large hardware resources in Web UI

```
### Example
mint:
addr: 'mint.a910.tak-cslab.org'
username: 'root'
password: 'xxxxxxxxxx'
```
## Requirements

Try to connect ssh on terminal
- Python 3.9 or later
- Paramiko
- FastAPI
- PyMongo
- MongoDB 5.0 or later

```
ssh [email protected]
```
## Installation

Starting app
ECoMan has several ways for running as below.

```
python app.py
- [Linux Machine (General)](docs/install_linux_machine.md)
- [Kubernetes](docs/install_kubernetes.md)

# uwsgi
pip install uwsgi
uwsgi --http :3301 --wsgi-file app.py --callable app
```
## Optional Parameters

Acceess Web UI
Hosts config file `hosts.yml` for ESXi Nodes:

```
http://<your-hostname>:3301/
hoge: # ESXi Node Name
addr: 'hoge.a910.tak-cslab.org' # ESXi Node Address
username: 'root' # ESXi Username
identity_file_path: "ssh/id_rsa" # SSH Private Key File
datastore_path: '/vmfs/volumes/datastore1/' # VM stored path on ESXi
installer_iso_path: "/vmfs/volumes/datastore1/os-images/ubuntu2004.iso" # Installer ISO stored path
network_port_group: "Management Network" # VM network port group
```

## Docker

```
docker run -it --rm -v $PWD:/config -e HOSTS_PATH=/config/hosts.yaml -p 2200:3301 tomoyk/ecoman
```

## Option: OAuth2-Proxy support

This app support enable user to SSO(Single Sing-On) with OAuth2-Proxy.

Example config `oauth2-proxy.cfg` is put that [here](oauth2-proxy.cfg.example).

New endpoint is `http://<your-hostname>:4180/`.

## Screenshot

VM List

<img src="https://raw.githubusercontent.com/cdsl-research/ecoman/master/images/ecoman1.jpg" width="500">

VM Detail
Environment Variables:

<img src="https://raw.githubusercontent.com/cdsl-research/ecoman/master/images/ecoman2.jpg" width="500">
| Name | Default Value | Type | Description | Component |
| --- | --- | --- | --- | --- |
| MONGO_USERNAME | | String | If this value is empty, ECoMan connects to MongoDB without authentication. | crawler, dashboard |
| MONGO_PASSWORD | | String | | crawler, dashboard |
| MONGO_DBNAME | ecoman | String | | crawler, dashboard |
| MONGO_HOST | 127.0.0.1 | String | | crawler, dashboard |
| CRAWLER_INTERVAL | 60 | Integer | | crawler |
| DASHBOARD_THRESHOLD_CPU | 5 | Integer | CPU usage on VM lists is emphasized by this value. | dashboard |
| DASHBOARD_THRESHOLD_RAM_MB | 8192 | Integer | RAM usage on VM lists is emphasized by this value. | dashboard |
| DASHBOARD_THRESHOLD_STORAGE_GB | 50 | Integer | Storage usage on VM lists is emphasized by this value. | dashboard |
| EXECUTOR_ADDRESS | 127.0.0.1 | String | | dashboard |
| EXECUTOR_PORT | 8600 | Integer | | dashboard, executor |

VM Creation
## Architecture

<img src="https://raw.githubusercontent.com/cdsl-research/ecoman/master/images/ecoman3.jpg" width="500">
ECoMan has following system archtiecture.

## Demo Movie
- `crawler` fetches VMs info via SSH and regist VMs info to MongoDB. This component works by polling.
- `dashboard` provides Web UI to Administrators. When Administrator accesses `dashboard`, it fetches VMs info from MongoDB and returns to Administrator.
- `executor` receives actions, "Create VM" or "Update VM's power", from `dashboard` and does the actions via SSH.

[Demo Link](https://twitter.com/i/status/1277117890764828673)
<img src="assets/architecture.png">
Loading