def get_pfc_wwpns(self): """Returns a set of the Physical FC Adapter WWPNs on this VIOS.""" path = u.xpath(bp.IO_CFG_ROOT, bp.IO_SLOTS_ROOT, bp.IO_SLOT_ROOT, bp.ASSOC_IO_SLOT_ROOT, bp.RELATED_IO_ADPT_ROOT, bp.IO_PFC_ADPT_ROOT, bp.PFC_PORTS_ROOT, bp.PFC_PORT_ROOT, bp.PFC_PORT_WWPN) return set(self._get_vals(path))
def vnet_uri_list(self): """Returns a list of the Virtual Network URIs. This is a READ-ONLY list. Modification should take place through the LoadGroup vnet_uri_list. As the LoadGroups are modified, this list will be dynamically updated. """ return self.get_href(u.xpath(_NB_VNETS, c.LINK))
def load_grps(self): """Returns the load groups. The first in the list is the primary.""" lg_list = [ LoadGroup.wrap(x, nb_root=self) for x in self.element.findall(u.xpath(_NB_LGS, _NB_LG)) ] temp_list = _order_by_pvid(lg_list, self.pvid) return ewrap.ActionableList(temp_list, self._load_grps)
def pfc_ports(self): """The physical Fibre Channel ports assigned to the VIOS.""" path = u.xpath(bp.IO_CFG_ROOT, bp.IO_SLOTS_ROOT, bp.IO_SLOT_ROOT, bp.ASSOC_IO_SLOT_ROOT, bp.RELATED_IO_ADPT_ROOT, bp.IO_PFC_ADPT_ROOT, bp.PFC_PORTS_ROOT, bp.PFC_PORT_ROOT) elems = self._find(path, use_find_all=True) resp = [] for elem in elems: resp.append(bp.PhysFCPort.wrap(elem)) return resp
def vnet_uri_list(self): """Returns a list of the Virtual Network URIs. If the vnet_aware trait (see traits.py) is set to False, the user should not modify this. Virtual Networks become 'realized' off of the system's VLANs/vSwitches. However, if set to True, one can add a Virtual Network to the vSwitch before it is used. The task classes (cna.py and network_bridger.py) should abstract the user away from these deviations in traits. """ uri_resp_list = list(self.get_href(u.xpath(_LG_VNETS, c.LINK))) return ewrap.ActionableList(uri_resp_list, self.__update_uri_list)
def _get_trunks(self): """Returns all of the trunk adapters. The first is the primary adapter. All others are the additional adapters. """ # It is not expected that the API will return the adapters such that # the first is the primary. Yet to reduce complexity in the other # methods that work with the trunks, the returned value from here # will order it as such. trunk_elem_list = [TrunkAdapter.wrap(x) for x in self.element.findall(u.xpath(SEA_TRUNKS, TA_ROOT))] return _order_by_pvid(trunk_elem_list, self.pvid)
def io_adapter(self): """Jumps over the 'Related IO Adapter' element direct to the I/O. This is another area where the schema has a two step jump that the API can avoid. This method skips over the RelatedIOAdapter and jumps right to the IO Adapter. Return values are either the generic IOAdapter or the PhysFCAdapter. """ # The child can be either an IO Adapter or a PhysFCAdapter. # Need to check for both... io_adpt_root = self._find( u.xpath(RELATED_IO_ADPT_ROOT, IOAdapter.schema_type)) if io_adpt_root is not None: return IOAdapter.wrap(io_adpt_root) # Didn't have the generic...check for non-generic. io_adpt_root = self._find( u.xpath(RELATED_IO_ADPT_ROOT, PhysFCAdapter.schema_type)) if io_adpt_root is not None: return PhysFCAdapter.wrap(io_adpt_root) return None
def _rebuild_vnet_list(self): """A callback from the Load Group to rebuild the virtual network list. Needed due to the API using both the LoadGroup and Network Bridge as a source. But usage at an API level should be through Load Groups. """ # Find all the children Virtual Networks. search = u.xpath(_NB_LGS, _NB_LG, _NB_VNETS, c.LINK) new_vnets = copy.deepcopy(self.element.findall(search)) # Find and replace the current element. cur_vnets = self.element.find(_NB_VNETS) self.element.replace( cur_vnets, ent.Element(_NB_VNETS, self.adapter, children=new_vnets))
def _get_trunks(self): """Returns all of the trunk adapters. The first is the primary adapter. All others are the additional adapters. """ # It is not expected that the API will return the adapters such that # the first is the primary. Yet to reduce complexity in the other # methods that work with the trunks, the returned value from here # will order it as such. trunk_elem_list = [ TrunkAdapter.wrap(x) for x in self.element.findall(u.xpath(SEA_TRUNKS, TA_ROOT)) ] return _order_by_pvid(trunk_elem_list, self.pvid)
def vnet_uri_list(self): """Returns a list of the Virtual Network URIs. If the vnet_aware trait (see traits.py) is set, then the addition of VLANs is driven via virtual networks rather than straight VLAN modification. This uri list is what drives the modification. If the trait is set to false, then the modification should be driven via the trunk adapters on the SEA directly. This list will also be empty. The task classes (cna.py and network_bridger.py) should abstract the user away from these deviations in traits. """ uri_resp_list = list(self.get_href(u.xpath(_LG_VNETS, c.LINK))) return ewrap.ActionableList(uri_resp_list, self.__update_uri_list)
def create_job(job_el, entry_type, *args, **kwargs): self.assertEqual(entry_type, clust.Cluster.schema_type) job = jwrap.Job.wrap(ent.Entry({}, job_el, None)) param_vals = job._get_vals(u.xpath( 'JobParameters', 'JobParameter', 'ParameterValue')) self.assertEqual( param_vals[0], '<uom:Cluster xmlns:uom="http://www.ibm.com/xmlns/systems/powe' 'r/firmware/uom/mc/2012_10/" schemaVersion="V1_0"><uom:Metadat' 'a><uom:Atom/></uom:Metadata><uom:ClusterName>clust_name</uom:' 'ClusterName><uom:RepositoryDisk schemaVersion="V1_0"><uom:Phy' 'sicalVolume schemaVersion="V1_0"><uom:Metadata><uom:Atom/></u' 'om:Metadata><uom:VolumeName>repos_pv_name</uom:VolumeName></u' 'om:PhysicalVolume></uom:RepositoryDisk><uom:Node schemaVersio' 'n="V1_0"><uom:Node schemaVersion="V1_0"><uom:Metadata><uom:At' 'om/></uom:Metadata><uom:HostName>vios1</uom:HostName><uom:Par' 'titionID>5</uom:PartitionID><uom:MachineTypeModelAndSerialNum' 'ber schemaVersion="V1_0"><uom:Metadata><uom:Atom/></uom:Metad' 'ata><uom:MachineType>XXXX</uom:MachineType><uom:Model>YYY</uo' 'm:Model><uom:SerialNumber>ZZZZZZZ</uom:SerialNumber></uom:Mac' 'hineTypeModelAndSerialNumber><uom:VirtualIOServer href="https' '://a.example.com:12443/rest/api/uom/VirtualIOServer/12345678-' '1234-1234-1234-123456789012" rel="related"/></uom:Node></uom:' 'Node></uom:Cluster>') self.assertEqual( param_vals[1], '<uom:SharedStoragePool xmlns:uom="http://www.ibm.com/xmlns/sy' 'stems/power/firmware/uom/mc/2012_10/" schemaVersion="V1_0"><u' 'om:Metadata><uom:Atom/></uom:Metadata><uom:PhysicalVolumes sc' 'hemaVersion="V1_0"><uom:PhysicalVolume schemaVersion="V1_0"><' 'uom:Metadata><uom:Atom/></uom:Metadata><uom:VolumeName>hdisk1' '</uom:VolumeName></uom:PhysicalVolume><uom:PhysicalVolume sch' 'emaVersion="V1_0"><uom:Metadata><uom:Atom/></uom:Metadata><uo' 'm:VolumeName>hdisk2</uom:VolumeName></uom:PhysicalVolume><uom' ':PhysicalVolume schemaVersion="V1_0"><uom:Metadata><uom:Atom/' '></uom:Metadata><uom:VolumeName>hdisk3</uom:VolumeName></uom:' 'PhysicalVolume></uom:PhysicalVolumes><uom:StoragePoolName>ssp' '_name</uom:StoragePoolName></uom:SharedStoragePool>') return mock.MagicMock()
def create_job(job_el, entry_type, *args, **kwargs): self.assertEqual(entry_type, clust.Cluster.schema_type) job = jwrap.Job.wrap(ent.Entry({}, job_el, None)) param_vals = job._get_vals( u.xpath('JobParameters', 'JobParameter', 'ParameterValue')) self.assertEqual( param_vals[0], '<uom:Cluster xmlns:uom="http://www.ibm.com/xmlns/systems/powe' 'r/firmware/uom/mc/2012_10/" schemaVersion="V1_0"><uom:Metadat' 'a><uom:Atom/></uom:Metadata><uom:ClusterName>clust_name</uom:' 'ClusterName><uom:RepositoryDisk schemaVersion="V1_0"><uom:Phy' 'sicalVolume schemaVersion="V1_0"><uom:Metadata><uom:Atom/></u' 'om:Metadata><uom:VolumeName>repos_pv_name</uom:VolumeName></u' 'om:PhysicalVolume></uom:RepositoryDisk><uom:Node schemaVersio' 'n="V1_0"><uom:Node schemaVersion="V1_0"><uom:Metadata><uom:At' 'om/></uom:Metadata><uom:HostName>vios1</uom:HostName><uom:Par' 'titionID>5</uom:PartitionID><uom:MachineTypeModelAndSerialNum' 'ber schemaVersion="V1_0"><uom:Metadata><uom:Atom/></uom:Metad' 'ata><uom:MachineType>XXXX</uom:MachineType><uom:Model>YYY</uo' 'm:Model><uom:SerialNumber>ZZZZZZZ</uom:SerialNumber></uom:Mac' 'hineTypeModelAndSerialNumber><uom:VirtualIOServer href="https' '://a.example.com:12443/rest/api/uom/VirtualIOServer/12345678-' '1234-1234-1234-123456789012" rel="related"/></uom:Node></uom:' 'Node></uom:Cluster>') self.assertEqual( param_vals[1], '<uom:SharedStoragePool xmlns:uom="http://www.ibm.com/xmlns/sy' 'stems/power/firmware/uom/mc/2012_10/" schemaVersion="V1_0"><u' 'om:Metadata><uom:Atom/></uom:Metadata><uom:PhysicalVolumes sc' 'hemaVersion="V1_0"><uom:PhysicalVolume schemaVersion="V1_0"><' 'uom:Metadata><uom:Atom/></uom:Metadata><uom:VolumeName>hdisk1' '</uom:VolumeName></uom:PhysicalVolume><uom:PhysicalVolume sch' 'emaVersion="V1_0"><uom:Metadata><uom:Atom/></uom:Metadata><uo' 'm:VolumeName>hdisk2</uom:VolumeName></uom:PhysicalVolume><uom' ':PhysicalVolume schemaVersion="V1_0"><uom:Metadata><uom:Atom/' '></uom:Metadata><uom:VolumeName>hdisk3</uom:VolumeName></uom:' 'PhysicalVolume></uom:PhysicalVolumes><uom:StoragePoolName>ssp' '_name</uom:StoragePoolName></uom:SharedStoragePool>') return mock.MagicMock()
"""Wrappers, constants, and helpers around ManagementConsole.""" from oslo_log import log as logging import pypowervm.const as c import pypowervm.util as u import pypowervm.wrappers.entry_wrapper as ewrap import pypowervm.wrappers.mtms as mtmwrap LOG = logging.getLogger(__name__) _MGD_FRAMES = 'ManagedFrames' _MGD_SYS = 'ManagedSystems' _MGMT_CON_NAME = 'ManagementConsoleName' _MGND_SYS_LINK = u.xpath("ManagedSystems", c.LINK) # NETI XPath constants _NETI_ROOT = 'NetworkInterfaces' _MGMT_NETI_ROOT = 'ManagementConsoleNetworkInterface' _MGMT_NETI_NAME = 'InterfaceName' _MGMT_NETI_ADDRESS = 'NetworkAddress' _PWR_ENT_POOLS = 'PowerEnterprisePools' # SSH Config _PUB_KEY = 'PublicSSHKey' _AUTH_KEYS = 'AuthorizedKeys' _AUTH_KEY = 'AuthorizedKey' _KEY = 'Key'
def vswitch_uri(self): """Returns the URI for the associated vSwitch.""" return self.get_href(u.xpath(_VADPT_VSWITCH, c.LINK), one_result=True)
_VOL_UID = 'VolumeUniqueID' _VOL_NAME = 'VolumeName' _RESERVE_POLICY = 'ReservePolicy' _IO_ADPT_CHOICE = 'IOAdapterChoice' _IO_ADPT = 'IOAdapter' _IO_LINK_AGG_ADPT_ID = 'AdapterID' _IO_LINK_AGG_DESC = 'Description' _IO_LINK_AGG_DEV_NAME = 'DeviceName' _IO_LINK_AGG_DEV_TYPE = 'DeviceType' _IO_LINK_AGG_DRC_NAME = 'DynamicReconfigurationConnectorName' _IO_LINK_AGG_PHYS_LOC = 'PhysicalLocation' _IO_LINK_AGG_UDID = 'UniqueDeviceID' _VIRT_MEDIA_REPOSITORY_PATH = u.xpath(_VIO_MEDIA_REPOS, 'VirtualMediaRepository') _IF_ADDR = u.xpath('IPInterface', 'IPAddress') _ETHERNET_BACKING_DEVICE = u.xpath(_VIO_FREE_ETH_BACKDEVS_FOR_SEA, 'IOAdapterChoice', net.ETH_BACK_DEV) _SEA_PATH = u.xpath(_VIO_SEAS, net.SHARED_ETH_ADPT) # Mapping Constants _MAP_STORAGE = 'Storage' _MAP_TARGET_DEV = 'TargetDevice' _MAP_CLIENT_LPAR = 'AssociatedLogicalPartition' _MAP_PORT = 'Port' _MAP_ORDER = (_MAP_CLIENT_LPAR, stor.CLIENT_ADPT, stor.SERVER_ADPT, _MAP_STORAGE) _VFC_MAP_ORDER = (_MAP_CLIENT_LPAR, stor.CLIENT_ADPT, _MAP_PORT, stor.SERVER_ADPT, _MAP_STORAGE)
def _associated_vswitch_uri(self, href): self.set_href(u.xpath(_TA_ASSOC_VSWITCH, c.LINK), href)
def associated_vswitch_uri(self): """Returns the associated vswitch href.""" return self.get_href(u.xpath(_TA_ASSOC_VSWITCH, c.LINK), one_result=True)
def load_grps(self): """Returns the load groups. The first in the list is the primary.""" lg_list = [LoadGroup.wrap(x, nb_root=self) for x in self.element.findall(u.xpath(_NB_LGS, _NB_LG))] temp_list = _order_by_pvid(lg_list, self.pvid) return ewrap.ActionableList(temp_list, self._load_grps)
def vswitch_uri(self, new_val): self.set_href(u.xpath(_VADPT_VSWITCH, c.LINK), new_val)
import pypowervm.util as u import pypowervm.wrappers.entry_wrapper as ewrap import pypowervm.wrappers.iocard as card import pypowervm.wrappers.mtms as mtmwrap LOG = logging.getLogger(__name__) # ManagedSystem XPath constants _PRIMARY_IP_ADDRESS = 'PrimaryIPAddress' _HOST_IP_ADDRESS = _PRIMARY_IP_ADDRESS _STATE = 'State' _SYSTEM_NAME = 'SystemName' _MASTER_MODE = 'IsPowerVMManagementMaster' _SYS_CAPABILITIES = 'AssociatedSystemCapabilities' _ACTIVE_LPM_CAP = u.xpath(_SYS_CAPABILITIES, 'ActiveLogicalPartitionMobilityCapable') _INACTIVE_LPM_CAP = u.xpath(_SYS_CAPABILITIES, 'InactiveLogicalPartitionMobilityCapable') _VETH_MAC_ADDR_CAP = u.xpath(_SYS_CAPABILITIES, 'VirtualEthernetCustomMACAddressCapable') _IBMi_LPM_CAP = u.xpath(_SYS_CAPABILITIES, 'IBMiLogicalPartitionMobilityCapable') _IBMi_RESTRICTEDIO_CAP = u.xpath(_SYS_CAPABILITIES, 'IBMiRestrictedIOModeCapable') _SIMP_REMOTE_RESTART_CAP = u.xpath( _SYS_CAPABILITIES, 'PowerVMLogicalPartitionSimplifiedRemoteRestartCapable') _AME_CAP = u.xpath(_SYS_CAPABILITIES, 'ActiveMemoryExpansionCapable') _AIX_CAP = u.xpath(_SYS_CAPABILITIES, 'AIXCapable') _IBMi_CAP = u.xpath(_SYS_CAPABILITIES, 'IBMiCapable') _LINUX_CAP = u.xpath(_SYS_CAPABILITIES, 'LinuxCapable') _SHR_PROC_POOL_CAP = u.xpath(_SYS_CAPABILITIES, 'SharedProcessorPoolCapable')
import six import pypowervm.const as pc import pypowervm.entities as ent import pypowervm.exceptions as pvmex from pypowervm.i18n import _ import pypowervm.util as u import pypowervm.wrappers.entry_wrapper as ewrap LOG = logging.getLogger(__name__) CONF = cfg.CONF _JOBS = 'jobs' _REQ_OP = 'RequestedOperation' _JOB_GROUP_NAME = u.xpath(_REQ_OP, 'GroupName') _JOB_OPERATION_NAME = u.xpath(_REQ_OP, 'OperationName') _JOB_PARAM = u.xpath('Results', 'JobParameter') _JOB_RESULTS_NAME = u.xpath(_JOB_PARAM, 'ParameterName') _JOB_RESULTS_VALUE = u.xpath(_JOB_PARAM, 'ParameterValue') _RESPONSE_EXCEPTION = 'ResponseException' _JOB_MESSAGE = u.xpath(_RESPONSE_EXCEPTION, 'Message') _JOB_STACKTRACE = u.xpath(_RESPONSE_EXCEPTION, 'StackTrace') _JOB_STATUS = 'Status' _JOB_ID = 'JobID' class JobStatus(object): NOT_ACTIVE = 'NOT_STARTED' RUNNING = 'RUNNING' COMPLETED_OK = 'COMPLETED_OK'
import pypowervm.const as c import pypowervm.util as u import pypowervm.wrappers.entry_wrapper as ewrap import pypowervm.wrappers.mtms as mtmwrap LOG = logging.getLogger(__name__) # ManagedSystem XPath constants _PRIMARY_IP_ADDRESS = 'PrimaryIPAddress' _HOST_IP_ADDRESS = _PRIMARY_IP_ADDRESS _STATE = 'State' _SYSTEM_NAME = 'SystemName' _MASTER_MODE = 'IsPowerVMManagementMaster' _SYS_CAPABILITIES = 'AssociatedSystemCapabilities' _ACTIVE_LPM_CAP = u.xpath( _SYS_CAPABILITIES, 'ActiveLogicalPartitionMobilityCapable') _INACTIVE_LPM_CAP = u.xpath( _SYS_CAPABILITIES, 'InactiveLogicalPartitionMobilityCapable') _VETH_MAC_ADDR_CAP = u.xpath( _SYS_CAPABILITIES, 'VirtualEthernetCustomMACAddressCapable') _IBMi_LPM_CAP = u.xpath( _SYS_CAPABILITIES, 'IBMiLogicalPartitionMobilityCapable') _IBMi_RESTRICTEDIO_CAP = u.xpath( _SYS_CAPABILITIES, 'IBMiRestrictedIOModeCapable') _SIMP_REMOTE_RESTART_CAP = u.xpath( _SYS_CAPABILITIES, 'PowerVMLogicalPartitionSimplifiedRemoteRestartCapable') _AIX_CAP = u.xpath(_SYS_CAPABILITIES, 'AIXCapable') _IBMi_CAP = u.xpath(_SYS_CAPABILITIES, 'IBMiCapable') _LINUX_CAP = u.xpath(_SYS_CAPABILITIES, 'LinuxCapable') _SHR_PROC_POOL_CAP = u.xpath( _SYS_CAPABILITIES, 'SharedProcessorPoolCapable')
_VOL_UID = 'VolumeUniqueID' _VOL_NAME = 'VolumeName' _RESERVE_POLICY = 'ReservePolicy' _IO_ADPT_CHOICE = 'IOAdapterChoice' _IO_ADPT = 'IOAdapter' _IO_LINK_AGG_ADPT_ID = 'AdapterID' _IO_LINK_AGG_DESC = 'Description' _IO_LINK_AGG_DEV_NAME = 'DeviceName' _IO_LINK_AGG_DEV_TYPE = 'DeviceType' _IO_LINK_AGG_DRC_NAME = 'DynamicReconfigurationConnectorName' _IO_LINK_AGG_PHYS_LOC = 'PhysicalLocation' _IO_LINK_AGG_UDID = 'UniqueDeviceID' _VIRT_MEDIA_REPOSITORY_PATH = u.xpath(_VIO_MEDIA_REPOS, 'VirtualMediaRepository') _IF_ADDR = u.xpath('IPInterface', 'IPAddress') _ETHERNET_BACKING_DEVICE = u.xpath(_VIO_FREE_ETH_BACKDEVS_FOR_SEA, 'IOAdapterChoice', net.ETH_BACK_DEV) _SEA_PATH = u.xpath(net.NB_SEAS, net.SHARED_ETH_ADPT) # Mapping Constants _MAP_STORAGE = 'Storage' _MAP_CLIENT_LPAR = 'AssociatedLogicalPartition' _MAP_PORT = 'Port' _MAP_ORDER = (_MAP_CLIENT_LPAR, stor.CLIENT_ADPT, stor.SERVER_ADPT, _MAP_STORAGE) _WWPNS_PATH = u.xpath(_VIO_VFC_MAPPINGS, 'VirtualFibreChannelMapping', stor.CLIENT_ADPT, 'WWPNs') _PVS_PATH = u.xpath(stor.PVS, stor.PHYS_VOL)