Skip to content

Commit

Permalink
Add update_mapping helper function. Fix syntax errors
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Grover <agrover@redhat.com>
  • Loading branch information
Andy Grover committed Apr 22, 2013
1 parent c7fb1ec commit f762f1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
1 change: 0 additions & 1 deletion targetd/block.py
Expand Up @@ -73,7 +73,6 @@ def initialize(config_dict):
export_list=export_list,
export_create=export_create,
export_destroy=export_destroy,
pool_list=pools,
)


Expand Down
27 changes: 19 additions & 8 deletions targetd/main.py
Expand Up @@ -23,14 +23,16 @@
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from SocketServer import ThreadingMixIn
from threading import Lock
import yaml
import itertools
import socket
import ssl

config_path = "/etc/target/targetd.yaml"

default_config = dict(
block_pools = ['vg-targetd']
fs_pools = []
block_pools = ['vg-targetd'],
fs_pools = [],
user="admin",
# security: no default password
target_name="iqn.2003-01.org.linux-iscsi.%s:targetd" % socket.gethostname(),
Expand Down Expand Up @@ -244,6 +246,20 @@ def load_config(config_path):
raise AttributeError


def update_mapping():
# wait until now so submodules can import 'main' safely
import block
import fs

mapping.update(block.initialize(config))
mapping.update(fs.initialize(config))

# one method requires output from both modules
def pool_list(req):
return list(itertools.chain(block.block_pools(req), fs.fs_pools(req)))

mapping['pool_list'] = pool_list

def main():
server = None

Expand All @@ -254,12 +270,7 @@ def main():

setproctitle.setproctitle("targetd")

# wait until now so submodules can import 'main' safely
import block
import fs

mapping.update(block.initialize(config))
mapping.update(fs.initialize(config))
update_mapping()

if config['ssl']:
server_class = TLSThreadedHTTPServer
Expand Down

0 comments on commit f762f1c

Please sign in to comment.