os-xenapi v2: Expose python interfaces for some Dom0 plugins
This patch is to implement os-xenapi V2 which will provide python interface for calling dom0 plugins 1. wrapper of xenhost.py wrapper of bandwidth.py in host_network.py 2. wrapper of partition_utils.py wrapper of kernel.py wrapper of ipxe.py wrapper of workarounds.py in disk_management.py 3. wrapper of migration.py wrapper of console.py in vm_management.py Note: https://review.openstack.org/#/c/453493/ this is the nova patch that verify the correctness of this patch Change-Id: Ib588577cd22d0d3b8cda634b82e7993571bec7e8
This commit is contained in:
parent
728293aaad
commit
912e8c7a30
66
os_xenapi/client/disk_management.py
Normal file
66
os_xenapi/client/disk_management.py
Normal file
@ -0,0 +1,66 @@
|
||||
# Copyright 2017 Citrix Systems
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
def inject_ipxe_config(session, sr_path, vdi_uuid, boot_menu_url, ip_address,
|
||||
netmask, gateway, dns, mkisofs_cmd):
|
||||
session.call_plugin_serialized('ipxe.py', 'inject', sr_path, vdi_uuid,
|
||||
boot_menu_url, ip_address, netmask,
|
||||
gateway, dns, mkisofs_cmd)
|
||||
|
||||
|
||||
def copy_vdi(session, vdi_ref, vdi_size, image_id=None):
|
||||
args = {}
|
||||
args['vdi-ref'] = vdi_ref
|
||||
args['image-size'] = str(vdi_size)
|
||||
if image_id:
|
||||
args['cached-image'] = image_id
|
||||
session.call_plugin('kernel.py', 'copy_vdi', args)
|
||||
|
||||
|
||||
def create_kernel_ramdisk(session, image_id, new_image_uuid):
|
||||
args = {}
|
||||
args['cached-image'] = image_id
|
||||
args['new-image-uuid'] = new_image_uuid
|
||||
session.call_plugin('kernel.py', 'create_kernel_ramdisk', args)
|
||||
|
||||
|
||||
def remove_kernel_ramdisk(session, kernel_file=None, ramdisk_file=None):
|
||||
args = {}
|
||||
if kernel_file:
|
||||
args['kernel-file'] = kernel_file
|
||||
if ramdisk_file:
|
||||
args['ramdisk-file'] = ramdisk_file
|
||||
if args:
|
||||
session.call_plugin('kernel.py', 'remove_kernel_ramdisk', args)
|
||||
|
||||
|
||||
def safe_copy_vdis(session, sr_path, vdi_uuids, uuid_stack):
|
||||
return session.call_plugin_serialized(
|
||||
'workarounds.py', 'safe_copy_vdis', sr_path, vdi_uuids, uuid_stack)
|
||||
|
||||
|
||||
def make_partition(session, dev, partition_start, partition_end):
|
||||
session.call_plugin_serialized('partition_utils.py', 'make_partition',
|
||||
dev, partition_start, partition_end)
|
||||
|
||||
|
||||
def mkfs(session, dev, partnum, fs_type, fs_label):
|
||||
session.call_plugin_serialized('partition_utils.py', 'mkfs', dev, partnum,
|
||||
fs_type, fs_label)
|
||||
|
||||
|
||||
def wait_for_dev(session, dev_path, max_seconds):
|
||||
return session.call_plugin_serialized('partition_utils.py', 'wait_for_dev',
|
||||
dev_path, max_seconds)
|
@ -22,3 +22,113 @@ def ovs_create_port(session, bridge, port, iface_id, mac, status):
|
||||
'status': status}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def ovs_add_port(session, bridge, port):
|
||||
args = {'cmd': 'ovs_add_port',
|
||||
'args': {'bridge_name': bridge, 'port_name': port}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def ovs_del_port(session, bridge, port):
|
||||
args = {'cmd': 'ovs_del_port',
|
||||
'args': {'bridge_name': bridge, 'port_name': port}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def ovs_del_br(session, bridge_name):
|
||||
args = {'cmd': 'ovs_del_br',
|
||||
'args': {'bridge_name': bridge_name}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def brctl_add_if(session, bridge_name, interface_name):
|
||||
args = {'cmd': 'brctl_add_if',
|
||||
'args': {'bridge_name': bridge_name,
|
||||
'interface_name': interface_name}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def brctl_del_if(session, bridge_name, interface_name):
|
||||
args = {'cmd': 'brctl_del_if',
|
||||
'args': {'bridge_name': bridge_name,
|
||||
'interface_name': interface_name}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def brctl_del_br(session, bridge_name):
|
||||
args = {'cmd': 'brctl_del_br',
|
||||
'args': {'bridge_name': bridge_name}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def brctl_add_br(session, bridge_name):
|
||||
args = {'cmd': 'brctl_add_br',
|
||||
'args': {'bridge_name': bridge_name}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def brctl_set_fd(session, bridge_name, fd):
|
||||
args = {'cmd': 'brctl_set_fd',
|
||||
'args': {'bridge_name': bridge_name,
|
||||
'fd': fd}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def brctl_set_stp(session, bridge_name, stp_opt):
|
||||
args = {'cmd': 'brctl_set_stp',
|
||||
'args': {'bridge_name': bridge_name,
|
||||
'option': stp_opt}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def ip_link_add_veth_pair(session, dev1_name, dev2_name):
|
||||
args = {'cmd': 'ip_link_add_veth_pair',
|
||||
'args': {'dev1_name': dev1_name,
|
||||
'dev2_name': dev2_name}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def ip_link_del_dev(session, device):
|
||||
args = {'cmd': 'ip_link_del_dev',
|
||||
'args': {'device_name': device}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def ip_link_get_dev(session, device):
|
||||
args = {'cmd': 'ip_link_get_dev',
|
||||
'args': {'device_name': device}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def ip_link_set_dev(session, device, option):
|
||||
args = {'cmd': 'ip_link_set_dev',
|
||||
'args': {'device_name': device,
|
||||
'option': option}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def ip_link_set_promisc(session, device, promisc_option):
|
||||
args = {'cmd': 'ip_link_set_promisc',
|
||||
'args': {'device_name': device,
|
||||
'option': promisc_option}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
||||
|
||||
|
||||
def fetch_all_bandwidth(session):
|
||||
return session.call_plugin_serialized('bandwidth.py',
|
||||
'fetch_all_bandwidth')
|
||||
|
29
os_xenapi/client/vm_management.py
Normal file
29
os_xenapi/client/vm_management.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Copyright 2017 Citrix Systems
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
def get_console_log(session, dom_id):
|
||||
return session.call_plugin('console.py', 'get_console_log',
|
||||
{'dom_id': dom_id})
|
||||
|
||||
|
||||
def transfer_vhd(session, instance_uuid, host, vdi_uuid, sr_path, seq_num):
|
||||
session.call_plugin_serialized('migration.py', 'transfer_vhd',
|
||||
instance_uuid, host, vdi_uuid, sr_path,
|
||||
seq_num)
|
||||
|
||||
|
||||
def receive_vhd(session, instance_uuid, sr_path, uuid_stack):
|
||||
return session.call_plugin_serialized('migration.py', 'move_vhds_into_sr',
|
||||
instance_uuid, sr_path, uuid_stack)
|
Loading…
x
Reference in New Issue
Block a user