def init_odata_id(self, odata_id, system_dir, system_url): """ ADD DOCUMENTATION """ self._config = utils.process_id(odata_id, system_dir, system_url) self.odata_id = self._config['@odata.id'] if 'links' in self._config: self.link_key = 'links' self.members_ids = self._config[self.link_key]['Members'] for member in self.members_ids: config = utils.process_id(member['@odata.id'], system_dir, system_url) vlans = None if 'VLANs' in config['Links']: vlans_config = utils.process_id( config['Links']['VLANs']['@odata.id'], system_dir, system_url) vlans_members = [] for vlan in vlans_config['Links']['Members']: vlans_members.append( utils.process_id(vlan['@odata.id'], system_dir, system_url)) vlans = VLANs(vlans_config, vlans_members) member_obj = EthernetNetworkInterface(config, vlans) self.members.append(member_obj) self._calculate_ports()
def init_odata_id(self, odata_id, system_dir, system_url): """ Initialize via an OData ID """ self.odata_id = odata_id self._config = utils.process_id(odata_id, system_dir, system_url) devices = self._config['Devices'] for device in devices: kwargs = {} if 'OEM' in device: kwargs['oem'] = device['OEM'] if 'Manufacturer' in device: kwargs['manufacturer'] = device['Manufacturer'] if 'Size' in device: kwargs['size'] = device['Size'] if 'Model' in device: kwargs['model'] = device['Model'] self.devices.append( Device(device['Name'], device['Status'], **kwargs)) del self._config['Devices'] self.initialized = True
def init_odata_id(self, odata_id, system_dir, system_url): """ Populate the SimpleStorage object from the OData ID. Arguments: odata_id - OData ID in the system configuration system_dir - Directory of the index.html where the system resides rest_base - Chunk of the URL to remove """ self._config = utils.process_id(odata_id, system_dir, system_url) self.storage_gb = 0 self.odata_id = odata_id self.member_ids = self._config['Links']['Members'] # Populating the members list for member in self.member_ids: ss = SimpleStorage() ss.init_odata_id(member['@odata.id'], system_dir, system_url) self.members.append(ss) # Calculating amount of storage self._calculate_storage() # Updating the "Modified" key self._config['Modified'] = utils.timestamp() self.initialized = True