예제 #1
0
 def setupCredentials(self):
     """
     Create Credentials or Manage existing Credentials        
     """
     logger = self.getLoggerInstance()
     credentialConfig, status = self.loadCredentialInputs()
     if not status:
         return credentialConfig, False
     resCRE, statCRE = self.getResponse("GET", "Credential")
     creResponse = []
     for credential in credentialConfig:
         found = False
         if not statCRE and "No information found" in resCRE:
             found = False
         else:
             found = [
                 creList["credential"]["id"]
                 for creList in resCRE["credentialList"]
                 if creList["credential"]["label"] == credential["Name"]
             ]
         if not found:
             action = "POST"
             creId = ""
         else:
             action = "PUT"
             creId = found[0]
         resDC, statDC = self.defineCredential(credential, creId, action)
         creResponse.append(str(resDC))
         if not statDC:
             return creResponse, False
         if not found: creId = resDC["credential"]["id"]
         self.credentialMap[credential["Name"]] = creId
     logger.info(' credentialMap : ')
     logger.debug(self.credentialMap)
     return creResponse, True
예제 #2
0
    def test_cleanePublishedTemplates(self):

        response = self.cleanUpTemplates()
        logger = self.getLoggerInstance()
        logger.debug('Cleaning Published Template Response is')
        logger.info(response)
        self.log_data("Cleaning Published Template Response is :%s" %
                      str(response))
예제 #3
0
    def test_cleanDeployedTemplates(self):

        response = self.cleanUpServices()
        logger = self.getLoggerInstance()
        logger.debug('Cleaning Deployed  Services  Response is')
        logger.info(response)
        logger.info(response)
        self.log_data("Cleaning Deployed  Services  Response is :%s" %
                      str(response))
예제 #4
0
    def getAddOnModule(self):
        """
        Get list of  add on module         
        """
        logger = self.getLoggerInstance()
        resCRE, statCRE = self.getResponse("GET", "AddOnModule")

        logger.info('Add On Module : ')
        logger.debug(resCRE)
        return resCRE, True
예제 #5
0
 def getAddOnModuleById(self, refId=""):
     """
     Get list of  add on module         
     """
     logger = self.getLoggerInstance()
     response, status = self.getResponse("GET", "AddOnModule", refId=refId)
     if status:
         logger.info('Add On got successfully bye refId: ')
         logger.debug(response)
         self.log_data('Add On Module get successfully:')
         self.log_data('Payload:')
         self.log_data(response)
         return response, True
     else:
         "Please check URI not able to get add on module info", False
예제 #6
0
 def createAddOnModule(self):
     """
     Get list of  add on module         
     """
     logger = self.getLoggerInstance()
     payload = self.readFile(globalVars.addOnModulePayload)
     payload = payload.replace("$uploadUrl", globalVars.aDDOnModulePath)
     response, status = self.getResponse("POST", "AddOnModule", payload)
     if status:
         logger.info('Add On Module created successfully: ')
         logger.debug(response)
         self.log_data('Add On Module created successfully:')
         self.log_data('Payload:')
         self.log_data(payload)
         return response, True
     else:
         "Please check input value add on module not created", False
예제 #7
0
    def findNetworksIdAddress(self,
                              nwid="",
                              action="GET",
                              payload="",
                              verify=False):
        """
        Getting used Networks id..Network must be defined         
        """

        url = self.buildUrl("Network")
        url = url + "/" + "%s" % nwid + "/" + "ipaddresses"
        logger = self.getLoggerInstance()
        logger.info("url")
        logger.info(url)

        uri = self.buildHeaderUri("Network")
        uri = uri + "/" + "%s" % nwid + "/" + "ipaddresses"
        startTime = datetime.datetime.now()
        logger.info(startTime)

        headers = self.generateSecurityHeader(uri, 'GET', globalVars.apiKey,
                                              globalVars.apiSecret,
                                              globalVars.userAgent)
        response = requests.get(url, headers=headers, verify=verify)
        endTime = datetime.datetime.now()
        elapsedTime = "%s" % (endTime - startTime)
        if response.text != "":
            self.log_data(
                "%s\nAction: %s \nHeader: %s \nPayload: %s" %
                (url, action, headers, payload), response.status_code, "",
                startTime, endTime, elapsedTime)

        else:
            self.log_data(
                "%s\nAction: %s \nHeader: %s \nPayload: %s" %
                (url, action, headers, payload), response.status_code,
                response.text, startTime, endTime, elapsedTime)
            time.sleep(globalVars.defReqWaitTime)
        if response.status_code in (200, 201, 202, 203, 204):
            # requests.codes.OK:
            if response.text != "":
                data = json.loads(response.text)
                return self.convertUTA(data), True
            else:
                return "No information found", False

        else:
            "Not able to get network ip list", False
