def test_c_CreateRemoveConfig(self):
     print('CREATE CONFIG')
     config = 'changelog-config-' + str(random.randint(0, 10000))
     DockerSwarmTools.CreateSwarmConfig(
         os.path.join(TestTools.TEST_SAMPLE_FOLDER, 'CHANGELOG.md'), config)
     DockerSwarmTools.RemoveSwarmConfig(config)
     print('DONE CREATE CONFIG')
 def test_d_CreateRemoveSecret(self):
     print('CREATE SECRET')
     secret = 'changelog-secret-' + str(random.randint(0, 10000))
     DockerSwarmTools.CreateSwarmSecret(
         os.path.join(TestTools.TEST_SAMPLE_FOLDER, 'CHANGELOG.md'), secret)
     DockerSwarmTools.RemoveSwarmSecret(secret)
     print('DONE CREATE SECRET')
    def test_e_CreateRemoveVolume(self):
        print('CREATE VOLUME')
        volume = 'test-volume-' + str(random.randint(0, 10000))
        DockerSwarmTools.CreateSwarmVolume(volume)
        DockerSwarmTools.RemoveSwarmVolume(volume)

        DockerSwarmTools.CreateSwarmVolume(volume, driver='local')
        DockerSwarmTools.RemoveSwarmVolume(volume)

        print('DONE CREATE VOLUME')
 def test_f_CreateRemoveStack(self):
     print('CREATE STACK')
     stack = 'test-stack-' + str(random.randint(0, 10000))
     TerminalTools.LoadEnvironmentVariables(
         os.path.join(TestTools.TEST_SAMPLE_FOLDER, '.env'))
     DockerComposeTools.DockerComposeBuild(
         [os.path.join(TestTools.TEST_SAMPLE_FOLDER, 'docker-compose.yml')])
     DockerSwarmTools.DeployStack(
         os.path.join(TestTools.TEST_SAMPLE_FOLDER, 'docker-compose.yml'),
         stack)
     DockerSwarmTools.RemoveStack(stack)
     print('DONE CREATE STACK')
    def test_b_CreateRemoveNetwork(self):
        print('CREATE NETWORK')
        network = 'my-network-' + str(random.randint(0, 10000))
        DockerSwarmTools.CreateSwarmNetwork(network)
        DockerSwarmTools.RemoveSwarmNetwork(network)

        DockerSwarmTools.CreateSwarmNetwork(network,
                                            encrypted=True,
                                            driver="overlay",
                                            attachable=False,
                                            options=['--ipv6'])
        DockerSwarmTools.RemoveSwarmNetwork(network)

        print('DONE CREATE NETWORK')
Esempio n. 6
0
def StartSwarm(arguments):
    DockerSwarmTools.StartSwarm()
    SwarmVolumes.HandleVolumes(['-volume', '-create', 'all'] + arguments)
    SwarmConfigs.HandleConfigs(['-config', '-create', 'all'] + arguments)
    SwarmSecrets.HandleSecrets(['-secret', '-create', 'all'] + arguments)
    SwarmNetworks.HandleNetworks(['-network', '-create', 'all'] + arguments)
    SwarmStacks.HandleStacks(['-stack', '-deploy', 'all'] + arguments)
Esempio n. 7
0
def CreateVolume(volumeName, volumeProperties):
    if volumeProperties == None:
        volumeProperties = {}
    driver = YamlTools.TryGetFromDictionary(volumeProperties, 'driver',
                                            'local')
    driverOptions = YamlTools.TryGetFromDictionary(volumeProperties,
                                                   'driverOptions', [])

    DockerSwarmTools.CreateSwarmVolume(volumeName, driver, driverOptions)
