File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,26 @@ func (s *Service) VirtualMachineFromUUID(ctx context.Context, uuid string) (*Vir
9898 return nil , rest .NotFoundErr
9999}
100100
101+ // return true if there is any vm having specified name
102+ func (s * Service ) VirtualMachineExistsWithName (ctx context.Context , name string ) (bool , error ) {
103+ nodes , err := s .Nodes (ctx )
104+ if err != nil {
105+ return false , err
106+ }
107+ for _ , node := range nodes {
108+ vms , err := s .restclient .GetVirtualMachines (ctx , node .Node )
109+ if err != nil {
110+ continue
111+ }
112+ for _ , vm := range vms {
113+ if vm .Name == name {
114+ return true , nil
115+ }
116+ }
117+ }
118+ return false , nil
119+ }
120+
101121func ConvertSMBiosToUUID (smbios string ) (string , error ) {
102122 re := regexp .MustCompile (fmt .Sprintf ("uuid=%s" , UUIDFormat ))
103123 match := re .FindString (smbios )
You can’t perform that action at this time.
0 commit comments