Example #1
0
 def adjust_for_heartbeat(self, parents):
     LOG.debug('Virtman: adjust_for_heartbeat according to '
               'connections: %s ' % parents)
     parent_connections = utils.reform_connections(parents)
     if self.is_local_has_image or len(parent_connections) == 0:
         parent_connections = self.image_connections
     self.rebuild_multipath(parent_connections)
Example #2
0
    def _deploy_base_image(self):
        # TODO: Roll back if failed !
        """
        deploy image in compute node, return the origin path to create snapshot
        :param image_connection: the connection towards to the base image
        :returns: origin path to create snapshot
        """
        LOG.debug("Virtman: in deploy_base_image, image name = %s, "
                  "has multipath = %s, has origin = %s, has cache = %s, "
                  "is_login = %s" %
                  (self.image_name, self.has_multipath, self.has_origin,
                   self.has_cache, self.is_login))
        # Check if it had origin or not!
        if self.has_origin:
            return self.origin_path

        # save the base_image paths
        found = None
        for connection in self.image_connections:
            if connection['target_portal'].find(CONF.host_ip) >= 0:
                found = connection
                break
        if found is not None:
            self.image_connections = [found]
            self.is_local_has_image = True
        LOG.debug("Virtman: my host_ip = %s, is_local_has_image = %s!,"
                  " now image_connections = %s" %
                  (CONF.host_ip, self.is_local_has_image,
                   self.image_connections))

        # Reform connections
        if self.is_local_has_image:
            parent_connections = []
        else:
            parent_connections = utils.reform_connections(self._get_parent())
        LOG.debug("Virtman: parents for volt is %s" % parent_connections)
        self.rebuild_multipath(parent_connections)
        build_chain = Chain()
        build_chain.add_step(partial(self._create_cache),
                             partial(self._delete_cache))
        build_chain.add_step(partial(self._create_origin),
                             partial(self._delete_origin))
        build_chain.add_step(partial(self._create_target),
                             partial(self._delete_target))
        build_chain.add_step(partial(self._login_master),
                             partial(self._logout_master))
        build_chain.do()

        # self._create_cache()
        # self._create_origin()
        # self._create_target()
        # self._login_master()

        LOG.debug("Virtman: baseimage OK!\n"
                  "target_id =  %s, origin_path = %s, origin_name = %s, "
                  "cached_path = %s, multipath_path = %s, multipath_name = %s" %
                  (self.target_id, self.origin_path, self.origin_name,
                   self.cached_path, self.multipath_path, self.multipath_name))

        return self.origin_path
Example #3
0
    def modify_parent_connection(self):
        if self.is_local_has_image:
            parent_connections = self.image_connections
        else:
            parent_connections = \
                utils.reform_connections(self.get_parent()) or \
                self.image_connections

        return parent_connections
Example #4
0
 def __init__(self, image_name, image_connections):
     super(FakeBaseImage, self).__init__()
     self.image_name = image_name
     self.multipath_name = 'multipath_' + self.image_name
     self.origin_name = 'origin_' + self.image_name
     self.image_connections = utils.reform_connections(image_connections)
     self.is_local_has_image = False
     self.paths = {}
     self.has_target = False
     self.is_login = False
     self.iqn = self.image_connections[0]['target_iqn']
     self.multipath_path = None
     self.cached_path = None
     self.origin_path = None
     self.peer_id = ''
     self.target_id = 0
     LOG.debug("Virtman: initialize base image of image_name %s" %
               self.image_name)
Example #5
0
 def __init__(self, image_name, image_connections):
     self.image_name = image_name
     self.image_connections = utils.reform_connections(image_connections)
     self.is_local_has_image = False
     self.paths = {}
     self.has_multipath = False
     self.has_cache = False
     self.has_origin = False
     self.has_target = False
     self.is_login = False
     self.iqn = self.image_connections[0]['target_iqn']
     self.multipath_name = 'multipath_' + self.image_name
     self.origin_name = 'origin_' + self.image_name
     self.multipath_path = None
     self.cached_path = None
     self.origin_path = None
     # TODO: all virtual machines called image
     self.peer_id = ''
     self.target_id = 0
     self.status = STATUS.empty
     self.status_lock = threading.Lock()
     LOG.debug("Virtman: creating a base image of image_name %s" %
               self.image_name)
Example #6
0
 def adjust_for_heartbeat(self, parents):
     LOG.debug('Virtman: adjust_for_heartbeat according to '
               'connections: %s ' % parents)
     parent_connections = utils.reform_connections(parents)
     self.rebuild_multipath(parent_connections)