Module Expr Str Import alias Import alias ImportFrom alias identifier ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str ClassDef bases AttributeLoad NameLoad attr body Expr Str FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str NameLoad Return Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad AttributeLoad NameLoad attr attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad TryExcept body With Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr For NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr body Expr Call AttributeLoad NameLoad attr Str NameLoad Assign NameStore BinOpMod NameLoad SubscriptLoad NameLoad Index Num Assign NameStore ListLoad For NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr body Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr SubscriptLoad NameLoad Index Num If CompareIs NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Str SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Continue Expr Call AttributeLoad NameLoad attr Dict Str Str Str Str Str Call AttributeLoad AttributeLoad NameLoad attr attr SubscriptLoad NameLoad Index Num NameLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num NameLoad handlers ExceptHandler type AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr Index Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameLoad For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr NameLoad If CompareEq SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str body If Call NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Str SubscriptLoad NameLoad Index Str Assign NameStore NameLoad orelse Expr Call AttributeLoad NameLoad attr Str SubscriptLoad NameLoad Index Str Expr Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str TryExcept body With Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr SubscriptLoad NameLoad Index Str handlers ExceptHandler type AttributeLoad AttributeLoad NameLoad attr attr body Expr Call AttributeLoad NameLoad attr Str SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Return Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str NameLoad AttributeLoad Call AttributeLoad AttributeLoad NameLoad attr attr SubscriptLoad NameLoad Index Str AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr attr Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr Index Num For NameStore SubscriptLoad NameLoad Index Str body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad With Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad TryExcept body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr handlers ExceptHandler type AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Str Return For NameStore NameLoad body If CompareIn NameLoad AttributeLoad NameLoad attr body Return AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str NameLoad decorator_list decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return BoolOpAnd CompareEq SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str CompareEq SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str CompareEq SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str CompareEq SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str CompareEq SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str decorator_list
N/A N/A 
This module contains the logic for collecting server group information from a
cloud and deploying server groups on a cloud.

