コード例 #1
0
 def test_from_file(self):
     """
     Test parsing a hello world JSON example and returning back the
     respective anymarkup content
     """
     _, tmpfilename = tempfile.mkstemp()
     f = open(tmpfilename, 'w')
     f.write("{ 'hello': 'world'}")
     f.close()
     KubeConfig.from_file(tmpfilename)
コード例 #2
0
 def test_from_file(self):
     """
     Test parsing a hello world JSON example and returning back the
     respective anymarkup content
     """
     _, tmpfilename = tempfile.mkstemp()
     f = open(tmpfilename, 'w')
     f.write("{ 'hello': 'world'}")
     f.close()
     KubeConfig.from_file(tmpfilename)
コード例 #3
0
ファイル: openshift.py プロジェクト: projectatomic/atomicapp
    def init(self):
        self.oc_artifacts = {}

        logger.debug("Given config: %s", self.config)
        if self.config.get("namespace"):
            self.namespace = self.config.get("namespace")

        logger.info("Using namespace %s", self.namespace)

        self._process_artifacts()

        if self.dryrun:
            return
        '''
        Config_file:
            If a config_file has been provided, use the configuration
            from the file and load the associated generated file.
            If a config_file exists (--provider-config) use that.

        Params:
            If any provider specific parameters have been provided,
            load the configuration through the answers.conf file

        .kube/config:
            If no config file or params are provided by user then try to find and
            use a config file at the default location.

        no config at all:
            If no .kube/config file can be found then try to connect to the default
            unauthenticated http://localhost:8080/api end-point.
        '''

        default_config_loc = os.path.join(Utils.getRoot(),
                                          Utils.getUserHome().strip('/'),
                                          '.kube/config')

        if self.config_file:
            logger.debug("Provider configuration provided")
            self.api = Client(KubeConfig.from_file(self.config_file),
                              "openshift")
        elif self._check_required_params():
            logger.debug("Generating .kube/config from given parameters")
            self.api = Client(self._from_required_params(), "openshift")
        elif os.path.isfile(default_config_loc):
            logger.debug(
                ".kube/config exists, using default configuration file")
            self.api = Client(KubeConfig.from_file(default_config_loc),
                              "openshift")
        else:
            self.config["provider-api"] = OC_DEFAULT_API
            self.api = Client(self._from_required_params(), "openshift")

        self._check_namespaces()
コード例 #4
0
ファイル: kubernetes.py プロジェクト: chuanchang/atomicapp
    def init(self):
        self.k8s_artifacts = {}

        logger.debug("Given config: %s", self.config)
        if self.config.get("namespace"):
            self.namespace = self.config.get("namespace")

        logger.info("Using namespace %s", self.namespace)

        self._process_artifacts()

        if self.dryrun:
            return

        '''
        Config_file:
            If a config_file has been provided, use the configuration
            from the file and load the associated generated file.
            If a config_file exists (--provider-config) use that.

        Params:
            If any provider specific parameters have been provided,
            load the configuration through the answers.conf file

        .kube/config:
            If no config file or params are provided by user then try to find and
            use a config file at the default location.

        no config at all:
            If no .kube/config file can be found then try to connect to the default
            unauthenticated http://localhost:8080/api end-point.
        '''

        default_config_loc = os.path.join(
            Utils.getRoot(), Utils.getUserHome().strip('/'), '.kube/config')

        if self.config_file:
            logger.debug("Provider configuration provided")
            self.api = Client(KubeConfig.from_file(self.config_file), "kubernetes")
        elif self._check_required_params():
            logger.debug("Generating .kube/config from given parameters")
            self.api = Client(self._from_required_params(), "kubernetes")
        elif os.path.isfile(default_config_loc):
            logger.debug(".kube/config exists, using default configuration file")
            self.api = Client(KubeConfig.from_file(default_config_loc), "kubernetes")
        else:
            self.config["provider-api"] = K8S_DEFAULT_API
            self.api = Client(self._from_required_params(), "kubernetes")

        # Check if the namespace that the app is being deployed to is available
        self._check_namespaces()