Created
February 15, 2019 10:15
-
-
Save maiqueb/d644bebb8af19357977387d2d5999c18 to your computer and use it in GitHub Desktop.
ovirt-engine: update vnic profile port mirroring through python API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Copyright (c) 2019 Red Hat, Inc. | |
# | |
# 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. | |
import logging | |
import ovirtsdk4 as sdk | |
import ovirtsdk4.types as types | |
logging.basicConfig(level=logging.DEBUG, filename='vnic_update.log') | |
# your parameter defined below | |
engine_fqdn = 'YOUR_FQDN' | |
vnic_profile_name = 'YOU_VNIC_PROFILE_NAME' | |
engine_password = '????' | |
# end | |
connection = sdk.Connection( | |
url='https://{fqdn}/ovirt-engine/api'.format(fqdn=engine_fqdn), | |
username='admin@internal', | |
password=engine_password, | |
ca_file='ca.pem', | |
debug=True, | |
log=logging.getLogger(), | |
) | |
vnic_profile_service = connection.system_service().vnic_profiles_service() | |
the_vnic_profile = next(( | |
vnic_profile for vnic_profile in vnic_profile_service.list() | |
if vnic_profile.name == vnic_profile_name | |
)) | |
the_vnic = vnic_profile_service.profile_service(the_vnic_profile.id) | |
# update the port mirroring value | |
updated_vnic = the_vnic.update(profile=types.VnicProfile(port_mirroring=True)) | |
# Close the connection to the server | |
connection.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment