Search in sources :

Example 1 with NetworkOfferingVO

use of com.cloud.offerings.NetworkOfferingVO in project cloudstack by apache.

the class NuageVspEntityBuilder method buildVspNetwork.

public VspNetwork buildVspNetwork(long domainId, Network network) {
    VspNetwork.Builder vspNetworkBuilder = new VspNetwork.Builder().id(network.getId()).uuid(network.getUuid()).name(network.getName()).cidr(network.getCidr()).gateway(network.getGateway());
    DomainVO domain = _domainDao.findById(domainId);
    VspDomain vspDomain = buildVspDomain(domain);
    vspNetworkBuilder.domain(vspDomain);
    AccountVO account = _accountDao.findById(network.getAccountId());
    if (account != null) {
        vspNetworkBuilder.accountUuid(account.getUuid()).accountName(account.getAccountName());
    }
    NetworkOfferingVO networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId());
    vspNetworkBuilder.egressDefaultPolicy(networkOffering.getEgressDefaultPolicy()).publicAccess(networkOffering.getSupportsPublicAccess());
    if (network.getVpcId() != null) {
        VpcVO vpc = _vpcDao.findById(network.getVpcId());
        vspNetworkBuilder.vpcUuid(vpc.getUuid()).vpcName(vpc.getName()).networkType(VspNetwork.NetworkType.Vpc);
    } else {
        if (networkOffering.getGuestType() == Network.GuestType.Shared) {
            List<VlanVO> vlans = _vlanDao.listVlansByNetworkIdIncludingRemoved(network.getId());
            List<VspAddressRange> vspAddressRanges = Lists.transform(vlans, new Function<VlanVO, VspAddressRange>() {

                @Nullable
                @Override
                public VspAddressRange apply(VlanVO vlanVO) {
                    return new VspAddressRange.Builder().gateway(vlanVO.getVlanGateway()).netmask(vlanVO.getVlanNetmask()).build();
                }
            });
            vspNetworkBuilder.networkType(VspNetwork.NetworkType.Shared).addressRanges(vspAddressRanges);
        } else if (_networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.SourceNat) || _networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.StaticNat)) {
            vspNetworkBuilder.networkType(VspNetwork.NetworkType.L3);
        } else {
            vspNetworkBuilder.networkType(VspNetwork.NetworkType.L2);
        }
    }
    boolean firewallServiceSupported = _networkModel.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.Firewall);
    vspNetworkBuilder.firewallServiceSupported(firewallServiceSupported);
    String preConfiguredDomainTemplateName = NuageVspUtil.getPreConfiguredDomainTemplateName(_configurationDao, _networkDetailsDao, network, networkOffering);
    vspNetworkBuilder.domainTemplateName(preConfiguredDomainTemplateName);
    if (usesVirtualRouter(networkOffering.getId())) {
        try {
            List<Pair<String, String>> ipAddressRanges = networkOffering.getGuestType() == Network.GuestType.Shared ? getSharedIpAddressRanges(network.getId()) : getIpAddressRanges(network);
            String virtualRouterIp = getVirtualRouterIP(network, ipAddressRanges);
            vspNetworkBuilder.virtualRouterIp(virtualRouterIp);
        } catch (InsufficientVirtualNetworkCapacityException ex) {
            s_logger.error("There is an insufficient network capacity in network " + network.getId(), ex);
            throw new CloudRuntimeException("There is an insufficient network capacity in network " + network.getId(), ex);
        }
    }
    return vspNetworkBuilder.build();
}
Also used : VspDomain(net.nuage.vsp.acs.client.api.model.VspDomain) VspAddressRange(net.nuage.vsp.acs.client.api.model.VspAddressRange) AccountVO(com.cloud.user.AccountVO) DomainVO(com.cloud.domain.DomainVO) VpcVO(com.cloud.network.vpc.VpcVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InsufficientVirtualNetworkCapacityException(com.cloud.exception.InsufficientVirtualNetworkCapacityException) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) VspNetwork(net.nuage.vsp.acs.client.api.model.VspNetwork) VlanVO(com.cloud.dc.VlanVO) Nullable(javax.annotation.Nullable) Pair(net.nuage.vsp.acs.client.common.model.Pair)

