Skip to content

Commit

Permalink
comment out broken parts
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrizhu committed Mar 6, 2024
1 parent 68d433b commit e2404eb
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 13 deletions.
34 changes: 34 additions & 0 deletions internal/controllers/bridge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* eve - management toolkit for libvirt servers
* Copyright (C) 2022-2023 BNS Services LLC
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package controllers

import (
"sync"

"github.com/google/uuid"
)

type Bridge struct {
Mutex sync.Mutex `json:"-" db:"-"`
ID uuid.UUID `json:"id"`
HV uuid.UUID `json:"hv" db:"hv_id"`
Enabled bool `json:"enabled"`
Name string `json:"name"`
Remarks string `json:"remarks"`
}
27 changes: 15 additions & 12 deletions internal/controllers/hv.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,22 @@ import (
"github.com/jackc/pgx/v5"
)

// This is the HV struct that will be stored in the DB.
type HV struct {
ID uuid.UUID `json:"id"`
Hostname string `json:"hostname"`
AutoUrl string `json:"auto_url" db:"auto_url"`
AutoSerial string `json:"auto_serial" db:"auto_serial"`
Site string `json:"site"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Remarks string `json:"remarks"`
Mutex sync.Mutex `json:"-" db:"-"`
VMs map[uuid.UUID]*VM `json:"-" db:"-"`
Auto *auto.Auto `json:"-" db:"-"`
Specs *models.HV `json:"-" db:"-"`
ID uuid.UUID `json:"id"`
Hostname string `json:"hostname"`
AutoUrl string `json:"auto_url" db:"auto_url"`
AutoSerial string `json:"auto_serial" db:"auto_serial"`
Site string `json:"site"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Remarks string `json:"remarks"`
Mutex sync.Mutex `json:"-" db:"-"`
VMs map[uuid.UUID]*VM `json:"-" db:"-"`
Storages map[uuid.UUID]*Storage `json:"-" db:"-"` // storage places for VM disks, isos, backups
Bridges map[uuid.UUID]*Bridge `json:"-" db:"-"` // bridges for VMs
Auto *auto.Auto `json:"-" db:"-"` // auto conn details
Specs *models.HV `json:"-" db:"-"` // specs fetched from auto
}

func getHVs(cloud *HVList) (err error) {
Expand Down
38 changes: 38 additions & 0 deletions internal/controllers/storage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* eve - management toolkit for libvirt servers
* Copyright (C) 2022-2023 BNS Services LLC
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package controllers

import (
"sync"

"github.com/google/uuid"
)

type Storage struct {
Mutex sync.Mutex `json:"-" db:"-"`
ID uuid.UUID `json:"id"`
HV uuid.UUID `json:"hv" db:"hv_id"`
Enabeld bool `json:"enabled" db:"enabled"`
Type string `json:"type" db:"type"`
Path string `json:"path" db:"path"`
Iso bool `json:"iso" db:"iso"`
Disk bool `json:"disk" db:"disk"`
CloudImage bool `json:"cloud_image" db:"cloud_image"`
Remarks string `json:"remarks" db:"remarks"`
}
4 changes: 3 additions & 1 deletion internal/controllers/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ type VM struct {
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Remarks string `json:"remarks"`
Domain models.VM `json:"-" db:"-"`
Domain models.VM `json:"-" db:"-"` // data from libvirt
}

type VMNic struct {
Mutex sync.Mutex `db:"-" json:"-"`
ID uuid.UUID
Bridge uuid.UUID
name string
MAC string
IP []net.IP `db:"-"`
Expand All @@ -63,6 +64,7 @@ type VMNic struct {
type VMStorage struct {
Mutex sync.Mutex `db:"-" json:"-"`
ID uuid.UUID
Storage uuid.UUID
Size int
Created time.Time
Updated time.Time
Expand Down
16 changes: 16 additions & 0 deletions sql/20221126030311_init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ CREATE TABLE public.hv (
remarks text NOT NULL DEFAULT ''
);

CREATE TABLE public.hv_storage (
id uuid NOT NULL PRIMARY KEY,
hv_id uuid NOT NULL REFERENCES hv (id),
name character varying(255) NOT NULL,
path character varying(255) NOT NULL,
remarks text NOT NULL DEFAULT ''
);

CREATE TABLE public.hv_network (
id uuid NOT NULL PRIMARY KEY,
hv_id uuid NOT NULL REFERENCES hv (id),
name character varying(255) NOT NULL,
bridge character varying(255) NOT NULL,
remarks text NOT NULL DEFAULT ''
);

CREATE TABLE public.vm (
id uuid NOT NULL PRIMARY KEY,
hv_id uuid NOT NULL REFERENCES hv (id),
Expand Down

0 comments on commit e2404eb

Please sign in to comment.