def setup_method(self): """ Called by pytest before each test method. Sets up HMC Credentials. """ self.hmc_creds = HmcCredentials()
def setup_method(self): """ Set up HMC data, Session to that HMC, Client, and Cpc object. """ self.hmc_creds = HmcCredentials() self.fake_data = dict( hmc_host='fake-host', hmc_name='fake-hmc', hmc_version='2.13.1', api_version='1.8', cpc_properties={ 'object-id': 'fake-cpc1-oid', # object-uri is set up automatically 'parent': None, 'class': 'cpc', 'name': 'fake-cpc1', 'description': 'Fake CPC #1 (DPM mode)', 'status': 'active', 'dpm-enabled': True, 'is-ensemble-member': False, 'iml-mode': 'dpm', 'available-features-list': [ dict(name='dpm-storage-management', state=True), ], })
def setup_method(self): self.hmc_creds = HmcCredentials()
class TestHMCCredentialsFile(object): """ Test your HMC credentials file, if you have one at the default location. """ def setup_method(self): self.hmc_creds = HmcCredentials() def test_1_format(self, capsys): """Test the format of the HMC credentials file.""" cpc_items = self.hmc_creds.get_cpc_items() if cpc_items is None: info(capsys, "HMC credentials file not found: %r - Skipping " "format check of HMC credentials file", self.hmc_creds.filepath) return assert len(cpc_items) > 0 def test_2_hmcs(self, capsys): """ Check out the HMCs specified in the HMC credentials file. Skip HMCs that cannot be contacted. """ cpc_items = self.hmc_creds.get_cpc_items() if cpc_items is None: info(capsys, "HMC credentials file not found: %r - Skipping the " "checking of HMCs", self.hmc_creds.filepath) return rt_config = zhmcclient.RetryTimeoutConfig( connect_timeout=10, connect_retries=1, ) # Check HMCs and their CPCs for cpc_name in cpc_items: cpc_item = cpc_items[cpc_name] hmc_host = cpc_item['hmc_host'] info(capsys, "Checking HMC %r for CPC %r", (hmc_host, cpc_name)) session = zhmcclient.Session( hmc_host, cpc_item['hmc_userid'], cpc_item['hmc_password'], retry_timeout_config=rt_config) client = zhmcclient.Client(session) try: session.logon() except zhmcclient.ConnectionError as exc: info(capsys, "Skipping HMC %r for CPC %r: %s", (hmc_host, cpc_name, exc)) continue cpcs = client.cpcs.list() cpc_names = [cpc.name for cpc in cpcs] if cpc_name not in cpc_names: raise AssertionError( "CPC {!r} not found in HMC {!r}.\n" "Existing CPCs: {!r}". format(cpc_name, hmc_host, cpc_names)) session.logoff()
def setup_method(self): """ Set up HMC data, Session to that HMC, Client, and Cpc object. """ self.hmc_creds = HmcCredentials() self.fake_data = dict( hmc_host='fake-host', hmc_name='fake-hmc', hmc_version='2.13.1', api_version='1.8', cpc_properties={ 'object-id': 'fake-cpc1-oid', # object-uri is set up automatically 'parent': None, 'class': 'cpc', 'name': 'CPC1', 'description': 'Fake CPC #1 (classic mode)', 'status': 'active', 'dpm-enabled': False, 'is-ensemble-member': False, 'iml-mode': 'lpar', }) self.faked_cpc_resources = { 'lpars': [ { 'properties': { 'partition-number': 0x41, 'partition-identifier': 0x41, 'name': 'LPAR1', 'status': 'operating', 'activation-mode': 'linux', 'next-activation-profile-name': 'LPAR1', 'last-used-activation-profile': 'LPAR1', }, }, { 'properties': { 'partition-number': 0x42, 'partition-identifier': 0x42, 'name': 'LPAR2', 'status': 'not-activated', 'activation-mode': 'not-set', 'next-activation-profile-name': 'LPAR2', 'last-used-activation-profile': 'LPAR2', }, }, ], 'reset_activation_profiles': [ { 'properties': { 'name': 'CPC1', 'iocds-name': 'ABC', }, }, ], 'load_activation_profiles': [ { 'properties': { 'name': 'LPAR1', 'ipl-type': 'ipltype-standard', 'ipl-address': '189AB', }, }, { 'properties': { 'name': 'LPAR2', 'ipl-type': 'ipltype-scsi', 'worldwide-port-name': '1234', 'logical-unit-number': '1234', 'boot-record-lba': '1234', 'disk-partition-id': 0, }, }, ], 'image_activation_profiles': [ { 'properties': { 'name': 'LPAR1', # TODO: Add more properties }, }, { 'properties': { 'name': 'LPAR2', # TODO: Add more properties }, }, ], } setup_logging()