text
stringlengths
0
828
self._subscription._wait_result(result)
except Exception as exc:
log.error(""error pausing instance %s: %s"", instance_id, exc)
raise
log.debug('paused instance(instance_id=%s)', instance_id)"
4953,"def restart(self, instance_id):
""""""restarts a paused instance.
:param str instance_id: instance identifier
:return: None
""""""
try:
if not self._paused:
log.debug(""node %s is not paused, can't restart"", instance_id)
return
self._paused = False
result = self._subscription._sms.start_role(
service_name=self._cloud_service._name,
deployment_name=self._cloud_service._name,
role_name=instance_id)
self._subscription._wait_result(result)
except Exception as exc:
log.error('error restarting instance %s: %s', instance_id, exc)
raise
log.debug('restarted instance(instance_id=%s)', instance_id)"
4954,"def start_instance(
self,
key_name,
public_key_path,
private_key_path,
security_group,
flavor,
image,
image_userdata,
location=None,
base_name=None,
username=None,
node_name=None,
host_name=None,
use_public_ips=None,
wait_timeout=None,
use_short_vm_names=None,
n_cloud_services=None,
n_storage_accounts=None,
**kwargs):
""""""Starts a new instance on the cloud using the given properties.
Multiple instances might be started in different threads at the same
time. The implementation should handle any problems regarding this
itself.
:return: str - instance id of the started instance
""""""
if self._start_failed:
raise Exception('start_instance for node %s: failing due to'
' previous errors.' % node_name)
index = None
with self._resource_lock:
# it'd be nice if elasticluster called something like
# init_cluster() with all the args that will be the
# same for every node created. But since it doesn't, handle that on
# first start_instance call.
if not self._cluster_prep_done:
self._times['CLUSTER_START'] = time.time()
self._config.setup(
key_name,
public_key_path,
private_key_path,
security_group,
location,
base_name=base_name,
username=username,
use_public_ips=use_public_ips,
wait_timeout=wait_timeout,
use_short_vm_names=use_short_vm_names,
n_cloud_services=n_cloud_services,
n_storage_accounts=n_storage_accounts,
**kwargs)
# we know we're starting the first node, so create global
# requirements now
self._create_global_reqs()
if self._start_failed:
return None
# this will allow vms to be created
self._times['SETUP_DONE'] = time.time()
self._cluster_prep_done = True
# absolute node index in cluster (0..n-1) determines what
# subscription, cloud service, storage
# account, etc. this VM will use. Create the vm and add it to
# its cloud service, then try to start it.
index = self._n_instances
v_m = AzureVM(
self._config,
index,
flavor=flavor,
image=image,
node_name=node_name,