def _detach_vlan_from_host(): attachment = _get_networkattachment_by_network_id(host, network_id) removal_action = params.Action( removed_network_attachments=params.NetworkAttachments( network_attachment=[params.NetworkAttachment( id=attachment.id)])) host.setupnetworks(removal_action)
def modify_ip_config(api, host, network_name, ip_configuration): network_id = api.networks.get(name=network_name).id attachment = _get_attachment_by_id(host, network_id) attachment.set_ip_address_assignments(ip_configuration) attachment_action = params.Action( modified_network_attachments=params.NetworkAttachments( network_attachment=[attachment]), check_connectivity=True) return host.setupnetworks(attachment_action)
def _modify_ip_config(api, host, ip_configuration): network_id = api.networks.get(name=VLAN100_NET).id attachment = _get_networkattachment_by_network_id(host, network_id) attachment.set_ip_address_assignments(ip_configuration) attachment_action = params.Action( modified_network_attachments=params.NetworkAttachments( network_attachment=[attachment]), check_connectivity=True) nt.assert_true(host.setupnetworks(attachment_action))
def detach_network_from_host(api, host, network_name, bond_name=None): network_id = api.networks.get(name=network_name).id attachment = _get_attachment_by_id(host, network_id) bonds = [nic for nic in host.nics.list() if bond_name and nic.name == bond_name] # there is no more than one bond removal_action = params.Action( removed_bonds=params.HostNics(host_nic=bonds), removed_network_attachments=params.NetworkAttachments( network_attachment=[params.NetworkAttachment( id=attachment.id)])) return host.setupnetworks(removal_action)
def attach_network_to_host(api, host, nic_name, network_name, ip_configuration, bonds=[]): network_attachment = params.NetworkAttachment( network=params.Network(name=network_name), host_nic=params.HostNIC(name=nic_name), ip_address_assignments=ip_configuration) attachment_action = params.Action( modified_bonds=params.HostNics(host_nic=bonds), modified_network_attachments=params.NetworkAttachments( network_attachment=[network_attachment]), check_connectivity=True) return host.setupnetworks(attachment_action)
def _attach_vlan_to_host(api, host, ip_configuration): mgmt_attachment = _get_mgmt_attachment(api, host) mgmt_nic_id = mgmt_attachment.get_host_nic().id mgmt_nic_name = host.nics.get(id=mgmt_nic_id).name vlan_network_attachment = params.NetworkAttachment( network=params.Network(name=VLAN100_NET), host_nic=params.HostNIC(name=mgmt_nic_name), ip_address_assignments=ip_configuration) attachment_action = params.Action( modified_network_attachments=params.NetworkAttachments( network_attachment=[vlan_network_attachment]), check_connectivity=True) host.setupnetworks(attachment_action)