예제 #1
0
    def test_from_json_file(self, mock_open, mock_login):
        json_config_content = u"""{
          "ip": "10.30.4.245",
          "credentials": {
            "username": "******",
            "password": "******"
          }
        }"""
        mock_open.return_value = self.__mock_file_open(json_config_content)
        ovc_client = OVC.from_json_file("config.json")

        self.assertIsInstance(ovc_client, OVC)
        self.assertEqual("10.30.4.245", ovc_client.connection._ovc_ip)
예제 #2
0
    def _create_simplivity_client(self):
        """
        Creates Simplivity client object using module prams/env variables/config file
        """
        if self.module.params.get('ovc_ip'):
            config = dict(ip=self.module.params['ovc_ip'],
                          credentials=dict(
                              username=self.module.params['username'],
                              password=self.module.params['password']))
            self.ovc_client = OVC(config)

        elif not self.module.params['config']:
            self.ovc_client = OVC.from_environment_variables()
        else:
            self.ovc_client = OVC.from_json_file(self.module.params['config'])