Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:ione-cloud/ione
Browse files Browse the repository at this point in the history
  • Loading branch information
slntopp committed Sep 30, 2021
2 parents b6e0290 + 0080865 commit 732431c
Show file tree
Hide file tree
Showing 33 changed files with 483 additions and 91 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.md
LICENSE
*.yml
ui
modules
*.service
nginx.*
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- uses: actions/[email protected]
- uses: actions/[email protected].0
- uses: actions/[email protected].1

- name: Dependencies
run: npm install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

steps:
- uses: actions/[email protected]
- uses: actions/[email protected].0
- uses: actions/[email protected].1

- name: Dependencies
run: npm install
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Create and publish a Docker images

on:
push:
branches: ['master', 'release']

env:
REGISTRY: ghcr.io

jobs:
ione:
runs-on: ubuntu-latest
environment: ione
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/support-pl/ione

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

ione-admin:
runs-on: ubuntu-latest
environment: ione-admin
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/support-pl/ione-admin

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: ui
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/[email protected]

- name: Setup Ruby
uses: ruby/setup-ruby@v1.81.0
uses: ruby/setup-ruby@v1.82.0
with:
ruby-version: 2.5

Expand Down
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM ruby:2.5.5-alpine

ADD . /ione
WORKDIR /ione

RUN apk update && apk add --virtual build-dependencies build-base
RUN apk add augeas-dev mariadb-dev
RUN bundle install

ENTRYPOINT ["sh", "command.sh"]
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
source 'https://rubygems.org'

