Exemplo n.º 1
0
    def write_fdu_error(self, fdu_uuid, instance_uuid, errno, errmsg):
        '''
        Writes the given error for the given FDU instance in YAKS

        parameters
        ----------
        fdu_uuid : string
            UUID of the FDU
        instance_uuid : string
            UUID of the instance
        errno : int
            Error number
        errmsg : string
            Error message
        '''
        record = self.connector.loc.actual.get_node_fdu(
            self.node, self.uuid, fdu_uuid, instance_uuid)
        if record is None:
            record = self.connector.loc.desired.get_node_fdu(
                self.node, self.uuid, fdu_uuid, instance_uuid)
        record = InfraFDU(record)
        record.set_status('ERROR')
        record.set_error_code(errno)
        record.set_error_msg('{}'.format(errmsg))
        self.connector.loc.actual.add_node_fdu(self.node, self.uuid, fdu_uuid,
                                               instance_uuid, record.to_json())
Exemplo n.º 2
0
Arquivo: fimapi.py Projeto: tor7/fog05
        def resume(self, instanceid, wait=True):
            '''

            Resume an FDU instance

            :param instanceid: FDU instance you want to resume
            :param wait: make the function blocking
            :return: instanceid
            '''

            node = self.connector.glob.actual.get_fdu_instance_node(
                self.sysid, self.tenantid, instanceid)
            if node is None:
                raise ValueError('Unable to find node for this instanceid')

            record = self.connector.glob.actual.get_node_fdu_instance(
                self.sysid, self.tenantid, node, instanceid)

            record = InfraFDU(record)

            record.set_status('RESUME')
            fduid = record.get_fdu_id()

            res = self.connector.glob.desired.add_node_fdu(
                self.sysid, self.tenantid, node, fduid, instanceid,
                record.to_json())
            if wait:
                self.__wait_node_fdu_state_change(instanceid, 'RUN')
            return res
Exemplo n.º 3
0
Arquivo: fimapi.py Projeto: tor7/fog05
        def undefine(self, instanceid, wait=True):
            '''

            This method undefine an FDU instance from a None

            :param instanceid: FDU instance you want to undefine
            :param wait: if wait before returning that the entity is undefined
            :return: instanceid
            '''
            node = self.connector.glob.actual.get_fdu_instance_node(
                self.sysid, self.tenantid, instanceid)
            if node is None:
                raise ValueError('Unable to find node for this instanceid')

            record = self.connector.glob.actual.get_node_fdu_instance(
                self.sysid, self.tenantid, node, instanceid)

            record = InfraFDU(record)

            record.set_status('UNDEFINE')
            fduid = record.get_fdu_id()

            self.connector.glob.desired.add_node_fdu(self.sysid, self.tenantid,
                                                     node, fduid, instanceid,
                                                     record.to_json())
            return instanceid
Exemplo n.º 4
0
        def migrate(self, instanceid, destination_node_uuid, wait=True):
            '''
            Migrates the given instance

            paremeters
            ----------
            instanceid : string
                UUID of instance
            destination_node_uuid : string
                UUID of destination node
            wait : bool
                optional, call will block until FDU is migrated

            returns
            -------
            string
            '''

            node = self.connector.glob.actual.get_fdu_instance_node(
                self.sysid, self.tenantid, instanceid)
            if node is None:
                raise ValueError('Unable to find node for this instanceid')
            record = self.connector.glob.actual.get_node_fdu_instance(
                self.sysid, self.tenantid, node, instanceid)

            src_record = InfraFDU(record)
            dst_record = InfraFDU(record)

            fduid = record.get_fdu_id()

            src_record.set_status('TAKE_OFF')
            dst_record.set_status('LAND')

            src_record.set_migration_properties(node, destination_node_uuid)
            dst_record.set_migration_properties(node, destination_node_uuid)


            self.connector.glob.desired.add_node_fdu(self.sysid, self.tenantid,
                                                destination_node_uuid,
                                                fduid, instanceid, dst_record.to_json())
            self.connector.glob.desired.add_node_fdu(self.sysid, self.tenantid,
                                                node, fduid, instanceid, src_record.to_json())

            if wait:
                self.__wait_node_fdu_state_change(instanceid, 'RUN')
            return instanceid
