2016-02-17 15:16:33 +08:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
|
|
|
import uuid
|
|
|
|
|
2016-09-05 20:35:06 -07:00
|
|
|
from openstackclient.tests.functional import base
|
2016-02-17 15:16:33 +08:00
|
|
|
|
|
|
|
|
2016-09-05 20:35:06 -07:00
|
|
|
class AggregateTests(base.TestCase):
|
2016-06-24 14:45:19 +03:00
|
|
|
"""Functional tests for aggregate."""
|
2016-02-17 15:16:33 +08:00
|
|
|
|
|
|
|
NAME = uuid.uuid4().hex
|
|
|
|
HEADERS = ['Name']
|
|
|
|
FIELDS = ['name']
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
2016-07-05 12:16:18 +03:00
|
|
|
opts = cls.get_opts(cls.FIELDS)
|
2016-03-03 12:32:09 -06:00
|
|
|
# Use the default 'nova' availability zone for the aggregate.
|
|
|
|
raw_output = cls.openstack(
|
|
|
|
'aggregate create --zone nova ' + cls.NAME + opts
|
|
|
|
)
|
2016-02-17 15:16:33 +08:00
|
|
|
expected = cls.NAME + '\n'
|
|
|
|
cls.assertOutput(expected, raw_output)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
raw_output = cls.openstack('aggregate delete ' + cls.NAME)
|
|
|
|
cls.assertOutput('', raw_output)
|
|
|
|
|
|
|
|
def test_aggregate_list(self):
|
2016-07-05 12:16:18 +03:00
|
|
|
opts = self.get_opts(self.HEADERS)
|
2016-02-17 15:16:33 +08:00
|
|
|
raw_output = self.openstack('aggregate list' + opts)
|
|
|
|
self.assertIn(self.NAME, raw_output)
|
|
|
|
|
|
|
|
def test_aggregate_show(self):
|
2016-07-05 12:16:18 +03:00
|
|
|
opts = self.get_opts(self.FIELDS)
|
2016-02-17 15:16:33 +08:00
|
|
|
raw_output = self.openstack('aggregate show ' + self.NAME + opts)
|
|
|
|
self.assertEqual(self.NAME + "\n", raw_output)
|
|
|
|
|
|
|
|
def test_aggregate_properties(self):
|
2016-07-05 12:16:18 +03:00
|
|
|
opts = self.get_opts(['properties'])
|
2016-02-17 15:16:33 +08:00
|
|
|
|
|
|
|
raw_output = self.openstack(
|
|
|
|
'aggregate set --property a=b --property c=d ' + self.NAME
|
|
|
|
)
|
|
|
|
self.assertEqual('', raw_output)
|
|
|
|
|
|
|
|
raw_output = self.openstack('aggregate show ' + self.NAME + opts)
|
|
|
|
self.assertIn("a='b', c='d'\n", raw_output)
|
2016-06-16 16:41:25 +08:00
|
|
|
|
|
|
|
raw_output = self.openstack(
|
|
|
|
'aggregate unset --property a ' + self.NAME
|
|
|
|
)
|
|
|
|
self.assertEqual('', raw_output)
|
|
|
|
|
|
|
|
raw_output = self.openstack('aggregate show ' + self.NAME + opts)
|
|
|
|
self.assertIn("c='d'\n", raw_output)
|