diff --git a/crm-platforms/openstack/openstack-fip-test-heat-expected.yaml b/crm-platforms/openstack/openstack-fip-test-heat-expected.yaml index a0d06a466..0c8bf4f2c 100644 --- a/crm-platforms/openstack/openstack-fip-test-heat-expected.yaml +++ b/crm-platforms/openstack/openstack-fip-test-heat-expected.yaml @@ -75,6 +75,15 @@ resources: - subnet: { get_resource: subnet-test } ip_address: 10.101.0.102 port_security_enabled: false + app-vm-subnet-test-port: + type: OS::Neutron::Port + properties: + name: app-vm-subnet-test-port + network: mex-k8s-net-1 + fixed_ips: + - subnet: { get_resource: subnet-test } + ip_address: 10.101.0.103 + port_security_enabled: false testvmgroup-sg: type: OS::Neutron::SecurityGroup properties: @@ -310,6 +319,52 @@ resources: skipk8s: no role: k8s-node k8smaster: 10.101.0.10 + + app-vm: + type: OS::Nova::Server + properties: + name: app-vm + networks: + - port: { get_resource: app-vm-subnet-test-port } + availability_zone: nova1 + image: mobiledgex-v9.9.9 + flavor: m1.medium + config_drive: true + user_data_format: RAW + user_data: | + #cloud-config + chef: + server_url: cheftestserver.mobiledgex.net/organizations/mobiledgex + node_name: app-vm + environment: "" + validation_name: mobiledgex-validator + validation_key: /etc/chef/client.pem + validation_cert: | + -----BEGIN RSA PRIVATE KEY----- + NDFGHJKLJHGHJKJNHJNBHJNBGYUJNBGHJNBGSZiO/8i6ERbmqPopV8GWC5VjxlZm + -----END RSA PRIVATE KEY----- + bootcmd: + - echo MOBILEDGEX CLOUD CONFIG START + - echo 'APT::Periodic::Enable "0";' > /etc/apt/apt.conf.d/10cloudinit-disable + - apt-get -y purge update-notifier-common ubuntu-release-upgrader-core landscape-common unattended-upgrades + - echo "Removed APT and Ubuntu extra packages" | systemd-cat + - cloud-init-per once ssh-users-ca echo "TrustedUserCAKeys /etc/ssh/trusted-user-ca-keys.pem" >> /etc/ssh/sshd_config + write_files: + - path: /etc/ssh/trusted-user-ca-keys.pem + content: ssh-rsa DUMMYTESTCACERT + append: true + - path: /etc/systemd/resolved.conf + content: | + [Resolve] + DNS=1.1.1.1 + FallbackDNS=1.0.0.1 + chpasswd: { expire: False } + ssh_pwauth: False + timezone: UTC + runcmd: + - systemctl restart systemd-resolved + - echo MOBILEDGEX doing ifconfig + - ifconfig -a rootlb-xyz-external-network-shared-port-fip: type: OS::Neutron::FloatingIPAssociation properties: diff --git a/crm-platforms/openstack/openstack-fip-test-heat.yaml b/crm-platforms/openstack/openstack-fip-test-heat.yaml index a0d06a466..0c8bf4f2c 100644 --- a/crm-platforms/openstack/openstack-fip-test-heat.yaml +++ b/crm-platforms/openstack/openstack-fip-test-heat.yaml @@ -75,6 +75,15 @@ resources: - subnet: { get_resource: subnet-test } ip_address: 10.101.0.102 port_security_enabled: false + app-vm-subnet-test-port: + type: OS::Neutron::Port + properties: + name: app-vm-subnet-test-port + network: mex-k8s-net-1 + fixed_ips: + - subnet: { get_resource: subnet-test } + ip_address: 10.101.0.103 + port_security_enabled: false testvmgroup-sg: type: OS::Neutron::SecurityGroup properties: @@ -310,6 +319,52 @@ resources: skipk8s: no role: k8s-node k8smaster: 10.101.0.10 + + app-vm: + type: OS::Nova::Server + properties: + name: app-vm + networks: + - port: { get_resource: app-vm-subnet-test-port } + availability_zone: nova1 + image: mobiledgex-v9.9.9 + flavor: m1.medium + config_drive: true + user_data_format: RAW + user_data: | + #cloud-config + chef: + server_url: cheftestserver.mobiledgex.net/organizations/mobiledgex + node_name: app-vm + environment: "" + validation_name: mobiledgex-validator + validation_key: /etc/chef/client.pem + validation_cert: | + -----BEGIN RSA PRIVATE KEY----- + NDFGHJKLJHGHJKJNHJNBHJNBGYUJNBGHJNBGSZiO/8i6ERbmqPopV8GWC5VjxlZm + -----END RSA PRIVATE KEY----- + bootcmd: + - echo MOBILEDGEX CLOUD CONFIG START + - echo 'APT::Periodic::Enable "0";' > /etc/apt/apt.conf.d/10cloudinit-disable + - apt-get -y purge update-notifier-common ubuntu-release-upgrader-core landscape-common unattended-upgrades + - echo "Removed APT and Ubuntu extra packages" | systemd-cat + - cloud-init-per once ssh-users-ca echo "TrustedUserCAKeys /etc/ssh/trusted-user-ca-keys.pem" >> /etc/ssh/sshd_config + write_files: + - path: /etc/ssh/trusted-user-ca-keys.pem + content: ssh-rsa DUMMYTESTCACERT + append: true + - path: /etc/systemd/resolved.conf + content: | + [Resolve] + DNS=1.1.1.1 + FallbackDNS=1.0.0.1 + chpasswd: { expire: False } + ssh_pwauth: False + timezone: UTC + runcmd: + - systemctl restart systemd-resolved + - echo MOBILEDGEX doing ifconfig + - ifconfig -a rootlb-xyz-external-network-shared-port-fip: type: OS::Neutron::FloatingIPAssociation properties: diff --git a/crm-platforms/openstack/openstack-test-heat-expected.yaml b/crm-platforms/openstack/openstack-test-heat-expected.yaml index 4c0b68410..d28b471ce 100644 --- a/crm-platforms/openstack/openstack-test-heat-expected.yaml +++ b/crm-platforms/openstack/openstack-test-heat-expected.yaml @@ -9,7 +9,7 @@ resources: cidr: 10.101.0.0/24 network: mex-k8s-net-1 gateway_ip: 10.101.0.1 - enable_dhcp: yes + enable_dhcp: no dns_nameservers: - 1.1.1.1 - 1.0.0.1 @@ -67,6 +67,15 @@ resources: - subnet: { get_resource: subnet-test } ip_address: 10.101.0.102 port_security_enabled: false + app-vm-subnet-test-port: + type: OS::Neutron::Port + properties: + name: app-vm-subnet-test-port + network: mex-k8s-net-1 + fixed_ips: + - subnet: { get_resource: subnet-test } + ip_address: 10.101.0.103 + port_security_enabled: false testvmgroup-sg: type: OS::Neutron::SecurityGroup properties: @@ -302,3 +311,49 @@ resources: skipk8s: no role: k8s-node k8smaster: 10.101.0.10 + + app-vm: + type: OS::Nova::Server + properties: + name: app-vm + networks: + - port: { get_resource: app-vm-subnet-test-port } + availability_zone: nova1 + image: mobiledgex-v9.9.9 + flavor: m1.medium + config_drive: true + user_data_format: RAW + user_data: | + #cloud-config + chef: + server_url: cheftestserver.mobiledgex.net/organizations/mobiledgex + node_name: app-vm + environment: "" + validation_name: mobiledgex-validator + validation_key: /etc/chef/client.pem + validation_cert: | + -----BEGIN RSA PRIVATE KEY----- + NDFGHJKLJHGHJKJNHJNBHJNBGYUJNBGHJNBGSZiO/8i6ERbmqPopV8GWC5VjxlZm + -----END RSA PRIVATE KEY----- + bootcmd: + - echo MOBILEDGEX CLOUD CONFIG START + - echo 'APT::Periodic::Enable "0";' > /etc/apt/apt.conf.d/10cloudinit-disable + - apt-get -y purge update-notifier-common ubuntu-release-upgrader-core landscape-common unattended-upgrades + - echo "Removed APT and Ubuntu extra packages" | systemd-cat + - cloud-init-per once ssh-users-ca echo "TrustedUserCAKeys /etc/ssh/trusted-user-ca-keys.pem" >> /etc/ssh/sshd_config + write_files: + - path: /etc/ssh/trusted-user-ca-keys.pem + content: ssh-rsa DUMMYTESTCACERT + append: true + - path: /etc/systemd/resolved.conf + content: | + [Resolve] + DNS=1.1.1.1 + FallbackDNS=1.0.0.1 + chpasswd: { expire: False } + ssh_pwauth: False + timezone: UTC + runcmd: + - systemctl restart systemd-resolved + - echo MOBILEDGEX doing ifconfig + - ifconfig -a diff --git a/crm-platforms/openstack/openstack-test-heat.yaml b/crm-platforms/openstack/openstack-test-heat.yaml index 4c0b68410..d28b471ce 100644 --- a/crm-platforms/openstack/openstack-test-heat.yaml +++ b/crm-platforms/openstack/openstack-test-heat.yaml @@ -9,7 +9,7 @@ resources: cidr: 10.101.0.0/24 network: mex-k8s-net-1 gateway_ip: 10.101.0.1 - enable_dhcp: yes + enable_dhcp: no dns_nameservers: - 1.1.1.1 - 1.0.0.1 @@ -67,6 +67,15 @@ resources: - subnet: { get_resource: subnet-test } ip_address: 10.101.0.102 port_security_enabled: false + app-vm-subnet-test-port: + type: OS::Neutron::Port + properties: + name: app-vm-subnet-test-port + network: mex-k8s-net-1 + fixed_ips: + - subnet: { get_resource: subnet-test } + ip_address: 10.101.0.103 + port_security_enabled: false testvmgroup-sg: type: OS::Neutron::SecurityGroup properties: @@ -302,3 +311,49 @@ resources: skipk8s: no role: k8s-node k8smaster: 10.101.0.10 + + app-vm: + type: OS::Nova::Server + properties: + name: app-vm + networks: + - port: { get_resource: app-vm-subnet-test-port } + availability_zone: nova1 + image: mobiledgex-v9.9.9 + flavor: m1.medium + config_drive: true + user_data_format: RAW + user_data: | + #cloud-config + chef: + server_url: cheftestserver.mobiledgex.net/organizations/mobiledgex + node_name: app-vm + environment: "" + validation_name: mobiledgex-validator + validation_key: /etc/chef/client.pem + validation_cert: | + -----BEGIN RSA PRIVATE KEY----- + NDFGHJKLJHGHJKJNHJNBHJNBGYUJNBGHJNBGSZiO/8i6ERbmqPopV8GWC5VjxlZm + -----END RSA PRIVATE KEY----- + bootcmd: + - echo MOBILEDGEX CLOUD CONFIG START + - echo 'APT::Periodic::Enable "0";' > /etc/apt/apt.conf.d/10cloudinit-disable + - apt-get -y purge update-notifier-common ubuntu-release-upgrader-core landscape-common unattended-upgrades + - echo "Removed APT and Ubuntu extra packages" | systemd-cat + - cloud-init-per once ssh-users-ca echo "TrustedUserCAKeys /etc/ssh/trusted-user-ca-keys.pem" >> /etc/ssh/sshd_config + write_files: + - path: /etc/ssh/trusted-user-ca-keys.pem + content: ssh-rsa DUMMYTESTCACERT + append: true + - path: /etc/systemd/resolved.conf + content: | + [Resolve] + DNS=1.1.1.1 + FallbackDNS=1.0.0.1 + chpasswd: { expire: False } + ssh_pwauth: False + timezone: UTC + runcmd: + - systemctl restart systemd-resolved + - echo MOBILEDGEX doing ifconfig + - ifconfig -a diff --git a/crm-platforms/openstack/openstack_heat_test.go b/crm-platforms/openstack/openstack_heat_test.go index ea73b2e47..8c1973bb6 100644 --- a/crm-platforms/openstack/openstack_heat_test.go +++ b/crm-platforms/openstack/openstack_heat_test.go @@ -59,6 +59,14 @@ var vms = []*vmlayer.VMRequestSpec{ ComputeAvailabilityZone: "nova1", ConnectToSubnet: subnetName, }, + { + Name: "app-vm", + Type: vmlayer.VMTypeAppVM, + FlavorName: "m1.medium", + ImageName: "mobiledgex-v9.9.9", + ComputeAvailabilityZone: "nova1", + ConnectToSubnet: subnetName, + }, } func validateStack(ctx context.Context, t *testing.T, vmgp *vmlayer.VMGroupOrchestrationParams, op *OpenstackPlatform) { @@ -103,7 +111,7 @@ func validateStack(ctx context.Context, t *testing.T, vmgp *vmlayer.VMGroupOrche keys, err := GetChefKeysFromOSResource(ctx, stackTemplate) require.Nil(t, err) - require.Equal(t, 4, len(keys)) + require.Equal(t, 5, len(keys)) for _, key := range keys { require.True(t, strings.HasPrefix(key, "-----BEGIN RSA PRIVATE KEY-----")) @@ -119,7 +127,7 @@ func validateStack(ctx context.Context, t *testing.T, vmgp *vmlayer.VMGroupOrche vmsUserData, err := GetUserDataFromOSResource(ctx, stackTemplate) require.Nil(t, err) - require.Equal(t, 4, len(vmsUserData)) + require.Equal(t, 5, len(vmsUserData)) for vName, userData := range vmsUserData { require.True(t, strings.HasPrefix(userData, "#cloud-config")) genUserData, ok := genVMsUserData[vName] @@ -214,6 +222,7 @@ func TestHeatTemplate(t *testing.T) { require.Nil(t, err) op.InitResourceReservations(ctx) op.VMProperties.CommonPf.Properties.SetValue("MEX_EXT_NETWORK", "external-network-shared") + op.VMProperties.CommonPf.Properties.SetValue("MEX_VM_APP_SUBNET_DHCP_ENABLED", "no") op.VMProperties.CommonPf.PlatformConfig.TestMode = true // Add chef params for _, vm := range vms { @@ -236,6 +245,7 @@ func TestHeatTemplate(t *testing.T) { require.Nil(t, err) validateStack(ctx, t, vmgp1, &op) + op.VMProperties.CommonPf.Properties.SetValue("MEX_VM_APP_SUBNET_DHCP_ENABLED", "yes") op.VMProperties.CommonPf.Properties.SetValue("MEX_NETWORK_SCHEME", "cidr=10.101.X.0/24,floatingipnet=public_internal,floatingipsubnet=subnetname,floatingipextnet=public") vmgp2, err := vmp.GetVMGroupOrchestrationParamsFromVMSpec(ctx, "openstack-fip-test", diff --git a/vmlayer/props.go b/vmlayer/props.go index cdfe18b45..e0893ddfc 100644 --- a/vmlayer/props.go +++ b/vmlayer/props.go @@ -166,6 +166,11 @@ var VMProviderProps = map[string]*edgeproto.PropertyInfo{ Name: "NTP Servers", Description: "Optional comma separated list of NTP servers to override default of ntp.ubuntu.com", }, + "MEX_VM_APP_SUBNET_DHCP_ENABLED": { + Name: "VM App subnet enable DHCP", + Description: "Enable DHCP for the subnet created for VM based applications (yes or no)", + Value: "yes", + }, } func GetSupportedRouterTypes() string { @@ -359,6 +364,11 @@ func (vp *VMProperties) GetCloudletCRMGatewayIPAndPort() (string, int) { return host, port } +func (vp *VMProperties) GetVMAppSubnetDHCPEnabled() string { + value, _ := vp.CommonPf.Properties.GetValue("MEX_VM_APP_SUBNET_DHCP_ENABLED") + return value +} + func (vp *VMProperties) GetChefClient() *chef.Client { return vp.CommonPf.ChefClient } diff --git a/vmlayer/vmparams.go b/vmlayer/vmparams.go index 86740bcde..d4a3f1443 100644 --- a/vmlayer/vmparams.go +++ b/vmlayer/vmparams.go @@ -638,12 +638,23 @@ func (v *VMPlatform) getVMGroupOrchestrationParamsFromGroupSpec(ctx context.Cont if err != nil { return nil, err } + vmAppSubnet := false + for _, vm := range spec.VMs { + if vm.Type == VMTypeAppVM { + vmAppSubnet = true + break + } + } + dhcpEnabled := "no" + if vmAppSubnet && v.VMProperties.GetVMAppSubnetDHCPEnabled() != "no" { + dhcpEnabled = "yes" + } if spec.NewSubnetName != "" { newSubnet := SubnetOrchestrationParams{ Name: spec.NewSubnetName, Id: v.VMProvider.IdSanitize(spec.NewSubnetName), CIDR: NextAvailableResource, - DHCPEnabled: "yes", + DHCPEnabled: dhcpEnabled, DNSServers: subnetDns, NetworkName: v.VMProperties.GetCloudletMexNetwork(), SecurityGroupName: spec.NewSecgrpName,