From: Weston Andros Adamson <dros@primarydata.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson <dros@primarydata.com>
Subject: [PATCH pynfs 13/17] dataserver: separate generic and 4.1 code
Date: Wed, 4 Jun 2014 17:02:01 -0400 [thread overview]
Message-ID: <1401915726-29092-14-git-send-email-dros@primarydata.com> (raw)
In-Reply-To: <1401915726-29092-1-git-send-email-dros@primarydata.com>
Signed-off-by: Weston Andros Adamson <dros@primarydata.com>
---
nfs4.1/dataserver.py | 99 ++++++++++++++++++++++++++++------------------------
1 file changed, 54 insertions(+), 45 deletions(-)
diff --git a/nfs4.1/dataserver.py b/nfs4.1/dataserver.py
index c73e195..40364d4 100644
--- a/nfs4.1/dataserver.py
+++ b/nfs4.1/dataserver.py
@@ -15,7 +15,7 @@ log = logging.getLogger("Dataserver Manager")
op4 = nfs_ops.NFS4ops()
-class DataServer41(object):
+class DataServer(object):
def __init__(self, server, port, path, flavor=rpc.AUTH_SYS, active=True, mdsds=True, multipath_servers=None, summary=None):
self.mdsds = mdsds
self.server = server
@@ -43,28 +43,44 @@ class DataServer41(object):
self.active = True
if not self.mdsds:
self.connect()
+ self.make_root()
def down(self):
+ self.disconnect()
self.active = False
- def connect(self):
- # only support root with AUTH_SYS for now
- s1 = rpc.security.instance(rpc.AUTH_SYS)
- self.cred1 = s1.init_cred(uid=0, gid=0)
- self.c1 = nfs4client.NFS4Client(self.server, self.port,
- summary=self.summary)
- self.c1.set_cred(self.cred1)
- self.c1.null()
- c = self.c1.new_client("DS.init_%s" % self.server)
- # This is a hack to ensure MDS/DS communication path is at least
- # as wide as the client/MDS channel (at least for linux client)
- fore_attrs = type4.channel_attrs4(0, 16384, 16384, 2868, 8, 8, [])
- self.sess = c.create_session(fore_attrs=fore_attrs)
- self.make_root()
+ def reset(self):
+ self.down()
+ self.up()
+
+ def get_netaddr4(self):
+ # STUB server multipathing not supported yet
+ uaddr = '.'.join([self.server,
+ str(self.port >> 8),
+ str(self.port & 0xff)])
+ return type4.netaddr4(self.proto, uaddr)
+
+ def get_multipath_netaddr4s(self):
+ netaddr4s = []
+ for addr in self.multipath_servers:
+ server, port = addr
+ uaddr = '.'.join([server,
+ str(port >> 8),
+ str(port & 0xff)])
+ proto = "tcp"
+ if server.find(':') >= 0:
+ proto = "tcp6"
+
+ netaddr4s.append(type4.netaddr4(proto, uaddr))
+ return netaddr4s
+
+ def fh_to_name(self, mds_fh):
+ return hashlib.sha1("%r" % mds_fh).hexdigest()
def disconnect(self):
pass
+class DataServer41(DataServer):
def _execute(self, ops, exceptions=[], delay=5, maxretries=3):
""" execute the NFS call
If an error code is specified in the exceptions it means that the
@@ -85,36 +101,28 @@ class DataServer41(object):
log.error("Too many retries with DS %s" % self.server)
raise Exception("Dataserver communication retry error")
elif res.status in state_errors:
- self.disconnect()
- self.connect()
+ self.reset()
else:
log.error("Unhandled status %s from DS %s" %
(nfsstat4[res.status], self.server))
raise Exception("Dataserver communication error")
- def get_netaddr4(self):
- # STUB server multipathing not supported yet
- uaddr = '.'.join([self.server,
- str(self.port >> 8),
- str(self.port & 0xff)])
- return type4.netaddr4(self.proto, uaddr)
-
- def get_multipath_netaddr4s(self):
- netaddr4s = []
- for addr in self.multipath_servers:
- server, port = addr
- uaddr = '.'.join([server,
- str(port >> 8),
- str(port & 0xff)])
- proto = "tcp"
- if server.find(':') >= 0:
- proto = "tcp6"
-
- netaddr4s.append(type4.netaddr4(proto, uaddr))
- return netaddr4s
-
+ def connect(self):
+ # only support root with AUTH_SYS for now
+ s1 = rpc.security.instance(rpc.AUTH_SYS)
+ self.cred1 = s1.init_cred(uid=0, gid=0)
+ self.c1 = nfs4client.NFS4Client(self.server, self.port,
+ summary=self.summary)
+ self.c1.set_cred(self.cred1)
+ self.c1.null()
+ c = self.c1.new_client("DS.init_%s" % self.server)
+ # This is a hack to ensure MDS/DS communication path is at least
+ # as wide as the client/MDS channel (at least for linux client)
+ fore_attrs = type4.channel_attrs4(0, 16384, 16384, 2868, 8, 8, [])
+ self.sess = c.create_session(fore_attrs=fore_attrs)
- def make_root(self, attrs={const4.FATTR4_MODE:0777}):
+ def make_root(self):
+ attrs = {const4.FATTR4_MODE:0777}
existing_path = []
kind = type4.createtype4(const4.NF4DIR)
for comp in self.path:
@@ -133,12 +141,13 @@ class DataServer41(object):
raise RuntimeError
# XXX clean DS directory
- def fh_to_name(self, mds_fh):
- return hashlib.sha1("%r" % mds_fh).hexdigest()
-
- def open_file(self, mds_fh, seqid=0,
- access=const4.OPEN4_SHARE_ACCESS_BOTH, deny=const4.OPEN4_SHARE_DENY_NONE,
- attrs={const4.FATTR4_MODE: 0777}, owner = "mds", mode=const4.GUARDED4):
+ def open_file(self, mds_fh):
+ seqid=0
+ access = const4.OPEN4_SHARE_ACCESS_BOTH
+ deny = const4.OPEN4_SHARE_DENY_NONE
+ attrs = {const4.FATTR4_MODE: 0777}
+ owner = "mds"
+ mode = const4.GUARDED4
verifier = self.sess.c.verifier
openflag = type4.openflag4(const4.OPEN4_CREATE, type4.createhow4(mode, attrs, verifier))
name = self.fh_to_name(mds_fh)
--
1.8.5.2 (Apple Git-48)
next prev parent reply other threads:[~2014-06-04 21:02 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-04 21:01 [PATCH pynfs 00/17] prep for flex file layout server Weston Andros Adamson
2014-06-04 21:01 ` [PATCH pynfs 01/17] 4.1 client: reclaim_complete after create_session Weston Andros Adamson
2014-06-05 2:26 ` J. Bruce Fields
2014-06-05 12:54 ` Weston Andros Adamson
2014-06-04 21:01 ` [PATCH pynfs 02/17] 4.1 server: service RECLAIM_COMPLETE operations Weston Andros Adamson
2014-06-05 2:29 ` J. Bruce Fields
2014-06-05 12:22 ` Trond Myklebust
2014-06-05 12:58 ` Weston Andros Adamson
2014-06-05 13:06 ` J. Bruce Fields
2014-06-05 13:18 ` Weston Andros Adamson
2014-06-05 13:34 ` Weston Andros Adamson
2014-06-05 13:41 ` J. Bruce Fields
2014-06-05 13:49 ` Weston Andros Adamson
2014-06-04 21:01 ` [PATCH pynfs 03/17] dataserver: only catch connection error Weston Andros Adamson
2014-06-04 21:01 ` [PATCH pynfs 04/17] 4.1 server: avoid traceback in DS disconnect() Weston Andros Adamson
2014-06-04 21:01 ` [PATCH pynfs 06/17] 4.1 client: remove unused imports Weston Andros Adamson
2014-06-04 21:01 ` [PATCH pynfs 07/17] 4.1 server: add -v flag & silence random output Weston Andros Adamson
2014-06-04 21:01 ` [PATCH pynfs 08/17] 4.1 server: add -s option to print summary of ops Weston Andros Adamson
2014-06-04 21:01 ` [PATCH pynfs 09/17] dataserver: make generic interface to ops Weston Andros Adamson
2014-06-04 21:01 ` [PATCH pynfs 10/17] dataserver: don't import * from nfs4 specific mods Weston Andros Adamson
2014-06-04 21:01 ` [PATCH pynfs 11/17] 4.1 server: move nfs4_ops.py to nfs_ops.py Weston Andros Adamson
2014-06-04 21:02 ` [PATCH pynfs 12/17] add mntv3, portmapv2 and nfsv3 .x files Weston Andros Adamson
2014-06-05 2:34 ` J. Bruce Fields
2014-06-04 21:02 ` Weston Andros Adamson [this message]
2014-06-04 21:02 ` [PATCH pynfs 14/17] 4.1 server: add support for NFSv3 data servers Weston Andros Adamson
2014-06-04 21:02 ` [PATCH pynfs 15/17] 4.1 server: get rid of old op_getdeviceinfo Weston Andros Adamson
2014-06-04 21:02 ` [PATCH pynfs 15/17] nfs41 svr: " Weston Andros Adamson
2014-06-04 21:02 ` [PATCH pynfs 16/17] rpc: on socket error, close and mark pipe inactive Weston Andros Adamson
2014-06-04 21:02 ` [PATCH pynfs 17/17] nfs3clnt: reconnect when sending on inactive pipe Weston Andros Adamson
[not found] ` <1401915726-29092-6-git-send-email-dros@primarydata.com>
2014-06-05 2:31 ` [PATCH pynfs 05/17] move .x files to subdir 'xdrdef' J. Bruce Fields
2014-06-05 12:51 ` Weston Andros Adamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401915726-29092-14-git-send-email-dros@primarydata.com \
--to=dros@primarydata.com \
--cc=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).