@@ -630,9 +630,42 @@ class iSCSIPool(StoragePool):
630630 """
631631 Create an iSCSI based storage pool
632632 """
633- def __init__ (self , * args , ** kwargs ):
634- raise RuntimeError , "Not implemented"
635633
634+ host = property (StoragePool .get_host , StoragePool .set_host )
635+
636+ def __init__ (self , conn , name , source_path = None , host = None ,
637+ target_path = None , uuid = None ):
638+ StoragePool .__init__ (self , name = name , type = StoragePool .TYPE_ISCSI ,
639+ uuid = None , target_path = target_path , conn = conn )
640+
641+ if source_path :
642+ self .source_path = source_path
643+ if host :
644+ self .host = host
645+
646+ # Need to overwrite pool *_source_path since iscsi device isn't
647+ # a fully qualified path
648+ def get_source_path (self ):
649+ return self ._source_path
650+ def set_source_path (self , val ):
651+ self ._source_path = val
652+ source_path = property (get_source_path , set_source_path )
653+
654+ def _get_default_target_path (self ):
655+ return DEFAULT_ISCSI_TARGET
656+
657+ def _get_target_xml (self ):
658+ xml = " <path>%s</path>\n " % escape (self .target_path )
659+ return xml
660+
661+ def _get_source_xml (self ):
662+ if not self .host :
663+ raise RuntimeError (_ ("Hostname is required" ))
664+ if not self .source_path :
665+ raise RuntimeError (_ ("Host path is required" ))
666+ xml = """ <host name="%s"/>\n """ % self .host + \
667+ """ <device path="%s"/>\n """ % escape (self .source_path )
668+ return xml
636669
637670class StorageVolume (StorageObject ):
638671 """
0 commit comments