-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
936415a
commit 521287c
Showing
16 changed files
with
387 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package libvirtc | ||
|
||
import "fmt" | ||
|
||
type Disk struct { | ||
// | ||
} | ||
|
||
func (d *Disk) Slot2Dev(bus string, slot uint8) string { | ||
prefix := "vd" | ||
if bus == "ide" || bus == "scsi" { | ||
prefix = "hd" | ||
} | ||
if slot <= 26 { | ||
return prefix + string('a'+slot-1) | ||
} | ||
return "" | ||
} | ||
|
||
func (d *Disk) Slot2DiskName(slot uint8) string { | ||
return fmt.Sprintf("disk%d.img", slot) | ||
} | ||
|
||
var DISK = &Disk{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package libvirtc | ||
|
||
import "fmt" | ||
|
||
type Interface struct { | ||
// | ||
} | ||
|
||
func (int *Interface) Slot2Dev(slot uint8) string { | ||
prefix := "vnet" | ||
if slot <= 32 { | ||
return fmt.Sprintf("%s%d", prefix, slot) | ||
} | ||
return "" | ||
} | ||
|
||
var INTERFACE = &Interface{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package schema | ||
|
||
import ( | ||
"github.com/danieldin95/lightstar/storage/libvirts" | ||
) | ||
|
||
type DataStore struct { | ||
UUID string `json:"uuid"` | ||
Name string `json:"name"` | ||
State string `json:"state"` | ||
Capacity uint64 `json:"capacity"` // bytes | ||
Allocation uint64 `json:"capacity"` // bytes | ||
Available uint64 `json:"available"` // Bytes | ||
} | ||
|
||
func NewDataStore(pol libvirts.Pool) DataStore { | ||
obj := DataStore{} | ||
obj.Name, _ = pol.GetName() | ||
if info, err := pol.GetInfo(); err == nil { | ||
obj.State = libvirts.PoolState2Str(info.State) | ||
obj.Capacity = info.Capacity | ||
obj.Available = info.Available | ||
obj.Allocation = info.Allocation | ||
} | ||
return obj | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package schema | ||
|
||
import ( | ||
"github.com/danieldin95/lightstar/network/libvirtn" | ||
) | ||
|
||
type Network struct { | ||
UUID string `json:"uuid"` | ||
Name string `json:"name"` | ||
State string `json:"state"` | ||
Address string `json:"network"` | ||
Mode string `json:"mode"` // nat, router. | ||
} | ||
|
||
func NewNetwork(net libvirtn.Network) Network { | ||
obj := Network{} | ||
obj.Name, _ = net.GetName() | ||
if ok, _ := net.IsActive(); ok { | ||
obj.State = "active" | ||
} else { | ||
obj.State = "inactive" | ||
} | ||
return obj | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.