示例#1
0
    def reassign():
        # NOTE(akscram): Initialization of fuelclient.
        fuel_config = flask.current_app.config["CLOUDS"]["fuel"]["endpoint"]
        os.environ["SERVER_ADDRESS"] = fuel_config["host"]
        os.environ["LISTEN_PORT"] = str(fuel_config["port"])
        os.environ["KEYSTONE_USER"] = fuel_config["username"]
        os.environ["KEYSTONE_PASS"] = fuel_config["password"]

        src_config = hooks.source.config()
        dst_config = hooks.destination.config()
        config = {
            "source": src_config["environment"],
            "destination": dst_config["environment"],
        }

        try:
            src = hooks.source.connect()
            dst = hooks.destination.connect()
            ctx = context.Context(config, src, dst)

            flow = node_tasks.reassign_node(ctx, host_id)
            LOG.debug("Reassigning flow: %s", flow)
            result = flows.run_flow(flow, ctx.store)
            LOG.debug("Result of migration: %s", result)
        except Exception:
            msg = ("Error is occured during reassigning host {}"
                   .format(host_id))
            LOG.exception(msg)
            events.emit("error", {
                "message": msg,
            }, namespace="/events")
示例#2
0
 def created_event(self, flavor):
     LOG.info("Flavor created: %s", flavor.id)
     events.emit(
         "create",
         {"id": flavor.id, "type": "flavor", "cloud": self.cloud.name, "data": flavor.to_dict()},
         namespace="/events",
     )
示例#3
0
文件: node.py 项目: UshF/pumphouse
 def unassign_start_event(self, node):
     events.emit("update", {
         "id": extract_hostname(node.data),
         "cloud": self.cloud.name,
         "type": "host",
         "action": "reassignment",
     }, namespace="/events")
示例#4
0
 def delete_event(self, keypair_info):
     LOG.info("Deleted keypair: %s", keypair_info["name"])
     events.emit(
         "delete",
         {"id": keypair_info["name"], "type": "keypair", "cloud": self.cloud.name, "data": None},
         namespace="/events",
     )
示例#5
0
 def create_event(self, keypair):
     LOG.info("Created keypair: %s", keypair.name)
     events.emit(
         "create",
         {"id": keypair.name, "type": "keypair", "cloud": self.cloud.name, "data": keypair.to_dict()},
         namespace="/events",
     )
示例#6
0
 def created_event(self, secgroup_info):
     events.emit("create", {
         "id": secgroup_info["id"],
         "type": "secgroup",
         "cloud": self.cloud.name,
         "data": secgroup_info,
     }, namespace="/events")
示例#7
0
文件: volume.py 项目: rmoe/pumphouse
 def upload_to_glance_event(self, image_info):
     LOG.info("Created: %s", image_info)
     events.emit("create", {
         "id": image_info["id"],
         "cloud": self.cloud.name,
         "type": "image",
         "data": dict(image_info)
     }, namespace="/events")
示例#8
0
文件: volume.py 项目: UshF/pumphouse
 def upload_to_glance_event(self, image_info):
     LOG.info("Created: %s", image_info)
     events.emit("volume snapshot create", {
         "cloud": self.cloud.name,
         "id": image_info["id"],
         "name": image_info["name"],
         "status": "active",
     }, namespace="/events")
示例#9
0
 def created_event(self, floating_ip):
     events.emit("create", {
         "id": floating_ip.address,
         "type": "floating_ip",
         "cloud": self.cloud.name,
         "data": dict(floating_ip.to_dict(),
                      name=floating_ip.address),
     }, namespace="/events")
示例#10
0
文件: node.py 项目: UshF/pumphouse
 def update_event(self, service):
     events.emit("update", {
         "id": service["host"],
         "cloud": self.cloud.name,
         "type": "host",
         "progress": None,
         "action": None,
     }, namespace="/events")
