text
stringlengths 0
828
|
---|
host_name=host_name, |
image_userdata=image_userdata) |
v_m._cloud_service._instances[v_m._qualified_name] = v_m |
try: |
v_m._cloud_service._start_vm(v_m) |
except Exception: |
log.error(traceback.format_exc()) |
log.error(""setting start_failed flag. Will not "" |
""try to start further nodes."") |
self._start_failed = True |
return None |
log.debug('started instance %s', v_m._qualified_name) |
if index == self._config._n_vms_requested - 1: |
# all nodes started |
self._times['NODES_STARTED'] = time.time() |
self._times['SETUP_ELAPSED'] = self._times['SETUP_DONE'] - \ |
self._times['CLUSTER_START'] |
self._times['NODE_START_ELAPSED'] = self._times['NODES_STARTED']\ |
- self._times['SETUP_DONE'] |
self._times['CLUSTER_START_ELAPSED'] = \ |
self._times['SETUP_ELAPSED'] + \ |
self._times['NODE_START_ELAPSED'] |
log.debug(""setup time: %.1f sec"", self._times['SETUP_ELAPSED']) |
log.debug(""node start time: %.1f sec (%.1f sec per vm)"", |
self._times['NODE_START_ELAPSED'], |
self._times['NODE_START_ELAPSED'] / |
self._config._n_vms_requested) |
log.debug(""total cluster start time: %.1f sec (%.1f sec per vm)"", |
self._times['CLUSTER_START_ELAPSED'], |
self._times['CLUSTER_START_ELAPSED'] / |
self._config._n_vms_requested) |
# pause here to try to address the fact that Ansible setup fails |
# more often on the first try than subsequent tries |
time.sleep(_retry_sleep()) |
self._save_or_update() # store our state |
return v_m._qualified_name" |
4955,"def stop_instance(self, instance_id): |
""""""Stops the instance gracefully. |
:param str instance_id: instance identifier |
:return: None |
"""""" |
self._restore_from_storage(instance_id) |
if self._start_failed: |
raise Exception('stop_instance for node %s: failing due to' |
' previous errors.' % instance_id) |
with self._resource_lock: |
try: |
v_m = self._qualified_name_to_vm(instance_id) |
if not v_m: |
err = ""stop_instance: can't find instance %s"" % instance_id |
log.error(err) |
raise Exception(err) |
v_m._cloud_service._stop_vm(v_m) |
# note: self._n_instances is a derived property, doesn't need |
# to be updated |
if self._n_instances == 0: |
log.debug('last instance deleted, destroying ' |
'global resources') |
self._delete_global_reqs() |
self._delete_cloud_provider_storage() |
except Exception as exc: |
log.error(traceback.format_exc()) |
log.error(""error stopping instance %s: %s"", instance_id, exc) |
raise |
log.debug('stopped instance %s', instance_id)" |
4956,"def get_ips(self, instance_id): |
""""""Retrieves the private and public ip addresses for a given instance. |
Note: Azure normally provides access to vms from a shared load |
balancer IP and |
mapping of ssh ports on the vms. So by default, the Azure provider |
returns strings |
of the form 'ip:port'. However, 'stock' elasticluster and ansible |
don't support this, |
so _use_public_ips uses Azure PublicIPs to expose each vm on the |
internet with its own IP |
and using the standard SSH port. |
:return: list (IPs) |
"""""" |
self._restore_from_storage(instance_id) |
if self._start_failed: |
raise Exception('get_ips for node %s: failing due to' |
' previous errors.' % instance_id) |
ret = list() |
v_m = self._qualified_name_to_vm(instance_id) |
if not v_m: |
raise Exception(""Can't find instance_id %s"" % instance_id) |
if self._config._use_public_ips: |
ret.append(v_m._public_ip) |
else: |
ret.append(""%s:%s"" % (v_m._public_ip, v_m._ssh_port)) |
log.debug('get_ips (instance %s) returning %s', |
instance_id, ', '.join(ret)) |
Subsets and Splits