def print_bar(msg):
- print ("--------------------------------------------")
- print (msg)
- print ("--------------------------------------------")
+ print("--------------------------------------------")
+ print(msg)
+ print("--------------------------------------------")
def get_configure_from_daisyconf(section, key):
return daisy_endpoint
-def prepare_install():
+def prepare_install(client):
global deployment_interface
try:
print("get config...")
cluster_id = clusters_info.id
print("cluster_id=%s." % cluster_id)
print("update network...")
- update_network(cluster_id, network_map)
+ update_network(cluster_id, network_map, client)
print("build pxe server to install os...")
deployment_interface = get_configure_from_daisyconf("PXE", "eth_name")
build_pxe_for_discover(cluster_id, client, deployment_interface)
elif conf['host'] and conf['host'] == 'yes':
isbare = False if 'isbare' in conf and conf['isbare'] == 0 else True
print("discover host...")
- discover_host(hosts_name)
+ discover_host(hosts_name, client)
time.sleep(10)
print("update hosts interface...")
- hosts_info = get_hosts()
+ hosts_info = get_hosts(client)
cluster_info = get_cluster(client)
cluster_id = cluster_info.id
add_hosts_interface(cluster_id, hosts_info, mac_address_map,
client.install.install(**cluster_meta)
-def discover_host(hosts_name):
+def discover_host(hosts_name, client):
while True:
- hosts_info = get_hosts()
+ hosts_info = get_hosts(client)
if len(hosts_info) == len(hosts_name):
print('discover hosts success!')
break
try:
client.disk_array.service_disk_add(**service_disk_meta)
except Exception as e:
- print e
+ print(e)
def enable_opendaylight(cluster_id, layer, client):
try:
client.roles.update(lb_role_id, **neutron_backend_info)
except Exception as e:
- print e
+ print(e)
if __name__ == "__main__":
daisy_endpoint = get_endpoint(daisyrc_path)
client = daisy_client.Client(version=daisy_version, endpoint=daisy_endpoint)
- prepare_install()
+ prepare_install(client)
def test_discover_host(mock_get_hosts, mock_sleep):
hosts_name = ['computer01', 'computer02', 'controller01', 'controller02', 'controller03']
mock_get_hosts.return_value = hosts_name
- discover_host(hosts_name)
+ client = StubTestClient()
+ discover_host(hosts_name, client)
mock_sleep.assert_not_called()