示例#11
0
文件: server.py 项目: rmoe/pumphouse
 def resume_event(self, server):
     LOG.info("Server resumed: %s", server["id"])
     events.emit("update", {
         "id": server["id"],
         "cloud": self.cloud.name,
         "type": "server",
         "data": server,
     }, namespace="/events")
示例#12
0
文件: server.py 项目: rmoe/pumphouse
 def execute(self, server_id):
     LOG.info("Migration of server %r started", server_id)
     events.emit("update", {
         "id": server_id,
         "cloud": self.cloud.name,
         "type": "server",
         "action": "migration",
     }, namespace="/events")
示例#13
0
 def created_event(self, tenant):
     LOG.info("Tenant created: %s", tenant.id)
     events.emit("create", {
         "id": tenant.id,
         "type": "tenant",
         "cloud": self.cloud.name,
         "data": tenant.to_dict(),
     }, namespace="/events")
示例#14
0
 def created_event(self, snapshot):
     events.emit("create", {
         "id": snapshot["id"],
         "type": "image",
         "cloud": self.cloud.name,
         "action": "uploading",
         "data": dict(snapshot),
     }, namespace="/events")
示例#15
0
 def created_event(self, user):
     LOG.info("Created user: %s", user)
     events.emit("create", {
         "id": user.id,
         "type": "user",
         "cloud": self.cloud.name,
         "data": user.to_dict(),
     }, namespace="/events")
示例#16
0
 def execute(self, volume, target_host):
     LOG.info("Evacuating volume %s to host %s...", volume.id, target_host)
     self.cloud.cinder.volumes.migrate_volume(volume, target_host, False)
     volume = utils.wait_for(volume.id, self.cloud.cinder.volumes.get,
                             get_volume_host, target_host)
     events.emit("update", event_from(self.cloud, volume),
                 namespace="/events")
     LOG.info("Evacuated volume %s to host %s", volume.id, target_host)
示例#17
0
 def assigned_event(self, address, server_id):
     events.emit("update", {
         "id": address,
         "type": "floating_ip",
         "cloud": self.cloud.name,
         "data": {
             "server_id": server_id,
         }
     }, namespace="/events")
示例#18
0
文件: image.py 项目: UshF/pumphouse
 def created_event(self, image):
     LOG.info("Image created: %s", image["id"])
     events.emit("create", {
         "id": image["id"],
         "type": "image",
         "cloud": self.dst_cloud.name,
         "action": "uploading",
         "data": dict(image),
     }, namespace="/events")
示例#19
0
文件: server.py 项目: rmoe/pumphouse
 def detach_event(self, volume_id):
     LOG.info("Volume updated: %s", volume_id)
     events.emit("update", {
         "id": volume_id,
         "cloud": self.cloud.name,
         "type": "volume",
         "action": "detach",
         "data": dict(server_ids=[]),
     }, namespace="/events")
示例#20
0
文件: image.py 项目: UshF/pumphouse
 def uploaded_event(self, image):
     LOG.info("Image uploaded: %s", image["id"])
     events.emit("update", {
         "id": image["id"],
         "type": "image",
         "cloud": self.dst_cloud.name,
         "progress": None,
         "action": None,
         "data": dict(image),
     }, namespace="/events")
示例#21
0
 def block_event(self, hostname):
     LOG.info("Service %r was blocked on host %r", self.binary, hostname)
     events.emit("update", {
         "id": hostname,
         "type": "host",
         "cloud": self.cloud.name,
         "data": {
             "status": "blocked",
         }
     }, namespace="/events")
示例#22
0
文件: volume.py 项目: UshF/pumphouse
 def create_volume_event(self, volume_info):
     LOG.info("Created: %s", volume_info)
     events.emit("volume create", {
         "cloud": self.cloud.name,
         "id": volume_info["id"],
         "status": "active",
         "display_name": volume_info["display_name"],
         "tenant_id": volume_info.get("os-vol-tenant-attr:tenant_id"),
         "host_id": volume_info.get("os-vol-host-attr:host"),
         "attachment_server_ids": [],
     }, namespace="/events")
