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': 1, 'vlan': 1}, {'mac': '00:00:01:02:03:06', 'port': 1, 'vlan': 1}, {'mac': '00:00:01:02:03:07', 'port': 1, '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%%;'), }, { 'name': 'cluster2', '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.110' }, '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.110' }, '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.110' }, '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.110' } }, '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': ["os-single-controller"], }), }, { 'hostname': 'host2', 'mac': '00:00:01:02:03:05', 'mutable': False, 'config_data': json.dumps({ 'networking': { 'interfaces': { 'management': { 'ip': '192.168.20.101', }, }, }, 'roles': ["os-network", "os-compute-worker"], }), }, ], 'cluster2': [ { 'hostname': 'host1', 'mac': '00:00:01:02:03:06', 'mutable': False, 'config_data': json.dumps({ 'networking': { 'interfaces': { 'management': { 'ip': '192.168.20.110', }, }, }, 'roles': ["os-single-controller"], }), }, { 'hostname': 'host2', 'mac': '00:00:01:02:03:07', 'mutable': False, 'config_data': json.dumps({ 'networking': { 'interfaces': { 'management': { 'ip': '192.168.20.111', }, }, }, 'roles': ["os-network", "os-compute-worker"], }), }, ], } 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' }, 'dashboard_roles': ['os-single-controller'], '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': { } }, '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-network', 'os-compute-worker']], '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', 'macaddress-eth0': '00:00:01:02:03:04', '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', 'ignore_proxy': '127.0.0.1,localhost,host1.1,192.168.20.100,host2.1,192.168.20.101', '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', 'macaddress-eth0': '00:00:01:02:03:05', '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', 'ignore_proxy': '127.0.0.1,localhost,host1.1,192.168.20.100,host2.1,192.168.20.101', 'ntp_server': '192.168.20.254', 'chef_client_name': 'host2.1', 'chef_node_name': u'host2.1' }, },{ 'profile': 'CentOS', 'name_servers_search': '2.ods.com ods.com', 'name': 'host1.2', 'hostname': 'host1', 'modify_interface': { 'dnsname-eth2': 'floating-host1.2.ods.com', 'dnsname-eth0': u'host1.2.ods.com', 'ipaddress-eth2': '10.145.88.110', 'static-eth2': True, 'static-eth0': True, 'netmask-eth0': '255.255.255.0', 'ipaddress-eth0': u'192.168.20.110', 'netmask-eth2': '255.255.254.0', 'macaddress-eth0': '00:00:01:02:03:06', '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', 'ignore_proxy': '127.0.0.1,localhost,host1.2,192.168.20.110,host2.2,192.168.20.111', 'ntp_server': '192.168.20.254', 'chef_client_name': 'host1.2', 'chef_node_name': u'host1.2' }, },{ 'profile': 'CentOS', 'name_servers_search': '2.ods.com ods.com', 'name': 'host2.2', 'hostname': 'host2', 'modify_interface': { 'dnsname-eth2': 'floating-host2.2.ods.com', 'dnsname-eth0': u'host2.2.ods.com', 'ipaddress-eth2': '10.145.88.111', 'static-eth2': True, 'static-eth0': True, 'netmask-eth0': '255.255.255.0', 'ipaddress-eth0': u'192.168.20.111', 'netmask-eth2': '255.255.254.0', 'macaddress-eth0': '00:00:01:02:03:07', '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', 'ignore_proxy': '127.0.0.1,localhost,host1.2,192.168.20.110,host2.2,192.168.20.111', 'ntp_server': '192.168.20.254', 'chef_client_name': 'host2.2', 'chef_node_name': u'host2.2' }, }], } 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', 'os-compute-worker'], }, 'cluster': '1', 'run_list': ['role[os-network]', 'role[os-compute-worker]'] }, 'host1.2': { 'roles_per_target_system': { 'openstack': ['os-single-controller'], }, 'cluster': '2', 'run_list': ['role[os-single-controller]'] }, 'host2.2': { 'roles_per_target_system': { 'openstack': ['os-network', 'os-compute-worker'], }, 'cluster': '2', 'run_list': ['role[os-network]', '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'} }, }, }, '2': { '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.110' } }, 'dashboard_roles': ['os-single-controller'], 'mq': { 'rabbitmq': {'bind_address': '192.168.20.110'} }, 'endpoints': { 'compute': { 'novnc': {'host': '192.168.20.110'}, 'xvpvnc': {'host': '192.168.20.110'}, 'service': {'host': '192.168.20.110'}, 'metadata': {'host': '192.168.20.110'} }, 'network': { 'service': {'host': '192.168.20.110'} }, 'image': { 'registry': {'host': '192.168.20.110'}, 'service': {'host': '192.168.20.110'} }, 'metering': { 'service': {'host': '192.168.20.110'} }, 'volume': { 'service': {'host': '192.168.20.110'} }, 'ec2': { 'admin': {'host': '192.168.20.110'}, 'service': {'host': '192.168.20.110'} }, 'identity': { 'admin': {'host': u'192.168.20.110'}, 'service': {'host': u'192.168.20.110'} }, }, }, }, }, }