示例#1
0
    def do_instance_action(self, alarm_key, alarm, instance_actions):
        nc = utils.get_python_novaclient()

        for action in instance_actions:
            action_type, vm_uuid = parse_instance_action(action)
            server = nc.servers.get(vm_uuid)

            if action_type == "Migrate":
                server.migrate()
                LOG.info("instance action %s invoked for %s", action_type,
                         server)
            elif action_type == "Reboot":
                server.reboot('HARD')
                LOG.info("instance action %s invoked for %s", action_type,
                         server)
示例#2
0
    def _validate_instanceaction(self, actions, project_id, context):
        instanceactions = [action for action in actions 
                           if utils.validate_instance_action(action)]
        parsed = [utils.parse_instance_action(a) for a in instanceactions]
        nc = utils.get_python_novaclient()
        err = "Server is not found"
        
        for action_type, vm_uuid in parsed:
            try:
                server = nc.servers.get(vm_uuid)
            except NotFound:
                raise exception.InvalidParameterValue(err)

            if not context.is_admin and server.tenant_id != project_id:
                raise exception.InvalidParameterValue(err)
示例#3
0
 def do_instance_action(self, alarm_key, alarm, instance_actions):
     nc = utils.get_python_novaclient()
     
     for action in instance_actions:
         action_type, vm_uuid = parse_instance_action(action)
         server = nc.servers.get(vm_uuid)
         
         if action_type == "Migrate":
             server.migrate()
             LOG.info("instance action %s invoked for %s", action_type, 
                      server)
         elif action_type == "Reboot":
             server.reboot('HARD')
             LOG.info("instance action %s invoked for %s", action_type,
                      server)