Example 2 with NetworkOfferingVO

use of com.cloud.offerings.NetworkOfferingVO in project cloudstack by apache.

the class NuageVspElementTest method testApplyStaticNats.

@Test
public void testApplyStaticNats() throws CloudException {
    final Network network = mock(Network.class);
    when(network.getUuid()).thenReturn("aaaaaa");
    when(network.getVpcId()).thenReturn(null);
    when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
    when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
    when(network.getDomainId()).thenReturn(NETWORK_ID);
    final DomainVO domVo = mock(DomainVO.class);
    when(_domainDao.findById(41l)).thenReturn(domVo);
    final NetworkOfferingVO ntwkoffer = mock(NetworkOfferingVO.class);
    when(ntwkoffer.getId()).thenReturn(NETWORK_ID);
    when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(ntwkoffer);
    final HostVO host = mock(HostVO.class);
    when(host.getId()).thenReturn(NETWORK_ID);
    final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
    when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
    when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] { nuageVspDevice }));
    when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
    when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
    when(_domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
    final Answer answer = mock(Answer.class);
    when(answer.getResult()).thenReturn(true);
    when(_agentManager.easySend(eq(NETWORK_ID), (Command) any())).thenReturn(answer);
    assertTrue(_nuageVspElement.applyStaticNats(network, new ArrayList<StaticNat>()));
}
Also used : NuageVspDeviceVO(com.cloud.network.NuageVspDeviceVO) DomainVO(com.cloud.domain.DomainVO) Answer(com.cloud.agent.api.Answer) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) HostVO(com.cloud.host.HostVO) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 3 with NetworkOfferingVO

use of com.cloud.offerings.NetworkOfferingVO in project cloudstack by apache.

the class NuageVspEntityBuilder method buildVspAclRule.

public VspAclRule buildVspAclRule(FirewallRule firewallRule, Network network) {
    VspAclRule.Builder vspAclRuleBuilder = new VspAclRule.Builder().uuid(firewallRule.getUuid()).protocol(firewallRule.getProtocol()).startPort(firewallRule.getSourcePortStart()).endPort(firewallRule.getSourcePortEnd()).sourceCidrList(firewallRule.getSourceCidrList()).priority(-1).type(VspAclRule.ACLType.Firewall);
    switch(firewallRule.getState()) {
        case Active:
            vspAclRuleBuilder.state(VspAclRule.ACLState.Active);
            break;
        case Add:
            vspAclRuleBuilder.state(VspAclRule.ACLState.Add);
            break;
        case Revoke:
            vspAclRuleBuilder.state(VspAclRule.ACLState.Revoke);
    }
    switch(firewallRule.getTrafficType()) {
        case Ingress:
            vspAclRuleBuilder.trafficType(VspAclRule.ACLTrafficType.Ingress);
            break;
        case Egress:
            vspAclRuleBuilder.trafficType(VspAclRule.ACLTrafficType.Egress);
    }
    NetworkOfferingVO networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId());
    if (firewallRule.getTrafficType() == FirewallRule.TrafficType.Egress && networkOffering.getEgressDefaultPolicy()) {
        vspAclRuleBuilder.action(VspAclRule.ACLAction.Deny);
    } else {
        vspAclRuleBuilder.action(VspAclRule.ACLAction.Allow);
    }
    if (firewallRule.getSourceIpAddressId() != null) {
        IPAddressVO ipAddress = _ipAddressDao.findById(firewallRule.getSourceIpAddressId());
        if (ipAddress != null) {
            vspAclRuleBuilder.sourceIpAddress(ipAddress.getVmIp() + "/32");
        }
    }
    return vspAclRuleBuilder.build();
}
Also used : VspAclRule(net.nuage.vsp.acs.client.api.model.VspAclRule) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) IPAddressVO(com.cloud.network.dao.IPAddressVO)

Example 4 with NetworkOfferingVO

use of com.cloud.offerings.NetworkOfferingVO in project cloudstack by apache.

the class NuageVspGuestNetworkGuruTest method testReserve.