Example:
    src_handler = ServerGroupsHandler(src_cloud)
    dst_handler = ServerGroupsHandler(dst_cloud)
    dst_handler.deploy_server_groups(src_handler.get_server_groups())
 N/A copy N/A pprint novaclient exceptions nova_exc cloudferry.lib.base compute cloudferry.lib.os.identity keystone cloudferry.lib.utils log cloudferry.lib.utils proxy_client cloudferry.lib.utils utils N/A LOG N/A N/A log getLogger __name__ N/A SQL_SELECT_ALL_GROUPS SELECT user_id, project_id, uuid, name, id FROM instance_groups WHERE deleted=0; N/A SQL_SELECT_POLICY SELECT policy FROM instance_group_policy WHERE group_id=%s AND deleted=0; N/A SQL_SELECT_GROUP_ID SELECT id FROM instance_groups WHERE uuid='{0}'; N/A SQL_DELETE_MEMBER DELETE FROM instance_group_member WHERE group_id={0}; N/A SQL_DELETE_POLICY DELETE FROM instance_group_member WHERE group_id={0}; N/A SQL_DELETE_GROUP DELETE_FROM instance_groups WHERE uuid='{0}'; N/A SQL_INSERT_GROUP INSERT INTO instance_groups (uuid, name, project_id, user_id, deleted) VALUES('{0}', '{1}', '{2}', '{3}', 0); N/A SQL_INSERT_POLICY INSERT INTO instance_group_policy (group_id, policy, deleted) VALUES({0}, '{1}', 0) ServerGroupsHandler N/A N/A compute Compute N/A N/A 
    Handler for Nova Server/Instance Groups on specified cloud.
    Allows for collection, creation and duplicate detection.
     __init__ N/A N/A self cloud N/A N/A N/A N/A N/A N/A super ServerGroupsHandler self __init__ N/A N/A self cloud cloud N/A N/A self compute N/A N/A N/A self cloud resources N/A N/A utils COMPUTE_RESOURCE N/A N/A self identity N/A N/A N/A self cloud resources N/A N/A utils IDENTITY_RESOURCE N/A N/A self config N/A N/A copy deepcopy N/A N/A self identity config N/A _execute N/A N/A self sql N/A N/A N/A 
        Logs SQL statement and executes using mysql connector from
        COMPUTE_RESOURCE
         N/A N/A N/A LOG debug SQL statement: %s sql N/A N/A N/A N/A N/A self compute mysql_connector execute sql N/A _nova_client N/A N/A self N/A N/A N/A 
        Property that returns COMPUTE_RESOURCE nova client
         N/A N/A N/A self compute nova_client N/A property get_server_groups N/A N/A self N/A N/A N/A 
        Return list of dictionaries containing server group details

        Returns:
            list: Empty if no server groups exist or server groups are not
                supported

            [
                {
                    "user": "<user name>",
                    "tenant": "<tenant name>",
                    "uuid": "<group uuid>",
                    "name": "<group name>",
                    "policies": [<policy_name>, ...]
                }
            ]
         N/A groups N/A N/A N/A N/A N/A N/A proxy_client expect_exception N/A nova_exc NotFound N/A N/A N/A N/A N/A N/A self _nova_client server_groups list N/A row N/A N/A N/A N/A self _execute SQL_SELECT_ALL_GROUPS fetchall N/A N/A N/A N/A LOG debug Resulting row: %s row N/A sql N/A SQL_SELECT_POLICY N/A row N/A 4 N/A policies N/A N/A policy N/A N/A N/A N/A self _execute sql fetchall N/A N/A N/A N/A policies append N/A policy N/A 0 N/A tenant_name N/A N/A N/A self identity try_get_tenant_name_by_id N/A row N/A 1 N/A N/A tenant_name None N/A N/A N/A N/A LOG info Tenant '%s' does not exist on the SRC. Skipping server group '%s'... N/A row N/A 1 N/A row N/A 3 N/A N/A N/A N/A groups append N/A user tenant uuid name policies N/A N/A N/A self identity try_get_username_by_id N/A row N/A 0 tenant_name N/A row N/A 2 N/A row N/A 3 policies N/A N/A N/A N/A nova_exc NotFound N/A N/A N/A N/A LOG info Cloud does not support server_groups N/A groups N/A _delete_server_group N/A N/A self server_group N/A N/A N/A 
        Uses the sql connector to do the following:
            Retrieves the appropriate group id using the groups UUID
            Removes associated members
            Removes associated policies
            Removes group itself
         N/A sql N/A N/A SQL_SELECT_GROUP_ID format N/A server_group N/A uuid N/A gid N/A N/A N/A N/A N/A self _execute sql fetchone N/A 0 N/A sql N/A N/A SQL_DELETE_MEMBER format gid N/A N/A N/A self _execute sql N/A sql N/A N/A SQL_DELETE_POLICY format gid N/A N/A N/A self _execute sql N/A sql N/A N/A SQL_DELETE_GROUP format N/A server_group N/A uuid N/A N/A N/A self _execute sql N/A deploy_server_groups N/A N/A self src_groups N/A N/A N/A 
        For each server groups in source cloud, UUID is checked for existence
        in destination cloud.
        If not existing the server group is created.
        If UUID matches a comparison is made and if there is a difference the
        server group is deleted and recreated.
        If UUID matches a comparison is made and there is no differences the
        group is skipped.
         N/A dst_groups N/A N/A self get_server_groups N/A src_group src_groups N/A N/A N/A N/A LOG debug Source HOST server_groups: %s N/A N/A pprint pformat src_group N/A dst_exists False N/A dst_group dst_groups N/A N/A N/A N/A LOG debug Destination HOST server_groups: %s N/A N/A pprint pformat dst_group N/A N/A N/A src_group N/A uuid N/A dst_group N/A uuid N/A N/A N/A _compare_groups src_group dst_group N/A N/A N/A N/A LOG info skipping matching server_group in destination: %s N/A src_group N/A name N/A dst_exists True N/A N/A N/A N/A LOG info deleting server_group collision in destination: %s N/A dst_group N/A name N/A N/A N/A self _delete_server_group dst_group N/A N/A dst_exists N/A N/A N/A N/A self _deploy_server_group src_group N/A _deploy_server_group N/A N/A self server_group N/A N/A N/A 
        Uses the sql connector to do the following:
            Inserts specified uuid, name, tenant uuid and user uuid into
            destination cloud.
            Retrieves internally incremented group id
            Inserts associated policies using group id

         N/A N/A N/A LOG info Deploying server_group for tenant %s to destination: %s N/A server_group N/A tenant N/A server_group N/A name N/A N/A N/A N/A N/A proxy_client expect_exception N/A N/A keystone ks_exceptions NotFound N/A N/A tenant_id N/A N/A N/A self identity get_tenant_id_by_name N/A server_group N/A tenant N/A N/A N/A N/A N/A keystone ks_exceptions NotFound N/A N/A N/A N/A LOG info Tenant '%s' does not exist on DST. Skipping server group '%s' with id='%s'... N/A server_group N/A tenant N/A server_group N/A name N/A server_group N/A uuid N/A N/A sql N/A N/A SQL_INSERT_GROUP format N/A server_group N/A uuid N/A server_group N/A name tenant_id N/A N/A N/A N/A self identity try_get_user_by_name N/A server_group N/A user N/A N/A N/A self config cloud user id N/A N/A N/A self _execute sql N/A sql N/A N/A SQL_SELECT_GROUP_ID format N/A server_group N/A uuid N/A gid N/A N/A N/A N/A N/A self _execute sql fetchone N/A 0 N/A policy N/A server_group N/A policies N/A N/A sql N/A N/A SQL_INSERT_POLICY format gid policy N/A N/A N/A self _execute sql N/A server_group N/A get_server_group_id_by_vm N/A N/A self instance_id instance_tenant N/A N/A N/A 
        Get Nova Server Group by it's member

        :param instance_id: VM's ID
        :param instance_tenant: VM's tenant name

        :return str: Nova Server Group ID
         N/A client_config N/A N/A copy deepcopy N/A self config N/A N/A N/A client_config cloud tenant instance_tenant N/A N/A N/A keystone AddAdminUserToNonAdminTenant N/A N/A self identity keystone_client N/A N/A client_config cloud user instance_tenant N/A N/A nclient N/A N/A N/A self compute get_client client_config N/A N/A N/A server_group_list N/A N/A N/A nclient server_groups list N/A N/A N/A N/A nova_exc NotFound N/A N/A N/A N/A LOG info Cloud does not support server_groups N/A N/A server_group server_group_list N/A N/A N/A instance_id N/A server_group members N/A N/A N/A server_group id N/A N/A N/A LOG debug Instance '%s' is not a member of any server group... instance_id N/A N/A _compare_groups N/A N/A group_a group_b N/A N/A N/A 
    Compares server group_a with server_group b

    Returns:
        bool: True if specified values are equal, otherwise false
     N/A N/A N/A N/A group_a N/A policies N/A group_b N/A policies N/A N/A group_a N/A tenant N/A group_b N/A tenant N/A N/A group_a N/A name N/A group_b N/A name N/A N/A group_a N/A user N/A group_b N/A user N/A N/A group_a N/A policies N/A group_b N/A policies N/A