def validate(self):
        self._validate_localdir()
        self._validate_securelocaldir()
        
        self.blankcreate_path = None
        self._validate_blankspacecreate()
        
        self.adapters = {}
        
        scp_path = self.p.get_conf_or_none("propagation", "scp")
        if scp_path:
            try:
                import propagate_scp
                self.adapters[PROP_ADAPTER_SCP] = propagate_scp.propadapter(self.p, self.c)
            except:
                msg = "SCP configuration present (propagation->scp) but cannot load a suitable SCP implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)
            
        guc_path = self.p.get_conf_or_none("propagation", "guc")
        if guc_path:
            try:
                import propagate_guc
                self.adapters[PROP_ADAPTER_GUC] = propagate_guc.propadapter(self.p, self.c)
            except:
                msg = "GridFTP configuration present (propagation->guc) but cannot load a suitable GridFTP implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)
        
        hdfs_path = self.p.get_conf_or_none("propagation", "hdfs")
        if hdfs_path:
            try:
                import propagate_hdfs
                self.adapters[PROP_ADAPTER_HDFS] = propagate_hdfs.propadapter(self.p, self.c)
            except:
                msg = "HDFS configuration present (propagation->hdfs) but cannot load a suitable HDFS implimentation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)    
        
        http_enabled = self.p.get_conf_or_none("propagation", "http")
        if http_enabled and http_enabled.strip().lower() == "true":
            import propagate_http
            self.adapters[PROP_ADAPTER_HTTP] = propagate_http.propadapter(self.p, self.c)

        if len(self.adapters) == 0:
            self.c.log.warn("There are no propagation adapters configured, propagation is disabled")
            return
            
        for keyword in self.adapters.keys():
            adapter = self.adapters[keyword]
            adapter.validate()