@Test
public void testReserve() throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, URISyntaxException {
    final NetworkVO network = mock(NetworkVO.class);
    when(network.getId()).thenReturn(NETWORK_ID);
    when(network.getUuid()).thenReturn("aaaaaa");
    when(network.getDataCenterId()).thenReturn(NETWORK_ID);
    when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
    when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
    when(network.getDomainId()).thenReturn(NETWORK_ID);
    when(network.getAccountId()).thenReturn(NETWORK_ID);
    when(network.getVpcId()).thenReturn(null);
    when(network.getBroadcastUri()).thenReturn(new URI("vsp://aaaaaa-aavvv/10.1.1.1"));
    final DataCenterVO dataCenter = mock(DataCenterVO.class);
    when(_dataCenterDao.findById(NETWORK_ID)).thenReturn(dataCenter);
    final AccountVO networksAccount = mock(AccountVO.class);
    when(networksAccount.getId()).thenReturn(NETWORK_ID);
    when(networksAccount.getUuid()).thenReturn("aaaa-abbbb");
    when(networksAccount.getType()).thenReturn(Account.ACCOUNT_TYPE_NORMAL);
    when(_accountDao.findById(NETWORK_ID)).thenReturn(networksAccount);
    final DomainVO networksDomain = mock(DomainVO.class);
    when(networksDomain.getId()).thenReturn(NETWORK_ID);
    when(networksDomain.getUuid()).thenReturn("aaaaa-bbbbb");
    when(_domainDao.findById(NETWORK_ID)).thenReturn(networksDomain);
    final NicVO nicvo = mock(NicVO.class);
    when(nicvo.getId()).thenReturn(NETWORK_ID);
    when(nicvo.getMacAddress()).thenReturn("aa-aa-aa-aa-aa-aa");
    when(nicvo.getUuid()).thenReturn("aaaa-fffff");
    when(nicvo.getNetworkId()).thenReturn(NETWORK_ID);
    when(nicvo.getInstanceId()).thenReturn(NETWORK_ID);
    when(_nicDao.findById(NETWORK_ID)).thenReturn(nicvo);
    when(_nicDao.findDefaultNicForVM(NETWORK_ID)).thenReturn(nicvo);
    final VirtualMachine vm = mock(VirtualMachine.class);
    when(vm.getId()).thenReturn(NETWORK_ID);
    when(vm.getType()).thenReturn(VirtualMachine.Type.User);
    final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class);
    when(vmProfile.getType()).thenReturn(VirtualMachine.Type.User);
    when(vmProfile.getInstanceName()).thenReturn("");
    when(vmProfile.getUuid()).thenReturn("aaaa-bbbbb");
    when(vmProfile.getVirtualMachine()).thenReturn(vm);
    NicProfile nicProfile = mock(NicProfile.class);
    when(nicProfile.getUuid()).thenReturn("aaa-bbbb");
    when(nicProfile.getId()).thenReturn(NETWORK_ID);
    when(nicProfile.getMacAddress()).thenReturn("aa-aa-aa-aa-aa-aa");
    final NetworkOfferingVO ntwkoffering = mock(NetworkOfferingVO.class);
    when(ntwkoffering.getId()).thenReturn(NETWORK_ID);
    when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(ntwkoffering);
    when(_networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network);
    when(_ipAddressDao.findByVmIdAndNetworkId(NETWORK_ID, NETWORK_ID)).thenReturn(null);
    when(_domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
    final Answer answer = mock(Answer.class);
    when(answer.getResult()).thenReturn(true);
    when(_agentManager.easySend(eq(NETWORK_ID), (Command) any())).thenReturn(answer);
    final ReservationContext reservationContext = mock(ReservationContext.class);
    when(reservationContext.getAccount()).thenReturn(networksAccount);
    when(reservationContext.getDomain()).thenReturn(networksDomain);
    _nuageVspGuestNetworkGuru.reserve(nicProfile, network, vmProfile, mock(DeployDestination.class), reservationContext);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) NicProfile(com.cloud.vm.NicProfile) URI(java.net.URI) AccountVO(com.cloud.user.AccountVO) ReservationContext(com.cloud.vm.ReservationContext) DomainVO(com.cloud.domain.DomainVO) Answer(com.cloud.agent.api.Answer) DeployDestination(com.cloud.deploy.DeployDestination) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) NicVO(com.cloud.vm.NicVO) VirtualMachine(com.cloud.vm.VirtualMachine) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 5 with NetworkOfferingVO

