Remove usage of remote from HDP Instance constructor

When Sahara is run in distributed mode, the Instance object is used in
sahara-api context. You can see the full stack trace in the bug description.
Here it is in the simplified form:
  * User requests HDP cluster scaling
  * Scaling validation (in HDP plugin)
  * HDP Instance objects are constructed
  * Sahara's instance.remote() is called inside the constructor

The remote is unavalable in sahara-api context and that causes the issue.
Moving invokation of instance.remote() out of constructor fixes it.

Change-Id: I0d09c7a19e4df7fce948994fb21028fe147d2782
Closes-bug: #1325989
This commit is contained in:
Dmitry Mescheryakov 2014-06-03 17:37:13 +04:00
parent 1983bc1103
commit 049e64a440

View File

@ -175,10 +175,7 @@ class ClusterSpec():
node_group.components = ng.node_processes[:] node_group.components = ng.node_processes[:]
node_group.ng_storage_paths = ng.storage_paths() node_group.ng_storage_paths = ng.storage_paths()
for instance in ng.instances: for instance in ng.instances:
node_group.instances.add(Instance(instance.fqdn(), node_group.instances.add(Instance(instance))
instance.management_ip,
instance.internal_ip,
instance.remote()))
self.node_groups[node_group.name] = node_group self.node_groups[node_group.name] = node_group
def _determine_deployed_services(self, cluster): def _determine_deployed_services(self, cluster):
@ -249,17 +246,17 @@ class User():
class Instance(): class Instance():
def __init__(self, fqdn, management_ip, internal_ip, remote): def __init__(self, sahara_instance):
self.inst_fqdn = fqdn self.inst_fqdn = sahara_instance.fqdn()
self.management_ip = management_ip self.management_ip = sahara_instance.management_ip
self.internal_ip = internal_ip self.internal_ip = sahara_instance.internal_ip
self.inst_remote = remote self.sahara_instance = sahara_instance
def fqdn(self): def fqdn(self):
return self.inst_fqdn return self.inst_fqdn
def remote(self): def remote(self):
return self.inst_remote return self.sahara_instance.remote()
def __hash__(self): def __hash__(self):
return hash(self.fqdn()) return hash(self.fqdn())