Beispiel #1
0
def gateway_directives_from_volume_info( volume_info, local_hostname, slice_secret ):
   """
   Extract gateway directives from an observer's description of the volume for this host.
   """
   
   gateway_directives = {
      "UG": {},
      "RG": {},
      "AG": {}
   }
   
   
   volume_name = volume_info[ observer_cred.OPENCLOUD_VOLUME_NAME ]
   gateway_name_prefix = volume_info[ observer_cred.OPENCLOUD_SLICE_GATEWAY_NAME_PREFIX ]
   
   # get what we need...
   try:
         
      RG_hostname = local_hostname
      AG_hostname = local_hostname 
      
      # global hostnames (i.e. multiple instantiations of the same gateway) override local hostnames.
      if volume_info[ observer_cred.OPENCLOUD_SLICE_AG_GLOBAL_HOSTNAME ] is not None:
         AG_hostname = volume_info[ observer_cred.OPENCLOUD_SLICE_AG_GLOBAL_HOSTNAME ]
      
      if volume_info[ observer_cred.OPENCLOUD_SLICE_RG_GLOBAL_HOSTNAME ] is not None:
         RG_hostname = volume_info[ observer_cred.OPENCLOUD_SLICE_RG_GLOBAL_HOSTNAME ]
      
      gateway_directives["UG"]["instantiate"]   = volume_info[ observer_cred.OPENCLOUD_SLICE_INSTANTIATE_UG ]
      gateway_directives["UG"]["run"]           = volume_info[ observer_cred.OPENCLOUD_SLICE_RUN_UG ]
      gateway_directives["UG"]["port"]          = volume_info[ observer_cred.OPENCLOUD_SLICE_UG_PORT ]
      gateway_directives["UG"]["closure"]       = volume_info[ observer_cred.OPENCLOUD_SLICE_UG_CLOSURE ]
      gateway_directives["UG"]["name"]          = provisioning.make_gateway_name( gateway_name_prefix, "UG", volume_name, local_hostname )
      gateway_directives["UG"]["key_password"]  = provisioning.make_gateway_private_key_password( gateway_directives["UG"]["name"], slice_secret )
      gateway_directives["UG"]["hostname"]      = local_hostname
      
      gateway_directives["RG"]["instantiate"]   = volume_info[ observer_cred.OPENCLOUD_SLICE_INSTANTIATE_RG ]
      gateway_directives["RG"]["run"]           = volume_info[ observer_cred.OPENCLOUD_SLICE_RUN_RG ]
      gateway_directives["RG"]["port"]          = volume_info[ observer_cred.OPENCLOUD_SLICE_RG_PORT ]
      gateway_directives["RG"]["closure"]       = volume_info[ observer_cred.OPENCLOUD_SLICE_RG_CLOSURE ]
      gateway_directives["RG"]["name"]          = provisioning.make_gateway_name( gateway_name_prefix, "RG", volume_name, RG_hostname )
      gateway_directives["RG"]["key_password"]  = provisioning.make_gateway_private_key_password( gateway_directives["RG"]["name"], slice_secret )
      gateway_directives["RG"]["hostname"]      = RG_hostname
      
      gateway_directives["AG"]["instantiate"]   = volume_info[ observer_cred.OPENCLOUD_SLICE_INSTANTIATE_AG ]
      gateway_directives["AG"]["run"]           = volume_info[ observer_cred.OPENCLOUD_SLICE_RUN_AG ]
      gateway_directives["AG"]["port"]          = volume_info[ observer_cred.OPENCLOUD_SLICE_AG_PORT ]
      gateway_directives["AG"]["closure"]       = volume_info[ observer_cred.OPENCLOUD_SLICE_AG_CLOSURE ]
      gateway_directives["AG"]["name"]          = provisioning.make_gateway_name( gateway_name_prefix, "AG", volume_name, AG_hostname )
      gateway_directives["AG"]["key_password"]  = provisioning.make_gateway_private_key_password( gateway_directives["AG"]["name"], slice_secret )
      gateway_directives["AG"]["hostname"]      = AG_hostname
      
   except Exception, e:
      log.exception(e)
      log.error("Invalid configuration for Volume %s" % volume_name)
      return None 
