4444
4545import org .apache .cloudstack .acl .ControlledEntity ;
4646import org .apache .cloudstack .acl .ControlledEntity .ACLType ;
47- import org .apache .cloudstack .acl .RoleVO ;
48- import org .apache .cloudstack .acl .apikeypair .ApiKeyPair ;
49- import org .apache .cloudstack .acl .apikeypair .ApiKeyPairPermission ;
50- import org .apache .cloudstack .acl .dao .RoleDao ;
47+
5148import org .apache .cloudstack .affinity .AffinityGroup ;
5249import org .apache .cloudstack .affinity .AffinityGroupResponse ;
5350import org .apache .cloudstack .annotation .AnnotationService ;
7471import org .apache .cloudstack .api .response .BackupOfferingResponse ;
7572import org .apache .cloudstack .api .response .BackupRepositoryResponse ;
7673import org .apache .cloudstack .api .response .BackupScheduleResponse ;
77- import org . apache . cloudstack . api . response . BaseRolePermissionResponse ;
74+
7875import org .apache .cloudstack .api .response .BgpPeerResponse ;
7976import org .apache .cloudstack .api .response .BucketResponse ;
8077import org .apache .cloudstack .api .response .CapabilityResponse ;
122119import org .apache .cloudstack .api .response .Ipv4RouteResponse ;
123120import org .apache .cloudstack .api .response .Ipv6RouteResponse ;
124121import org .apache .cloudstack .api .response .IsolationMethodResponse ;
125- import org .apache .cloudstack .api .response .ApiKeyPairResponse ;
126122import org .apache .cloudstack .api .response .LBHealthCheckPolicyResponse ;
127123import org .apache .cloudstack .api .response .LBHealthCheckResponse ;
128124import org .apache .cloudstack .api .response .LBStickinessPolicyResponse ;
306302import com .cloud .dc .dao .VlanDetailsDao ;
307303import com .cloud .domain .Domain ;
308304import com .cloud .domain .DomainVO ;
309- import com . cloud . domain . dao . DomainDao ;
305+
310306import com .cloud .event .Event ;
311307import com .cloud .exception .InvalidParameterValueException ;
312308import com .cloud .exception .PermissionDeniedException ;
381377import com .cloud .network .vpc .VpcOffering ;
382378import com .cloud .network .vpc .VpcVO ;
383379import com .cloud .network .vpc .dao .VpcOfferingDao ;
384- import com . cloud . network . vpn . Site2SiteVpnManager ;
380+
385381import com .cloud .offering .DiskOffering ;
386382import com .cloud .offering .NetworkOffering ;
387383import com .cloud .offering .NetworkOffering .Detail ;
424420import com .cloud .template .VirtualMachineTemplate ;
425421import com .cloud .user .Account ;
426422import com .cloud .user .AccountManager ;
427- import com .cloud .user .AccountVO ;
428- import com .cloud .user .ApiKeyPairState ;
423+
429424import com .cloud .user .SSHKeyPair ;
430425import com .cloud .user .User ;
431426import com .cloud .user .UserAccount ;
432427import com .cloud .user .UserData ;
433428import com .cloud .user .UserStatisticsVO ;
434- import com . cloud . user . dao . AccountDao ;
429+
435430import com .cloud .user .dao .UserDataDao ;
436431import com .cloud .user .dao .UserStatisticsDao ;
437432import com .cloud .uservm .UserVm ;
@@ -544,8 +539,7 @@ public class ApiResponseHelper implements ResponseGenerator, ResourceIdSupport {
544539 BgpPeerDao bgpPeerDao ;
545540 @ Inject
546541 RoutedIpv4Manager routedIpv4Manager ;
547- @ Inject
548- Site2SiteVpnManager site2SiteVpnManager ;
542+
549543 @ Inject
550544 ResourceIconManager resourceIconManager ;
551545 @ Inject
@@ -563,14 +557,7 @@ public static String getPrettyDomainPath(String path) {
563557 return domainPath .toString ();
564558 }
565559
566- @ Inject
567- private RoleDao roleDao ;
568-
569- @ Inject
570- private AccountDao accountDao ;
571560
572- @ Inject
573- private DomainDao domainDao ;
574561
575562 @ Override
576563 public UserResponse createUserResponse (User user ) {
@@ -616,7 +603,6 @@ public DomainResponse createDomainResponse(Domain domain) {
616603 if (domain .getChildCount () > 0 ) {
617604 domainResponse .setHasChild (true );
618605 }
619- populateDomainTags (domain .getUuid (), domainResponse );
620606 domainResponse .setObjectName ("domain" );
621607 return domainResponse ;
622608 }
@@ -1686,7 +1672,6 @@ public FirewallRuleResponse createPortForwardingRuleResponse(PortForwardingRule
16861672
16871673 Network guestNtwk = ApiDBUtils .findNetworkById (fwRule .getNetworkId ());
16881674 response .setNetworkId (guestNtwk .getUuid ());
1689- response .setNetworkName (guestNtwk .getName ());
16901675
16911676 IpAddress ip = ApiDBUtils .findIpAddressById (fwRule .getSourceIpAddressId ());
16921677
@@ -1914,8 +1899,6 @@ public SystemVmResponse createSystemVmResponse(VirtualMachine vm) {
19141899 vmResponse .setPublicNetmask (singleNicProfile .getIPv4Netmask ());
19151900 vmResponse .setGateway (singleNicProfile .getIPv4Gateway ());
19161901 }
1917- } else if (network .getTrafficType () == TrafficType .Storage ) {
1918- vmResponse .setStorageIp (singleNicProfile .getIPv4Address ());
19191902 }
19201903 }
19211904 }
@@ -1940,11 +1923,7 @@ public UserVm findUserVmById(Long vmId) {
19401923
19411924 }
19421925
1943- @ Override
1944- public UserVm findUserVmByNicId (Long nicId ) {
1945- NicVO nic = ApiDBUtils .findNicById (nicId );
1946- return ApiDBUtils .findUserVmById (nic .getInstanceId ());
1947- }
1926+
19481927
19491928 @ Override
19501929 public VolumeVO findVolumeById (Long volumeId ) {
@@ -2903,10 +2882,7 @@ public NetworkResponse createNetworkResponse(ResponseView view, Network network)
29032882 }
29042883 }
29052884
2906- if (CallContext .current ().getCallingAccount ().getType () == Account .Type .ADMIN &&
2907- network .getVpcId () == null && network .getGuestType () == Network .GuestType .Isolated ) {
2908- response .setKeepMacAddressOnPublicNic (network .getKeepMacAddressOnPublicNic ());
2909- }
2885+
29102886
29112887 response .setObjectName ("network" );
29122888 return response ;
@@ -3123,19 +3099,7 @@ public static void populateOwner(ControlledViewEntityResponse response, Controll
31233099 response .setDomainPath (getPrettyDomainPath (object .getDomainPath ()));
31243100 }
31253101
3126- public static void populateDomainTags (String domainUuid , DomainResponse domainResponse ) {
3127- List <ResourceTagJoinVO > tags = ApiDBUtils .listResourceTagViewByResourceUUID (domainUuid ,
3128- ResourceTag .ResourceObjectType .Domain );
3129- if (CollectionUtils .isEmpty (tags )) {
3130- return ;
3131- }
3132- Set <ResourceTagResponse > tagResponses = new HashSet <>();
3133- for (ResourceTagJoinVO tag : tags ) {
3134- ResourceTagResponse tagResponse = ApiDBUtils .newResourceTagResponse (tag , true );
3135- tagResponses .add (tagResponse );
3136- }
3137- domainResponse .setTags (tagResponses );
3138- }
3102+
31393103
31403104 private void populateAccount (ControlledEntityResponse response , long accountId ) {
31413105 Account account = ApiDBUtils .findAccountById (accountId );
@@ -3350,9 +3314,7 @@ public TrafficTypeResponse createTrafficTypeResponse(PhysicalNetworkTrafficType
33503314 PhysicalNetwork pnet = ApiDBUtils .findPhysicalNetworkById (result .getPhysicalNetworkId ());
33513315 if (pnet != null ) {
33523316 response .setPhysicalNetworkId (pnet .getUuid ());
3353- if (!pnet .getIsolationMethods ().isEmpty ()) {
3354- response .setIsolationMethods (String .join ("," , pnet .getIsolationMethods ()));
3355- }
3317+
33563318 }
33573319 if (result .getTrafficType () != null ) {
33583320 response .setTrafficType (result .getTrafficType ().toString ());
@@ -3363,7 +3325,7 @@ public TrafficTypeResponse createTrafficTypeResponse(PhysicalNetworkTrafficType
33633325 response .setVmwareLabel (result .getVmwareNetworkLabel ());
33643326 response .setHypervLabel (result .getHypervNetworkLabel ());
33653327 response .setOvm3Label (result .getOvm3NetworkLabel ());
3366- response . setVlan ( result . getVlan ());
3328+
33673329
33683330 response .setObjectName ("traffictype" );
33693331 return response ;
@@ -3590,7 +3552,7 @@ public VpcResponse createVpcResponse(ResponseView view, Vpc vpc) {
35903552 if (voff != null ) {
35913553 response .setVpcOfferingId (voff .getUuid ());
35923554 response .setVpcOfferingName (voff .getName ());
3593- response . setVpcOfferingConserveMode ( voff . isConserveMode ());
3555+
35943556 }
35953557 response .setCidr (vpc .getCidr ());
35963558 response .setRestartRequired (vpc .isRestartRequired ());
@@ -3686,9 +3648,7 @@ public VpcResponse createVpcResponse(ResponseView view, Vpc vpc) {
36863648 }
36873649 }
36883650
3689- if (CallContext .current ().getCallingAccount ().getType () == Account .Type .ADMIN ) {
3690- response .setKeepMacAddressOnPublicNic (vpc .getKeepMacAddressOnPublicNic ());
3691- }
3651+
36923652 response .setObjectName ("vpc" );
36933653 return response ;
36943654 }
@@ -3983,14 +3943,7 @@ public Site2SiteCustomerGatewayResponse createSite2SiteCustomerGatewayResponse(S
39833943 response .setIkeVersion (result .getIkeVersion ());
39843944 response .setSplitConnections (result .getSplitConnections ());
39853945
3986- Set <String > obsoleteParameters = site2SiteVpnManager .getObsoleteVpnGatewayParameters (result );
3987- if (CollectionUtils .isNotEmpty (obsoleteParameters )) {
3988- response .setContainsObsoleteParameters (obsoleteParameters .toString ());
3989- }
3990- Set <String > excludedParameters = site2SiteVpnManager .getExcludedVpnGatewayParameters (result );
3991- if (CollectionUtils .isNotEmpty (excludedParameters )) {
3992- response .setContainsExcludedParameters (excludedParameters .toString ());
3993- }
3946+
39943947
39953948 response .setObjectName ("vpncustomergateway" );
39963949 response .setHasAnnotation (annotationDao .hasAnnotations (result .getUuid (), AnnotationService .EntityType .VPN_CUSTOMER_GATEWAY .name (),
@@ -4716,7 +4669,7 @@ private UsageResourceDetails populateVmSnapshotUsageResponse(Usage usageRecord,
47164669 usageRecResponse .setVirtualSize (usageRecord .getVirtualSize ());
47174670 }
47184671 if (usageRecord .getOfferingId () != null ) {
4719- usageRecResponse .setOfferingId (usageRecord .getOfferingId ());
4672+ usageRecResponse .setOfferingId (usageRecord .getOfferingId (). toString () );
47204673 }
47214674 if (!oldFormat ) {
47224675 VolumeVO volume = null ;
@@ -4915,7 +4868,7 @@ public NicSecondaryIpResponse createSecondaryIPToNicResponse(NicSecondaryIp resu
49154868 setResponseIpAddress (result , response );
49164869 response .setNicId (nic .getUuid ());
49174870 response .setNwId (network .getUuid ());
4918- response . setDescription ( result . getDescription ());
4871+
49194872 response .setObjectName ("nicsecondaryip" );
49204873 return response ;
49214874 }
@@ -5002,7 +4955,7 @@ public NicResponse createNicResponse(Nic result) {
50024955 for (NicSecondaryIpVO ip : secondaryIps ) {
50034956 NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse ();
50044957 ipRes .setId (ip .getUuid ());
5005- ipRes . setDescription ( ip . getDescription ());
4958+
50064959 setResponseIpAddress (ip , ipRes );
50074960 ipList .add (ipRes );
50084961 }
@@ -5033,7 +4986,6 @@ public NicResponse createNicResponse(Nic result) {
50334986 response .setVpcName (vpc .getName ());
50344987 }
50354988
5036- response .setEnabled (result .isEnabled ());
50374989 return response ;
50384990 }
50394991
@@ -5964,81 +5916,6 @@ public ConsoleSessionResponse createConsoleSessionResponse(ConsoleSession consol
59645916 return consoleSessionResponse ;
59655917 }
59665918
5967- @ Override
5968- public ApiKeyPairResponse createKeyPairResponse (ApiKeyPair keyPair ) {
5969- ApiKeyPairResponse apiKeyPairResponse = new ApiKeyPairResponse ();
5970-
5971- populateApiKeyPairInApiKeyPairResponse (keyPair , apiKeyPairResponse );
5972- populateUserInApiKeyPairResponse (keyPair , apiKeyPairResponse );
5973-
5974- AccountVO account = accountDao .findByIdIncludingRemoved (keyPair .getAccountId ());
5975- apiKeyPairResponse .setAccountId (account .getUuid ());
5976- apiKeyPairResponse .setAccountName (account .getAccountName ());
5977- apiKeyPairResponse .setAccountType (account .getType ().toString ());
5978-
5979- populateDomainInApiKeyPairResponse (account .getDomainId (), apiKeyPairResponse );
5980- populateRoleInApiKeyPairResponse (account .getRoleId (), apiKeyPairResponse );
5981-
5982- return apiKeyPairResponse ;
5983- }
5984-
5985- protected void populateRoleInApiKeyPairResponse (Long roleId , ApiKeyPairResponse apiKeyPairResponse ) {
5986- RoleVO roleVO = roleDao .findById (roleId );
5987- apiKeyPairResponse .setRoleId (roleVO .getUuid ());
5988- apiKeyPairResponse .setRoleName (roleVO .getName ());
5989- apiKeyPairResponse .setRoleType (roleVO .getRoleType ().name ());
5990- }
5991-
5992- protected static void populateApiKeyPairInApiKeyPairResponse (ApiKeyPair keyPair , ApiKeyPairResponse apiKeyPairResponse ) {
5993- apiKeyPairResponse .setName (keyPair .getName ());
5994- apiKeyPairResponse .setApiKey (keyPair .getApiKey ());
5995- apiKeyPairResponse .setSecretKey (keyPair .getSecretKey ());
5996- apiKeyPairResponse .setDescription (keyPair .getDescription ());
5997- apiKeyPairResponse .setId (keyPair .getUuid ());
5998- apiKeyPairResponse .setCreated (keyPair .getCreated ());
5999- apiKeyPairResponse .setStartDate (keyPair .getStartDate ());
6000- apiKeyPairResponse .setEndDate (keyPair .getEndDate ());
6001-
6002- ApiKeyPairState state = ApiKeyPairState .ENABLED ;
6003- if (keyPair .getRemoved () != null ) {
6004- state = ApiKeyPairState .REMOVED ;
6005- } else if (keyPair .hasEndDatePassed ()) {
6006- state = ApiKeyPairState .EXPIRED ;
6007- }
6008- apiKeyPairResponse .setState (state );
6009- }
6010-
6011- protected void populateUserInApiKeyPairResponse (ApiKeyPair keyPair , ApiKeyPairResponse apiKeyPairResponse ) {
6012- User user = ApiDBUtils .findUserById (keyPair .getUserId ());
6013- apiKeyPairResponse .setUserId (user .getUuid ());
6014- apiKeyPairResponse .setUsername (user .getUsername ());
6015- }
6016-
6017- protected void populateDomainInApiKeyPairResponse (Long domainId , ApiKeyPairResponse apiKeyPairResponse ) {
6018- DomainVO domainVO = domainDao .findById (domainId );
6019- apiKeyPairResponse .setDomainId (domainVO .getUuid ());
6020- apiKeyPairResponse .setDomainName (domainVO .getName ());
6021- StringBuilder domainPath = new StringBuilder ("ROOT" );
6022- (domainPath .append (domainVO .getPath ())).deleteCharAt (domainPath .length () - 1 );
6023- apiKeyPairResponse .setDomainPath (domainPath .toString ());
6024- }
6025-
6026- @ Override
6027- public ListResponse <BaseRolePermissionResponse > createKeypairPermissionsResponse (final List <ApiKeyPairPermission > permissions ) {
6028- final ListResponse <BaseRolePermissionResponse > response = new ListResponse <>();
6029- final List <BaseRolePermissionResponse > permissionResponses = new ArrayList <>();
6030- for (final ApiKeyPairPermission permission : permissions ) {
6031- BaseRolePermissionResponse permissionResponse = new BaseRolePermissionResponse ();
6032- permissionResponse .setRule (permission .getRule ());
6033- permissionResponse .setRulePermission (permission .getPermission ());
6034- permissionResponse .setDescription (permission .getDescription ());
6035- permissionResponse .setObjectName ("keypermission" );
6036- permissionResponses .add (permissionResponse );
6037- }
6038- response .setResponses (permissionResponses );
6039- return response ;
6040- }
6041-
60425919 @ Override
60435920 public EntityManager getEntityManager () {
60445921 return _entityMgr ;
0 commit comments