def add_node(server_identity)
if server_identity
hash = OpenShift::DataStore.instance.find_district_with_node(server_identity)
unless hash
unless server_identities.has_key?(server_identity)
container = OpenShift::ApplicationContainerProxy.instance(server_identity)
begin
capacity = container.get_capacity
if capacity == 0
container_node_profile = container.get_node_profile
if container_node_profile == node_profile
container.set_district(@uuid, true)
server_identities[server_identity] = {"active" => true}
OpenShift::DataStore.instance.add_district_node(@uuid, server_identity)
else
raise OpenShift::OOException.new("Node with server identity: #{server_identity} is of node profile '#{container_node_profile}' and needs to be '#{node_profile}' to add to district '#{name}'")
end
else
raise OpenShift::OOException.new("Node with server identity: #{server_identity} already has apps on it")
end
rescue OpenShift::NodeException => e
raise OpenShift::OOException.new("Node with server identity: #{server_identity} could not be found")
end
else
raise OpenShift::OOException.new("Node with server identity: #{server_identity} already belongs to district: #{@uuid}")
end
else
raise OpenShift::OOException.new("Node with server identity: #{server_identity} already belongs to another district: #{hash["uuid"]}")
end
else
raise OpenShift::UserException.new("server_identity is required")
end
end