Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Filter is not valid for API" while creating a Tier #40

Closed
rmjstn opened this issue Feb 23, 2021 · 1 comment
Closed

"Filter is not valid for API" while creating a Tier #40

rmjstn opened this issue Feb 23, 2021 · 1 comment

Comments

@rmjstn
Copy link

rmjstn commented Feb 23, 2021

Hello,

I tired with master and vrni_6_1_0 branches.
VRNI version 6.1.0.1610450081.

I've got an error when I want to create a Tier with a particular filter.

Creating a filter with a selection on the VM names works :

tier=swagger_client.Tier()
tier.entity_type=swagger_client.AllEntityType.TIER
tier.name="Virtual Machines" 
group_membership_criteria=swagger_client.GroupMembershipCriteria()
group_membership_criteria.membership_type="SearchMembershipCriteria"
group_membership_criteria.ip_address_membership_criteria=None
tmp_list=[]
for virtual_machine in virtual_machine_list:
    tmp_list.append(virtual_machine.get_name())
filter="Name in (" + ', '.join("'{0}'".format(x) for x in tmp_list) + ")"
group_membership_criteria.search_membership_criteria = swagger_client.SearchMembershipCriteria(entity_type=swagger_client.AllEntityType.VIRTUALMACHINE, filter=filter)
tier.group_membership_criteria = [group_membership_criteria]
self.__application_api.add_tier(application.entity_id, tier)

Creating a filter with a selection on an Application name doesn't works (I want include another application as a Tier) :

print(application_solution)
tier=swagger_client.Tier()
tier.entity_type=swagger_client.AllEntityType.TIER
tier.name="Application " + application_solution["name"]
group_membership_criteria=swagger_client.GroupMembershipCriteria()
group_membership_criteria.membership_type="SearchMembershipCriteria"
group_membership_criteria.ip_address_membership_criteria=None
filter="application = 'Gitlab'"
group_membership_criteria.search_membership_criteria = swagger_client.SearchMembershipCriteria(entity_type=swagger_client.AllEntityType.BASEVIRTUALMACHINE, filter=filter)
tier.group_membership_criteria = [group_membership_criteria]
self.__application_api.add_tier(application.entity_id, tier)

I've got this error :

swagger_client.rest.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Server': 'nginx', 'Date': 'Tue, 23 Feb 2021 18:18:55 GMT', 'Content-Type': 'application/json', 'Content-Length': '65', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'})
HTTP response body: {"code":400,"message":"Filter is not valid for API","details":[]}	

If I create the same filter via the UI and print the Tier, I've got this :

{'application': {'entity_id': '10000:561:3585505518670791468',
                        'entity_type': 'Application'},
 'entity_id': '10000:562:156772085204643187',
 'entity_type': 'Tier',
 'group_membership_criteria': [{'ip_address_membership_criteria': None,
                                'membership_type': 'SearchMembershipCriteria',
                                'search_membership_criteria': {'entity_type': 'BaseVirtualMachine',
                                                               'filter': 'application '
                                                                         '= '
                                                                         "'Gitlab'"}}],
 'name': 'Application *******'}		

If I print the Tier I've build by code I've got this :

{'application': None,
 'entity_id': None,
 'entity_type': 'Tier',
 'group_membership_criteria': [{'ip_address_membership_criteria': None,
                                'membership_type': 'SearchMembershipCriteria',
                                'search_membership_criteria': {'entity_type': 'BaseVirtualMachine',
                                                               'filter': 'application '
                                                                         '= '
                                                                         "'Gitlab'"}}],
 'name': 'Application *******'}

It seems the same to me.

I post my problem here knowing that there is a good chance that the problem is coming from the API and not from the SDK...

Thanks,

Rémy

@rmjstn
Copy link
Author

rmjstn commented Mar 1, 2021

@rmjstn rmjstn closed this as completed Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant