Documentation ¶
Index ¶
- Constants
- type KvmService
- func (s *KvmService) AddExportVmTask(req v1.ExportVmReq) (err error)
- func (s *KvmService) CreateVmFromImage(req *v1.CreateVmReq, removeSameName bool) (dom *libvirt.Domain, vmMacAddress string, vmVncPort int, err error)
- func (s *KvmService) GetHeartbeat(mac string) (val time.Time)
- func (s *KvmService) GetIpByName(vmName string) (ip string)
- func (s *KvmService) GetVmIpByMac(macAddress string) (ip string, err error)
- func (s *KvmService) GetVms() (vms []domain.Vm)
- func (s *KvmService) StartVm(vmName string) error
- func (s *KvmService) UpdateHeartbeat(mac string)
- func (s *KvmService) UpdateVmMapAndDestroyTimeout(vms []domain.Vm)
- type LibvirtService
- func (s *LibvirtService) BootVmByName(name string) (err error)
- func (s *LibvirtService) Connect(str string)
- func (s *LibvirtService) DestroyVm(dom *libvirt.Domain) (err error)
- func (s *LibvirtService) ForceDestroyVmByName(name string) (bizErr *domain.BizErr)
- func (s *LibvirtService) GetVm(name string) (dom *libvirt.Domain, err error)
- func (s *LibvirtService) GetVmDef(name string) (xml string)
- func (s *LibvirtService) GetVmSnaps(vm string) (ret []v1.SnapItemResp)
- func (s *LibvirtService) IsAlive() (ret bool)
- func (s *LibvirtService) ListVm() (domains []libvirt.Domain)
- func (s *LibvirtService) RebootVmByName(name string) (err error)
- func (s *LibvirtService) RemoveVmByName(name string, removeDiskImage bool) (err error)
- func (s *LibvirtService) ResumeVmByName(name string) (err error)
- func (s *LibvirtService) SafeDestroyVmByName(name string) (bizErr *domain.BizErr)
- func (s *LibvirtService) ShutdownVmByName(name string) (err error)
- func (s *LibvirtService) StartVmByName(name string) (err error)
- func (s *LibvirtService) SuspendVmByName(name string) (err error)
- func (s *LibvirtService) TryThenForceDestroyVmByName(name string) (bizErr *domain.BizErr)
- type QemuService
- func (s *QemuService) GenMacAddress() string
- func (s *QemuService) GenMachine() string
- func (s *QemuService) GenVmDef(tmplXml, macAddress, vmName, backingPath string, vmCpu, vmMemory uint) (vmXml string, rawPath string, err error)
- func (s *QemuService) GenVmDefFromCfg(domCfg *libvirtxml.Domain, macAddress, vmName, backingPath string, ...) (vmXml string, rawPath string, err error)
- func (s *QemuService) GenVmDefTest(src, vmName, rawPath, backingPath string, vmCpu, vmMemory uint) (xml, macAddress string, err error)
- func (s *QemuService) GetBackingFileSize(diskPath string) (size int64)
- func (s *QemuService) GetBackingFileVirtualSize(diskPath string) (size int)
- func (s *QemuService) GetBaseImagePath(vm domain.Vm) (path string)
- func (s *QemuService) GetDisk(dom *libvirt.Domain) (path string, err error)
- func (s *QemuService) GetMainDiskIndex(domCfg *libvirtxml.Domain) (ret int)
Constants ¶
View Source
const ( LibvirtConnStrLocal = "qemu:///system" LibvirtConnStrRemote = "qemu+ssh://%s:22/system?socket=/var/run/libvirt/libvirt-sock" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KvmService ¶
type KvmService struct { VmMapVar map[string]domain.Vm SyncHeartbeatMap sync.Map TimeStamp int64 LibvirtService *LibvirtService `inject:""` QemuService *QemuService `inject:""` TaskRepo *hostRepo.TaskRepo `inject:""` }
func NewVmService ¶
func NewVmService() *KvmService
func (*KvmService) AddExportVmTask ¶
func (s *KvmService) AddExportVmTask(req v1.ExportVmReq) (err error)
func (*KvmService) CreateVmFromImage ¶
func (s *KvmService) CreateVmFromImage(req *v1.CreateVmReq, removeSameName bool) ( dom *libvirt.Domain, vmMacAddress string, vmVncPort int, err error)
func (*KvmService) GetHeartbeat ¶
func (s *KvmService) GetHeartbeat(mac string) (val time.Time)
func (*KvmService) GetIpByName ¶
func (s *KvmService) GetIpByName(vmName string) (ip string)
func (*KvmService) GetVmIpByMac ¶
func (s *KvmService) GetVmIpByMac(macAddress string) (ip string, err error)
func (*KvmService) GetVms ¶
func (s *KvmService) GetVms() (vms []domain.Vm)
func (*KvmService) StartVm ¶
func (s *KvmService) StartVm(vmName string) error
func (*KvmService) UpdateHeartbeat ¶
func (s *KvmService) UpdateHeartbeat(mac string)
func (*KvmService) UpdateVmMapAndDestroyTimeout ¶
func (s *KvmService) UpdateVmMapAndDestroyTimeout(vms []domain.Vm)
type LibvirtService ¶
type LibvirtService struct { LibvirtConn *libvirt.Connect QemuService *QemuService `inject:""` VmService *KvmService `inject:""` }
func NewLibvirtService ¶
func NewLibvirtService() *LibvirtService
func (*LibvirtService) BootVmByName ¶
func (s *LibvirtService) BootVmByName(name string) (err error)
func (*LibvirtService) Connect ¶
func (s *LibvirtService) Connect(str string)
func (*LibvirtService) DestroyVm ¶
func (s *LibvirtService) DestroyVm(dom *libvirt.Domain) (err error)
func (*LibvirtService) ForceDestroyVmByName ¶
func (s *LibvirtService) ForceDestroyVmByName(name string) (bizErr *domain.BizErr)
func (*LibvirtService) GetVm ¶
func (s *LibvirtService) GetVm(name string) (dom *libvirt.Domain, err error)
func (*LibvirtService) GetVmDef ¶
func (s *LibvirtService) GetVmDef(name string) (xml string)
func (*LibvirtService) GetVmSnaps ¶
func (s *LibvirtService) GetVmSnaps(vm string) (ret []v1.SnapItemResp)
func (*LibvirtService) IsAlive ¶
func (s *LibvirtService) IsAlive() (ret bool)
func (*LibvirtService) ListVm ¶
func (s *LibvirtService) ListVm() (domains []libvirt.Domain)
func (*LibvirtService) RebootVmByName ¶
func (s *LibvirtService) RebootVmByName(name string) (err error)
func (*LibvirtService) RemoveVmByName ¶
func (s *LibvirtService) RemoveVmByName(name string, removeDiskImage bool) (err error)
func (*LibvirtService) ResumeVmByName ¶
func (s *LibvirtService) ResumeVmByName(name string) (err error)
func (*LibvirtService) SafeDestroyVmByName ¶
func (s *LibvirtService) SafeDestroyVmByName(name string) (bizErr *domain.BizErr)
func (*LibvirtService) ShutdownVmByName ¶
func (s *LibvirtService) ShutdownVmByName(name string) (err error)
func (*LibvirtService) StartVmByName ¶
func (s *LibvirtService) StartVmByName(name string) (err error)
func (*LibvirtService) SuspendVmByName ¶
func (s *LibvirtService) SuspendVmByName(name string) (err error)
func (*LibvirtService) TryThenForceDestroyVmByName ¶
func (s *LibvirtService) TryThenForceDestroyVmByName(name string) (bizErr *domain.BizErr)
type QemuService ¶
type QemuService struct { }
func NewQemuService ¶
func NewQemuService() *QemuService
func (*QemuService) GenMacAddress ¶
func (s *QemuService) GenMacAddress() string
func (*QemuService) GenMachine ¶
func (s *QemuService) GenMachine() string
func (*QemuService) GenVmDefFromCfg ¶
func (s *QemuService) GenVmDefFromCfg(domCfg *libvirtxml.Domain, macAddress, vmName, backingPath string, vmCpu, vmMemory uint) ( vmXml string, rawPath string, err error)
func (*QemuService) GenVmDefTest ¶
func (s *QemuService) GenVmDefTest(src, vmName, rawPath, backingPath string, vmCpu, vmMemory uint) ( xml, macAddress string, err error)
func (*QemuService) GetBackingFileSize ¶
func (s *QemuService) GetBackingFileSize(diskPath string) (size int64)
func (*QemuService) GetBackingFileVirtualSize ¶
func (s *QemuService) GetBackingFileVirtualSize(diskPath string) (size int)
func (*QemuService) GetBaseImagePath ¶
func (s *QemuService) GetBaseImagePath(vm domain.Vm) (path string)
func (*QemuService) GetDisk ¶
func (s *QemuService) GetDisk(dom *libvirt.Domain) (path string, err error)
func (*QemuService) GetMainDiskIndex ¶
func (s *QemuService) GetMainDiskIndex(domCfg *libvirtxml.Domain) (ret int)
Click to show internal directories.
Click to hide internal directories.