Exemple #2
0
class DefaultImageProcurement:
    """ImageProcurement is the wcmodule responsible for making files accessible
    to the current VMM node before the deployment.  As well as processing files
    after deployment.  The typical pattern is propagation before running and
    unpropagation afterwards.  If there is an immediate-destroy event, this
    module will destroy all local files.
    
    That is what we assume most implementations would do, they don't necessarily
    have to.  Perhaps in some future implementation, this module will archive
    destroyed VMs to some storage array for auditing.
    
    """

    zope.interface.implements(workspacecontrol.api.modules.IImageProcurement)

    def __init__(self, params, common):
        self.p = params
        self.c = common
        self.localdir = None
        self.securelocaldir = None
        self.blankspacedir = None
        self.adapters = None  # dict: {keyword: instance of PropagationAdapter}

    # --------------------------------------------------------------------------
    # validate(), from ImageProcurement interface
    # --------------------------------------------------------------------------

    def validate(self):
        self._validate_localdir()
        self.securelocaldir = self._validate_securelocaldir("securelocaldir")

        self.blankcreate_path = None
        self._validate_blankspacecreate()
        self.blankspacedir = self._validate_blankspacedir("blankspacedir")

        self.adapters = {}

        cp_path = self.p.get_conf_or_none("propagation", "cp")
        if cp_path:
            try:
                import propagate_cp
                self.adapters[PROP_ADAPTER_CP] = propagate_cp.cp_propadapter(
                    self.p, self.c)
            except Exception, ex:
                msg = "CP configuration present (propagation->cp) but cannot load a suitable CP implementation in the code | %s" % (
                    str(ex))
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)

        scp_path = self.p.get_conf_or_none("propagation", "scp")
        if scp_path:
            try:
                import propagate_scp
                self.adapters[PROP_ADAPTER_SCP] = propagate_scp.propadapter(
                    self.p, self.c)
            except:
                msg = "SCP configuration present (propagation->scp) but cannot load a suitable SCP implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)

        guc_path = self.p.get_conf_or_none("propagation", "guc")
        if guc_path:
            try:
                import propagate_guc
                self.adapters[PROP_ADAPTER_GUC] = propagate_guc.propadapter(
                    self.p, self.c)
            except:
                msg = "GridFTP configuration present (propagation->guc) but cannot load a suitable GridFTP implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)

        hdfs_path = self.p.get_conf_or_none("propagation", "hdfs")
        if hdfs_path:
            try:
                import propagate_hdfs
                self.adapters[PROP_ADAPTER_HDFS] = propagate_hdfs.propadapter(
                    self.p, self.c)
            except:
                msg = "HDFS configuration present (propagation->hdfs) but cannot load a suitable HDFS implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)

        http_enabled = self.p.get_conf_or_none("propagation", "http")
        if http_enabled and http_enabled.strip().lower() == "true":
            import propagate_http
            self.adapters[PROP_ADAPTER_HTTP] = propagate_http.propadapter(
                self.p, self.c)

        https_enabled = self.p.get_conf_or_none("propagation", "https")
        if https_enabled and https_enabled.strip().lower() == "true":
            import propagate_https
            self.adapters[PROP_ADAPTER_HTTPS] = propagate_https.propadapter(
                self.p, self.c)

        if len(self.adapters) == 0:
            self.c.log.warn(
                "There are no propagation adapters configured, propagation is disabled"
            )
            return

        lt_enabled = self.p.get_conf_or_none("propagation", "lantorrent")
        if lt_enabled and lt_enabled.strip().lower() == "true":
            try:
                import propagate_lantorrent
                self.adapters[
                    PROP_ADAPTER_LANTORRENT] = propagate_lantorrent.LantorrentPropadapter(
                        self.p, self.c)
            except Exception, ex:
                msg = "lantorrent configuration present (propagation->lantorrent) but cannot load a suitable lantorrent implementation in the code: " + str(
                    ex)
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)
Exemple #3
0
    def validate(self):
        self._validate_localdir()
        self._validate_securelocaldir()

        self.blankcreate_path = None
        self._validate_blankspacecreate()

        self.adapters = {}

        qcow_create_path = self.p.get_conf_or_none("propagation",
                                                   "qcow_create")
        if qcow_create_path:
            try:
                import propagate_qcow
                self.adapters[PROP_ADAPTER_QCOW] = propagate_qcow.propadapter(
                    self.p, self.c)
            except:
                msg = "QCOW configuration present (propagation->qcow_create) but cannot load a suitable QCOW implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)

        scp_path = self.p.get_conf_or_none("propagation", "scp")
        if scp_path:
            try:
                import propagate_scp
                self.adapters[PROP_ADAPTER_SCP] = propagate_scp.propadapter(
                    self.p, self.c)
            except:
                msg = "SCP configuration present (propagation->scp) but cannot load a suitable SCP implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)

        guc_path = self.p.get_conf_or_none("propagation", "guc")
        if guc_path:
            try:
                import propagate_guc
                self.adapters[PROP_ADAPTER_GUC] = propagate_guc.propadapter(
                    self.p, self.c)
            except:
                msg = "GridFTP configuration present (propagation->guc) but cannot load a suitable GridFTP implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)

        hdfs_path = self.p.get_conf_or_none("propagation", "hdfs")
        if hdfs_path:
            try:
                import propagate_hdfs
                self.adapters[PROP_ADAPTER_HDFS] = propagate_hdfs.propadapter(
                    self.p, self.c)
            except:
                msg = "HDFS configuration present (propagation->hdfs) but cannot load a suitable HDFS implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)

        http_enabled = self.p.get_conf_or_none("propagation", "http")
        if http_enabled and http_enabled.strip().lower() == "true":
            import propagate_http
            self.adapters[PROP_ADAPTER_HTTP] = propagate_http.propadapter(
                self.p, self.c)

        https_enabled = self.p.get_conf_or_none("propagation", "https")
        if https_enabled and https_enabled.strip().lower() == "true":
            import propagate_https
            self.adapters[PROP_ADAPTER_HTTPS] = propagate_https.propadapter(
                self.p, self.c)

        if len(self.adapters) == 0:
            self.c.log.warn(
                "There are no propagation adapters configured, propagation is disabled"
            )
            return

        lt_enabled = self.p.get_conf_or_none("propagation", "lantorrent")
        if lt_enabled and lt_enabled.strip().lower() == "true":
            try:
                import propagate_lantorrent
                self.adapters[
                    PROP_ADAPTER_LANTORRENT] = propagate_lantorrent.LantorrentPropadapter(
                        self.p, self.c)
            except Exception, ex:
                msg = "lantorrent configuration present (propagation->lantorrent) but cannot load a suitable lantorrent implementation in the code: " + str(
                    ex)
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)
Exemple #4
0
    def validate(self):
        self._validate_localdir()
        self._validate_securelocaldir()
        
        self.blankcreate_path = None
        self._validate_blankspacecreate()
        
        self.adapters = {}
        
        qcow_create_path = self.p.get_conf_or_none("propagation", "qcow_create")
        if qcow_create_path:
            try:
                import propagate_qcow
                self.adapters[PROP_ADAPTER_QCOW] = propagate_qcow.propadapter(self.p, self.c)
            except:
                msg = "QCOW configuration present (propagation->qcow_create) but cannot load a suitable QCOW implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)


        scp_path = self.p.get_conf_or_none("propagation", "scp")
        if scp_path:
            try:
                import propagate_scp
                self.adapters[PROP_ADAPTER_SCP] = propagate_scp.propadapter(self.p, self.c)
            except:
                msg = "SCP configuration present (propagation->scp) but cannot load a suitable SCP implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)
            
        guc_path = self.p.get_conf_or_none("propagation", "guc")
        if guc_path:
            try:
                import propagate_guc
                self.adapters[PROP_ADAPTER_GUC] = propagate_guc.propadapter(self.p, self.c)
            except:
                msg = "GridFTP configuration present (propagation->guc) but cannot load a suitable GridFTP implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)
        
        hdfs_path = self.p.get_conf_or_none("propagation", "hdfs")
        if hdfs_path:
            try:
                import propagate_hdfs
                self.adapters[PROP_ADAPTER_HDFS] = propagate_hdfs.propadapter(self.p, self.c)
            except:
                msg = "HDFS configuration present (propagation->hdfs) but cannot load a suitable HDFS implementation in the code"
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)    
        
        http_enabled = self.p.get_conf_or_none("propagation", "http")
        if http_enabled and http_enabled.strip().lower() == "true":
            import propagate_http
            self.adapters[PROP_ADAPTER_HTTP] = propagate_http.propadapter(self.p, self.c)

        https_enabled = self.p.get_conf_or_none("propagation", "https")
        if https_enabled and https_enabled.strip().lower() == "true":
            import propagate_https
            self.adapters[PROP_ADAPTER_HTTPS] = propagate_https.propadapter(self.p, self.c)

        if len(self.adapters) == 0:
            self.c.log.warn("There are no propagation adapters configured, propagation is disabled")
            return


        lt_enabled = self.p.get_conf_or_none("propagation", "lantorrent")
        if lt_enabled and lt_enabled.strip().lower() == "true":
            try:
                import propagate_lantorrent
                self.adapters[PROP_ADAPTER_LANTORRENT] = propagate_lantorrent.LantorrentPropadapter(self.p, self.c)
            except Exception, ex:
                msg = "lantorrent configuration present (propagation->lantorrent) but cannot load a suitable lantorrent implementation in the code: " + str(ex)
                self.c.log.exception(msg + ": ")
                raise InvalidConfig(msg)