Merge "Use IRONIC_USE_RESOURCE_CLASSES in devstack plugin"
This commit is contained in:
commit
4dccc168c1
@ -184,19 +184,27 @@ function cleanup_mogan {
|
||||
|
||||
|
||||
function create_flavor {
|
||||
openstack baremetal flavor create ${MOGAN_DEFAULT_FLAVOR} --description 'Mogan default flavor' --resources ${MOGAN_DEFAULT_FLAVOR}=1
|
||||
}
|
||||
|
||||
|
||||
function update_ironic_node_resource_class {
|
||||
ironic_nodes=$(openstack baremetal node list -c UUID -f value)
|
||||
for node in ${ironic_nodes};do
|
||||
openstack --os-baremetal-api-version latest baremetal node set --resource-class ${MOGAN_DEFAULT_FLAVOR} ${node}
|
||||
done
|
||||
# this makes consistency with ironic resource class, will move the mogan flavor
|
||||
# creation to ironic devstack plugin when we are offical.
|
||||
if [[ "$IRONIC_IS_HARDWARE" == "False" ]]; then
|
||||
local ironic_node_cpu=$IRONIC_VM_SPECS_CPU
|
||||
local ironic_node_ram=$IRONIC_VM_SPECS_RAM
|
||||
local ironic_node_disk=$IRONIC_VM_SPECS_DISK
|
||||
else
|
||||
local ironic_node_cpu=$IRONIC_HW_NODE_CPU
|
||||
local ironic_node_ram=$IRONIC_HW_NODE_RAM
|
||||
local ironic_node_disk=$IRONIC_HW_NODE_DISK
|
||||
fi
|
||||
# this will look like baremetal_1cpu_256mbram_10gbdisk
|
||||
resource_class="baremetal_${ironic_node_cpu}cpu_${ironic_node_ram}mbram_${ironic_node_disk}gbdisk"
|
||||
openstack baremetal flavor create ${resource_class} --description 'Mogan default flavor' --resources ${resource_class}=1
|
||||
}
|
||||
|
||||
|
||||
if is_service_enabled mogan; then
|
||||
if [[ "$IRONIC_USE_RESOURCE_CLASSES" == "False" ]]; then
|
||||
die "Ironic node resource class is required for Mogan"
|
||||
fi
|
||||
if ! is_service_enabled placement; then
|
||||
die "placement service is required for Mogan"
|
||||
fi
|
||||
@ -218,8 +226,6 @@ if is_service_enabled mogan; then
|
||||
start_mogan
|
||||
echo_summary "Creating flavor"
|
||||
create_flavor
|
||||
echo_summary "Updating ironic node resource class"
|
||||
update_ironic_node_resource_class
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
|
@ -27,4 +27,3 @@ MOGAN_SERVICE_PORT=${MOGAN_SERVICE_PORT:-6688}
|
||||
MOGAN_SERVICE_PROTOCOL=${MOGAN_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
|
||||
|
||||
MOGAN_ADMIN_USER=${MOGAN_ADMIN_USER:-mogan}
|
||||
MOGAN_DEFAULT_FLAVOR=${MOGAN_DEFAULT_FLAVOR:-small}
|
||||
|
@ -298,6 +298,9 @@ Create devstack/local.conf with minimal settings required to enable Mogan
|
||||
# Swift temp URL's are required for agent_* drivers.
|
||||
SWIFT_ENABLE_TEMPURLS=True
|
||||
|
||||
# Set resource_classes for nodes to use placement service
|
||||
IRONIC_USE_RESOURCE_CLASSES=True
|
||||
|
||||
# Create 3 virtual machines to pose as Ironic's baremetal nodes.
|
||||
IRONIC_VM_COUNT=3
|
||||
IRONIC_VM_SSH_PORT=22
|
||||
|
@ -52,15 +52,14 @@ class BaseBaremetalComputeTest(tempest.test.BaseTestCase):
|
||||
cls.os_admin.network_floatingip_client
|
||||
|
||||
@classmethod
|
||||
def _get_small_flavor(cls):
|
||||
def _get_flavor(cls):
|
||||
# TODO(liusheng) we shouldn't depend on the default flavor
|
||||
# created by devstack.
|
||||
flavors = cls.baremetal_compute_client.list_flavors()
|
||||
for f in flavors:
|
||||
if f['name'] == 'small':
|
||||
return f['uuid']
|
||||
if flavors:
|
||||
return flavors[0]['uuid']
|
||||
else:
|
||||
# TODO(liusheng) we shouldn't depend on the default
|
||||
# type created by devstack
|
||||
raise exception.FlavorNotFound("'small' flavor not found.")
|
||||
raise exception.FlavorNotFound("No flavor found!")
|
||||
|
||||
@classmethod
|
||||
def _get_net_id(cls):
|
||||
@ -75,7 +74,7 @@ class BaseBaremetalComputeTest(tempest.test.BaseTestCase):
|
||||
super(BaseBaremetalComputeTest, cls).resource_setup()
|
||||
cls.flavor_ids = []
|
||||
cls.server_ids = []
|
||||
cls.small_flavor = cls._get_small_flavor()
|
||||
cls.flavor = cls._get_flavor()
|
||||
cls.image_id = CONF.compute.image_ref
|
||||
cls.net_id = cls._get_net_id()
|
||||
cls.ext_net_id = CONF.network.public_network_id
|
||||
@ -84,7 +83,7 @@ class BaseBaremetalComputeTest(tempest.test.BaseTestCase):
|
||||
def create_server(cls, wait_until_active=True):
|
||||
body = {'name': data_utils.rand_name('mogan_server'),
|
||||
'description': "mogan tempest server",
|
||||
'flavor_uuid': cls.small_flavor,
|
||||
'flavor_uuid': cls.flavor,
|
||||
'image_uuid': cls.image_id,
|
||||
"networks": [{"net_id": cls.net_id}]
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class BaremetalComputeAPIServersTest(base.BaseBaremetalComputeTest):
|
||||
resp = self.creation_resp
|
||||
self.assertEqual(self.server_ids[0], resp['uuid'])
|
||||
self.assertEqual('building', resp['status'])
|
||||
self.assertEqual(self.small_flavor, resp['flavor_uuid'])
|
||||
self.assertEqual(self.flavor, resp['flavor_uuid'])
|
||||
self.assertEqual('mogan tempest server', resp['description'])
|
||||
self.assertEqual(self.image_id, resp['image_uuid'])
|
||||
self.assertIn('launched_at', resp)
|
||||
@ -53,7 +53,7 @@ class BaremetalComputeAPIServersTest(base.BaseBaremetalComputeTest):
|
||||
resp = self.baremetal_compute_client.show_server(
|
||||
self.server_ids[0])
|
||||
self.assertEqual('active', resp['status'])
|
||||
self.assertEqual(self.small_flavor, resp['flavor_uuid'])
|
||||
self.assertEqual(self.flavor, resp['flavor_uuid'])
|
||||
self.assertEqual('mogan tempest server', resp['description'])
|
||||
self.assertEqual(self.image_id, resp['image_uuid'])
|
||||
self.assertEqual('power on', resp['power_state'])
|
||||
|
Loading…
Reference in New Issue
Block a user