From d3d21394db4a958bed55d856f780c127324a71b8 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 6 Apr 2016 14:06:00 -0700 Subject: [PATCH] Fix create_flavors on subnodes This makes us depend on n-api being enabled, which should avoid running this on subnodes, where it fails because of no credentials. Change-Id: I209bd59cd57be27c3375f5a2074361307abcafe9 Closes-Bug: #1567065 --- lib/nova | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/nova b/lib/nova index 8aca1a6cec..77bc3c8742 100644 --- a/lib/nova +++ b/lib/nova @@ -934,21 +934,23 @@ function stop_nova { # create_instance_types(): Create default flavors function create_flavors { - if ! openstack flavor list | grep -q ds512M; then - # Note that danms hates these flavors and apologizes for sdague - openstack flavor create --id c1 --ram 256 --disk 0 --vcpus 1 cirros256 - openstack flavor create --id d1 --ram 512 --disk 5 --vcpus 1 ds512M - openstack flavor create --id d2 --ram 1024 --disk 10 --vcpus 1 ds1G - openstack flavor create --id d3 --ram 2048 --disk 10 --vcpus 2 ds2G - openstack flavor create --id d4 --ram 4096 --disk 20 --vcpus 4 ds4G - fi + if is_service_enabled n-api; then + if ! openstack flavor list | grep -q ds512M; then + # Note that danms hates these flavors and apologizes for sdague + openstack flavor create --id c1 --ram 256 --disk 0 --vcpus 1 cirros256 + openstack flavor create --id d1 --ram 512 --disk 5 --vcpus 1 ds512M + openstack flavor create --id d2 --ram 1024 --disk 10 --vcpus 1 ds1G + openstack flavor create --id d3 --ram 2048 --disk 10 --vcpus 2 ds2G + openstack flavor create --id d4 --ram 4096 --disk 20 --vcpus 4 ds4G + fi - if ! openstack flavor list | grep -q m1.tiny; then - openstack flavor create --id 1 --ram 512 --disk 1 --vcpus 1 m1.tiny - openstack flavor create --id 2 --ram 2048 --disk 20 --vcpus 1 m1.small - openstack flavor create --id 3 --ram 4096 --disk 40 --vcpus 2 m1.medium - openstack flavor create --id 4 --ram 8192 --disk 80 --vcpus 4 m1.large - openstack flavor create --id 5 --ram 16384 --disk 160 --vcpus 8 m1.xlarge + if ! openstack flavor list | grep -q m1.tiny; then + openstack flavor create --id 1 --ram 512 --disk 1 --vcpus 1 m1.tiny + openstack flavor create --id 2 --ram 2048 --disk 20 --vcpus 1 m1.small + openstack flavor create --id 3 --ram 4096 --disk 40 --vcpus 2 m1.medium + openstack flavor create --id 4 --ram 8192 --disk 80 --vcpus 4 m1.large + openstack flavor create --id 5 --ram 16384 --disk 160 --vcpus 8 m1.xlarge + fi fi }