def Run(self, args): """Allows user to select configuration, and initialize it.""" if args.obsolete_project_arg: raise c_exc.InvalidArgumentException( args.obsolete_project_arg, '`gcloud init` has changed and no longer takes a PROJECT argument. ' 'Please use `gcloud source repos clone` to clone this ' 'project\'s source repositories.') log.status.write('Welcome! This command will take you through ' 'the configuration of gcloud.\n\n') if properties.VALUES.core.disable_prompts.GetBool(): raise c_exc.InvalidArgumentException( 'disable_prompts/--quiet', 'gcloud init command cannot run with disabled prompts.') configuration_name = self._PickConfiguration() if not configuration_name: return log.status.write('Your current configuration has been set to: [{0}]\n\n' .format(configuration_name)) if not args.skip_diagnostics: log.status.write('You can skip diagnostics next time by using the ' 'following flag:\n') log.status.write(' gcloud init --skip-diagnostics\n\n') network_passed = network_diagnostics.NetworkDiagnostic().RunChecks() if not network_passed: if not console_io.PromptContinue( message='Network errors detected.', prompt_string='Would you like to continue anyway', default=False): log.status.write('You can re-run diagnostics with the following ' 'command:\n') log.status.write(' gcloud info --run-diagnostics\n\n') return # User project quota is now the global default, but this command calls # legacy APIs where it should be disabled. It must happen after the config # settings are persisted so this temporary value doesn't get persisted as # well. base.DisableUserProjectQuota() if not self._PickAccount(args.console_only, preselected=args.account): return if not self._PickProject(preselected=args.project): return self._PickDefaultRegionAndZone() self._CreateBotoConfig() self._Summarize(configuration_name)
def testNetworkIssuesMaxFixRetriesMet(self): self.run_check_mock.return_value = (self._FAIL_RESULT, self.fixer_mock) self.fixer_mock.return_value = True self.assertFalse(network_diagnostics.NetworkDiagnostic().RunChecks()) max_retries = network_diagnostics.NetworkDiagnostic._MAX_RETRIES self.assertEqual(max_retries + 1, self.run_check_mock.call_count) self.assertEqual(max_retries, self.fixer_mock.call_count) self.AssertErrContains('Unable to fix Network diagnostic failure after 5 ' 'attempts.') self.AssertErrContains( 'ERROR: Network diagnostic failed (0/1 checks passed).')
def testNetworkIssuesProxyChangesMadeIssuesFixed(self): self.run_check_mock.side_effect = [ (self._FAIL_RESULT, self.fixer_mock), (check_base.Result(passed=True), None) ] self.fixer_mock.return_value = True self.assertTrue(network_diagnostics.NetworkDiagnostic().RunChecks()) self.assertEqual(2, self.run_check_mock.call_count) self.assertEqual(1, self.fixer_mock.call_count) self.AssertErrContains( 'Network diagnostic passed (1/1 checks passed).')
def Run(self, args): if args.run_diagnostics: network_diagnostics.NetworkDiagnostic().RunChecks() return holder = info_holder.InfoHolder() python_version = platforms.PythonVersion() if not python_version.IsSupported(): log.warn(( 'Only Python version {0} is supported for the Cloud SDK. Many ' 'commands will work with a previous version, but not all.' ).format(python_version.MinSupportedVersionString())) return holder
def Run(self, args): """Allows user to select configuration, and initialize it.""" if args.obsolete_project_arg: raise c_exc.InvalidArgumentException( args.obsolete_project_arg, '`gcloud init` has changed and no longer takes a PROJECT argument. ' 'Please use `gcloud source repos clone` to clone this ' 'project\'s source repositories.') log.status.write('Welcome! This command will take you through ' 'the configuration of gcloud.\n\n') if properties.VALUES.core.disable_prompts.GetBool(): raise c_exc.InvalidArgumentException( 'disable_prompts/--quiet', 'gcloud init command cannot run with disabled prompts.') configuration_name = self._PickConfiguration() if not configuration_name: return log.status.write( 'Your current configuration has been set to: [{0}]\n\n'.format( configuration_name)) if not network_diagnostics.NetworkDiagnostic().RunChecks(): return if not self._PickAccount(args.console_only, preselected=args.account): return project_id = self._PickProject(preselected=args.project) if not project_id: return self._PickDefaultRegionAndZone() self._CreateBotoConfig() self._Summarize(configuration_name)
def _RunDiagnostics(ignore_hidden_property_whitelist): network_diagnostics.NetworkDiagnostic().RunChecks() property_diagnostics.PropertyDiagnostic(ignore_hidden_property_whitelist)\ .RunChecks()
def _RunDiagnostics(): network_diagnostics.NetworkDiagnostic().RunChecks() property_diagnostics.PropertyDiagnostic().RunChecks()
def _RunDiagnostics(ignore_hidden_property_allowlist): passed_network = network_diagnostics.NetworkDiagnostic().RunChecks() passed_props = property_diagnostics.PropertyDiagnostic( ignore_hidden_property_allowlist).RunChecks() return passed_network and passed_props