Make sure container exists. It's only needed on newer
        versions of LXC.
965055
def ensure_container(self, name=None):
        """"""
        if get_lxc_version() < pkg_resources.parse_version('2.0.0'):
            # Nothing to do for old versions of LXC
            return

        if name is None:
            name = self.container_name

        args = [
            'lxc-create',
            '--name', name,
            '--template', 'none',
            '>', '/dev/null', '2>&1',
        ]
        os.system(' '.join(args))
579399
public function hasActualContainer(): bool
    {
        if (false === $this->environment->isDebug())
        {
            return true === $this->configCache()->isFresh();
        }

        return false;
    }
1107874
def get_init_container(self,
                           init_command,
                           init_args,
                           env_vars,
                           context_mounts,
                           persistence_outputs,
                           persistence_data):
        """"""
        env_vars = to_list(env_vars, check_none=True)
        volume_mounts = to_list(context_mounts, check_none=True)
        init_command = init_command or ["/bin/sh", "-c"]
        init_args = to_list(get_auth_context_args(entity='notebook', entity_name=self.job_name))
        return client.V1Container(
            name=self.init_container_name,
            image=self.init_docker_image,
            image_pull_policy=self.init_docker_image_pull_policy,
            command=init_command,
            args=init_args,
            env=env_vars,
            volume_mounts=volume_mounts)
778153
def create(name, config_file=None, template=None, backing_store=None, template_options=None):
    '''
    
    
    '''
    if exists(name):
        raise ContainerAlreadyExists("The Container %s is already created!" % name)
    cmd = 'lxc-create -n %s' % name

    if config_file:
        cmd += ' -f %s' % config_file
    if template:
        cmd += ' -t %s' % template
    if backing_store:
        cmd += ' -B %s' % backing_store
    if template_options:
        cmd += '-- %s' % template_options

    if subprocess.check_call('%s >> /dev/null' % cmd, shell=True) == 0:
        if not exists(name):
            _logger.critical("The Container %s doesn't seem to be created! (options: %s)", name, cmd[3:])
            raise ContainerNotExists("The container (%s) does not exist!" % name)

        _logger.info("Container %s has been created with options %s", name, cmd[3:])
        return 0
    else:
        return 1
69070
def exists(self, storagemodel:object, modeldefinition = None) -> bool:
        
        exists = False

        blobservice = modeldefinition['blobservice']
        container_name = modeldefinition['container']
        blob_name = storagemodel.name

        try:
            blobs = self.list(storagemodel, modeldefinition, where=storagemodel.name)
            if len(blobs) == 1:
                storagemodel.__mergeblob__(blobs[0])
                exists = True
                 
        except Exception as e:
            msg = 'can not retireve blob {} from storage because {!s}'.format(blob_name, e)
            raise AzureStorageWrapException(storagemodel, msg=msg)

        return exists
1026622
def create(path)
      raise ContainerError, "Container already exists." if exists?

      if path.is_a?(Hash)
        args = "-n #{name}"

        if !!path[:config_file]
          unless File.exists?(path[:config_file])
            raise ArgumentError, "File #{path[:config_file]} does not exist."
          end
          args += " -f #{path[:config_file]}"
        end

        if !!path[:template]
          template_dir =  path[:template_dir] || "/usr/lib/lxc/templates"
          template_path = File.join(template_dir,"lxc-#{path[:template]}")
          unless File.exists?(template_path)
            raise ArgumentError, "Template #{path[:template]} does not exist."
          end
          args += " -t #{path[:template]} "
        end

        args += " -B #{path[:backingstore]}" if !!path[:backingstore]
        args += " -- #{path[:template_options].join(" ")}".strip if !!path[:template_options]

        LXC.run("create", args)
        exists?
      else
        unless File.exists?(path)
          raise ArgumentError, "File #{path} does not exist."
        end

        LXC.run("create", "-n", name, "-f", path)
        exists?
      end
    end
570607
def _make_sure_dir_exists(self):
        
        filename = self.model_config.checkpoint_dir()
        pathlib.Path(filename).mkdir(parents=True, exist_ok=True)
