(self, federation)
return FederationID(new_federation.uuid)
Create a new federation.

        :param federation: a federation within the request body.
Create a new federation.
Create a new federation .
def post(self, federation):
        """Create a new federation.

        :param federation: a federation within the request body.
        """
        context = pecan.request.context
        policy.enforce(context, 'federation:create',
                       action='federation:create')

        federation_dict = federation.as_dict()

        # Validate `hostcluster_id`
        hostcluster_id = federation_dict.get('hostcluster_id')
        attr_validator.validate_federation_hostcluster(hostcluster_id)

        # Validate `properties` dict.
        properties_dict = federation_dict.get('properties')
        attr_validator.validate_federation_properties(properties_dict)

        federation_dict['project_id'] = context.project_id

        # If no name is specified, generate a random human-readable name
        name = (federation_dict.get('name') or
                self._generate_name_for_federation(context))
        federation_dict['name'] = name

        new_federation = objects.Federation(context, **federation_dict)
        new_federation.uuid = uuid.uuid4()

        # TODO(clenimar): remove hard-coded `create_timeout`.
        pecan.request.rpcapi.federation_create_async(new_federation,
                                                     create_timeout=15)

        return FederationID(new_federation.uuid)
def post ( self , federation ) : context = pecan . request . context policy . enforce ( context , 'federation:create' , action = 'federation:create' ) federation_dict = federation . as_dict ( ) # Validate `hostcluster_id` hostcluster_id = federation_dict . get ( 'hostcluster_id' ) attr_validator . validate_federation_hostcluster ( hostcluster_id ) # Validate `properties` dict. properties_dict = federation_dict . get ( 'properties' ) attr_validator . validate_federation_properties ( properties_dict ) federation_dict [ 'project_id' ] = context . project_id # If no name is specified, generate a random human-readable name name = ( federation_dict . get ( 'name' ) or self . _generate_name_for_federation ( context ) ) federation_dict [ 'name' ] = name new_federation = objects . Federation ( context , * * federation_dict ) new_federation . uuid = uuid . uuid4 ( ) # TODO(clenimar): remove hard-coded `create_timeout`. pecan . request . rpcapi . federation_create_async ( new_federation , create_timeout = 15 ) return FederationID ( new_federation . uuid )