Esempio n. 1
0
 def __load_variables(self):
     """
     Load extra variables, specified in the .mercury_config file.
     """
     
     for key in Configuration.get_all_keys("vars"):
         self.variables[key] = Configuration.get("vars", key)
Esempio n. 2
0
 def trust(self, certificate, peer):
     """
     Add the certificate to the SSL Known Hosts in the Configuration file, so we will
     always trust this host in future.
     """
     
     Configuration.set("ssl-known-hosts", "%s|%d" % peer, self.digest(certificate))
Esempio n. 3
0
    def trust(self, certificate, peer):
        """
        Add the certificate to the SSL Known Hosts in the Configuration file, so we will
        always trust this host in future.
        """

        Configuration.set("ssl-known-hosts", "%s|%d" % peer,
                          self.digest(certificate))
Esempio n. 4
0
    def enable(cls, path):
        """
        Re-add a Mercury module repository to the collection, that was created manually
        or has previously been removed with #disable().
        """

        if cls.looks_like_repo(path):
            Configuration.set('repositories', path, path)
        else:
            raise UnknownRepository(path)
Esempio n. 5
0
    def disable(cls, path):
        """
        Remove a Mercury module repository from the collection, but leave the file
        system intact.
        """

        if cls.is_repo(path):
            Configuration.delete('repositories', path)
        else:
            raise UnknownRepository(path)
Esempio n. 6
0
 def disable(cls, path):
     """
     Remove a Mercury module repository from the collection, but leave the file
     system intact.
     """
     
     if cls.is_repo(path):
         Configuration.delete('repositories', path)
     else:
         raise UnknownRepository(path)
Esempio n. 7
0
 def enable(cls, path):
     """
     Re-add a Mercury module repository to the collection, that was created manually
     or has previously been removed with #disable().
     """
     
     if cls.looks_like_repo(path):
         Configuration.set('repositories', path, path)
     else:
         raise UnknownRepository(path)
Esempio n. 8
0
 def delete(cls, url):
     """
     Removes a Mercury remote, with the specified URL.
     """
     
     if cls.get(url) != None:
         Configuration.delete('remotes', url)
         
         return True
     else:
         raise UnknownRemote(url)
Esempio n. 9
0
    def delete(cls, url):
        """
        Removes a Mercury remote, with the specified URL.
        """

        if cls.get(url) != None:
            Configuration.delete('remotes', url)

            return True
        else:
            raise UnknownRemote(url)
Esempio n. 10
0
 def all(cls):
     """
     Returns all known Mercury remotes.
     
     If the [remotes] section does not exist in the configuration file, we
     create it and add a default repository.
     """
     
     if not Configuration.has_section('remotes'):
         cls.create("https://raw.github.com/mwrlabs/mercury-modules/repository/")
         
     return Configuration.get_all_values('remotes')
Esempio n. 11
0
 def create(cls, url):
     """
     Create a new Mercury remote, with the specified URL.
     
     If the URL already exists, no remote will be created.
     """
     
     if cls.get(url) == None:
         Configuration.set('remotes', url, url)
         
         return True
     else:
         return False
Esempio n. 12
0
    def create(cls, url):
        """
        Create a new Mercury remote, with the specified URL.
        
        If the URL already exists, no remote will be created.
        """

        if cls.get(url) == None:
            Configuration.set('remotes', url, url)

            return True
        else:
            return False
Esempio n. 13
0
    def all(cls):
        """
        Returns all known Mercury remotes.
        
        If the [remotes] section does not exist in the configuration file, we
        create it and add a default repository.
        """

        if not Configuration.has_section('remotes'):
            cls.create(
                "https://raw.github.com/mwrlabs/mercury-modules/repository/")

        return Configuration.get_all_values('remotes')
Esempio n. 14
0
 def provision(self, path):
     """
     Provision new CA Key Material.
     
     This will overwrite any existing CA.
     """
     
     self.authority.create_ca()
     
     Configuration.set("ssl", "ca_path", path)
     
     fs.write(self.ca_certificate_path(), ca.CA.certificate_to_pem(self.authority.ca_cert))
     fs.write(self.__ca_key_path(), ca.CA.pkey_to_pem(self.authority.ca_key))
     
     return True
Esempio n. 15
0
    def provision(self, path):
        """
        Provision new CA Key Material.
        
        This will overwrite any existing CA.
        """

        self.authority.create_ca()

        Configuration.set("ssl", "ca_path", path)

        fs.write(self.ca_certificate_path(),
                 ca.CA.certificate_to_pem(self.authority.ca_cert))
        fs.write(self.__ca_key_path(),
                 ca.CA.pkey_to_pem(self.authority.ca_key))

        return True
Esempio n. 16
0
    def get(cls, url):
        """
        Get an instance of Remote, initialised with the remote settings.
        """

        url = Configuration.get('remotes', url)

        if url != None:
            return cls(url)
        else:
            return None
Esempio n. 17
0
 def ca_path(self, skip_default=False):
     """
     Get the path to the CA Key Material, as defined by the configuration file.
     """
     
     ca_path = Configuration.get("ssl", "ca_path")
     
     if ca_path == None and skip_default == False:
         ca_path = os.path.join(os.path.dirname(__file__), "embedded_ca")
     
     return ca_path
Esempio n. 18
0
    def ca_path(self, skip_default=False):
        """
        Get the path to the CA Key Material, as defined by the configuration file.
        """

        ca_path = Configuration.get("ssl", "ca_path")

        if ca_path == None and skip_default == False:
            ca_path = os.path.join(os.path.dirname(__file__), "embedded_ca")

        return ca_path
Esempio n. 19
0
 def get(cls, url):
     """
     Get an instance of Remote, initialised with the remote settings.
     """
     
     url = Configuration.get('remotes', url)
     
     if url != None:
         return cls(url)
     else:
         return None
Esempio n. 20
0
 def all(cls):
     """
     Returns all known Mercury repositories. 
     """
     
     return Configuration.get_all_values('repositories')
Esempio n. 21
0
    def all(cls):
        """
        Returns all known Mercury repositories. 
        """

        return Configuration.get_all_values('repositories')
Esempio n. 22
0
    def trusted_certificate_for(self, peer):
        """
        Fetches the trusted certificate for a peer.
        """

        return Configuration.get("ssl-known-hosts", "%s|%d" % peer)
Esempio n. 23
0
 def trusted_certificate_for(self, peer):
     """
     Fetches the trusted certificate for a peer.
     """
     
     return Configuration.get("ssl-known-hosts", "%s|%d" % peer)