示例#1
0
def ca():
    '''When the Certificate Authority is available, copy the CA from the
    default location to the /srv/kubernetes directory. '''
    ca_crt = '/srv/kubernetes/ca.crt'
    # Copy the Certificate Authority to the destination directory.
    tlslib.ca(None, ca_crt, user='******', group='ubuntu')
    set_state('k8s.certificate.authority available')
示例#2
0
文件: k8s.py 项目: mbruzek/layer-k8s
def ca():
    '''When the Certificate Authority is available, copy the CA from the
    default location to the /srv/kubernetes directory. '''
    ca_crt = '/srv/kubernetes/ca.crt'
    # Copy the Certificate Authority to the destination directory.
    tlslib.ca(None, ca_crt, user='******', group='ubuntu')
    set_state('k8s.certificate.authority available')
示例#3
0
 def test_ca(self):
     """Test the CA copy method."""
     directory = os.path.join(self.temporary_directory, 'ca')
     user = pwd.getpwuid(os.getuid())[0]
     group = pwd.getpwuid(os.getuid())[0]
     destination = os.path.join(directory, 'ca.crt')
     tlslib.ca('unit_tests/tls-test.crt', destination, user, group)
     assert os.path.isdir(directory)
     assert os.path.isfile(destination)
示例#4
0
 def test_ca(self):
     """Test the CA copy method."""
     directory = os.path.join(self.temporary_directory, 'ca')
     user = pwd.getpwuid(os.getuid())[0]
     group = pwd.getpwuid(os.getuid())[0]
     destination = os.path.join(directory, 'ca.crt')
     tlslib.ca('unit_tests/tls-test.crt', destination, user, group)
     assert os.path.isdir(directory)
     assert os.path.isfile(destination)
示例#5
0
def prepare_default_client_credentials():
    """ Generate a downloadable package for clients to use to speak to the
    swarm cluster. """

    # Leverage TLSLib to copy the default cert from PKI
    client_cert(None, "./swarm_credentials/cert.pem")
    client_key(None, "./swarm_credentials/key.pem")
    ca(None, "./swarm_credentials/ca.pem")

    with open("swarm_credentials/key.pem", "r") as fp:
        key_contents = fp.read()
    with open("swarm_credentials/cert.pem", "r") as fp:
        crt_contents = fp.read()

    leader_set({"client_cert": crt_contents, "client_key": key_contents})
示例#6
0
def prepare_default_client_credentials():
    """ Generate a downloadable package for clients to use to speak to the
    swarm cluster. """

    # Leverage TLSLib to copy the default cert from PKI
    client_cert(None, './swarm_credentials/cert.pem')
    client_key(None, './swarm_credentials/key.pem')
    ca(None, './swarm_credentials/ca.pem')

    with open('swarm_credentials/key.pem', 'r') as fp:
        key_contents = fp.read()
    with open('swarm_credentials/cert.pem', 'r') as fp:
        crt_contents = fp.read()

    leader_set({'client_cert': crt_contents, 'client_key': key_contents})