AppController/djinn.rb
# This SOAP-exposed method dynamically scales up a currently running
# AppScale deployment. For virtualized clusters, this assumes the
# user has given us a list of IP addresses where AppScale has been
# installed to, and for cloud deployments, we assume that the user
# wants to use the same credentials as for their current deployment.
# Args:
#   ips_hash: A Hash that maps roles (e.g., appengine, database) to the
#     IP address (in virtualized deployments) or unique identifier (in
#     cloud deployments) that should run that role.
#   secret: A String password that is used to authenticate the request
#     to add nodes to the deployment.
# Returns:
#   BAD_SECRET_MSG: If the secret given does not match the secret for
#     this AppScale deployment.
#   BAD_INPUT_MSG: If ips_hash was not a Hash.
#   Otherwise, returns a Hash that maps IP addresses to the roles that
#     will be hosted on them (the inverse of ips_hash).
This SOAP-exposed method dynamically scales up a currently running
AppScale deployment. For virtualized clusters, this assumes the
user has given us a list of IP addresses where AppScale has been
installed to, and for cloud deployments, we assume that the user
wants to use the same credentials as for their current deployment.
Args:
ips_hash: A Hash that maps roles  to the
IP address (in virtualized deployments) or unique identifier (in
cloud deployments) that should run that role.
secret: A String password that is used to authenticate the request
to add nodes to the deployment.
Returns:
BAD_SECRET_MSG: If the secret given does not match the secret for
this AppScale deployment.
BAD_INPUT_MSG: If ips_hash was not a Hash.
Otherwise, returns a Hash that maps IP addresses to the roles that
will be hosted on them (the inverse of ips_hash).
This SOAP - exposed method dynamically scales up a currently running AppScale deployment . For virtualized clusters this assumes the user has given us a list of IP addresses where AppScale has been installed to and for cloud deployments we assume that the user wants to use the same credentials as for their current deployment . Args : ips_hash : A Hash that maps roles to the IP address ( in virtualized deployments ) or unique identifier ( in cloud deployments ) that should run that role . secret : A String password that is used to authenticate the request to add nodes to the deployment . Returns : BAD_SECRET_MSG : If the secret given does not match the secret for this AppScale deployment . BAD_INPUT_MSG : If ips_hash was not a Hash . Otherwise returns a Hash that maps IP addresses to the roles that will be hosted on them ( the inverse of ips_hash ) .
def start_roles_on_nodes(ips_hash, secret)
    return BAD_SECRET_MSG unless valid_secret?(secret)
    ips_hash = JSON.load(ips_hash)
    if ips_hash.class != Hash
      Djinn.log_warn("Was expecting ips_hash to be a Hash, not " +
        "a #{ips_hash.class}")
      return BAD_INPUT_MSG
    end
    Djinn.log_info("Received a request to start additional roles on " +
      "new machines, with the following placement strategy: " +
      "#{ips_hash.inspect}")
    ips_to_roles = {}
    ips_hash.each { |role, ip_or_ips|
      if ip_or_ips.class == String
        ips = [ip_or_ips]  
      else
        ips = ip_or_ips  
      end
      ips.each { |ip|
        if ips_to_roles[ip].nil?
          ips_to_roles[ip] = []
        end
        ips_to_roles[ip] << role
      }
    }
    Thread.new {
      if is_cloud?
        start_new_roles_on_nodes_in_cloud(ips_to_roles)
      else
        start_new_roles_on_nodes_in_xen(ips_to_roles)
      end
    }
    return ips_to_roles
  end
def start_roles_on_nodes ( ips_hash , secret ) return BAD_SECRET_MSG unless valid_secret? ( secret ) ips_hash = JSON . load ( ips_hash ) if ips_hash . class != Hash Djinn . log_warn ( "Was expecting ips_hash to be a Hash, not " + "a #{ips_hash.class}" ) return BAD_INPUT_MSG end Djinn . log_info ( "Received a request to start additional roles on " + "new machines, with the following placement strategy: " + "#{ips_hash.inspect}" ) ips_to_roles = { } ips_hash . each { | role , ip_or_ips | if ip_or_ips . class == String ips = [ ip_or_ips ] else ips = ip_or_ips end ips . each { | ip | if ips_to_roles [ ip ] . nil? ips_to_roles [ ip ] = [ ] end ips_to_roles [ ip ] << role } } Thread . new { if is_cloud? start_new_roles_on_nodes_in_cloud ( ips_to_roles ) else start_new_roles_on_nodes_in_xen ( ips_to_roles ) end } return ips_to_roles end
This SOAP-exposed method dynamically scales up a currently running
AppScale deployment.
This SOAP - exposed method dynamically scales up a currently running AppScale deployment .
# ips_hash maps roles to IPs, but the internal format here maps # IPs to roles, so convert to the right format # just one IP # a list of IPs
ips_hash
<not_specific>
secret
<not_specific>