text stringlengths 0 828 |
|---|
self.log_feature_error(feature, str(e)) |
# any error in a feature should fail immediately - unless it occurred |
# from the remove() method in which case continue the rest of the |
# feature removal from there |
if error is not None and raise_exception: |
exception_msg = ""%s action failed for feature %s: %s"" % (action, feature, error) |
if self.phase == PHASE.REMOVE: |
raise FormulaException(exception_msg) |
else: |
raise SprinterException(exception_msg) |
return error" |
1395,"def _specialize(self, reconfigure=False): |
"""""" Add variables and specialize contexts """""" |
# add in the 'root_dir' directories to the context dictionaries |
for manifest in [self.source, self.target]: |
context_dict = {} |
if manifest: |
for s in manifest.formula_sections(): |
context_dict[""%s:root_dir"" % s] = self.directory.install_directory(s) |
context_dict['config:root_dir'] = self.directory.root_dir |
context_dict['config:node'] = system.NODE |
manifest.add_additional_context(context_dict) |
self._validate_manifest() |
for feature in self.features.run_order: |
if not reconfigure: |
self.run_action(feature, 'resolve') |
# if a target doesn't exist, no need to prompt. |
instance = self.features[feature] |
if instance.target: |
self.run_action(feature, 'prompt')" |
1396,"def _copy_source_to_target(self): |
"""""" copy source user configuration to target """""" |
if self.source and self.target: |
for k, v in self.source.items('config'): |
# always have source override target. |
self.target.set_input(k, v)" |
1397,"def grab_inputs(self, reconfigure=False): |
"""""" Resolve the source and target config section """""" |
self._copy_source_to_target() |
if self.target: |
self.target.grab_inputs(force=reconfigure)" |
1398,"def connect(host, username, password, port=443, verify=False, debug=False): |
''' |
Connect to a vCenter via the API |
:param host: Hostname or IP of the vCenter |
:type host: str or unicode |
:param username: Username |
:type user: str or unicode |
:param password: Password |
:type user: str or unicode |
:param port: Port on which the vCenter API is running (default: 443) |
:type port: int |
:param verify: Whether to verify SSL certs upon connection (default: False) |
:type verify: bool |
:param debug: Debug option (default: False) |
:type debug: bool |
:return: Content |
:rtype: vim.ServiceInstanceContent |
''' |
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) |
if not verify: |
# Disable warnings about unsigned certificates |
context.verify_mode = ssl.CERT_NONE |
requests.packages.urllib3.disable_warnings() |
try: |
si = SmartConnect( |
host=host, |
user=username, |
pwd=password, |
port=port, |
sslContext=context |
) |
# Register auto disconnect |
atexit.register(Disconnect, si) |
# Return content |
return si.RetrieveContent() |
except IOError as e: |
print('I/O error({0}): {1}'.format(e.errno, e.strerror)) |
except vmodl.MethodFault as e: |
print('Connection could not be established', file=sys.stderr) |
raise ConnectionError('Connection could not be established') |
print('Caught vmodl fault: ', e.msg, file=sys.stderr) |
if debug: |
traceback.print_exc() |
except Exception as e: |
print('Caught exception:', str(e), file=sys.stderr) |
if debug: |
traceback.print_exc()" |
1399,"def parse(ignore_file='.gitignore', git_dir='.git', additional_files=(), |
global_=True, root_dir=None, defaults=True): |
"""""" |
Collects a list of all ignore patterns configured in a local Git repository |
as specified in the Git documentation. See |
ERROR: type should be string, got " https://git-scm.com/docs/gitignore#_description" |
The returned #IgnoreListCollection is guaranteed to contain at least one |
#IgnoreList with #IgnoreList.root pointing to the specified *root_dir* (which |
defaults to the parent directory of *git_dir*) as the first element. |
"""""" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.