Skip to content

Commit

Permalink
ncm-opennebula: Fix wrapping and indentation in pan
Browse files Browse the repository at this point in the history
  • Loading branch information
jrha committed Nov 28, 2024
1 parent a45fab7 commit d0ec94e
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 156 deletions.
4 changes: 2 additions & 2 deletions ncm-opennebula/src/main/pan/components/opennebula/common.pan
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
};
Expand Down
56 changes: 43 additions & 13 deletions ncm-opennebula/src/main/pan/components/opennebula/schema.pan
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions ncm-opennebula/src/main/pan/components/opennebula/sudo.pan
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
12 changes: 6 additions & 6 deletions ncm-opennebula/src/main/pan/quattor/aii/opennebula/functions.pan
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down Expand Up @@ -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")) {
Expand All @@ -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;
};
};
Expand Down
5 changes: 3 additions & 2 deletions ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
};
Expand Down
6 changes: 4 additions & 2 deletions ncm-opennebula/src/main/resources/tests/profiles/vm.pan
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading

0 comments on commit d0ec94e

Please sign in to comment.