+ def update_access_credentials(self, access_info):
+ """Verify if all the required access config params are provided and
+ updates access config in default vrops config file
+ """
+ update_status = False
+ wr_status = False
+ #Check if all the required config params are passed in request
+ if not all (keys in access_info for keys in req_config_params):
+ self.logger.debug("All required Access Config Parameters not provided")
+ self.logger.debug("List of required Access Config Parameters: {}".format(req_config_params))
+ self.logger.debug("List of given Access Config Parameters: {}".format(access_info))
+ return update_status
+
+ wr_status = self.write_access_config(access_info)
+ return wr_status #True/False
+
+ def write_access_config(self, access_info):
+ """Write access configuration to vROPs config file.
+ """
+ wr_status = False
+ try:
+ tree = XmlElementTree.parse(CONFIG_FILE_PATH)
+ root = tree.getroot()
+ alarmParams = {}
+ for config in root:
+ if config.tag == 'Access_Config':
+ for param in config:
+ for key,val in access_info.iteritems():
+ if param.tag == key:
+ #print param.tag, val
+ param.text = val
+
+ tree.write(CONFIG_FILE_PATH)
+ wr_status = True
+ except Exception as exp:
+ self.logger.warn("Failed to update Access Config Parameters: {}".format(exp))
+
+ return wr_status
+
+
+ def publish_access_update_response(self, access_update_status, access_info_req):
+ """Publish access update response
+ """
+ topic = 'access_credentials'
+ msg_key = 'vim_access_credentials_response'
+ response_msg = {"schema_version":1.0,
+ "schema_type":"vim_access_credentials_response",
+ "correlation_id":access_info_req['access_config']['correlation_id'],
+ "status":access_update_status
+ }
+ self.logger.info("Publishing response:\nTopic={}\nKey={}\nValue={}"\
+ .format(topic, msg_key, response_msg))
+ #Core Add producer
+ self.producer_access_credentials.publish(key=msg_key, value=json.dumps(response_msg), topic=topic)