Package com.cloud.user

Examples of com.cloud.user.UserContext


        });
    }

    @Override @ActionEvent(eventType = EventTypes.EVENT_ROUTER_STOP, eventDescription = "stopping router Vm", async = true)
    public VirtualRouter stopRouter(long routerId, boolean forced) throws ResourceUnavailableException, ConcurrentOperationException {
        UserContext context = UserContext.current();
        Account account = context.getCaller();

        // verify parameters
        DomainRouterVO router = _routerDao.findById(routerId);
        if (router == null) {
            throw new InvalidParameterValueException("Unable to find router by id " + routerId + ".");
View Full Code Here


        }
    }

    //Ensure router status is update to date before execute this function. The function would try best to recover all routers except MASTER
    protected void recoverRedundantNetwork(DomainRouterVO masterRouter, DomainRouterVO backupRouter) {
        UserContext context = UserContext.current();
        context.setAccountId(1);                           
        if (masterRouter.getState() == State.Running && backupRouter.getState() == State.Running) {
            HostVO masterHost = _hostDao.findById(masterRouter.getHostId());
            HostVO backupHost = _hostDao.findById(backupRouter.getHostId());
            if (masterHost.getStatus() == Status.Up && backupHost.getStatus() == Status.Up) {
                String title =  "Reboot " + backupRouter.getInstanceName() + " to ensure redundant virtual routers work";
View Full Code Here

        return false;
    }

    @Override
    public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
        UserContext context = UserContext.current();
        context.setAccountId(1);
        List<DomainRouterVO> routers = _routerDao.listIsolatedByHostId(host.getId());
        for (DomainRouterVO router : routers) {
            if (router.isStopPending()) {
                State state = router.getState();
                if (state != State.Stopped && state != State.Destroyed) {
View Full Code Here

    SearchBuilder<RemoteAccessVpnVO> VpnSearch;

    @Override
    public RemoteAccessVpn createRemoteAccessVpn(long publicIpId, String ipRange, boolean openFirewall, long networkId)
            throws NetworkRuleConflictException {
        UserContext ctx = UserContext.current();
        Account caller = ctx.getCaller();

        // make sure ip address exists
        PublicIpAddress ipAddr = _networkMgr.getPublicIpAddress(publicIpId);
        if (ipAddr == null) {
            throw new InvalidParameterValueException("Unable to create remote access vpn, invalid public IP address id" + publicIpId);
View Full Code Here

    @Override
    public void finalizeStop(VirtualMachineProfile<SecondaryStorageVmVO> profile, StopAnswer answer) {
        //release elastic IP here
        IPAddressVO ip = _ipAddressDao.findByAssociatedVmId(profile.getId());
        if (ip != null && ip.getSystem()) {
            UserContext ctx = UserContext.current();
            try {
                _rulesMgr.disableStaticNat(ip.getId(), ctx.getCaller(), ctx.getCallerUserId(), true);
            } catch (Exception ex) {
                s_logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex);
            }
        }
    }
View Full Code Here

    protected long saveStartedEvent() {
        return saveStartedEvent(getEventType(), "Executing job for " + getEventDescription(), getStartEventId());
    }

    protected long saveStartedEvent(String eventType, String description, Long startEventId) {
        UserContext ctx = UserContext.current();
        Long userId = ctx.getCallerUserId();
        userId = (userId == null) ? User.UID_SYSTEM : userId;
        Long startEvent = startEventId;
        if (startEvent == null) {
            startEvent = 0L;
        }
View Full Code Here

    protected long saveCompletedEvent(String level, String description) {
        return saveCompletedEvent(level, getEventType(), description, getStartEventId());
    }

    protected long saveCompletedEvent(String level, String eventType, String description, Long startEventId) {
        UserContext ctx = UserContext.current();
        Long userId = ctx.getCallerUserId();
        userId = (userId == null) ? User.UID_SYSTEM : userId;
        Long startEvent = startEventId;
        if (startEvent == null) {
            startEvent = 0L;
        }
View Full Code Here

    }


    @Override
    public void execute() throws ResourceUnavailableException {
        UserContext callerContext = UserContext.current();
        boolean success = true;
        PortForwardingRule rule = null;
        try {
            UserContext.current().setEventDetails("Rule Id: " + getEntityId());

            if (getOpenFirewall()) {
                success = success && _firewallService.applyIngressFirewallRules(ipAddressId, callerContext.getCaller());
            }

            success = success && _rulesService.applyPortForwardingRules(ipAddressId, callerContext.getCaller());

            // State is different after the rule is applied, so get new object here
            rule = _entityMgr.findById(PortForwardingRule.class, getEntityId());
            FirewallRuleResponse fwResponse = new FirewallRuleResponse();
            if (rule != null) {
View Full Code Here

        cidrlist = cidrs;
    }

    @Override
    public void execute() throws ResourceUnavailableException {
        UserContext callerContext = UserContext.current();
        boolean success = false;
        FirewallRule rule = _entityMgr.findById(FirewallRule.class, getEntityId());
        try {
            UserContext.current().setEventDetails("Rule Id: " + getEntityId());
            success = _firewallService.applyIngressFirewallRules(rule.getSourceIpAddressId(), callerContext.getCaller());

            // State is different after the rule is applied, so get new object here
            rule = _entityMgr.findById(FirewallRule.class, getEntityId());
            FirewallResponse fwResponse = new FirewallResponse();
            if (rule != null) {
View Full Code Here

    @Override
    public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, StopAnswer answer) {
        //release elastic IP here if assigned
        IPAddressVO ip = _ipAddressDao.findByAssociatedVmId(profile.getId());
        if (ip != null && ip.getSystem()) {
            UserContext ctx = UserContext.current();
            try {
                _rulesMgr.disableStaticNat(ip.getId(), ctx.getCaller(), ctx.getCallerUserId(), true);
            } catch (Exception ex) {
                s_logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex);
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.cloud.user.UserContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.