Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
cf2e27a
keypairs added in api-constants
bicrxm Jul 2, 2021
ac655fe
names parameter added
bicrxm Jul 2, 2021
2c7404f
findbynames method added in dao
bicrxm Jul 2, 2021
4cdd371
change in impl to find and reset multiple keys
bicrxm Jul 2, 2021
274ab95
findbynames method implemented
bicrxm Jul 2, 2021
17c40a5
Merge branch 'main' of https://github.com/apache/cloudstack
bicrxm Jul 3, 2021
4d8f56e
log the publickeys, check the ssh keys given exists or not
bicrxm Jul 3, 2021
65029d9
new ArrayList<>
bicrxm Jul 5, 2021
0f7a274
Merge branch 'main' of https://github.com/apache/cloudstack
bicrxm Jul 5, 2021
00e2634
SQL IN toArray
bicrxm Jul 6, 2021
33b8bd8
keypair
bicrxm Jul 6, 2021
055e8b3
null pointer exception solved with + concatanation
bicrxm Jul 6, 2021
fb0dce9
null pointer exception solved with + concatanation
bicrxm Jul 6, 2021
3b13ab7
error resolved
bicrxm Jul 6, 2021
f271ab5
keypair name to names in uservmresponse
bicrxm Jul 15, 2021
2621b67
keypair name is set in the uservmresponse, from the details
bicrxm Jul 15, 2021
55fb578
Merge branch 'apache:main' into main
bicrxm Jul 15, 2021
0f2ffdb
null checks are removed, keypairnames are stored in a string, sent to…
bicrxm Jul 15, 2021
13b78f2
Merge branch 'main' of https://github.com/apache/cloudstack
bicrxm Jul 15, 2021
2f15af7
Merge https://github.com/bicrxm/cloudstack
bicrxm Jul 15, 2021
689f824
commit first eval
bicrxm Jul 16, 2021
264a4f1
Merge branch 'apache:main' into main
bicrxm Jul 16, 2021
48be6cf
deploy vm takes multiple ssh-keys
bicrxm Jul 20, 2021
10d3d76
Merge branch 'main' of https://github.com/bicrxm/cloudstack into main
bicrxm Jul 20, 2021
31065ba
Merge branch 'apache:main' into main
bicrxm Jul 30, 2021
748b624
Deploy VM UI changed to accept multiple ssh keys
bicrxm Jul 30, 2021
4be4c93
Merge branch 'main' of https://github.com/bicrxm/cloudstack into main
bicrxm Jul 30, 2021
623cafd
Merge branch 'apache:main' into main
bicrxm Aug 3, 2021
24bdc35
Reset SSH UI API changed
bicrxm Aug 6, 2021
7357d7a
ResetSSH.vue
bicrxm Aug 6, 2021
a655d81
ssh keys joined, ssh added in infocard
bicrxm Aug 11, 2021
1da700c
changes made
bicrxm Aug 12, 2021
32da941
schema error resolved
bicrxm Aug 13, 2021
3841ca3
potential null pointer exception removed
bicrxm Aug 16, 2021
0310e2e
Update UserVmManagerImpl.java
bicrxm Aug 18, 2021
c9fd95c
Update DeployVMCmd.java
bicrxm Aug 18, 2021
b632f22
Update DeployVMCmd.java
bicrxm Aug 18, 2021
45c6b99
Update ResetVMSSHKeyCmd.java
bicrxm Aug 18, 2021
792704c
Update UserVmJoinDaoImpl.java
bicrxm Aug 18, 2021
12c22a2
.
bicrxm Aug 18, 2021
127c2fb
arraylist
bicrxm Aug 18, 2021
9d93efd
Update DeployVMCmd.java
bicrxm Aug 20, 2021
83d4e9a
Update UserVmManagerImpl.java
bicrxm Aug 20, 2021
0b48e23
Update ResetVMSSHKeyCmd.java
bicrxm Aug 27, 2021
2fd16dd
Merge branch 'main' of github.com:apache/cloudstack into mul-ssh-keys
davidjumani Feb 8, 2022
111b1ad
Update db
davidjumani Feb 8, 2022
5703b8f
Fix list vm by keypair
davidjumani Feb 8, 2022
ca2a764
ui fixes
davidjumani Feb 8, 2022
2961f9e
Fix typos
davidjumani Feb 8, 2022
1ebcc69
ui fixes
davidjumani Feb 8, 2022
d898ca2
Cleanup
davidjumani Feb 10, 2022
0718a3e
Adding deprecated and since in api params
davidjumani Feb 10, 2022
e12c14a
Merge branch 'main' of github.com:apache/cloudstack into mul-ssh-keys
davidjumani Feb 16, 2022
bf4f491
Merge branch 'main' of github.com:apache/cloudstack into mul-ssh-keys
davidjumani Feb 21, 2022
b85b4e7
Adding upgrade for existing vms with ssh keys
davidjumani Feb 23, 2022
4ad1c66
Merge branch 'main' of github.com:apache/cloudstack into mul-ssh-keys
davidjumani Feb 23, 2022
669dea4
Handle no key for cks
davidjumani Feb 23, 2022
47b4796
Show existing keyparis in reset ssh key form
davidjumani Feb 23, 2022
754f3f0
get keys from the right account
davidjumani Feb 24, 2022
b8a6174
Merge branch 'main' of github.com:apache/cloudstack into mul-ssh-keys
davidjumani Feb 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/src/main/java/com/cloud/vm/UserVmService.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, E
*/
UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList,
Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod,
String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIp, Boolean displayVm, String keyboard,
String userData, List<String> sshKeyPairs, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIp, Boolean displayVm, String keyboard,
List<Long> affinityGroupIdList, Map<String, String> customParameter, String customId, Map<String, Map<Integer, String>> dhcpOptionMap,
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId) throws InsufficientCapacityException,
Expand Down Expand Up @@ -297,7 +297,7 @@ UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering s
*/
UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList,
List<Long> securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard,
HTTPMethod httpmethod, String userData, List<String> sshKeyPairs, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard,
List<Long> affinityGroupIdList, Map<String, String> customParameters, String customId, Map<String, Map<Integer, String>> dhcpOptionMap,
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId) throws InsufficientCapacityException,
Expand Down Expand Up @@ -377,7 +377,7 @@ UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOfferin
*/
UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner,
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData,
String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList,
List<String> sshKeyPairs, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList,
Map<String, String> customParameters, String customId, Map<String, Map<Integer, String>> dhcpOptionMap, Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
Map<String, String> templateOvfPropertiesMap, boolean dynamicScalingEnabled, String type, Long overrideDiskOfferingId)

Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/vm/VmDetailConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public interface VmDetailConstants {
String MESSAGE_RESERVED_CAPACITY_FREED_FLAG = "Message.ReservedCapacityFreed.Flag";
String DEPLOY_VM = "deployvm";
String SSH_PUBLIC_KEY = "SSH.PublicKey";
String SSH_KEY_PAIR_NAMES = "SSH.KeyPairNames";
String PASSWORD = "password";
String ENCRYPTED_PASSWORD = "Encrypted.Password";

Expand All @@ -73,5 +74,6 @@ public interface VmDetailConstants {
String DISK_OFFERING = "diskOffering";

String DEPLOY_AS_IS_CONFIGURATION = "configurationId";
String KEY_PAIR_NAMES = "keypairnames";
String CKS_CONTROL_NODE_LOGIN_USER = "controlNodeLoginUser";
}
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ public class ApiConstants {
public static final String NETWORKRATE = "networkrate";
public static final String HOST_TAGS = "hosttags";
public static final String SSH_KEYPAIR = "keypair";
public static final String SSH_KEYPAIRS = "keypairs";
public static final String HTTPMETHOD = "httpmethod";
public static final String HOST_CPU_CAPACITY = "hostcpucapacity";
public static final String HOST_CPU_NUM = "hostcpunum";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,13 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
length = 1048576)
private String userData;

@Deprecated
@Parameter(name = ApiConstants.SSH_KEYPAIR, type = CommandType.STRING, description = "name of the ssh key pair used to login to the virtual machine")
private String sshKeyPairName;

@Parameter(name = ApiConstants.SSH_KEYPAIRS, type = CommandType.LIST, collectionType = CommandType.STRING, since="4.17", description = "names of the ssh key pairs used to login to the virtual machine")
private List<String> sshKeyPairNames;

@Parameter(name = ApiConstants.HOST_ID, type = CommandType.UUID, entityType = HostResponse.class, description = "destination Host ID to deploy the VM to - parameter available for root admin only")
private Long hostId;

Expand Down Expand Up @@ -444,8 +448,15 @@ public String getName() {
return name;
}

public String getSSHKeyPairName() {
return sshKeyPairName;
public List<String> getSSHKeyPairNames() {
List<String> sshKeyPairs = new ArrayList<String>();
if(sshKeyPairNames != null) {
sshKeyPairs = sshKeyPairNames;
}
if(sshKeyPairName != null && !sshKeyPairName.isEmpty()) {
sshKeyPairs.add(sshKeyPairName);
}
return sshKeyPairs;
}

public Long getHostId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
import com.cloud.uservm.UserVm;
import com.cloud.vm.VirtualMachine;

import java.util.ArrayList;
import java.util.List;

@APICommand(name = "resetSSHKeyForVirtualMachine", responseObject = UserVmResponse.class, description = "Resets the SSH Key for virtual machine. " +
"The virtual machine must be in a \"Stopped\" state. [async]", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
Expand All @@ -58,8 +61,12 @@ public class ResetVMSSHKeyCmd extends BaseAsyncCmd implements UserCmd {
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine")
private Long id;

@Parameter(name = ApiConstants.SSH_KEYPAIR, type = CommandType.STRING, required = true, description = "name of the ssh key pair used to login to the virtual machine")
private String name;
@Deprecated
@Parameter(name = ApiConstants.SSH_KEYPAIR, type = CommandType.STRING ,description = "name of the ssh key pair used to login to the virtual machine")
String name;

@Parameter(name = ApiConstants.SSH_KEYPAIRS, type = CommandType.LIST, collectionType = CommandType.STRING, since="4.17", description = "names of the ssh key pairs to be used to login to the virtual machine")
List<String> names;

//Owner information
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an optional account for the ssh key. Must be used with domainId.")
Expand All @@ -78,8 +85,15 @@ public class ResetVMSSHKeyCmd extends BaseAsyncCmd implements UserCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public String getName() {
return name;
public List<String> getNames() {
List<String> keypairnames = new ArrayList<String>();
if (names != null) {
keypairnames = names;
}
if (name != null && !name.isEmpty()) {
keypairnames.add(name);
}
return keypairnames;
}

public Long getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
@Param(description = "List of read-only Vm details as comma separated string.", since = "4.16.0")
private String readOnlyDetails;

@SerializedName(ApiConstants.SSH_KEYPAIR)
@Param(description = "ssh key-pair")
private String keyPairName;
@SerializedName(ApiConstants.SSH_KEYPAIRS)
@Param(description = "ssh key-pairs")
private String keyPairNames;

@SerializedName("affinitygroup")
@Param(description = "list of affinity groups associated with the virtual machine", responseObject = AffinityGroupResponse.class)
Expand Down Expand Up @@ -588,8 +588,8 @@ public String getInstanceName() {
return instanceName;
}

public String getKeyPairName() {
return keyPairName;
public String getKeyPairNames() {
return keyPairNames;
}

public Set<AffinityGroupResponse> getAffinityGroupList() {
Expand Down Expand Up @@ -848,8 +848,8 @@ public void setTags(Set<ResourceTagResponse> tags) {
this.tags = tags;
}

public void setKeyPairName(String keyPairName) {
this.keyPairName = keyPairName;
public void setKeyPairNames(String keyPairNames) {
this.keyPairNames = keyPairNames;
}

public void setAffinityGroupList(Set<AffinityGroupResponse> affinityGroups) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public interface SSHKeyPairDao extends GenericDao<SSHKeyPairVO, Long> {

public SSHKeyPairVO findByPublicKey(long accountId, long domainId, String publicKey);

public List<SSHKeyPairVO> findByNames(long accountId, long domainId, List<String> names);

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;


import com.cloud.utils.db.Filter;
import org.springframework.stereotype.Component;

import com.cloud.user.SSHKeyPairVO;
Expand Down Expand Up @@ -63,6 +64,16 @@ public SSHKeyPairVO findByName(long accountId, long domainId, String name) {
return findOneBy(sc);
}

@Override
public List<SSHKeyPairVO> findByNames(long accountId, long domainId, List<String> names) {
SearchCriteria<SSHKeyPairVO> sc = createSearchCriteria();
final Filter filter = new Filter(SSHKeyPairVO.class,"name",false, null, null);
sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
sc.addAnd("name", SearchCriteria.Op.IN, names.toArray());
return this.search(sc, filter);
}

@Override
public SSHKeyPairVO findByPublicKey(String publicKey) {
SearchCriteria<SSHKeyPairVO> sc = createSearchCriteria();
Expand Down
3 changes: 1 addition & 2 deletions engine/schema/src/main/java/com/cloud/vm/VMInstanceVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,7 @@ public Map<String, String> getDetails() {

public void setDetail(String name, String value) {
assert (details != null) : "Did you forget to load the details?";

details.put(name, value);
this.details.put(name, value);
}

public void setDetails(Map<String, String> details) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ SELECT
`user_ip_address`.`id` AS `public_ip_id`,
`user_ip_address`.`uuid` AS `public_ip_uuid`,
`user_ip_address`.`public_ip_address` AS `public_ip_address`,
`ssh_keypairs`.`keypair_name` AS `keypair_name`,
`ssh_details`.`value` AS `keypair_names`,
`resource_tags`.`id` AS `tag_id`,
`resource_tags`.`uuid` AS `tag_uuid`,
`resource_tags`.`key` AS `tag_key`,
Expand All @@ -495,7 +495,7 @@ SELECT
`affinity_group`.`description` AS `affinity_group_description`,
`vm_instance`.`dynamically_scalable` AS `dynamically_scalable`
FROM
(((((((((((((((((((((((((((((((((`user_vm`
((((((((((((((((((((((((((((((((`user_vm`
JOIN `vm_instance` ON (((`vm_instance`.`id` = `user_vm`.`id`)
AND ISNULL(`vm_instance`.`removed`))))
JOIN `account` ON ((`vm_instance`.`account_id` = `account`.`id`)))
Expand Down Expand Up @@ -524,9 +524,7 @@ FROM
AND ISNULL(`vpc`.`removed`))))
LEFT JOIN `user_ip_address` ON ((`user_ip_address`.`vm_id` = `vm_instance`.`id`)))
LEFT JOIN `user_vm_details` `ssh_details` ON (((`ssh_details`.`vm_id` = `vm_instance`.`id`)
AND (`ssh_details`.`name` = 'SSH.PublicKey'))))
LEFT JOIN `ssh_keypairs` ON (((`ssh_keypairs`.`public_key` = `ssh_details`.`value`)
AND (`ssh_keypairs`.`account_id` = `account`.`id`))))
AND (`ssh_details`.`name` = 'SSH.KeyPairNames'))))
LEFT JOIN `resource_tags` ON (((`resource_tags`.`resource_id` = `vm_instance`.`id`)
AND (`resource_tags`.`resource_type` = 'UserVm'))))
LEFT JOIN `async_job` ON (((`async_job`.`instance_id` = `vm_instance`.`id`)
Expand Down Expand Up @@ -646,3 +644,11 @@ CREATE VIEW `cloud`.`domain_router_view` AS

INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) SELECT UUID(), 3, 'listConfigurations', 'ALLOW', (SELECT MAX(`sort_order`)+1 FROM `cloud`.`role_permissions`) ON DUPLICATE KEY UPDATE rule=rule;
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) SELECT UUID(), 3, 'updateConfiguration', 'ALLOW', (SELECT MAX(`sort_order`)+1 FROM `cloud`.`role_permissions`) ON DUPLICATE KEY UPDATE rule=rule;

INSERT INTO `cloud`.`user_vm_details`(`vm_id`, `name`, `value`)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidjumani
is it possible that ssh keypairs are under different account but have same public key ?
for example, a user register a public key under ROOT/admin, then register same public key in his owner account ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible but an edge case since users would not register the same key twice. I don' think we need to consider this scenario

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidjumani
I think it would be better to consider all possible scenarios.

my sugguestion is

INSERT INTO `cloud`.`user_vm_details`(`vm_id`, `name`, `value`)
SELECT `user_vm_details`.`vm_id`, 'SSH.KeyPairNames', `ssh_keypairs`.`keypair_name`
        FROM `cloud`.`user_vm_details`
        INNER JOIN `cloud`.`ssh_keypairs` ON ssh_keypairs.public_key = user_vm_details.value
        INNER JOIN `cloud`.`vm_instance` ON vm_instance.id = user_vm_details.vm_id
        WHERE ssh_keypairs.account_id = vm_instance.account_id

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidjumani @nvazquez
what's your opinion on this comment ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weizhouapache Makes sense. I'll make the changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this addressed? This is NOT an edge case, I have customers using this setup extensively.

There is also a unique key constraint in the table, so pls make sure this is not a problem

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's been addressed

SELECT `user_vm_details`.`vm_id`, 'SSH.KeyPairNames', `ssh_keypairs`.`keypair_name`
FROM `cloud`.`user_vm_details`
INNER JOIN `cloud`.`ssh_keypairs` ON ssh_keypairs.public_key = user_vm_details.value
INNER JOIN `cloud`.`vm_instance` ON vm_instance.id = user_vm_details.vm_id
WHERE ssh_keypairs.account_id = vm_instance.account_id;

Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,13 @@ protected UserVm createKubernetesNode(String joinIp) throws ManagementServerExce
logAndThrow(Level.ERROR, "Failed to read Kubernetes node configuration file", e);
}
String base64UserData = Base64.encodeBase64String(k8sNodeConfig.getBytes(com.cloud.utils.StringUtils.getPreferredCharset()));
List<String> keypairs = new ArrayList<String>();
if (StringUtils.isNotBlank(kubernetesCluster.getKeyPair())) {
keypairs.add(kubernetesCluster.getKeyPair());
}
nodeVm = userVmService.createAdvancedVirtualMachine(zone, serviceOffering, clusterTemplate, networkIds, owner,
hostName, hostName, null, null, null,
Hypervisor.HypervisorType.None, BaseCmd.HTTPMethod.POST, base64UserData, kubernetesCluster.getKeyPair(),
Hypervisor.HypervisorType.None, BaseCmd.HTTPMethod.POST, base64UserData, keypairs,
null, addrs, null, null, null, customParameterMap, null, null, null, null, true, UserVmManager.CKS_NODE, null);
if (LOGGER.isInfoEnabled()) {
LOGGER.info(String.format("Created node VM : %s, %s in the Kubernetes cluster : %s", hostName, nodeVm.getUuid(), kubernetesCluster.getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,13 @@ private UserVm createKubernetesControlNode(final Network network, String serverI
logAndThrow(Level.ERROR, "Failed to read Kubernetes control node configuration file", e);
}
String base64UserData = Base64.encodeBase64String(k8sControlNodeConfig.getBytes(com.cloud.utils.StringUtils.getPreferredCharset()));
List<String> keypairs = new ArrayList<String>();
if (StringUtils.isNotBlank(kubernetesCluster.getKeyPair())) {
keypairs.add(kubernetesCluster.getKeyPair());
}
controlVm = userVmService.createAdvancedVirtualMachine(zone, serviceOffering, clusterTemplate, networkIds, owner,
hostName, hostName, null, null, null,
Hypervisor.HypervisorType.None, BaseCmd.HTTPMethod.POST, base64UserData, kubernetesCluster.getKeyPair(),
Hypervisor.HypervisorType.None, BaseCmd.HTTPMethod.POST, base64UserData, keypairs,
requestedIps, addrs, null, null, null, customParameterMap, null, null, null, null, true, UserVmManager.CKS_NODE, null);
if (LOGGER.isInfoEnabled()) {
LOGGER.info(String.format("Created control VM ID: %s, %s in the Kubernetes cluster : %s", controlVm.getUuid(), hostName, kubernetesCluster.getName()));
Expand Down Expand Up @@ -273,9 +277,13 @@ private UserVm createKubernetesAdditionalControlNode(final String joinIp, final
logAndThrow(Level.ERROR, "Failed to read Kubernetes control configuration file", e);
}
String base64UserData = Base64.encodeBase64String(k8sControlNodeConfig.getBytes(com.cloud.utils.StringUtils.getPreferredCharset()));
List<String> keypairs = new ArrayList<String>();
if (StringUtils.isNotBlank(kubernetesCluster.getKeyPair())) {
keypairs.add(kubernetesCluster.getKeyPair());
}
additionalControlVm = userVmService.createAdvancedVirtualMachine(zone, serviceOffering, clusterTemplate, networkIds, owner,
hostName, hostName, null, null, null,
Hypervisor.HypervisorType.None, BaseCmd.HTTPMethod.POST, base64UserData, kubernetesCluster.getKeyPair(),
Hypervisor.HypervisorType.None, BaseCmd.HTTPMethod.POST, base64UserData, keypairs,
null, addrs, null, null, null, customParameterMap, null, null, null, null, true, UserVmManager.CKS_NODE, null);
if (LOGGER.isInfoEnabled()) {
LOGGER.info(String.format("Created control VM ID : %s, %s in the Kubernetes cluster : %s", additionalControlVm.getUuid(), hostName, kubernetesCluster.getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsInternal(ListVMsCmd cm
}

if (keyPairName != null) {
sb.and("keyPairName", sb.entity().getKeypairName(), SearchCriteria.Op.EQ);
sb.and("keyPairName", sb.entity().getKeypairNames(), SearchCriteria.Op.FIND_IN_SET);
}

if (!isRootAdmin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public UserVmResponse newUserVmResponse(ResponseView view, String objectName, Us

userVmResponse.setPublicIpId(userVm.getPublicIpUuid());
userVmResponse.setPublicIp(userVm.getPublicIpAddress());
userVmResponse.setKeyPairName(userVm.getKeypairName());
userVmResponse.setKeyPairNames(userVm.getKeypairNames());
userVmResponse.setOsTypeId(userVm.getGuestOsUuid());
GuestOS guestOS = ApiDBUtils.findGuestOSById(userVm.getGuestOsId());
if (guestOS != null) {
Expand Down
8 changes: 4 additions & 4 deletions server/src/main/java/com/cloud/api/query/vo/UserVmJoinVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ public class UserVmJoinVO extends BaseViewWithTagInformationVO implements Contro
@Column(name = "project_name")
private String projectName;

@Column(name = "keypair_name")
private String keypairName;
@Column(name = "keypair_names")
private String keypairNames;

@Column(name = "job_id")
private Long jobId;
Expand Down Expand Up @@ -779,8 +779,8 @@ public String getProjectName() {
return projectName;
}

public String getKeypairName() {
return keypairName;
public String getKeypairNames() {
return keypairNames;
}

public boolean isLimitCpuUse() {
Expand Down
Loading