Beispiel #2
0
def setup_global_RG(principal_id,
                    volume_name,
                    gateway_name_prefix,
                    slice_secret,
                    RG_port,
                    RG_closure,
                    global_hostname="localhost"):
    """
    Create/read an RG that will run on each host, on a particular global hostname.
    """

    client = connect_syndicate()

    RG_name = syndicate_provisioning.make_gateway_name(gateway_name_prefix,
                                                       "RG", volume_name,
                                                       global_hostname)
    RG_key_password = syndicate_provisioning.make_gateway_private_key_password(
        RG_name, slice_secret)

    try:
        rc = syndicate_provisioning.ensure_RG_exists(client,
                                                     principal_id,
                                                     volume_name,
                                                     RG_name,
                                                     global_hostname,
                                                     RG_port,
                                                     RG_key_password,
                                                     closure=RG_closure)
    except Exception, e:
        logger.exception(e)
        return False
Beispiel #3
0
def setup_global_RG( principal_id, volume_name, gateway_name_prefix, slice_secret, RG_port, RG_closure, global_hostname="localhost" ):
    """
    Create/read an RG that will run on each host, on a particular global hostname.
    """
    
    client = connect_syndicate()
   
    RG_name = syndicate_provisioning.make_gateway_name( gateway_name_prefix, "RG", volume_name, global_hostname )
    RG_key_password = syndicate_provisioning.make_gateway_private_key_password( RG_name, slice_secret )

    try:
       rc = syndicate_provisioning.ensure_RG_exists( client, principal_id, volume_name, RG_name, global_hostname, RG_port, RG_key_password, closure=RG_closure )
    except Exception, e:
       logger.exception(e)
       return False 
Beispiel #4
0
    """
    client = connect_syndicate()

    try:
        rc = ensure_volume_access_right_exists(user_email, volume_name, caps)
        assert rc is True, "Failed to create access right for %s in %s" % (
            user_email, volume_name)

    except Exception, e:
        logger.exception(e)
        return False

    RG_name = syndicate_provisioning.make_gateway_name("OpenCloud", "RG",
                                                       volume_name,
                                                       "localhost")
    RG_key_password = syndicate_provisioning.make_gateway_private_key_password(
        RG_name, slice_secret)

    try:
        rc = syndicate_provisioning.ensure_RG_exists(client,
                                                     user_email,
                                                     volume_name,
                                                     RG_name,
                                                     "localhost",
                                                     RG_port,
                                                     RG_key_password,
                                                     closure=RG_closure)
    except Exception, e:
        logger.exception(e)
        return False

    return True
Beispiel #5
0
    Set up the Volume to allow the slice to provision UGs in it, and to fire up RGs.
       * create the Volume Access Right for the user, so (s)he can create Gateways.
       * provision a single Replica Gateway, serving on localhost.
    """
    client = connect_syndicate()
    
    try:
       rc = ensure_volume_access_right_exists( user_email, volume_name, caps )
       assert rc is True, "Failed to create access right for %s in %s" % (user_email, volume_name)
       
    except Exception, e:
       logger.exception(e)
       return False
    
    RG_name = syndicate_provisioning.make_gateway_name( "OpenCloud", "RG", volume_name, "localhost" )
    RG_key_password = syndicate_provisioning.make_gateway_private_key_password( RG_name, slice_secret )
    
    try:
       rc = syndicate_provisioning.ensure_RG_exists( client, user_email, volume_name, RG_name, "localhost", RG_port, RG_key_password, closure=RG_closure )
    except Exception, e:
       logger.exception(e)
       return False
    
    return True
       

#-------------------------------
def teardown_volume_access( user_email, volume_name ):
    """
    Revoke access to a Volume for a User.
      * remove the user's Volume Access Right