Beispiel #1
0
    def create_volume(self,
                      vol_name,
                      vol_size,
                      uid,
                      gid,
                      export_policy='default'):
        """Create ONTAP volume"""
        volume = Volume(vol_name, self.aggregate)

        status, error_message = volume.make_volume(vol_size, uid, gid,
                                                   export_policy)

        if status != "COMPLETED":
            if error_message == "Duplicate volume name %s.  (errno=17)" % vol_name:
                vol_status = self.set_status(200, "Volume", vol_name)
            else:
                vol_status = self.set_status(400, "Volume", vol_name,
                                             error_message)
        else:
            vol_status = self.set_status(201, "Volume", vol_name)

        vol_size = ""
        if vol_status['code'] != 400:
            if volume.check_vol():
                vol_size = volume.get_size()
            else:
                vol_status = self.set_status(500, "Volume", vol_name,
                                             "Check_vol failed")

        return [vol_status], vol_size
Beispiel #2
0
    def create_clone(self, vol_name, uid, gid, clone_name, snapshot_name=None):
        """Create clone of snapshot for a developer workspace"""
        volume = Volume(vol_name, self.aggregate)
        vol_size = ""

        if snapshot_name is None:
            status, error_message, clone = volume.make_clone_without_snapshot(
                clone_name, uid, gid)
        else:
            status, error_message, clone = volume.make_clone(
                snapshot_name, clone_name, uid, gid)

        if status != "COMPLETED":
            if error_message == "Duplicate volume name %s.  (errno=17)" % clone_name:
                clone_status = self.set_status(200, "Clone", clone_name)
            else:
                clone_status = self.set_status(400, "Clone", clone_name,
                                               error_message)
                return [clone_status], vol_size
        else:
            clone_status = self.set_status(201, "Clone", clone_name)

        if clone.check_vol():
            status, error_message, junction_name = clone.mount()
            if status != "COMPLETED":
                junction_status = self.set_status(400, "Junction",
                                                  junction_name, error_message)
                return [clone_status, junction_status], vol_size
            else:
                junction_status = self.set_status(201, "Junction",
                                                  junction_name)

                if self.aggregate.check_vol_junction(clone_name,
                                                     junction_name):
                    vol_size = volume.get_size()
                    return [clone_status, junction_status], vol_size

        else:
            clone_status = self.set_status(500, "Clone", clone_name,
                                           "Check_vol failed")
            return [clone_status], vol_size