Exemplo n.º 5
0
Arquivo: fimapi.py Projeto: tor7/fog05
        def migrate(self, instanceid, destination_node_uuid, wait=True):
            '''

            Live migrate an instance between two nodes

            The migration is issued when this command is sended,
             there is a little overhead for the copy of the base image and the disk image


            :param instanceid: fdu you want to migrate
            :param destination_node_uuid: destination node
            :param wait: optional wait before returning
            :return: instanceid
            '''

            node = self.connector.glob.actual.get_fdu_instance_node(
                self.sysid, self.tenantid, instanceid)
            if node is None:
                raise ValueError('Unable to find node for this instanceid')
            record = self.connector.glob.actual.get_node_fdu_instance(
                self.sysid, self.tenantid, node, instanceid)

            src_record = InfraFDU(record)
            dst_record = InfraFDU(record)

            fduid = record.get_fdu_id()

            src_record.set_status('TAKE_OFF')
            dst_record.set_status('LAND')

            src_record.set_migration_properties(node, destination_node_uuid)
            dst_record.set_migration_properties(node, destination_node_uuid)

            self.connector.glob.desired.add_node_fdu(self.sysid, self.tenantid,
                                                     destination_node_uuid,
                                                     fduid, instanceid,
                                                     dst_record.to_json())
            self.connector.glob.desired.add_node_fdu(self.sysid, self.tenantid,
                                                     node, fduid, instanceid,
                                                     src_record.to_json())

            if wait:
                self.__wait_node_fdu_state_change(instanceid, 'RUN')
            return instanceid
Exemplo n.º 6
0
 def update_fdu_status(self, fdu_uuid, instance_uuid, status):
     record = self.connector.loc.actual.get_node_fdu(
         self.node, self.uuid, fdu_uuid, instance_uuid)
     if record is None:
         record = self.connector.loc.desired.get_node_fdu(
             self.node, self.uuid, fdu_uuid, instance_uuid)
     record = InfraFDU(record)
     record.set_status(status)
     self.connector.loc.actual.add_node_fdu(self.node, self.uuid, fdu_uuid,
                                            instance_uuid, record.to_json())
Exemplo n.º 7
0
 def write_fdu_error(self, fdu_uuid, instance_uuid, errno, errmsg):
     record = self.connector.loc.actual.get_node_fdu(
         self.node, self.uuid, fdu_uuid, instance_uuid)
     if record is None:
         record = self.connector.loc.desired.get_node_fdu(
             self.node, self.uuid, fdu_uuid, instance_uuid)
     record = InfraFDU(record)
     record.set_status('ERROR')
     record.set_error_code(errno)
     record.set_error_msg('{}'.format(errmsg))
     self.connector.loc.actual.add_node_fdu(self.node, self.uuid, fdu_uuid,
                                            instance_uuid, record.to_json())
Exemplo n.º 8
0
    def update_fdu_status(self, fdu_uuid, instance_uuid, status):
        '''
        Updates the status of the given FDU instance in YAKS

        parameters
        ----------
        fdu_uuid : string
            UUID of the FDU
        instance_uuid : string
            UUID of the instance
        status : string
            New status of the instance
        '''
        record = self.connector.loc.actual.get_node_fdu(
            self.node, self.uuid, fdu_uuid, instance_uuid)
        if record is None:
            record = self.connector.loc.desired.get_node_fdu(
                self.node, self.uuid, fdu_uuid, instance_uuid)
        record = InfraFDU(record)
        record.set_status(status)
        self.connector.loc.actual.add_node_fdu(self.node, self.uuid, fdu_uuid,
                                               instance_uuid, record.to_json())
Exemplo n.º 9
0
        def stop(self, instanceid, wait=True):
            '''
            Stops the given instance

            paremeters
            ----------
            instanceid : string
                UUID of instance
            wait : bool
                optional, call will block until FDU is stopeed

            returns
            -------
            string
            '''

            node = self.connector.glob.actual.get_fdu_instance_node(
                self.sysid, self.tenantid, instanceid)
            if node is None:
                raise ValueError('Unable to find node for this instanceid')

            record = self.connector.glob.actual.get_node_fdu_instance(
                self.sysid, self.tenantid, node, instanceid)

            record = InfraFDU(record)

            record.set_status('STOP')
            fduid = record.get_fdu_id()

            res = self.connector.glob.desired.add_node_fdu(self.sysid, self.tenantid, node, fduid, instanceid, record.to_json())
            if wait:
                self.__wait_node_fdu_state_change(instanceid,  'CONFIGURE')
            return instanceid
Exemplo n.º 10
0
        def undefine(self, instanceid):
            '''
            Undefines the given instance

            paremeters
            ----------
            instanceid : string
                UUID of instance


            returns
            -------
            string
            '''
            node = self.connector.glob.actual.get_fdu_instance_node(self.sysid, self.tenantid, instanceid)
            if node is None:
                raise ValueError('Unable to find node for this instanceid')

            record = self.connector.glob.actual.get_node_fdu_instance(
                self.sysid, self.tenantid, node, instanceid)

            record = InfraFDU(record)

            record.set_status('UNDEFINE')
            fduid = record.get_fdu_id()

            self.connector.glob.desired.add_node_fdu(self.sysid, self.tenantid, node, fduid, instanceid, record.to_json())
            return instanceid