Merge "Adding --insecure flag"
This commit is contained in:
		| @@ -20,7 +20,7 @@ from mistralclient.api.v2 import client as client_v2 | ||||
| def client(mistral_url=None, username=None, api_key=None, | ||||
|            project_name=None, auth_url=None, project_id=None, | ||||
|            endpoint_type='publicURL', service_type='workflow', | ||||
|            auth_token=None, user_id=None, cacert=None): | ||||
|            auth_token=None, user_id=None, cacert=None, insecure=False): | ||||
|  | ||||
|         if mistral_url and not isinstance(mistral_url, six.string_types): | ||||
|             raise RuntimeError('Mistral url should be a string.') | ||||
| @@ -36,7 +36,8 @@ def client(mistral_url=None, username=None, api_key=None, | ||||
|             service_type=service_type, | ||||
|             auth_token=auth_token, | ||||
|             user_id=user_id, | ||||
|             cacert=cacert | ||||
|             cacert=cacert, | ||||
|             insecure=insecure | ||||
|         ) | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -31,25 +31,39 @@ class Client(object): | ||||
|     def __init__(self, mistral_url=None, username=None, api_key=None, | ||||
|                  project_name=None, auth_url=None, project_id=None, | ||||
|                  endpoint_type='publicURL', service_type='workflowv2', | ||||
|                  auth_token=None, user_id=None, cacert=None): | ||||
|                  auth_token=None, user_id=None, cacert=None, insecure=False): | ||||
|  | ||||
|         if mistral_url and not isinstance(mistral_url, six.string_types): | ||||
|             raise RuntimeError('Mistral url should be string') | ||||
|  | ||||
|         if auth_url: | ||||
|             (mistral_url, auth_token, project_id, user_id) = ( | ||||
|                 self.authenticate(mistral_url, username, api_key, | ||||
|                                   project_name, auth_url, project_id, | ||||
|                                   endpoint_type, service_type, auth_token, | ||||
|                                   user_id, cacert)) | ||||
|                 self.authenticate( | ||||
|                     mistral_url, | ||||
|                     username, | ||||
|                     api_key, | ||||
|                     project_name, | ||||
|                     auth_url, | ||||
|                     project_id, | ||||
|                     endpoint_type, | ||||
|                     service_type, | ||||
|                     auth_token, | ||||
|                     user_id, | ||||
|                     cacert, | ||||
|                     insecure | ||||
|                 ) | ||||
|             ) | ||||
|  | ||||
|         if not mistral_url: | ||||
|             mistral_url = "http://localhost:8989/v2" | ||||
|  | ||||
|         self.http_client = httpclient.HTTPClient(mistral_url, | ||||
|                                                  auth_token, | ||||
|                                                  project_id, | ||||
|                                                  user_id) | ||||
|         self.http_client = httpclient.HTTPClient( | ||||
|             mistral_url, | ||||
|             auth_token, | ||||
|             project_id, | ||||
|             user_id | ||||
|         ) | ||||
|  | ||||
|         # Create all resource managers. | ||||
|         self.workbooks = workbooks.WorkbookManager(self) | ||||
|         self.executions = executions.ExecutionManager(self) | ||||
| @@ -64,15 +78,18 @@ class Client(object): | ||||
|     def authenticate(self, mistral_url=None, username=None, api_key=None, | ||||
|                      project_name=None, auth_url=None, project_id=None, | ||||
|                      endpoint_type='publicURL', service_type='workflowv2', | ||||
|                      auth_token=None, user_id=None, cacert=None): | ||||
|                      auth_token=None, user_id=None, cacert=None, | ||||
|                      insecure=False): | ||||
|  | ||||
|         if project_name and project_id: | ||||
|             raise RuntimeError('Only project name or ' | ||||
|                                'project id should be set') | ||||
|             raise RuntimeError( | ||||
|                 'Only project name or project id should be set' | ||||
|             ) | ||||
|  | ||||
|         if username and user_id: | ||||
|             raise RuntimeError('Only user name or user id' | ||||
|                                ' should be set') | ||||
|             raise RuntimeError( | ||||
|                 'Only user name or user id should be set' | ||||
|             ) | ||||
|  | ||||
|         keystone_client = _get_keystone_client(auth_url) | ||||
|  | ||||
| @@ -85,7 +102,9 @@ class Client(object): | ||||
|             tenant_name=project_name, | ||||
|             auth_url=auth_url, | ||||
|             endpoint=auth_url, | ||||
|             cacert=cacert) | ||||
|             cacert=cacert, | ||||
|             insecure=insecure | ||||
|         ) | ||||
|  | ||||
|         keystone.authenticate() | ||||
|         token = keystone.auth_token | ||||
|   | ||||
| @@ -43,8 +43,12 @@ LOG = logging.getLogger(__name__) | ||||
| class OpenStackHelpFormatter(argparse.HelpFormatter): | ||||
|     def __init__(self, prog, indent_increment=2, max_help_position=32, | ||||
|                  width=None): | ||||
|         super(OpenStackHelpFormatter, self).__init__(prog, indent_increment, | ||||
|                                                      max_help_position, width) | ||||
|         super(OpenStackHelpFormatter, self).__init__( | ||||
|             prog, | ||||
|             indent_increment, | ||||
|             max_help_position, | ||||
|             width | ||||
|         ) | ||||
|  | ||||
|     def start_section(self, heading): | ||||
|         # Title-case the headings. | ||||
| @@ -114,8 +118,10 @@ class MistralShell(app.App): | ||||
|         log_lvl = logging.DEBUG if self.options.debug else logging.WARNING | ||||
|         logging.basicConfig( | ||||
|             format="%(levelname)s (%(module)s) %(message)s", | ||||
|             level=log_lvl) | ||||
|             level=log_lvl | ||||
|         ) | ||||
|         logging.getLogger('iso8601').setLevel(logging.WARNING) | ||||
|  | ||||
|         if self.options.verbose_level <= 1: | ||||
|             logging.getLogger('requests').setLevel(logging.WARNING) | ||||
|  | ||||
| @@ -262,6 +268,14 @@ class MistralShell(app.App): | ||||
|             default=c.env('OS_CACERT'), | ||||
|             help='Authentication CA Certificate (Env: OS_CACERT)' | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             '--insecure', | ||||
|             action='store_true', | ||||
|             dest='insecure', | ||||
|             default=c.env('MISTRALCLIENT_INSECURE', default=False), | ||||
|             help='Disables SSL/TLS certificate verification ' | ||||
|                  '(Env: MISTRALCLIENT_INSECURE)' | ||||
|         ) | ||||
|         return parser | ||||
|  | ||||
|     def initialize_app(self, argv): | ||||
| @@ -284,16 +298,19 @@ class MistralShell(app.App): | ||||
|         if do_help or ('bash-completion' in argv): | ||||
|             self.options.auth_url = None | ||||
|  | ||||
|         self.client = client.client(mistral_url=self.options.mistral_url, | ||||
|                                     username=self.options.username, | ||||
|                                     api_key=self.options.password, | ||||
|                                     project_name=self.options.tenant_name, | ||||
|                                     auth_url=self.options.auth_url, | ||||
|                                     project_id=self.options.tenant_id, | ||||
|                                     endpoint_type=self.options.endpoint_type, | ||||
|                                     service_type=self.options.service_type, | ||||
|                                     auth_token=self.options.token, | ||||
|                                     cacert=self.options.cacert) | ||||
|         self.client = client.client( | ||||
|             mistral_url=self.options.mistral_url, | ||||
|             username=self.options.username, | ||||
|             api_key=self.options.password, | ||||
|             project_name=self.options.tenant_name, | ||||
|             auth_url=self.options.auth_url, | ||||
|             project_id=self.options.tenant_id, | ||||
|             endpoint_type=self.options.endpoint_type, | ||||
|             service_type=self.options.service_type, | ||||
|             auth_token=self.options.token, | ||||
|             cacert=self.options.cacert, | ||||
|             insecure=self.options.insecure | ||||
|         ) | ||||
|  | ||||
|     def _set_shell_commands(self, cmds_dict): | ||||
|         for k, v in cmds_dict.items(): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jenkins
					Jenkins