# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright 2012 OpenStack LLC.
#
#    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.

from migrate import ForeignKeyConstraint
from sqlalchemy import Boolean, BigInteger, Column, DateTime, Float, ForeignKey
from sqlalchemy import Index, Integer, MetaData, String, Table, Text

from nova import flags
from nova.openstack.common import log as logging

FLAGS = flags.FLAGS

LOG = logging.getLogger(__name__)


# Note on the autoincrement flag: this is defaulted for primary key columns
# of integral type, so is no longer set explicitly in such cases.

def _populate_instance_types(instance_types_table):
    if FLAGS.connection_type == "libvirt":
        default_inst_types = {
        'm1.tiny': dict(mem=512, vcpus=1, root_gb=0, eph_gb=0, flavid=1),
        'm1.small': dict(mem=2048, vcpus=1, root_gb=10, eph_gb=20, flavid=2),
        'm1.medium': dict(mem=4096, vcpus=2, root_gb=10, eph_gb=40, flavid=3),
        'm1.large': dict(mem=8192, vcpus=4, root_gb=10, eph_gb=80, flavid=4),
        'm1.xlarge': dict(mem=16384, vcpus=8, root_gb=10, eph_gb=160, flavid=5),
        'cg1.small':
              dict(mem=2048, vcpus=1, root_gb=20, eph_gb=20, flavid=101),
        'cg1.medium':
              dict(mem=4096, vcpus=2, root_gb=20, eph_gb=40, flavid=102),
        'cg1.large':
              dict(mem=8192, vcpus=4, root_gb=20, eph_gb=80, flavid=103),
        'cg1.xlarge':
              dict(mem=16384, vcpus=8, root_gb=20, eph_gb=160, flavid=104),
        'cg1.2xlarge':
              dict(mem=16384, vcpus=8, root_gb=20, eph_gb=320, flavid=105),
        'cg1.4xlarge':
              dict(mem=22000, vcpus=8, root_gb=20, eph_gb=640, flavid=106),
        'sh1.small':
              dict(mem=2048, vcpus=1, root_gb=20, eph_gb=20, flavid=201),
        'sh1.medium':