use of com.cloud.offerings.NetworkOfferingVO in project cloudstack by apache.

the class ApiResponseHelper method createUsageResponse.

@Override
public UsageRecordResponse createUsageResponse(Usage usageRecord) {
    UsageRecordResponse usageRecResponse = new UsageRecordResponse();
    Account account = ApiDBUtils.findAccountById(usageRecord.getAccountId());
    if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
        //find the project
        Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
        if (project != null) {
            usageRecResponse.setProjectId(project.getUuid());
            usageRecResponse.setProjectName(project.getName());
        }
    } else {
        usageRecResponse.setAccountId(account.getUuid());
        usageRecResponse.setAccountName(account.getAccountName());
    }
    Domain domain = ApiDBUtils.findDomainById(usageRecord.getDomainId());
    if (domain != null) {
        usageRecResponse.setDomainId(domain.getUuid());
        usageRecResponse.setDomainName(domain.getName());
    }
    if (usageRecord.getZoneId() != null) {
        DataCenter zone = ApiDBUtils.findZoneById(usageRecord.getZoneId());
        if (zone != null) {
            usageRecResponse.setZoneId(zone.getUuid());
        }
    }
    usageRecResponse.setDescription(usageRecord.getDescription());
    usageRecResponse.setUsage(usageRecord.getUsageDisplay());
    usageRecResponse.setUsageType(usageRecord.getUsageType());
    if (usageRecord.getVmInstanceId() != null) {
        VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getVmInstanceId());
        if (vm != null) {
            usageRecResponse.setVirtualMachineId(vm.getUuid());
        }
    }
    usageRecResponse.setVmName(usageRecord.getVmName());
    if (usageRecord.getTemplateId() != null) {
        VMTemplateVO template = ApiDBUtils.findTemplateById(usageRecord.getTemplateId());
        if (template != null) {
            usageRecResponse.setTemplateId(template.getUuid());
        }
    }
    if (usageRecord.getUsageType() == UsageTypes.RUNNING_VM || usageRecord.getUsageType() == UsageTypes.ALLOCATED_VM) {
        ServiceOfferingVO svcOffering = _entityMgr.findByIdIncludingRemoved(ServiceOfferingVO.class, usageRecord.getOfferingId().toString());
        //Service Offering Id
        usageRecResponse.setOfferingId(svcOffering.getUuid());
        //VM Instance ID
        VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getUsageId().toString());
        if (vm != null) {
            usageRecResponse.setUsageId(vm.getUuid());
        }
        //Hypervisor Type
        usageRecResponse.setType(usageRecord.getType());
        //Dynamic compute offerings details
        usageRecResponse.setCpuNumber(usageRecord.getCpuCores());
        usageRecResponse.setCpuSpeed(usageRecord.getCpuSpeed());
        usageRecResponse.setMemory(usageRecord.getMemory());
    } else if (usageRecord.getUsageType() == UsageTypes.IP_ADDRESS) {
        //isSourceNAT
        usageRecResponse.setSourceNat((usageRecord.getType().equals("SourceNat")) ? true : false);
        //isSystem
        usageRecResponse.setSystem((usageRecord.getSize() == 1) ? true : false);
        //IP Address ID
        IPAddressVO ip = _entityMgr.findByIdIncludingRemoved(IPAddressVO.class, usageRecord.getUsageId().toString());
        if (ip != null) {
            usageRecResponse.setUsageId(ip.getUuid());
        }
    } else if (usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_SENT || usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_RECEIVED) {
        //Device Type
        usageRecResponse.setType(usageRecord.getType());
        if (usageRecord.getType().equals("DomainRouter")) {
            //Domain Router Id
            VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getUsageId().toString());
            if (vm != null) {
                usageRecResponse.setUsageId(vm.getUuid());
            }
        } else {
            //External Device Host Id
            HostVO host = _entityMgr.findByIdIncludingRemoved(HostVO.class, usageRecord.getUsageId().toString());
            if (host != null) {
                usageRecResponse.setUsageId(host.getUuid());
            }
        }
        //Network ID
        if ((usageRecord.getNetworkId() != null) && (usageRecord.getNetworkId() != 0)) {
            NetworkVO network = _entityMgr.findByIdIncludingRemoved(NetworkVO.class, usageRecord.getNetworkId().toString());
            if (network != null) {
                usageRecResponse.setNetworkId(network.getUuid());
            }
        }
    } else if (usageRecord.getUsageType() == UsageTypes.VM_DISK_IO_READ || usageRecord.getUsageType() == UsageTypes.VM_DISK_IO_WRITE || usageRecord.getUsageType() == UsageTypes.VM_DISK_BYTES_READ || usageRecord.getUsageType() == UsageTypes.VM_DISK_BYTES_WRITE) {
        //Device Type
        usageRecResponse.setType(usageRecord.getType());
        //VM Instance Id
        VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
        if (vm != null) {
            usageRecResponse.setVirtualMachineId(vm.getUuid());
        }
        //Volume ID
        VolumeVO volume = _entityMgr.findByIdIncludingRemoved(VolumeVO.class, usageRecord.getUsageId().toString());
        if (volume != null) {
            usageRecResponse.setUsageId(volume.getUuid());
        }
    } else if (usageRecord.getUsageType() == UsageTypes.VOLUME) {
        //Volume ID
        VolumeVO volume = _entityMgr.findByIdIncludingRemoved(VolumeVO.class, usageRecord.getUsageId().toString());
        if (volume != null) {
            usageRecResponse.setUsageId(volume.getUuid());
        }
        //Volume Size
        usageRecResponse.setSize(usageRecord.getSize());
        //Disk Offering Id
        if (usageRecord.getOfferingId() != null) {
            DiskOfferingVO diskOff = _entityMgr.findByIdIncludingRemoved(DiskOfferingVO.class, usageRecord.getOfferingId().toString());
            usageRecResponse.setOfferingId(diskOff.getUuid());
        }
    } else if (usageRecord.getUsageType() == UsageTypes.TEMPLATE || usageRecord.getUsageType() == UsageTypes.ISO) {
        //Template/ISO ID
        VMTemplateVO tmpl = _entityMgr.findByIdIncludingRemoved(VMTemplateVO.class, usageRecord.getUsageId().toString());
        if (tmpl != null) {
            usageRecResponse.setUsageId(tmpl.getUuid());
        }
        //Template/ISO Size
        usageRecResponse.setSize(usageRecord.getSize());
        if (usageRecord.getUsageType() == UsageTypes.ISO) {
            usageRecResponse.setVirtualSize(usageRecord.getSize());
        } else {
            usageRecResponse.setVirtualSize(usageRecord.getVirtualSize());
        }
    } else if (usageRecord.getUsageType() == UsageTypes.SNAPSHOT) {
        //Snapshot ID
        SnapshotVO snap = _entityMgr.findByIdIncludingRemoved(SnapshotVO.class, usageRecord.getUsageId().toString());
        if (snap != null) {
            usageRecResponse.setUsageId(snap.getUuid());
        }
        //Snapshot Size
        usageRecResponse.setSize(usageRecord.getSize());
    } else if (usageRecord.getUsageType() == UsageTypes.LOAD_BALANCER_POLICY) {
        //Load Balancer Policy ID
        LoadBalancerVO lb = _entityMgr.findByIdIncludingRemoved(LoadBalancerVO.class, usageRecord.getUsageId().toString());
        if (lb != null) {
            usageRecResponse.setUsageId(lb.getUuid());
        }
    } else if (usageRecord.getUsageType() == UsageTypes.PORT_FORWARDING_RULE) {
        //Port Forwarding Rule ID
        PortForwardingRuleVO pf = _entityMgr.findByIdIncludingRemoved(PortForwardingRuleVO.class, usageRecord.getUsageId().toString());
        if (pf != null) {
            usageRecResponse.setUsageId(pf.getUuid());
        }
    } else if (usageRecord.getUsageType() == UsageTypes.NETWORK_OFFERING) {
        //Network Offering Id
        NetworkOfferingVO netOff = _entityMgr.findByIdIncludingRemoved(NetworkOfferingVO.class, usageRecord.getOfferingId().toString());
        usageRecResponse.setOfferingId(netOff.getUuid());
        //is Default
        usageRecResponse.setDefault((usageRecord.getUsageId() == 1) ? true : false);
    } else if (usageRecord.getUsageType() == UsageTypes.VPN_USERS) {
        //VPN User ID
        VpnUserVO vpnUser = _entityMgr.findByIdIncludingRemoved(VpnUserVO.class, usageRecord.getUsageId().toString());
        if (vpnUser != null) {
            usageRecResponse.setUsageId(vpnUser.getUuid());
        }
    } else if (usageRecord.getUsageType() == UsageTypes.SECURITY_GROUP) {
        //Security Group Id
        SecurityGroupVO sg = _entityMgr.findByIdIncludingRemoved(SecurityGroupVO.class, usageRecord.getUsageId().toString());
        if (sg != null) {
            usageRecResponse.setUsageId(sg.getUuid());
        }
    } else if (usageRecord.getUsageType() == UsageTypes.VM_SNAPSHOT) {
        VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
        if (vm != null) {
            usageRecResponse.setVmName(vm.getInstanceName());
            usageRecResponse.setUsageId(vm.getUuid());
        }
        usageRecResponse.setSize(usageRecord.getSize());
        if (usageRecord.getOfferingId() != null) {
            usageRecResponse.setOfferingId(usageRecord.getOfferingId().toString());
        }
    }
    if (usageRecord.getRawUsage() != null) {
        DecimalFormat decimalFormat = new DecimalFormat("###########.######");
        usageRecResponse.setRawUsage(decimalFormat.format(usageRecord.getRawUsage()));
    }
    if (usageRecord.getStartDate() != null) {
        usageRecResponse.setStartDate(getDateStringInternal(usageRecord.getStartDate()));
    }
    if (usageRecord.getEndDate() != null) {
        usageRecResponse.setEndDate(getDateStringInternal(usageRecord.getEndDate()));
    }
    return usageRecResponse;
}
Also used : UsageRecordResponse(org.apache.cloudstack.api.response.UsageRecordResponse) ProjectAccount(com.cloud.projects.ProjectAccount) UserAccount(com.cloud.user.UserAccount) Account(com.cloud.user.Account) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) PortForwardingRuleVO(com.cloud.network.rules.PortForwardingRuleVO) SecurityGroupVO(com.cloud.network.security.SecurityGroupVO) VpnUserVO(com.cloud.network.VpnUserVO) DecimalFormat(java.text.DecimalFormat) VMTemplateVO(com.cloud.storage.VMTemplateVO) LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) VMInstanceVO(com.cloud.vm.VMInstanceVO) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) HostVO(com.cloud.host.HostVO) Project(com.cloud.projects.Project) DataCenter(com.cloud.dc.DataCenter) SnapshotVO(com.cloud.storage.SnapshotVO) VolumeVO(com.cloud.storage.VolumeVO) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) IPAddressVO(com.cloud.network.dao.IPAddressVO) Domain(com.cloud.domain.Domain)

Aggregations

NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)128 NetworkVO (com.cloud.network.dao.NetworkVO)45 ArrayList (java.util.ArrayList)34 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)32 Network (com.cloud.network.Network)27 DB (com.cloud.utils.db.DB)27 Test (org.junit.Test)27 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)26 Service (com.cloud.network.Network.Service)26 Account (com.cloud.user.Account)24 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)23 Provider (com.cloud.network.Network.Provider)22 PhysicalNetwork (com.cloud.network.PhysicalNetwork)21 HashSet (java.util.HashSet)21 TransactionStatus (com.cloud.utils.db.TransactionStatus)20 HashMap (java.util.HashMap)20 Set (java.util.Set)20 DataCenterVO (com.cloud.dc.DataCenterVO)19 NetworkOffering (com.cloud.offering.NetworkOffering)19 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)18