Ejemplo n.º 1
0
 public override void deleteZVol(volume vol)
 {
     lock (events)
     {
         events.Add(new mockedCall("deleteZVol", "vol: " + vol));
     }
 }
Ejemplo n.º 2
0
        public override volume findVolumeByMountpoint(List <volume> volumesToSearch, string mountpoint)
        {
            lock (events)
            {
                events.Add(new mockedCall("findVolumeByMountpoint", "vols: '" + volumesToSearch + "' mountpoint: " + mountpoint));
            }

            if (volumesToSearch == null)
            {
                return(null);
            }

            volume toRet = volumesToSearch.SingleOrDefault(x => x.mountpoint == mountpoint);

            if (toRet != null)
            {
                return(toRet);
            }

            if (volumesToSearch.All(x => x.children != null && x.children.Count == 0) || volumesToSearch.Count == 0)
            {
                return(null);
            }

            foreach (volume vol in volumesToSearch)
            {
                volume maybeThis = findVolumeByMountpoint(vol.children, mountpoint);
                if (maybeThis != null)
                {
                    return(maybeThis);
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        public override volume findVolumeByName(List <volume> vols, string name)
        {
            if (vols == null)
            {
                return(null);
            }

            volume toRet = vols.SingleOrDefault(x => x.name == name);

            if (toRet != null)
            {
                return(toRet);
            }

            if (vols.All(x => x.children != null && x.children.Count == 0) || vols.Count == 0)
            {
                return(null);
            }

            foreach (volume vol in vols)
            {
                volume maybeThis = findVolumeByName(vol.children, name);
                if (maybeThis != null)
                {
                    return(maybeThis);
                }
            }

            return(null);
        }
Ejemplo n.º 4
0
        public override volume findVolumeByName(List <volume> volsToSearch, string cloneName)
        {
            lock (events)
            {
                events.Add(new mockedCall("findVolumeByName", "volumes: '" + volsToSearch + "' cloneName: " + cloneName));
            }

            if (volsToSearch == null)
            {
                return(null);
            }

            volume toRet = volsToSearch.SingleOrDefault(x => x.name == cloneName);

            if (toRet != null)
            {
                return(toRet);
            }

            if (volsToSearch.All(x => x.children != null && x.children.Count == 0) || volsToSearch.Count == 0)
            {
                return(null);
            }

            foreach (volume vol in volsToSearch)
            {
                volume maybeThis = findVolumeByName(vol.children, cloneName);
                if (maybeThis != null)
                {
                    return(maybeThis);
                }
            }

            return(null);
        }
Ejemplo n.º 5
0
        public override volume findParentVolume(List <volume> volumesToSearch, volume volToFind)
        {
            lock (events)
            {
                events.Add(new mockedCall("findParentVolume", "vols: '" + volumesToSearch + "' volToFind: " + volToFind));
            }

            return(volumesToSearch.Single(x => x.children.Contains(volToFind)));
        }
Ejemplo n.º 6
0
        public void addVolume(volume toAdd)
        {
            lock (events)
            {
                events.Add(new mockedCall("addVolume", "toAdd: " + toAdd));
            }

            lock (volumes)
            {
                volumes.Add(toAdd);
            }
        }
Ejemplo n.º 7
0
 public override void deleteZVol(volume toDelete)
 {
     // Oh no, the freenas API keeps returning HTTP 404 when I try to delete a volume! :( We ignore it and use the web UI
     // instead. ;_;
     lock (nonAPIReqLock)
     {
         DoNonAPIReq("", HttpStatusCode.OK);
         string url        = "account/login/";
         string payloadStr = string.Format("username={0}&password={1}", _username, _password);
         DoNonAPIReq(url, HttpStatusCode.OK, payloadStr);
         // Now we can do the request to delete the snapshot.
         string resp = DoNonAPIReq("storage/zvol/delete/" + toDelete.path + "/", HttpStatusCode.OK, "");
         if (resp.Contains("\"error\": true") || !resp.Contains("Volume successfully destroyed"))
         {
             throw new nasAccessException("Volume deletion failed: " + resp);
         }
     }
 }
Ejemplo n.º 8
0
        public override volume findParentVolume(List <volume> vols, volume volToFind)
        {
            volume toRet = vols.SingleOrDefault(x => x.children.Count(y => y.name == volToFind.name && x.volType == "dataset") > 0);

            if (toRet != null)
            {
                return(toRet);
            }

            if (vols.All(x => x.children.Count == 0) || vols.Count == 0)
            {
                return(null);
            }

            foreach (volume vol in vols)
            {
                return(findParentVolume(vol.children, volToFind));
            }

            return(null);
        }
Ejemplo n.º 9
0
 public abstract void deleteZVol(volume vol);
Ejemplo n.º 10
0
 public abstract volume findParentVolume(List <volume> vols, volume volToFind);
Ejemplo n.º 11
0
 public override void deleteZVol(volume vol)
 {
     waitUntilISCSIConfigFlushed();
     uncachedNAS.deleteZVol(vol);
 }
Ejemplo n.º 12
0
 public override volume findParentVolume(List <volume> vols, volume volToFind)
 {
     return(uncachedNAS.findParentVolume(vols, volToFind));
 }