gem 'augeas'
gem 'colorize'
gem 'file-tail'
gem 'mysql2'
gem 'net-sftp', '3.0.0'
gem 'net-ssh', '6.1.0'
gem 'nori'
gem 'opennebula'
gem 'sequel'
gem 'sinatra-contrib'
gem 'sinatra-websocket'
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ Creators:
[Support.pl](https://support.pl)
[slnt_opp](https://slnt-opp.xyz)

## Main additional features
## Table of Contents

- [System requirements](#system-requirements)
- [Installation classic](#install)
- [Running in Docker](#running-in-docker)
- [Notes](#important-notes)

## Main features

- Transparent showback
- Balance
Expand Down Expand Up @@ -193,6 +200,41 @@ Environment=GEM_PATH=/usr/local/rvm/gems/ruby-2.5.8:/usr/local/rvm/gems/ruby-2.5
</table>
---------------------------------------------------------------------------------------------------------

## Running in Docker

1. Download needed files using:

```shell
mkdir ione && cd ione && \
wget https://raw.githubusercontent.com/Support-pl/ione/master/sys/ione.conf && \
wget https://raw.githubusercontent.com/Support-pl/ione/ione-tp/docker-compose.yml
```

2. Pre-configure IONe in `ione.conf` if needed
3. Configure credentials and endpoints in `docker-compose.yml` ([reference below](#docker-environment-variables-reference))

3.1 You may need to change tags to anything else from `latest` sometimes. Check [Github packages](https://github.com/orgs/Support-pl/packages?repo_name=ione) to see latest published versions

4. Start IONe using `docker-compose up -d`

### Docker environment variables reference

```shell
ALPINE=true # just required to make IONe reading data from env instead of default ONe files
IONE_LOCATION=/ione # IONe root dir in container
ONE_LOCATION=/ione/sys # IONe configs dir path
LOG_LOCATION=/log # Path to dir to write IONe logs in
ONE_CREDENTIALS="oneadmin:passwd" # oneadmin or other ONe admin(!) user credentials
ONE_ENDPOINT="http://localhost:2633/RPC2" # ONe XML-RPC API endpoint

# Database connection(must be same DB with ONe and have at least READ access to ONe tables)
DB_BACKEND=mysql
DB_HOST=10.6.6.6
DB_USER=oneadmin
DB_PASSWORD:passwd
DB_DATABASE=opennebula
```

Thanks for choosing us, contacts for support are in "Contacts" section at the beginning of this `README`

## Important Notes
Expand Down
4 changes: 4 additions & 0 deletions command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

rake hooks_tp
ruby /ione/ione_server.rb
8 changes: 6 additions & 2 deletions core/*.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
require 'core/load_oned_conf.rb'
require 'core/connect_db.rb'
if ENV["ALPINE"] == 'true' then
require 'core/connect_db_env.rb'
else
require 'core/load_oned_conf.rb'
require 'core/connect_db.rb'
end
require 'core/settings.rb'
12 changes: 11 additions & 1 deletion core/connect_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@
ops.merge! adapter: adapter

require 'sequel'
$db = Sequel.connect(**ops)
begin
print "Connecting to DB... "
$db = Sequel.connect(**ops)
rescue => e
puts "Error connecting to DB: #{e.message}"
puts "Retrying in 60 sec"
sleep 60
puts "Retrying..."
retry
end
puts "Connected"
31 changes: 31 additions & 0 deletions core/connect_db_env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
db_backend = ENV['DB_BACKEND'] # mysql or postgresql
case db_backend
when "mysql"
adapter = :mysql2
when "postgresql"
adapter = :postgres
else
STDERR.puts "OneDB backend(#{db_backend}) is not supported, exiting..."
exit 1
end

ops = {}
ops[:host] = ENV['DB_HOST']
ops[:user] = ENV['DB_USER']
ops[:password] = ENV['DB_PASSWORD']
ops[:database] = ENV['DB_DATABASE']

ops.merge! adapter: adapter

require 'sequel'
begin
print "Connecting to DB... "
$db = Sequel.connect(**ops)
rescue => e
puts "Error connecting to DB: #{e.message}"
puts "Retrying in 60 sec"
sleep 60
puts "Retrying..."
retry
end
puts "Connected"
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.7'
services:
ione:
image: ghcr.io/support-pl/ione:latest
network_mode: host
environment:
ALPINE: "true"
IONE_LOCATION: /ione
ONE_LOCATION: /ione/sys
LOG_LOCATION: /log
ONE_CREDENTIALS: "oneadmin:password"
DB_BACKEND: mysql
DB_HOST: localhost
DB_USER: oneadmin
DB_PASSWORD: DBpassword
DB_DATABASE: opennebula
ONE_ENDPOINT: "http://localhost:2633/RPC2"
ports:
- 8009:8009
volumes:
- ./sys:/ione/sys
- /var/log/one:/log
ione-admin:
image: ghcr.io/support-pl/ione-admin:latest
network_mode: host
environment:
VUE_APP_IONE_API_BASE_URL: http://localhost:8009
ports:
- 5000:5000
19 changes: 12 additions & 7 deletions hooks/check_balance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,24 @@
exit 0
end

ETC_LOCATION = "/etc/one/"
ONED_CONF = ETC_LOCATION + '/oned.conf'

$: << '/usr/lib/one/ruby'
$: << '/usr/lib/one/ione'
ALPINE = ENV["ALPINE"] == "true"
if ALPINE then
$: << ENV["IONE_LOCATION"]
else
ETC_LOCATION = "/etc/one/"
ONED_CONF = ETC_LOCATION + '/oned.conf'
$: << '/usr/lib/one/ione'
end

require 'opennebula'
include OpenNebula

vm = VirtualMachine.new_with_id(vmid, Client.new)
client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new

vm = VirtualMachine.new_with_id(vmid, client)
vm.info!

u = User.new_with_id vm['UID'].to_i, Client.new
u = User.new_with_id vm['UID'].to_i, client
u.info!

exit 0 if u.groups.include? 0
Expand Down
18 changes: 11 additions & 7 deletions hooks/disk_record_crt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,25 @@
exit 0
end

RUBY_LIB_LOCATION = "/usr/lib/one/ruby"
ETC_LOCATION = "/etc/one/"

$: << RUBY_LIB_LOCATION
ALPINE = ENV["ALPINE"] == "true"
if ALPINE then
$: << ENV["IONE_LOCATION"]
else
ETC_LOCATION = "/etc/one/"
ONED_CONF = ETC_LOCATION + '/oned.conf'
$: << '/usr/lib/one/ione'
end
$: << '/usr/lib/one/ione'

vm = xml.xpath("//PARAMETER[TYPE='IN' and POSITION=2]/VALUE").text

require 'opennebula'
include OpenNebula

vm = VirtualMachine.new_with_id vm, Client.new
vm.info!
client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new

ONED_CONF = ETC_LOCATION + '/oned.conf'
vm = VirtualMachine.new_with_id vm, client
vm.info!

require 'core/*'
require 'json'
Expand Down
19 changes: 11 additions & 8 deletions hooks/disk_record_del.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,24 @@
exit 0
end

RUBY_LIB_LOCATION = "/usr/lib/one/ruby"
ETC_LOCATION = "/etc/one/"

$: << RUBY_LIB_LOCATION
$: << '/usr/lib/one/ione'
ALPINE = ENV["ALPINE"] == "true"
if ALPINE then
$: << ENV["IONE_LOCATION"]
else
ETC_LOCATION = "/etc/one/"
ONED_CONF = ETC_LOCATION + '/oned.conf'
$: << '/usr/lib/one/ione'
end

vm = xml.xpath("//PARAMETER[TYPE='IN' and POSITION=2]/VALUE").text

require 'opennebula'
include OpenNebula

vm = VirtualMachine.new_with_id vm, Client.new
vm.info!
client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new

ONED_CONF = ETC_LOCATION + '/oned.conf'
vm = VirtualMachine.new_with_id vm, client
vm.info!

require 'core/*'

Expand Down
Loading

0 comments on commit 732431c

Please sign in to comment.