Skip to content

Commit

Permalink
EDGECLOUD-4318: Multiple subnets with DHCP enabled set to yes fails f…
Browse files Browse the repository at this point in the history
…or KDDI cloudlets (#1280)
  • Loading branch information
ashxjain authored and venkytv committed Jan 28, 2021
1 parent 3d91d55 commit fcc4ac0
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 5 deletions.
55 changes: 55 additions & 0 deletions crm-platforms/openstack/openstack-fip-test-heat-expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
55 changes: 55 additions & 0 deletions crm-platforms/openstack/openstack-fip-test-heat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
57 changes: 56 additions & 1 deletion crm-platforms/openstack/openstack-test-heat-expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
57 changes: 56 additions & 1 deletion crm-platforms/openstack/openstack-test-heat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
14 changes: 12 additions & 2 deletions crm-platforms/openstack/openstack_heat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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-----"))
Expand All @@ -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]
Expand Down Expand Up @@ -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 {
Expand All @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions vmlayer/props.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
13 changes: 12 additions & 1 deletion vmlayer/vmparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fcc4ac0

Please sign in to comment.