diff --git a/ncm-opennebula/src/main/pan/components/opennebula/common.pan b/ncm-opennebula/src/main/pan/components/opennebula/common.pan index 32ab25d927..f89ee1ce0c 100644 --- a/ncm-opennebula/src/main/pan/components/opennebula/common.pan +++ b/ncm-opennebula/src/main/pan/components/opennebula/common.pan @@ -83,13 +83,13 @@ check if a specific type of vnet has the right attributes } function is_consistent_vnet = { vn = ARGV[0]; - # phydev is only required by vxlan networks if (vn['vn_mad'] == 'vxlan') { + # phydev is only required by vxlan networks if (!exists(vn['phydev'])) { error("VXLAN vnet requires 'phydev' value to attach a bridge"); }; - # if not the bridge is mandatory } else { + # if not the bridge is mandatory if (!exists(vn['bridge'])) { error("vnet with 'vn_mad' '%s' requires a 'bridge' value", vn['vn_mad']); }; diff --git a/ncm-opennebula/src/main/pan/components/opennebula/schema.pan b/ncm-opennebula/src/main/pan/components/opennebula/schema.pan index 07b785171f..160223af46 100755 --- a/ncm-opennebula/src/main/pan/components/opennebula/schema.pan +++ b/ncm-opennebula/src/main/pan/components/opennebula/schema.pan @@ -936,19 +936,49 @@ type opennebula_sunstone = { "marketplace_password" ? string "marketplace_url" : type_absoluteURI = 'http://marketplace.opennebula.io/' "oneflow_server" : type_absoluteURI = 'http://localhost:2474/' - "instance_types" : opennebula_instance_types[] = list ( - dict("name", "small-x1", "cpu", 1, "vcpu", 1, "memory", 128, - "description", "Very small instance for testing purposes"), - dict("name", "small-x2", "cpu", 2, "vcpu", 2, "memory", 512, - "description", "Small instance for testing multi-core applications"), - dict("name", "medium-x2", "cpu", 2, "vcpu", 2, "memory", 1024, - "description", "General purpose instance for low-load servers"), - dict("name", "medium-x4", "cpu", 4, "vcpu", 4, "memory", 2048, - "description", "General purpose instance for medium-load servers"), - dict("name", "large-x4", "cpu", 4, "vcpu", 4, "memory", 4096, - "description", "General purpose instance for servers"), - dict("name", "large-x8", "cpu", 8, "vcpu", 8, "memory", 8192, - "description", "General purpose instance for high-load servers"), + "instance_types" : opennebula_instance_types[] = list( + dict( + "name", "small-x1", + "cpu", 1, + "vcpu", 1, + "memory", 128, + "description", "Very small instance for testing purposes", + ), + dict( + "name", "small-x2", + "cpu", 2, + "vcpu", 2, + "memory", 512, + "description", "Small instance for testing multi-core applications", + ), + dict( + "name", "medium-x2", + "cpu", 2, + "vcpu", 2, + "memory", 1024, + "description", "General purpose instance for low-load servers", + ), + dict( + "name", "medium-x4", + "cpu", 4, + "vcpu", 4, + "memory", 2048, + "description", "General purpose instance for medium-load servers", + ), + dict( + "name", "large-x4", + "cpu", 4, + "vcpu", 4, + "memory", 4096, + "description", "General purpose instance for servers", + ), + dict( + "name", "large-x8", + "cpu", 8, + "vcpu", 8, + "memory", 8192, + "description", "General purpose instance for high-load servers", + ), ) @{List of Ruby files containing custom routes to be loaded} "routes" : string[] = list("oneflow", "vcenter", "support", "nsx") diff --git a/ncm-opennebula/src/main/pan/components/opennebula/sudo.pan b/ncm-opennebula/src/main/pan/components/opennebula/sudo.pan index 07df531d43..d34de0a495 100644 --- a/ncm-opennebula/src/main/pan/components/opennebula/sudo.pan +++ b/ncm-opennebula/src/main/pan/components/opennebula/sudo.pan @@ -29,10 +29,12 @@ include 'components/sudo/config'; '/usr/sbin/brctl', ); foreach (i; cmd; sudolist){ - nl = dict("host", "ALL", + nl = dict( + "host", "ALL", "options", "NOPASSWD:", "run_as", "ALL", - "user", "oneadmin"); + "user", "oneadmin", + ); nl["cmd"] = cmd; append(nl); }; diff --git a/ncm-opennebula/src/main/pan/quattor/aii/opennebula/functions.pan b/ncm-opennebula/src/main/pan/quattor/aii/opennebula/functions.pan index 7e59020a78..a39093a41f 100644 --- a/ncm-opennebula/src/main/pan/quattor/aii/opennebula/functions.pan +++ b/ncm-opennebula/src/main/pan/quattor/aii/opennebula/functions.pan @@ -20,8 +20,7 @@ function opennebula_ipv42mac = { error("usage: \"hwaddr\" = opennebula_ipv42mac(MAC_PREFIX, IP)"); }; # Sanity check - if (!match(ARGV[0], - '^[0-9a-f]{2}[:][0-9a-f]{2}$')) { + if (!match(ARGV[0], '^[0-9a-f]{2}[:][0-9a-f]{2}$')) { error(format("Invalid MAC_PREFIX format: %s", ARGV[0])); }; if (!is_ipv4(ARGV[1])) { @@ -53,8 +52,7 @@ function opennebula_replace_vm_mac = { error("usage: opennebula_replace_vm_mac(MAC_PREFIX)"); }; # Sanity check - if (!match(ARGV[0], - '^[0-9a-f]{2}[:][0-9a-f]{2}$')) { + if (!match(ARGV[0], '^[0-9a-f]{2}[:][0-9a-f]{2}$')) { error(format("Invalid MAC_PREFIX format (%s)", ARGV[0])); }; foreach (ethk; ethv; value("/hardware/cards/nic")) { @@ -69,8 +67,10 @@ function opennebula_replace_vm_mac = { }; if (exists(interv['bridge']) && exists("/system/network/interfaces/" + interv['bridge'] + "/ip")) { - mac = opennebula_ipv42mac(ARGV[0], - value("/system/network/interfaces/" + interv['bridge'] + "/ip")); + mac = opennebula_ipv42mac( + ARGV[0], + value("/system/network/interfaces/" + interv['bridge'] + "/ip") + ); SELF[eth]['hwaddr'] = mac; }; }; diff --git a/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan b/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan index b8ef44b95e..e5424f9e18 100644 --- a/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan +++ b/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan @@ -66,12 +66,13 @@ type opennebula_vmtemplate_vnet = string{} with { }; # check if all interfaces have an entry in the map foreach (k; v; value("/system/network/interfaces")) { - if ((! exists(SELF[k])) && + if ( + (! exists(SELF[k])) && (! exists(v['plugin']['vxlan'])) && # VXLAN interfaces do not need vnet mapping (! (exists(v['type']) && match(v['type'], '^(Bridge|OVSBridge|IPIP)$'))) && # special types no real dev (! (exists(v['driver']) && (v['driver'] == 'bonding'))) && # bonding interface is no real device (! (match(k, '^ib\d+$') && exists("/hardware/cards/ib/" + k))) # It's ok if this is an IB device - ) { + ) { error("/system/network/interfaces/%s has no entry in the vnet map", k); }; }; diff --git a/ncm-opennebula/src/main/resources/tests/profiles/vm.pan b/ncm-opennebula/src/main/resources/tests/profiles/vm.pan index 1f60d6e52d..710c534bb5 100644 --- a/ncm-opennebula/src/main/resources/tests/profiles/vm.pan +++ b/ncm-opennebula/src/main/resources/tests/profiles/vm.pan @@ -159,12 +159,14 @@ prefix "/system/opennebula"; "eth0", "br100", "eth1", "br101", "eth2", "br101", - "eth3", "br101"); + "eth3", "br101", +); "datastore" = dict( "vda", "ceph", "vdb", "default", - "vdc", "rdm"); + "vdc", "rdm", +); "diskrdmpath" = dict( "vdc", "/dev/sdc", diff --git a/ncm-opennebula/src/test/resources/one.pan b/ncm-opennebula/src/test/resources/one.pan index 914ffd2b1b..31aa66d16e 100644 --- a/ncm-opennebula/src/test/resources/one.pan +++ b/ncm-opennebula/src/test/resources/one.pan @@ -75,11 +75,11 @@ prefix "/software/components/opennebula"; "clusters" = dict( "red.cluster", dict( - "reserved_cpu", 10, - "reserved_mem", 2097152, - "labels", list("quattor", "quattor/VO"), - "description", "red.cluster managed by quattor", - ), + "reserved_cpu", 10, + "reserved_mem", 2097152, + "labels", list("quattor", "quattor/VO"), + "description", "red.cluster managed by quattor", + ), ); "vmgroups" = dict( @@ -98,149 +98,149 @@ prefix "/software/components/opennebula"; "policy", "AFFINED", ), ), - "labels", list("quattor", "quattor/ha_group"), - "description", "New HA VM group managed by quattor", + "labels", list("quattor", "quattor/ha_group"), + "description", "New HA VM group managed by quattor", ), ); "vnets" = dict( "altaria.os", dict( - "bridge", "br100", - "gateway", "10.141.3.250", - "dns", "10.141.3.250", - "network_mask", "255.255.0.0", - "labels", list("quattor", "quattor/private"), - ), + "bridge", "br100", + "gateway", "10.141.3.250", + "dns", "10.141.3.250", + "network_mask", "255.255.0.0", + "labels", list("quattor", "quattor/private"), + ), "altaria.vsc", dict( - "bridge", "br101", - "gateway", "10.141.3.250", - "dns", "10.141.3.250", - "network_mask", "255.255.0.0", - "labels", list("quattor", "quattor/public"), - ), + "bridge", "br101", + "gateway", "10.141.3.250", + "dns", "10.141.3.250", + "network_mask", "255.255.0.0", + "labels", list("quattor", "quattor/public"), + ), "pool.altaria.os", dict( - "bridge", "br100", - "bridge_ovs", "ovsbr0", - "gateway", "10.141.3.250", - "dns", "10.141.3.250", - "network_mask", "255.255.0.0", - "vlan", true, - "vlan_id", 0, - "vn_mad", "ovswitch", - "ar", dict( - "type", "IP4", - "ip", "10.141.14.100", - "size", 29 - ), - "labels", list("quattor", "quattor/vlans"), + "bridge", "br100", + "bridge_ovs", "ovsbr0", + "gateway", "10.141.3.250", + "dns", "10.141.3.250", + "network_mask", "255.255.0.0", + "vlan", true, + "vlan_id", 0, + "vn_mad", "ovswitch", + "ar", dict( + "type", "IP4", + "ip", "10.141.14.100", + "size", 29 ), + "labels", list("quattor", "quattor/vlans"), + ), "vxlan.vmpool.os", dict( - "gateway", "10.1.20.250", - "dns", "10.1.20.1", - "network_mask", "255.255.255.0", - "vlan", true, - "vlan_id", 10, - "vn_mad", "vxlan", - "ar", dict( - "type", "IP4", - "ip", "10.1.20.100", - "size", 100, - ), - "phydev", "ib0", - "filter_ip_spoofing", true, - "filter_mac_spoofing", true, - "labels", list("quattor", "quattor/vlans"), - "permissions", dict( - "owner", "lsimngar", - "group", "users", - "mode", 0440, - ), - "clusters", list("default", "red.cluster"), + "gateway", "10.1.20.250", + "dns", "10.1.20.1", + "network_mask", "255.255.255.0", + "vlan", true, + "vlan_id", 10, + "vn_mad", "vxlan", + "ar", dict( + "type", "IP4", + "ip", "10.1.20.100", + "size", 100, + ), + "phydev", "ib0", + "filter_ip_spoofing", true, + "filter_mac_spoofing", true, + "labels", list("quattor", "quattor/vlans"), + "permissions", dict( + "owner", "lsimngar", + "group", "users", + "mode", 0440, ), + "clusters", list("default", "red.cluster"), + ), ); "datastores" = dict( - "ceph.altaria", dict( - "bridge_list", list("hyp004.cubone.os"), - "ceph_host", list("ceph001.cubone.os", "ceph002.cubone.os", "ceph003.cubone.os"), - "ceph_secret", "8371ae8a-386d-44d7-a228-c42de4259c6e", - "ceph_user", "libvirt", - "disk_type", "RBD", - "datastore_capacity_check", true, - "ceph_user_key", "AQCGZr1TeFUBMRBBHExosSnNXvlhuKexxcczpw==", - "pool_name", "one", - "type", "IMAGE_DS", - "ds_mad", "ceph", - "labels", list("quattor", "quattor/ceph"), - ), - "nfs", dict( - "datastore_capacity_check", true, - "ds_mad", "fs", - "tm_mad", "shared", - "type", "IMAGE_DS", - "labels", list("quattor", "quattor/nfs"), - "permissions", dict( - "owner", "lsimngar", - "group", "users", - "mode", 0440, - ), - "clusters", list("red.cluster"), - ), - "system", dict( - "tm_mad", "shared", - "ds_mad", "fs", - "type", "SYSTEM_DS", - "clusters", list("default", "red.cluster"), - ), - "rdm", dict( - "tm_mad", "dev", - "ds_mad", "dev", - "type", "IMAGE_DS", - "disk_type", "BLOCK", - "datastore_capacity_check", false, - "labels", list("quattor", "quattor/rdm"), - ), - "cephsys.altaria", dict( - "tm_mad", "ceph", - "type", "SYSTEM_DS", - "bridge_list", list("hyp004.cubone.os"), - "ceph_host", list("ceph001.cubone.os", "ceph002.cubone.os", "ceph003.cubone.os"), - "ceph_secret", "8371ae8a-386d-44d7-a228-c42de4259c6e", - "ceph_user", "libvirt", - "disk_type", "RBD", - "pool_name", "one", - "clusters", list("default", "red.cluster"), + "ceph.altaria", dict( + "bridge_list", list("hyp004.cubone.os"), + "ceph_host", list("ceph001.cubone.os", "ceph002.cubone.os", "ceph003.cubone.os"), + "ceph_secret", "8371ae8a-386d-44d7-a228-c42de4259c6e", + "ceph_user", "libvirt", + "disk_type", "RBD", + "datastore_capacity_check", true, + "ceph_user_key", "AQCGZr1TeFUBMRBBHExosSnNXvlhuKexxcczpw==", + "pool_name", "one", + "type", "IMAGE_DS", + "ds_mad", "ceph", + "labels", list("quattor", "quattor/ceph"), + ), + "nfs", dict( + "datastore_capacity_check", true, + "ds_mad", "fs", + "tm_mad", "shared", + "type", "IMAGE_DS", + "labels", list("quattor", "quattor/nfs"), + "permissions", dict( + "owner", "lsimngar", + "group", "users", + "mode", 0440, ), + "clusters", list("red.cluster"), + ), + "system", dict( + "tm_mad", "shared", + "ds_mad", "fs", + "type", "SYSTEM_DS", + "clusters", list("default", "red.cluster"), + ), + "rdm", dict( + "tm_mad", "dev", + "ds_mad", "dev", + "type", "IMAGE_DS", + "disk_type", "BLOCK", + "datastore_capacity_check", false, + "labels", list("quattor", "quattor/rdm"), + ), + "cephsys.altaria", dict( + "tm_mad", "ceph", + "type", "SYSTEM_DS", + "bridge_list", list("hyp004.cubone.os"), + "ceph_host", list("ceph001.cubone.os", "ceph002.cubone.os", "ceph003.cubone.os"), + "ceph_secret", "8371ae8a-386d-44d7-a228-c42de4259c6e", + "ceph_user", "libvirt", + "disk_type", "RBD", + "pool_name", "one", + "clusters", list("default", "red.cluster"), + ), ); "groups" = dict( - "gvo01", dict( - "description", "gvo01 group managed by quattor", - "labels", list("quattor", "quattor/VO"), - ), + "gvo01", dict( + "description", "gvo01 group managed by quattor", + "labels", list("quattor", "quattor/VO"), + ), ); "users" = dict( - "lsimngar", dict( - "password", "my_fancy_pass", - "ssh_public_key", list( - 'ssh-dss AAAAB3NzaC1kc3MAAACBAOTAivURhU user@OptiPlex-790', - 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ hello@mylaptop' - ), - "group", "oneadmin", - "labels", list("quattor", "quattor/localuser"), - ), - "stdweird", dict( - "password", "another_fancy_pass", + "lsimngar", dict( + "password", "my_fancy_pass", + "ssh_public_key", list( + 'ssh-dss AAAAB3NzaC1kc3MAAACBAOTAivURhU user@OptiPlex-790', + 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ hello@mylaptop' ), - "serveradmin", dict( - "password", "yet_another_fancy_pass", - ), - "oneadmin", dict( - "ssh_public_key", list( - 'ssh-dss AAAAB3NzaC1yc2EAAAADAQABAAABAQDI4gvhOpwKbukZP/Tht/GmKcRCBHGn8JadVlgb9U6O/EP/hR1KLDbKY7KVjVOlUcvfawn44SIGsmKCzehYJV2s/XU1QSaaLrjB7n+vfOyj1C3EgzfZcMOHvL51xPuSgIoKd9oER/63B/pUV/BEZK5LEC06O1LgAjwLy2DrHNN3cQdnTbxQ4vM5ggDb/BC+DyRYlN5NG74VFguVQmoqMPA8FYXBvT/bBvIAZFw7piZIQFd6C803dtG61234 another@laptop' - ), + "group", "oneadmin", + "labels", list("quattor", "quattor/localuser"), + ), + "stdweird", dict( + "password", "another_fancy_pass", + ), + "serveradmin", dict( + "password", "yet_another_fancy_pass", + ), + "oneadmin", dict( + "ssh_public_key", list( + 'ssh-dss AAAAB3NzaC1yc2EAAAADAQABAAABAQDI4gvhOpwKbukZP/Tht/GmKcRCBHGn8JadVlgb9U6O/EP/hR1KLDbKY7KVjVOlUcvfawn44SIGsmKCzehYJV2s/XU1QSaaLrjB7n+vfOyj1C3EgzfZcMOHvL51xPuSgIoKd9oER/63B/pUV/BEZK5LEC06O1LgAjwLy2DrHNN3cQdnTbxQ4vM5ggDb/BC+DyRYlN5NG74VFguVQmoqMPA8FYXBvT/bBvIAZFw7piZIQFd6C803dtG61234 another@laptop' ), + ), ); "hosts" = dict( @@ -249,7 +249,7 @@ prefix "/software/components/opennebula"; # Add hyp103 in a different cluster 'hyp103', dict( "cluster", "red.cluster", - ), + ), 'hyp104', dict(), ); diff --git a/ncm-opennebula/src/test/resources/vm.pan b/ncm-opennebula/src/test/resources/vm.pan index 2d7f567beb..1b942e0279 100644 --- a/ncm-opennebula/src/test/resources/vm.pan +++ b/ncm-opennebula/src/test/resources/vm.pan @@ -133,11 +133,13 @@ prefix "/system/opennebula"; "eth0", "altaria.os", "eth1", "altaria.vsc", "eth2", "altaria.vsc", - "eth3", "altaria.vsc"); + "eth3", "altaria.vsc", +); "datastore" = dict( "vda", "ceph.altaria", - "vdb", "ceph.altaria"); + "vdb", "ceph.altaria", +); "graphics" = "SPICE";