Create new module nova_powervm.virt.powervm.mgmt containing utilities around the PowerVM management partition. Moved vm.get_mgmt_partition into the new module. Change-Id: I67d88148c78a5c966e16ddb4b490a398250b2120changes/05/186905/2
parent
d0bf3dbd2b
commit
797755c029
@ -0,0 +1,44 @@
|
||||
# Copyright 2015 IBM Corp.
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from nova import test
|
||||
from pypowervm.tests.wrappers.util import pvmhttp
|
||||
from pypowervm.wrappers import logical_partition as pvm_lpar
|
||||
|
||||
from nova_powervm.tests.virt.powervm import fixtures as fx
|
||||
from nova_powervm.virt.powervm import mgmt
|
||||
|
||||
LPAR_HTTPRESP_FILE = "lpar.txt"
|
||||
|
||||
|
||||
class TestVM(test.TestCase):
|
||||
def setUp(self):
|
||||
super(TestVM, self).setUp()
|
||||
self.pypvm = self.useFixture(fx.PyPowerVM())
|
||||
self.apt = self.pypvm.apt
|
||||
|
||||
lpar_http = pvmhttp.load_pvm_resp(LPAR_HTTPRESP_FILE, adapter=self.apt)
|
||||
self.assertNotEqual(lpar_http, None,
|
||||
"Could not load %s " %
|
||||
LPAR_HTTPRESP_FILE)
|
||||
|
||||
self.resp = lpar_http.response
|
||||
|
||||
def test_get_mgmt_partition(self):
|
||||
self.apt.read.return_value = self.resp
|
||||
mp_wrap = mgmt.get_mgmt_partition(self.apt)
|
||||
self.assertIsInstance(mp_wrap, pvm_lpar.LPAR)
|
||||
self.assertTrue(mp_wrap.is_mgmt_partition)
|
@ -0,0 +1,37 @@
|
||||
# Copyright 2015 IBM Corp.
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Utilities related to the PowerVM management partition.
|
||||
|
||||
The management partition is a special LPAR that runs the PowerVM REST API
|
||||
service. It itself appears through the REST API as a LogicalPartition of type
|
||||
aixlinux, but with the is_mgmt_partition property set to True.
|
||||
|
||||
The PowerVM Nova Compute service runs on the management partition.
|
||||
"""
|
||||
from nova.i18n import _
|
||||
from pypowervm.wrappers import logical_partition as pvm_lpar
|
||||
|
||||
|
||||
def get_mgmt_partition(adapter):
|
||||
"""Get the LPAR wrapper for this host's management partition.
|
||||
|
||||
:param adapter: The adapter for the pypowervm API.
|
||||
"""
|
||||
wraps = pvm_lpar.LPAR.search(adapter, is_mgmt_partition=True)
|
||||
if len(wraps) != 1:
|
||||
raise Exception(_("Unable to find a single management partition."))
|
||||
return wraps[0]
|
Loading…
Reference in new issue