lxd/storage_lvm.go
func (s *storageLvm) StorageCoreInit() error {
	s.sType = storageTypeLvm
	typeName, err := storageTypeToString(s.sType)
	if err != nil {
		return err
	}
	s.sTypeName = typeName

	if lvmVersion != "" {
		s.sTypeVersion = lvmVersion
		return nil
	}

	output, err := shared.RunCommand("lvm", "version")
	if err != nil {
		return fmt.Errorf("Error getting LVM version: %v\noutput:'%s'", err, output)
	}
	lines := strings.Split(output, "\n")

	s.sTypeVersion = ""
	for idx, line := range lines {
		fields := strings.SplitAfterN(line, ":", 2)
		if len(fields) < 2 {
			continue
		}
		if idx > 0 {
			s.sTypeVersion += " / "
		}
		s.sTypeVersion += strings.TrimSpace(fields[1])
	}

	lvmVersion = s.sTypeVersion

	return nil
}
func (s *storageLvm) StorageCoreInit() error {
	s.sType = storageTypeLvm
	typeName, err := storageTypeToString(s.sType)
	if err != nil {
		return err
	}
	s.sTypeName = typeName

	if lvmVersion != "" {
		s.sTypeVersion = lvmVersion
		return nil
	}

	output, err := shared.RunCommand("lvm", "version")
	if err != nil {
		return fmt.Errorf("Error getting LVM version: %v\noutput:'%s'", err, output)
	}
	lines := strings.Split(output, "\n")

	s.sTypeVersion = ""
	for idx, line := range lines {
		fields := strings.SplitAfterN(line, ":", 2)
		if len(fields) < 2 {
			continue
		}
		if idx > 0 {
			s.sTypeVersion += " / "
		}
		s.sTypeVersion += strings.TrimSpace(fields[1])
	}

	lvmVersion = s.sTypeVersion

	return nil
}
func ( s * storageLvm ) StorageCoreInit ( ) error { s . sType = storageTypeLvm typeName , err := storageTypeToString ( s . sType ) if err != nil { return err } s . sTypeName = typeName if lvmVersion != " " { s . sTypeVersion = lvmVersion return nil } output , err := shared . RunCommand ( " " , " " ) if err != nil { return fmt . Errorf ( " \n " , err , output ) } lines := strings . Split ( output , " \n " ) s . sTypeVersion = " " for idx , line := range lines { fields := strings . SplitAfterN ( line , " " , 2 ) if len ( fields ) < 2 { continue } if idx > 0 { s . sTypeVersion += " " } s . sTypeVersion += strings . TrimSpace ( fields [ 1 ] ) } lvmVersion = s . sTypeVersion return nil }
// Only initialize the minimal information we need about a given storage type.
Only initialize the minimal information we need about a given storage type .