示例#23
0
文件: node.py 项目: UshF/pumphouse
 def assign_start_event(self, node):
     hostname = extract_hostname(node.data)
     events.emit("create", {
         "id": hostname,
         "cloud": self.cloud.name,
         "type": "host",
         "action": "reassignment",
         "data": {
             "name": hostname,
         }
     }, namespace="/events")
示例#24
0
文件: node.py 项目: UshF/pumphouse
 def provisioning_event(self, progress, node):
     LOG.debug("Waiting for deploy: %r, %r", progress, node)
     events.emit("update", {
         "id": extract_hostname(node.data),
         "type": "host",
         "cloud": self.cloud.name,
         "progress": node.data["progress"],
         "data": {
             "status": node.data["status"],
         }
     }, namespace="/events")
示例#25
0
文件: server.py 项目: rmoe/pumphouse
 def terminate_event(self, server):
     LOG.info("Server terminated: %s", server["id"])
     events.emit("delete", {
         "id": server["id"],
         "type": "server",
         "cloud": self.cloud.name,
     }, namespace="/events")
     server_volumes = server.get("os-extended-volumes:volumes_attached",
                                 [])
     for volume in server_volumes:
         self.detach_event(volume["id"])
示例#26
0
文件: volume.py 项目: rmoe/pumphouse
 def create_volume_event(self, volume_info):
     LOG.info("Created: %s", volume_info)
     events.emit("create", {
         "id": volume_info["id"],
         "cloud": self.cloud.name,
         "type": "volume",
         "data": dict(volume_info,
                      host_id=volume_info.get("os-vol-host-attr:host", None),
                      name=volume_info["display_name"],
                      server_ids=[att["server_id"]
                                  for att in volume_info["attachments"]]),
     }, namespace="/events")
示例#27
0
文件: image.py 项目: UshF/pumphouse
 def report(self, absolute):
     cloud_name, src_image, dst_image = self.context
     LOG.info("Image %r uploaded on %3.2f%%",
              dst_image["id"], absolute * 100)
     events.emit("update", {
         "id": dst_image["id"],
         "type": "image",
         "cloud": cloud_name,
         "action": None,
         "progress": round(absolute * 100),
         "data": dict(dst_image),
     }, namespace="/events")
示例#28
0
 def execute(self, attachment):
     self.cloud.nova.volumes.create_server_volume(
         attachment["server_id"],
         attachment["volume_id"],
         attachment["device"],
     )
     volume = utils.wait_for(
         attachment["volume_id"],
         self.cloud.cinder.volumes.get,
         value="in-use",
     )
     events.emit("update", event_from(self.cloud, volume),
                 namespace="/events")
     LOG.info("Reattached volume %(volume_id)s from server %(server_id)s",
              attachment)
示例#29
0
文件: server.py 项目: rmoe/pumphouse
 def revert(self, server_id, result, flow_failures):
     msg = ("Migration of server {} failed by reason {}"
            .format(server_id, result))
     LOG.warning(msg)
     events.emit("log", {
         "level": "error",
         "message": msg,
     }, namespace="/events")
     events.emit("update", {
         "id": server_id,
         "cloud": self.cloud.name,
         "type": "server",
         "progress": None,
         "action": None,
     }, namespace="/events")
示例#30
0
文件: server.py 项目: rmoe/pumphouse
 def spawn_event(self, server):
     LOG.info("Server spawned: %s", server)
     if HYPERVISOR_HOSTNAME_ATTR not in server:
         LOG.warning("Could not get %r attribute from server %r",
                     HYPERVISOR_HOSTNAME_ATTR, server)
         return
     hostname = server[HYPERVISOR_HOSTNAME_ATTR]
     events.emit("create", {
         "id": server["id"],
         "cloud": self.cloud.name,
         "type": "server",
         "action": "migration",
         "data": dict(server,
                      image_id=server["image"]["id"],
                      host_id=hostname),
     }, namespace="/events")