xiaodongwang 36a7843d6d support testmode in chef
Change-Id: I9c43ff2aaf3ae96aa4ef826e0a0caddffffbaba2
2014-04-18 18:19:03 +00:00

781 lines
29 KiB
Plaintext

import simplejson as json
ADAPTERS = [
{'name': 'CentOS_openstack', 'os': 'CentOS', 'target_system': 'openstack'},
]
ROLES = [
{'name': 'os-single-controller', 'target_system': 'openstack'},
{'name': 'os-network', 'target_system': 'openstack'},
{'name': 'os-compute-worker', 'target_system': 'openstack'},
]
SWITCHES = [
{'ip': '1.2.3.4', 'vendor_info': 'huawei', 'credential_data': json.dumps({'version': 'v2c', 'community': 'public'})},
]
MACHINES_BY_SWITCH = {
'1.2.3.4': [
{'mac': '00:00:01:02:03:04', 'port': 1, 'vlan': 1},
{'mac': '00:00:01:02:03:05', 'port': 2, 'vlan': 1},
{'mac': '00:00:01:02:03:06', 'port': 3, 'vlan': 1},
{'mac': '00:00:01:02:03:07', 'port': 4, 'vlan': 1},
{'mac': '00:00:01:02:03:08', 'port': 5, 'vlan': 1},
{'mac': '00:00:01:02:03:09', 'port': 6, 'vlan': 1},
{'mac': '00:00:01:02:03:10', 'port': 7, 'vlan': 1},
{'mac': '00:00:01:02:03:11', 'port': 8, 'vlan': 1},
{'mac': '00:00:01:02:03:12', 'port': 9, 'vlan': 1},
{'mac': '00:00:01:02:03:13', 'port': 10, 'vlan': 1},
],
}
CLUSTERS = [
{
'name': 'cluster1',
'adapter': 'CentOS_openstack',
'mutable': False,
'security_config': json.dumps({
'server_credentials': {
'username': 'root', 'password': 'huawei'
},
'service_credentials': {
'username': 'service', 'password': 'huawei'
},
'console_credentials': {
'username': 'admin', 'password': 'huawei'
}
}),
'networking_config': json.dumps({
'interfaces': {
'management': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.255.0',
'ip_end': '192.168.20.200',
'gateway': '',
'ip_start': '192.168.20.100'
},
'storage': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.200',
'gateway': '10.145.88.1',
'ip_start': '10.145.88.100'
},
'public': {
'nic': 'eth2',
'promisc': 1,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.255',
'gateway': '10.145.88.1',
'ip_start': '10.145.88.100'
},
'tenant': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.120',
'gateway': '10.145.88.1',
'ip_start': '10.145.88.100'
}
},
'global': {
'nameservers': '192.168.20.254',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'search_path': 'ods.com',
'gateway': '10.145.88.1'
},
}),
'partition_config': json.dumps('/home 20%%;/tmp 10%%;/var 30%%;'),
},
]
HOSTS_BY_CLUSTER = {
'cluster1': [
{
'hostname': 'host1',
'mac': '00:00:01:02:03:04',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.100',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host2',
'mac': '00:00:01:02:03:05',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.101',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host3',
'mac': '00:00:01:02:03:06',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.102',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host4',
'mac': '00:00:01:02:03:07',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.103',
},
},
},
'roles': ["os-compute-worker"],
}),
},
{
'hostname': 'host5',
'mac': '00:00:01:02:03:08',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.104',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host6',
'mac': '00:00:01:02:03:09',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.105',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host7',
'mac': '00:00:01:02:03:10',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.106',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host8',
'mac': '00:00:01:02:03:11',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.107',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host9',
'mac': '00:00:01:02:03:12',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.108',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host10',
'mac': '00:00:01:02:03:13',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.109',
},
},
},
'roles': [],
}),
},
],
}
cobbler_MOCK = {
'host_configs': []
}
chef_MOCK = {
'configs': {
'openstack': {
'env_default': {
'all_roles': {
'os-single-controller': 'openstack controller node',
'os-network': 'openstack network node',
'os-compute-worker': 'openstack nova node'
},
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
},
'role_mapping': {
'os-single-controller': {
'/db/mysql/bind_address': '/networking/interfaces/management/ip',
'/mq/rabbitmq/bind_address': '/networking/interfaces/management/ip',
'/endpoints/compute/metadata/host': '/networking/interfaces/management/ip',
'/endpoints/compute/novnc/host': '/networking/interfaces/management/ip',
'/endpoints/compute/service/host': '/networking/interfaces/management/ip',
'/endpoints/compute/xvpvnc/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/admin/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/service/host': '/networking/interfaces/management/ip',
'/endpoints/identity/admin/host': '/networking/interfaces/management/ip',
'/endpoints/identity/service/host': '/networking/interfaces/management/ip',
'/endpoints/image/registry/host': '/networking/interfaces/management/ip',
'/endpoints/image/service/host': '/networking/interfaces/management/ip',
'/endpoints/metering/service/host': '/networking/interfaces/management/ip',
'/endpoints/network/service/host': '/networking/interfaces/management/ip',
'/endpoints/volume/service/host': '/networking/interfaces/management/ip'
},
'os-network': {
},
'os-compute-worker': {
}
},
'dashboard_roles': ['os-single-controller'],
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-network', 'os-compute-worker'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker':-1}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller', 'os-network', 'os-compute-worker']],
'exclusives':[]
},
'2': {
'bundles': [['os-compute-worker','os-network']],
'exclusives':['os-single-controller']
},
},
},
},
},
},
}
cobbler_EXPECTED = {
'expected_host_configs': [{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host1.1',
'hostname': 'host1',
'modify_interface': {
'dnsname-eth2': 'floating-host1.1.ods.com',
'dnsname-eth0': u'host1.1.ods.com',
'ipaddress-eth2': '10.145.88.100',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.100',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host1.1',
'chef_node_name': u'host1.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host2.1',
'hostname': 'host2',
'modify_interface': {
'dnsname-eth2': 'floating-host2.1.ods.com',
'dnsname-eth0': u'host2.1.ods.com',
'ipaddress-eth2': '10.145.88.101',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.101',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host2.1',
'chef_node_name': u'host2.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host3.1',
'hostname': 'host3',
'modify_interface': {
'dnsname-eth2': 'floating-host3.1.ods.com',
'dnsname-eth0': u'host3.1.ods.com',
'ipaddress-eth2': '10.145.88.102',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.102',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host3.1',
'chef_node_name': u'host3.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host4.1',
'hostname': 'host4',
'modify_interface': {
'dnsname-eth2': 'floating-host4.1.ods.com',
'dnsname-eth0': u'host4.1.ods.com',
'ipaddress-eth2': '10.145.88.103',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.103',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host4.1',
'chef_node_name': u'host4.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host5.1',
'hostname': 'host5',
'modify_interface': {
'dnsname-eth2': 'floating-host5.1.ods.com',
'dnsname-eth0': u'host5.1.ods.com',
'ipaddress-eth2': '10.145.88.104',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.104',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host5.1',
'chef_node_name': u'host5.1'
},
}, {
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host6.1',
'hostname': 'host6',
'modify_interface': {
'dnsname-eth2': 'floating-host6.1.ods.com',
'dnsname-eth0': u'host6.1.ods.com',
'ipaddress-eth2': '10.145.88.105',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.105',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host6.1',
'chef_node_name': u'host6.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host7.1',
'hostname': 'host7',
'modify_interface': {
'dnsname-eth2': 'floating-host7.1.ods.com',
'dnsname-eth0': u'host7.1.ods.com',
'ipaddress-eth2': '10.145.88.106',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.106',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host7.1',
'chef_node_name': u'host7.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host8.1',
'hostname': 'host8',
'modify_interface': {
'dnsname-eth2': 'floating-host8.1.ods.com',
'dnsname-eth0': u'host8.1.ods.com',
'ipaddress-eth2': '10.145.88.107',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.107',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host8.1',
'chef_node_name': u'host8.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host9.1',
'hostname': 'host9',
'modify_interface': {
'dnsname-eth2': 'floating-host9.1.ods.com',
'dnsname-eth0': u'host9.1.ods.com',
'ipaddress-eth2': '10.145.88.108',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.108',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host9.1',
'chef_node_name': u'host9.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host10.1',
'hostname': 'host10',
'modify_interface': {
'dnsname-eth2': 'floating-host10.1.ods.com',
'dnsname-eth0': u'host10.1.ods.com',
'ipaddress-eth2': '10.145.88.109',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.109',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host10.1',
'chef_node_name': u'host10.1'
},
}],
}
chef_EXPECTED = {
'expected_configs': {
'host1.1': {
'roles_per_target_system': {
'openstack': ['os-single-controller'],
},
'cluster': '1',
'run_list': ['role[os-single-controller]']
},
'host2.1': {
'roles_per_target_system': {
'openstack': ['os-network'],
},
'cluster': '1',
'run_list': ['role[os-network]']
},
'host3.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host4.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host5.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host6.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host7.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host8.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host9.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host10.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'openstack': {
'1': {
'credential': {
'identity': {
'users': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.100'
}
},
'dashboard_roles': ['os-single-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.100'}
},
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.100'},
'xvpvnc': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'},
'metadata': {'host': '192.168.20.100'}
},
'network': {
'service': {'host': '192.168.20.100'}
},
'image': {
'registry': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'metering': {
'service': {'host': '192.168.20.100'}
},
'volume': {
'service': {'host': '192.168.20.100'}
},
'ec2': {
'admin': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'identity': {
'admin': {'host': u'192.168.20.100'},
'service': {'host': u'192.168.20.100'}
},
},
},
},
},
}