insights/client/connection.py
def group_systems(self, group_name, systems):
        """
        Adds an array of systems to specified group

        Args:
            group_name: Display name of group
            systems: Array of {'machine_id': machine_id}
        """
        api_group_id = None
        headers = {'Content-Type': 'application/json'}
        group_path = self.api_url + '/v1/groups'
        group_get_path = group_path + ('?display_name=%s' % quote(group_name))

        logger.debug("GET group: %s", group_get_path)
        net_logger.info("GET %s", group_get_path)
        get_group = self.session.get(group_get_path)
        logger.debug("GET group status: %s", get_group.status_code)
        if get_group.status_code == 200:
            api_group_id = get_group.json()['id']

        if get_group.status_code == 404:
            # Group does not exist, POST to create
            logger.debug("POST group")
            data = json.dumps({'display_name': group_name})
            net_logger.info("POST", group_path)
            post_group = self.session.post(group_path,
                                           headers=headers,
                                           data=data)
            logger.debug("POST group status: %s", post_group.status_code)
            logger.debug("POST Group: %s", post_group.json())
            self.handle_fail_rcs(post_group)
            api_group_id = post_group.json()['id']

        logger.debug("PUT group")
        data = json.dumps(systems)
        net_logger.info("PUT %s", group_path + ('/%s/systems' % api_group_id))
        put_group = self.session.put(group_path +
                                     ('/%s/systems' % api_group_id),
                                     headers=headers,
                                     data=data)
        logger.debug("PUT group status: %d", put_group.status_code)
        logger.debug("PUT Group: %s", put_group.json())

        Adds an array of systems to specified group

        Args:
            group_name: Display name of group
            systems: Array of {'machine_id': machine_id}
        
Adds an array of systems to specified group
Adds an array of systems to specified group
def group_systems(self, group_name, systems):
        api_group_id = None
        headers = {'Content-Type': 'application/json'}
        group_path = self.api_url + '/v1/groups'
        group_get_path = group_path + ('?display_name=%s' % quote(group_name))
        logger.debug("GET group: %s", group_get_path)
        net_logger.info("GET %s", group_get_path)
        get_group = self.session.get(group_get_path)
        logger.debug("GET group status: %s", get_group.status_code)
        if get_group.status_code == 200:
            api_group_id = get_group.json()['id']
        if get_group.status_code == 404:
            logger.debug("POST group")
            data = json.dumps({'display_name': group_name})
            net_logger.info("POST", group_path)
            post_group = self.session.post(group_path,
                                           headers=headers,
                                           data=data)
            logger.debug("POST group status: %s", post_group.status_code)
            logger.debug("POST Group: %s", post_group.json())
            self.handle_fail_rcs(post_group)
            api_group_id = post_group.json()['id']
        logger.debug("PUT group")
        data = json.dumps(systems)
        net_logger.info("PUT %s", group_path + ('/%s/systems' % api_group_id))
        put_group = self.session.put(group_path +
                                     ('/%s/systems' % api_group_id),
                                     headers=headers,
                                     data=data)
        logger.debug("PUT group status: %d", put_group.status_code)
        logger.debug("PUT Group: %s", put_group.json())
def group_systems ( self , group_name , systems ) : api_group_id = None headers = { 'Content-Type' : 'application/json' } group_path = self . api_url + '/v1/groups' group_get_path = group_path + ( '?display_name=%s' % quote ( group_name ) ) logger . debug ( "GET group: %s" , group_get_path ) net_logger . info ( "GET %s" , group_get_path ) get_group = self . session . get ( group_get_path ) logger . debug ( "GET group status: %s" , get_group . status_code ) if get_group . status_code == 200 : api_group_id = get_group . json ( ) [ 'id' ] if get_group . status_code == 404 : logger . debug ( "POST group" ) data = json . dumps ( { 'display_name' : group_name } ) net_logger . info ( "POST" , group_path ) post_group = self . session . post ( group_path , headers = headers , data = data ) logger . debug ( "POST group status: %s" , post_group . status_code ) logger . debug ( "POST Group: %s" , post_group . json ( ) ) self . handle_fail_rcs ( post_group ) api_group_id = post_group . json ( ) [ 'id' ] logger . debug ( "PUT group" ) data = json . dumps ( systems ) net_logger . info ( "PUT %s" , group_path + ( '/%s/systems' % api_group_id ) ) put_group = self . session . put ( group_path + ( '/%s/systems' % api_group_id ) , headers = headers , data = data ) logger . debug ( "PUT group status: %d" , put_group . status_code ) logger . debug ( "PUT Group: %s" , put_group . json ( ) )
Adds an array of systems to specified group
Adds an array of systems to specified group
"""
        Adds an array of systems to specified group

        Args:
            group_name: Display name of group
            systems: Array of {'machine_id': machine_id}
        """ # Group does not exist, POST to create
self
group_name
Display name of group
Display name of group
systems
Array of {'machine_id': machine_id}
Array of { ' machine_id ' : machine_id }