822010
public function exists($key)
    {
        $this->init();
        list($containerName, $key) = $this->tokenizeKey($key);

        $listBlobsOptions = new ListBlobsOptions();
        $listBlobsOptions->setPrefix($key);

        try {
            $blobsList = $this->blobProxy->listBlobs($containerName, $listBlobsOptions);

            foreach ($blobsList->getBlobs() as $blob) {
                if ($key === $blob->getName()) {
                    return true;
                }
            }
        } catch (ServiceException $e) {
            $errorCode = $this->getErrorCodeFromServiceException($e);
            if ($this->multiContainerMode && self::ERROR_CONTAINER_NOT_FOUND === $errorCode) {
                return false;
            }
            $this->failIfContainerNotFound($e, 'check if key exists', $containerName);

            throw new \RuntimeException(sprintf(
                'Failed to check if key "%s" exists in container "%s": %s (%s).',
                $key,
                $containerName,
                $e->getErrorText(),
                $errorCode
            ), $e->getCode());
        }

        return false;
    }
812714
def info(name):
    '''
    
    '''
    if not exists(name):
        raise ContainerNotExists("The container (%s) does not exist!" % name)
    cmd = ['lxc-info', '-n', name]
    out = subprocess.check_output(cmd).splitlines()
    info = {}
    for line in out:
        k, v = line.split()
        info[k] = v
    return info
371964
@Override
    public Container getContainer(TargetDescription target) {
        Validate.notNull(target, "Target must be specified");
        if (TargetDescription.DEFAULT.equals(target)) {
            return findDefaultContainer();
        }
        return findMatchingContainer(target.getName());
    }
395918
def clone_from(source)
      raise ContainerError, "Container already exists." if exists?

      unless LXC.container(source).exists?
        raise ContainerError, "Source container does not exist."
      end

      run("clone", "-o", source)
      exists?
    end
1272381
def include!(container)
      container_modules = container.singleton_class.included_modules

      # If the container is an EventContainer and we can include it, then do that
      include_events(container) if container_modules.include?(Discordrb::EventContainer) && respond_to?(:include_events)

      if container_modules.include? Discordrb::Commands::CommandContainer
        include_commands(container)
        include_buckets(container)
      elsif !container_modules.include? Discordrb::EventContainer
        raise "Could not include! this particular container - ancestors: #{container_modules}"
      end
    end
325088
public function containerExists($container = '')
    {
        $this->checkConnection();

        try {
            /** @var Container $container */
            $container = $this->blobConn->getContainer($container);

            return !empty($container);
        } catch (\Exception $ex) {
            if ($ex instanceof ClientErrorResponseException) {
                if ($ex->getCode() === 404 || str_contains($ex->getMessage(), '404')) {
                    return false;
                }
            }
            static::handleGuzzleException($ex);
            throw new DfException('Failed to list containers: ' . $ex->getMessage());
        }
    }
716227
def create_missing(self):
        
        if getattr(self, 'content_type', '') == 'docker':
            self._fields['docker_upstream_name'].required = True
        super(Repository, self).create_missing()
921489
def native_container(self):
        """"""
        if self.__native is None:
            self.__native = self._get_container()

        return self.__native
351914
def _container_factory(self, **options):
        
        ac_dict = options.get("ac_dict", False)
        _dicts = [x for x in (options.get(o) for o in self.dict_options())
                  if x]

        if self.dict_options() and ac_dict and callable(ac_dict):
            return ac_dict  # Higher priority than ac_ordered.
        if _dicts and callable(_dicts[0]):
            return _dicts[0]
        if self.ordered() and options.get("ac_ordered", False):
            return anyconfig.compat.OrderedDict

        return dict
115448
def ensure_exists(self):
        """"""
        if not cache.exists(self.config):
            logger.debug("Wily cache not found, creating.")
            cache.create(self.config)
            logger.debug("Created wily cache")
        else:
            logger.debug(f"Cache {self.config.cache_path} exists")