Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16.release #1

Open
wants to merge 18 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# sphinx build directories
_build/

# dotfiles
.*
!.gitignore
!.github
!.mailmap
# compiled python files
*.py[co]
__pycache__/
# setup.py egg_info
*.egg-info
# emacs backup files
*~
# hg stuff
*.orig
status
# odoo filestore
odoo/filestore
# maintenance migration scripts
odoo/addons/base/maintenance

# generated for windows installer?
install/win32/*.bat
install/win32/meta.py

# needed only when building for win32
setup/win32/static/less/
setup/win32/static/wkhtmltopdf/
setup/win32/static/postgresql*.exe

# js tooling
node_modules
jsconfig.json
tsconfig.json
package-lock.json
package.json
.husky

# various virtualenv
/bin/
/build/
/dist/
/include/
/lib/
/man/
/share/
/src/
30 changes: 30 additions & 0 deletions proxmox/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Setup config in proxmox

Downdload this project in connect node in proxmox and execute `./setup.sh` script.

## Output

```bash
Setup config in proxmox \n
Create group thorpe \n
Create user thorpe_access@pve
Add to thorpe groupe user thorpe_access@pve
Create and config api token
┌──────────────┬──────────────────────────────────────────────────────────
│ key │ value
╞══════════════╪══════════════════════════════════════════════════════════
│ full-tokenid │ thorpe_access@pve!thorpe_api_token
├──────────────┼──────────────────────────────────────────────────────────
│ info │ {"comment":"Token to acess by thorpe integration","privse
├──────────────┼──────────────────────────────────────────────────────────
│ value │ 219cd33f-fc7a-4cb8-b94e-32d4a4df99de
└──────────────┴──────────────────────────────────────────────────────────
Add permitions to api token \n
Add permitions to vms
Add permitions to storage
Add permitions to nodes
Add permitions to group user \n
```

The config of api token is finish, copy `full-tokenid` to `Token` in thorpe-base and `value` to `Secret` in thorpe-base

20 changes: 20 additions & 0 deletions proxmox/permitions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
echo "Add permitions to api token \n"

echo "Add permitions to vms"
pveum aclmod /vms -token thorpe_access@pve!thorpe_api_token -role Thorpe.instance

echo "Add permitions to storage"
pveum aclmod /storage/local-lvm -token thorpe_access@pve!thorpe_api_token -role Thorpe.storage
pveum aclmod /storage/local -token thorpe_access@pve!thorpe_api_token -role Thorpe.storage
pveum aclmod /storage -token thorpe_access@pve!thorpe_api_token -role Thorpe.storage
pveum aclmod /storage -token thorpe_access@pve!thorpe_api_token -role Thorpe.template

echo "Add permitions to nodes"
pveum aclmod /nodes -token thorpe_access@pve!thorpe_api_token -role Thorpe.nodes


echo "Add permitions to group user \n"
pveum aclmod /storage/local-lvm -group thorpe -role Thorpe.storage
pveum aclmod /storage/local -group thorpe -role Thorpe.storage


15 changes: 15 additions & 0 deletions proxmox/roles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# create Role to manager lxc and vms
#
pveum role add Thorpe.instance --privs "Datastore.Audit VM.Allocate VM.Audit VM.Config.CDROM VM.Config.Disk VM.Migrate VM.Monitor VM.PowerMgmt"

# create Role to list nodes
#
pveum role add Thorpe.nodes --privs "Sys.Audit"

# create Role to manger storage
#
pveum role add Thorpe.storage --privs "Datastore.Allocate Datastore.AllocateSpace Datastore.Audit VM.Audit"

# create Role to list templates lxc and vms
#
pveum role add Thorpe.template --privs "VM.Audit"
12 changes: 12 additions & 0 deletions proxmox/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

# this setup thorpe config in proxmox
echo "Setup config in proxmox \n"

./roles.sh

./user.sh

./token.sh

./permitions.sh

2 changes: 2 additions & 0 deletions proxmox/token.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "Create and config api token"
pveum user token add thorpe_access@pve thorpe_api_token -comment "Token to acess by thorpe integration"
9 changes: 9 additions & 0 deletions proxmox/user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

echo "Create group thorpe \n"
pveum groupadd thorpe -comment "Goup to manager thorpe access"

echo "Create user thorpe_access@pve"
pveum useradd thorpe_access@pve -comment "User to thorpe config"

echo "Add to thorpe groupe user thorpe_access@pve"
pveum usermod thorpe_access@pve -group thorpe
50 changes: 50 additions & 0 deletions roadmap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
MODULO PARA GERENCIAR O MENU E AS CONFIGURAÇÔES

Nome: thorpe-base
Descrição: Adicionar 1 ou mais PVE Cluster nos Banco, configurar usuário e token de acesso ele irá usar as configurações de thorpe-products para criar thorpe-machines

MODULO PARA GERENCIAR PRODUTOS PADRÃO

Nome: thorpe-products
Descrição: Irá listar produtos base/template para poder adicionar no e-commerce com alguns valores padrões (Node para fazer o deployment, Rede Disponível, LXC ou VM | Número de CPUs(lxc) ou CPUS + Sockets(vm) + Discos + Imagens disponívels (Tkl-odoo, tkl-wordpres, tkl-debian, debin, ubuntu etc)

MODULO PARA GERENCIAR MAQUINAS/CONTAINERS

Nome: thorpe-machine
Descrição: Irá listar as maquinas já disponíveis e os usuários vinculados a elas, irá disponibilizar valores estáticos de status da maquina, nº de CPUs ativos atualmente, RAM Disponível e Uso de Disco

MODULO PARA GERENCIAR PERMISSÕES DE ACESSO AS MAQUINAS

Nome: thorpe-users
Descrição: irá vincular res.partners a faturas e thorpe-machines ativas


---------------------------------------------------------------

##thorpe-base##
MENU CONFIGURAÇÃO

--PVE CLUSTER
----PVE AUTH
----PVE NODES
----PVE MACHINES (vm ou lxc)

##thorpe-machines##

Estrutura:
type(lxc/vm): #Herado do thorpe-base
domain: #input do usuário na loja
cores: #input do usuário na loja
mem: #input do usuário na loja
disk: #input do usuário na loja
image: #input do usuário na loja
!owner: #herdado do res.partner/e-commerce-sale

##thorpe-users one-to-many (Odoo nativo)
model(owner:machine) será equivalente a:
res.partner:thorpe.machine

##thorpe-products
pve.node:
pve.network
pve.machine (lxc ou vm)
4 changes: 0 additions & 4 deletions sales-thorpe/__init__.py

This file was deleted.

21 changes: 0 additions & 21 deletions sales-thorpe/controllers/controllers.py

This file was deleted.

1 change: 1 addition & 0 deletions thorpe_base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
27 changes: 27 additions & 0 deletions thorpe_base/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
'name': "Thorpe Base",
'version': '1.0',
'summary': "The base thorpe project for api connect to proxmox",
'sequence': 10,
'description': """
Thorpe base
This module create configuration to api proxmox connect.
""",
'author': 'Marcos Méndez & Enieber Cunha | pop.coop',
'category': 'Applications',
'license': 'AGPL-3',
'depends': ['base', 'mail'],
'data': [
'security/ir.model.access.csv',
'views/thorpe_base.xml',
'data/ir_cron_nodes.xml',
'data/ir_cron_storages.xml',
'views/thorpe_nodes.xml',
'views/thorpe_storages.xml',
'views/menu.xml',
],
'images': ['static/img/icon.png'],
'installable': True,
'application': True,
'auto_install': False,
}
15 changes: 15 additions & 0 deletions thorpe_base/data/ir_cron_nodes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding='UTF-8'?>
<odoo>
<data noupdate="1">
<record id="ir_cron_thorpe_nodes" model="ir.cron">
<field name="name">Update Nodes PVE</field>
<field name="model_id" ref="model_thorpe_update_nodes"/>
<field name="state">code</field>
<field name="code">model.update_nodes()</field>
<field name='interval_number'>1</field>
<field name='interval_type'>hours</field>
<field name="numbercall">-1</field>
<field name="active" eval="True"/>
</record>
</data>
</odoo>
15 changes: 15 additions & 0 deletions thorpe_base/data/ir_cron_storages.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding='UTF-8'?>
<odoo>
<data noupdate="1">
<record id="ir_cron_thorpe_storage" model="ir.cron">
<field name="name">Atualizar Storages com dados do Node selecionado</field>
<field name="model_id" ref="model_thorpe_update_storage"/>
<field name="state">code</field>
<field name="code">model.update_storages()</field>
<field name='interval_number'>1</field>
<field name='interval_type'>hours</field>
<field name="numbercall">-1</field>
<field name="active" eval="True"/>
</record>
</data>
</odoo>
5 changes: 5 additions & 0 deletions thorpe_base/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import thorpe_base
from . import thorpe_base_node
from . import thorpe_base_storage
from . import update_nodes
from . import update_storages
16 changes: 16 additions & 0 deletions thorpe_base/models/thorpe_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from odoo import _, api, fields, models

class ThorpeBase(models.Model):
_name = 'thorpe.base'
_description = 'Infraestruct Orchestrator conection'

#Model Fields
name = fields.Char(string="Name", required=True)
region = fields.Char(string="Region", required=True)
url = fields.Char(string="Url Api", required=True)
token = fields.Char(string="Token Api", required=True)
secret = fields.Char(string="Secret Token", required=True)
expiration = fields.Date(string="Expiration", required=True)
latitude = fields.Float(string="Latitude", required=True)
longitude = fields.Float(string="Longitude", required=True)
comments = fields.Text(string="Comments", required=False, translate=True)
10 changes: 10 additions & 0 deletions thorpe_base/models/thorpe_base_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import _, api, fields, models

class ThorpeBaseNode(models.Model):
_name = 'thorpe.base.node'
_description = 'Nodes of pve selected'

name = fields.Char(string="Name", required=True)
pve_id = fields.Many2one("thorpe.base", string="pve", required=True)
selected_to_sales = fields.Boolean(string="Active to Sales", required=True, default=False)
status = fields.Char(string="status", required=True)
10 changes: 10 additions & 0 deletions thorpe_base/models/thorpe_base_storage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import _, api, fields, models

class ThorpeBaseStorage(models.Model):
_name = 'thorpe.base.storage'
_description = 'Storage of node selected'

name = fields.Char(string="Name", required=True)
node_id = fields.Many2one("thorpe.base.node", string="node", required=True)
selected_to_images = fields.Boolean(string="Active to use", default=False, required=True)
used_fraction = fields.Char(string="Fraction Used", required=True)
Loading