Esempio n. 8
0
    def Remove(self, artifacts=[]):
        stackFiles = self._GetFilesFromCache(artifacts)
        stackFilesToRemove = []
        for stackFile in stackFiles:
            stackName, version, stackFileIsValid = StackVersionTools.GetStackNameAndVersionFromStackFile(
                stackFile, artifactIdentifier=self._artifactIdentifier)
            if not (stackFileIsValid):
                continue

            DockerSwarmTools.RemoveStack(stackName)
            stackFilesToRemove.append(stackFile)

        if self._removeFilesFromCache:
            for removedStackFile in stackFilesToRemove:
                os.remove(removedStackFile)
Esempio n. 9
0
def CreateNetwork(networkName, networkProperties):
    if networkProperties == None:
        networkProperties = {}
    elif isinstance(networkProperties, bool):
        networkProperties = {'encrypted': networkProperties}

    encrypted = YamlTools.TryGetFromDictionary(networkProperties, 'encrypted',
                                               False)
    driver = YamlTools.TryGetFromDictionary(networkProperties, 'driver',
                                            'overlay')
    attachable = YamlTools.TryGetFromDictionary(networkProperties,
                                                'attachable', True)
    options = YamlTools.TryGetFromDictionary(networkProperties, 'options', [])

    DockerSwarmTools.CreateSwarmNetwork(networkName, encrypted, driver,
                                        attachable, options)
Esempio n. 10
0
    def Deploy(self, artifacts=[]):
        stackFiles = self._GetFilesFromCache(artifacts)
        for stackFile in stackFiles:
            stackName, version, stackFileIsValid = StackVersionTools.GetStackNameAndVersionFromStackFile(
                stackFile, artifactIdentifier=self._artifactIdentifier)
            if not (stackFileIsValid):
                continue

            valid = True
            if self.__verifyStacksOnDeploy:
                valid = self.__verificationHandler.VerifyStackFile(stackFile)

            if valid:
                DockerSwarmTools.DeployStack(stackFile,
                                             stackName,
                                             withRegistryAuth=True)
            else:
                warnings.warn(
                    "Skipping deployment of stack {0} since it is invalid!".
                    format(stackName))
Esempio n. 11
0
def RemoveSecret(secretName):
    DockerSwarmTools.RemoveSwarmSecret(secretName)
Esempio n. 12
0
def CreateSecret(secretName, secretFile):
    DockerSwarmTools.CreateSwarmSecret(secretFile, secretName)
Esempio n. 13
0
def DeployStack(stackName, composeFile, environmentFiles):
    DockerSwarmTools.DeployStack(composeFile,
                                 stackName,
                                 environmentFiles,
                                 withRegistryAuth=True)
 def test_a_StartSwarm(self):
     print('SWARM START')
     DockerSwarmTools.StartSwarm()
     print('DONE SWARM START')
Esempio n. 15
0
def CreateConfig(configName, configFile):
    DockerSwarmTools.CreateSwarmConfig(configFile, configName)
Esempio n. 16
0
def DeployStack(stackName, composeFile, environmentFiles):
    DockerSwarmTools.DeployStack(composeFile, stackName, environmentFiles)
Esempio n. 17
0
def RemoveConfig(configName):
    DockerSwarmTools.RemoveSwarmConfig(configName)
Esempio n. 18
0
def RemoveNetwork(networkName):
    DockerSwarmTools.RemoveSwarmNetwork(networkName)
Esempio n. 19
0
def RemoveVolume(volumeName):
    DockerSwarmTools.RemoveSwarmVolume(volumeName)
Esempio n. 20
0
def RemoveStack(stack):
    DockerSwarmTools.RemoveStack(stack)
Esempio n. 21
0
def InitWithSwarmManager(swmInfrastructureFiles: []):
    if not(__CheckSwarmManagementYamlFileExists(yamlFiles=swmInfrastructureFiles)):
        DockerSwarmTools.StartSwarm()
        return
    arguments = __GetSwarmManagementArgumentsWithInfrastructureFiles(swmInfrastructureFiles)
    SwarmManager.StartSwarm(arguments=arguments)