def create_goal_context():
    #print "The ROS argument is:", args.ros
    neurobots_dict = None
    if args.ros != False: # != False makes sure that processing --ros without parameters (an empty list) ends up in the second branch
        logger.info("Fetching problem from ROS database")
        import ros_database
        (prob,neurobots_dict) = ros_database.get_problem_from_database(dom)
    else:
        logger.info("Loading problem %s" % args.problem)
        prob = pddl.load_problem(args.problem, dom)
    logger.debug("REF: " + args.references)
    refs = reference_list.ReferenceList(prob, args.references)
    
    serialization_path = "/tmp/reference_list" if not args.serialized_partitions else (args.serialized_partitions[0])
    file_serialization = serialization_path + ".ser"
    file_serialization_hash = serialization_path + "_hash.ser"
    
    world_hash_ok = check_world_hash(file_serialization_hash, neurobots_dict)
    constants.WORLD_HASH_OK = world_hash_ok
    constants.SERIALIZATION_PATH = serialization_path
    
    if not world_hash_ok:
        create_world_hash_file(file_serialization_hash, neurobots_dict)
    
    if not constants.SERIALIZE_PARTITIONS or (constants.SERIALIZE_PARTITIONS and not refs.deserialize(file_serialization)):
        logger.debug("\033[93m atomic_partitions\033[0m")
        refs.create_atomic_partitions()
        logger.debug("\033[93m extended_partitions\033[0m")
        refs.create_extended_partitions()
        logger.debug("\033[93m optimistic_partitions\033[0m")
        refs.create_optimistic_partitions()
        if constants.SERIALIZE_PARTITIONS:
            refs.serialize(file_serialization)
            
    if args.refs:
        logger.debug("Refs...")
        logger.debug("refs: " + args.refs)
        if args.type is not None:
            types = [dom.types[args.type]]
            logger.debug("types:" + types)
        else:
            types = dom.types.itervalues()

        for t in types:
            logger.debug("\n")
            logger.debug(t + ":")
            for p in refs.type_partitions[t]:
                logger.debug( "     %.2f|%.2f:  %s" % (p.information(), p.information(potential=True), p))

            logger.debug( "   total I: ~%.2f" % refs.type_information[t])

        # for t in types:
        #     groups = refs.filter_groups(refs.groups, typ=t)
        #     if not groups:
        #         continue
        #     print t, ":"
        #     best = refs.get_best_groups(t)
        #     print "   ", refs.group_gain(best, typ=t), map(lambda x: map(str, x), best)
        #     print "\n"
        #     for g in refs.get_all_groups(t):
        #         I = refs.group_gain([g], typ=t)
        #         print "      ", I , map(str, g)
        exit(0)
    return (goals.GoalContext(prob, refs),neurobots_dict)
import pddllib.extensions

pddl.register_extension_package(pddllib.extensions)

import goals, reference_list, references, partitions, evaluation

rospack = rospkg.RosPack()
config_path = rospack.get_path('goal_planner_gui')
config_path += '/src/'

setupLogger()

if args.mute:
    logger.setLevel(logging.CRITICAL)

logger.info("Loading domain %s" % args.domain)
dom = pddl.load_domain(args.domain)

def create_world_hash_file(file, neurobots_dict):
    import os.path
    file = open(file, 'w')
    h = hash(str(neurobots_dict))
    logger2.debug("Write hash of world to disk: %s", h)
    file.write(str(h))
    file.close()
    
def check_world_hash(file, neurobots_dict):
    import os.path
    logger2.debug("world hash file: %s!", file)
    if os.path.isfile(file):
        h = hash(str(neurobots_dict))
예제 #10
0
 def test_cleanCredential(self):
     response = self.cleanCredential()
     logger = self.getLoggerInstance()
     logger.debug('Cleane Credential Response is')
     logger.info(response)
예제 #11
0
 def test_cleanNetwork(self):
     response = self.cleanNetwork()
     logger = self.getLoggerInstance()
     logger.debug('Cleane Network Response is')
     logger.info(response)
예제 #12
0
 def test_cleanManagedDevice(self):
     response = self.cleanManagedDevice()
     logger = self.getLoggerInstance()
     logger.debug('Cleane ManagedDevice Devices Response is')
     logger.info(response)
예제 #13
0
 def test_cleanDiscoveryDevice(self):
     response = self.cleanDiscovery()
     logger = self.getLoggerInstance()
     logger.debug('Cleane descovery Devices Response is')
     logger.info(response)
예제 #14
0
    def test_cleaneServerPool(self):

        response = self.cleanServerPool()
        logger = self.getLoggerInstance()
        logger.debug('Cleane Server Pool Response is')
        logger.info(response)