Verify create agent attributes of V2/V3 APIs
This patch adds the JSON schema for Nova V2/V3 create agent APIs
includes the attributes to block the backward incompatibility change
in the future.
The response body of v2 and v3 API is the below:
{
    "agent": {
        "agent_id": 1,
        "hypervisor": "xen",
        "os": "linux",
        "architecture": "x86",
        "version": "7.0",
        "url": "xxx://xxx/xxx/xxx1",
        "md5hash": "add6bb58e139be103324d04d82d8f546"
    }
}
Partially implements blueprint nova-api-attribute-test
Change-Id: I86aeae6a6337ce60e2b69e207a6e015950b95a36
			
			
This commit is contained in:
		@@ -38,3 +38,24 @@ list_agents = {
 | 
			
		||||
        'required': ['agents']
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
common_create_agent = {
 | 
			
		||||
    'type': 'object',
 | 
			
		||||
    'properties': {
 | 
			
		||||
        'agent': {
 | 
			
		||||
            'type': 'object',
 | 
			
		||||
            'properties': {
 | 
			
		||||
                'agent_id': {'type': ['integer', 'string']},
 | 
			
		||||
                'hypervisor': {'type': 'string'},
 | 
			
		||||
                'os': {'type': 'string'},
 | 
			
		||||
                'architecture': {'type': 'string'},
 | 
			
		||||
                'version': {'type': 'string'},
 | 
			
		||||
                'url': {'type': 'string', 'format': 'uri'},
 | 
			
		||||
                'md5hash': {'type': 'string'}
 | 
			
		||||
            },
 | 
			
		||||
            'required': ['agent_id', 'hypervisor', 'os', 'architecture',
 | 
			
		||||
                         'version', 'url', 'md5hash']
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    'required': ['agent']
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,13 @@
 | 
			
		||||
#    License for the specific language governing permissions and limitations
 | 
			
		||||
#    under the License.
 | 
			
		||||
 | 
			
		||||
from tempest.api_schema.compute import agents
 | 
			
		||||
 | 
			
		||||
create_agent = {
 | 
			
		||||
    'status_code': [200],
 | 
			
		||||
    'response_body': agents.common_create_agent
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
delete_agent = {
 | 
			
		||||
    'status_code': [200]
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,13 @@
 | 
			
		||||
#    License for the specific language governing permissions and limitations
 | 
			
		||||
#    under the License.
 | 
			
		||||
 | 
			
		||||
from tempest.api_schema.compute import agents
 | 
			
		||||
 | 
			
		||||
create_agent = {
 | 
			
		||||
    'status_code': [201],
 | 
			
		||||
    'response_body': agents.common_create_agent
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
delete_agent = {
 | 
			
		||||
    'status_code': [204]
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -46,7 +46,9 @@ class AgentsClientJSON(rest_client.RestClient):
 | 
			
		||||
        """Create an agent build."""
 | 
			
		||||
        post_body = json.dumps({'agent': kwargs})
 | 
			
		||||
        resp, body = self.post('os-agents', post_body)
 | 
			
		||||
        return resp, self._parse_resp(body)
 | 
			
		||||
        body = json.loads(body)
 | 
			
		||||
        self.validate_response(schema.create_agent, resp, body)
 | 
			
		||||
        return resp, body['agent']
 | 
			
		||||
 | 
			
		||||
    def delete_agent(self, agent_id):
 | 
			
		||||
        """Delete an existing agent build."""
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,9 @@ class AgentsV3ClientJSON(rest_client.RestClient):
 | 
			
		||||
        """Create an agent build."""
 | 
			
		||||
        post_body = json.dumps({'agent': kwargs})
 | 
			
		||||
        resp, body = self.post('os-agents', post_body)
 | 
			
		||||
        return resp, self._parse_resp(body)
 | 
			
		||||
        body = json.loads(body)
 | 
			
		||||
        self.validate_response(schema.create_agent, resp, body)
 | 
			
		||||
        return resp, body['agent']
 | 
			
		||||
 | 
			
		||||
    def delete_agent(self, agent_id):
 | 
			
		||||
        """Delete an existing agent build."""
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user