예제 #1
0
    def mount(self):
        """
        Mount a GlusterFS volume for use.
        """
        if self.fs and self._mounted:
            # Already mounted
            return

        self.fs = api.glfs_new(self.volname)
        if not self.fs:
            err = ctypes.get_errno()
            raise LibgfapiException("glfs_new(%s) failed: %s" %
                                    (self.volname, os.strerror(err)))

        ret = api.glfs_set_volfile_server(self.fs, self.protocol, self.host,
                                          self.port)
        if ret < 0:
            err = ctypes.get_errno()
            raise LibgfapiException("glfs_set_volfile_server(%s, %s, %s, "
                                    "%s) failed: %s" %
                                    (self.fs, self.protocol, self.host,
                                     self.port, os.strerror(err)))

        self.set_logging(self.log_file, self.log_level)

        if self.fs and not self._mounted:
            ret = api.glfs_init(self.fs)
            if ret < 0:
                err = ctypes.get_errno()
                raise LibgfapiException("glfs_init(%s) failed: %s" %
                                        (self.fs, os.strerror(err)))
            else:
                self._mounted = True
예제 #2
0
    def mount(self):
        """
        Mount a GlusterFS volume for use.
        """
        if self.fs and self._mounted:
            # Already mounted
            return

        self.fs = api.glfs_new(self.volname)
        if not self.fs:
            raise LibgfapiException("glfs_new(%s) failed." % (self.volname))

        ret = api.glfs_set_volfile_server(self.fs, self.protocol,
                                          self.host, self.port)
        if ret < 0:
            # FIXME: For some reason, get_errno() is not able to capture
            # proper errno. Until then..
            # https://bugzilla.redhat.com/show_bug.cgi?id=1196161
            raise LibgfapiException("glfs_set_volfile_server(%s, %s, %s, "
                                    "%s) failed." % (self.fs, self.protocol,
                                                     self.host, self.port))

        self.set_logging(self.log_file, self.log_level)

        if self.fs and not self._mounted:
            ret = api.glfs_init(self.fs)
            if ret < 0:
                raise LibgfapiException("glfs_init(%s) failed." % (self.fs))
            else:
                self._mounted = True
예제 #3
0
    def mount(self):
        """
        Mount a GlusterFS volume for use.

        :raises: LibgfapiException on failure
        """
        if self.fs and self._mounted:
            # Already mounted
            return

        self.fs = api.glfs_new(self.volname)
        if not self.fs:
            err = ctypes.get_errno()
            raise LibgfapiException("glfs_new(%s) failed: %s" %
                                    (self.volname, os.strerror(err)))

        ret = api.glfs_set_volfile_server(self.fs, self.protocol,
                                          self.host, self.port)
        if ret < 0:
            err = ctypes.get_errno()
            raise LibgfapiException("glfs_set_volfile_server(%s, %s, %s, "
                                    "%s) failed: %s" % (self.fs, self.protocol,
                                                        self.host, self.port,
                                                        os.strerror(err)))

        self.set_logging(self.log_file, self.log_level)

        if self.fs and not self._mounted:
            ret = api.glfs_init(self.fs)
            if ret < 0:
                err = ctypes.get_errno()
                raise LibgfapiException("glfs_init(%s) failed: %s" %
                                        (self.fs, os.strerror(err)))
            else:
                self._mounted = True
예제 #4
0
 def __init__(self, host, volid, proto="tcp", port=24007):
     # Add a reference so the module-level variable "api" doesn't
     # get yanked out from under us (see comment above File def'n).
     self._api = api
     self.fs = api.glfs_new(volid)
     api.glfs_set_volfile_server(self.fs, proto, host, port)
예제 #5
0
 def __init__(self, host, volid, proto="tcp", port=24007):
     # Add a reference so the module-level variable "api" doesn't
     # get yanked out from under us (see comment above File def'n).
     self._api = api
     self.fs = api.glfs_new(volid)
     api.glfs_set_volfile_server(self.fs, proto, host, port)