예제 #1
0
    def get_unique_name(self, prefix="", suffix="", length=4):
        """
        Get unique name for a new container

        :param prefix: Name prefix string
        :param suffix: Name suffix string
        :param length: Length of random string (greater than 1)
        :return: Container name guaranteed to not be in-use.
        """
        assert length > 1
        all_containers = [_.container_name for _ in self.list_containers()]
        check = lambda name: name not in all_containers
        return utils.get_unique_name(check, prefix, suffix, length)
예제 #2
0
 def _init_test_depenent(self):
     users = []
     for line in self.parent_subtest.stuff['passwd'].splitlines():
         line = line.strip()
         try:
             users.append(line.split(':', 1)[0])
         except IndexError:
             pass
     user = utils.get_unique_name(lambda name: name not in users, "user",
                                  length=6)
     self.sub_stuff['execution_failure'] = "Unable to find user %s" % user
     self.sub_stuff['subargs'] = ['--rm', '--interactive',
                                  '--user=%s' % user]
예제 #3
0
 def _init_test_depenent(self):
     users = []
     for line in self.parent_subtest.stuff['passwd'].splitlines():
         line = line.strip()
         try:
             users.append(line.split(':', 1)[0])
         except IndexError:
             pass
     user = utils.get_unique_name(lambda name: name not in users,
                                  "user",
                                  length=6)
     self.sub_stuff['execution_failure'] = "Unable to find user %s" % user
     self.sub_stuff['subargs'] = [
         '--rm', '--interactive',
         '--user=%s' % user
     ]
예제 #4
0
    def get_unique_name(self, prefix="", suffix="", length=4):
        """
        Get unique name for a new container

        :param prefix: Name prefix string
        :param suffix: Name suffix string
        :param length: Length of random string (greater than 1)
        :return: Container name guaranteed to not be in-use.
        """
        assert length > 1
        if prefix:
            prefix = "%s-%s" % (self.subtest.__class__.__name__, prefix)
        else:
            prefix = self.subtest.__class__.__name__
        all_containers = [_.container_name for _ in self.list_containers()]
        check = lambda name: name not in all_containers
        return utils.get_unique_name(check, prefix, suffix, length)