Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ncm-opennebula: Open vSwitch support and VNET pools #466

Merged
merged 13 commits into from
Apr 27, 2015
23 changes: 21 additions & 2 deletions ncm-opennebula/src/main/pan/components/opennebula/schema.pan
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ include 'quattor/schema';
include 'pan/types';

type uuid = string with match(SELF,'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
Copy link
Member

Choose a reason for hiding this comment

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

Is this generally useful enough to be added to pan/types instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

probably yes, as far as I know uuid type is used by ceph and opennebula components

Copy link
Member

Choose a reason for hiding this comment

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

If it's used by more than on component then I'd say yes, do you feel like opening a new PR to add it to pan/types and another to remove it from the components?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jrha ok no prob

type macaddr = string with match(SELF, '([0-9A-F]{2}[:-]){5}([0-9A-F]{2})');
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be different from hwaddr as defined in pan/types?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mmm.. no I will remove this type to use hwaddr instead


type directory = string with match(SELF,'[^/]+/?$');

Expand Down Expand Up @@ -133,6 +134,19 @@ type opennebula_ceph_datastore = {
"rbd_format" ? long(1..2)
};

@{
Copy link
Member

Choose a reason for hiding this comment

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

all the annotations must be fixed according to http://quattor-pan.readthedocs.org/en/latest/pan-book/pan-book.html#annotations. in particular, the annotation for a type has to start with @documentation{, should be simple search and replace

type for vnet ars specific attributes.
type and size are mandatory
@}
type opennebula_ar = {
"type" : string with match(SELF, "^(IP4|IP6|IP4_6|ETHER)$")
"ip" ? type_ipv4
Copy link
Member

Choose a reason for hiding this comment

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

If type can be IP6, does this mean ip could be an IPv6 address?

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case no, ip is always an IPv4, for IPv6 pools ip value is not taken into account (don't ask me why..).

http://docs.opennebula.org/4.12/user/virtual_resource_management/vgg.html#vgg

Copy link
Member

Choose a reason for hiding this comment

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

Okay I see, it's because their IPv6 support is only for auto-configured addresses.

Worth having a validation rule to enforce this?

Copy link
Member Author

Choose a reason for hiding this comment

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

opennebula ignores the values that are not used, so now is quite safe and flexible but in any case I can try different possibilities in our testbed and see if we get some issue. If so yes, we can include a validation rule to be more strict with the pool definition.

Copy link
Member

Choose a reason for hiding this comment

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

Up to you, depends whether it makes it nicer to use or not.

"size" : long (1..)
"mac" ? macaddr
"global_prefix" ? string
"ula_prefix" ? string
};

@{ type for an opennebula datastore. Defaults to a ceph datastore (ds_mad is ceph) @}
Copy link
Member

Choose a reason for hiding this comment

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

this is backwards incompatible change.
@jrha since there is no release with the opennebula component, i guess it's ok-ish to do so?

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, but perhaps worth explicitly stating this in the PR text.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jrha ok, I have included a new comment into PR description to clarify this point

type opennebula_datastore = {
include opennebula_ceph_datastore
Expand All @@ -147,11 +161,14 @@ type opennebula_datastore = {

type opennebula_vnet = {
"name" : string
"type" : string = 'FIXED'
"bridge" : string
"gateway" : type_ipv4
"dns" : type_ipv4
"network_mask" : type_ipv4
"bridge_ovs" ? string
"vlan" ? boolean
"vlan_id" ? long(0..4095)
"ar" ? opennebula_ar
};

type opennebula_user = {
Expand Down Expand Up @@ -207,7 +224,7 @@ type opennebula_oned = {
"image_restricted_attr" : string = 'SOURCE'
"inherit_datastore_attr" : string[] = list("CEPH_HOST", "CEPH_SECRET", "CEPH_USER",
"RBD_FORMAT", "GLUSTER_HOST", "GLUSTER_VOLUME")
"inherit_vnet_attr" : string = 'VLAN_TAGGED_ID'
"inherit_vnet_attr" : string[] = list("VLAN_TAGGED_ID", "BRIDGE_OVS")
Copy link
Member

Choose a reason for hiding this comment

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

also backwards incompatible

Copy link
Member

Choose a reason for hiding this comment

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

As above, this is fine, but explicitly state this in the PR text.

};

@{
Expand Down Expand Up @@ -247,6 +264,8 @@ type component_opennebula = {
'untouchables' : opennebula_untouchables
'oned' : opennebula_oned
'ssh_multiplex' : boolean = true
'host_ovs' ? boolean
'host_hyp' : string = 'kvm' with match (SELF, '^(kvm|xen)$')
'tm_system_ds' ? string with match(SELF, "^(shared|ssh|vmfs)$")
} = nlist();

6 changes: 5 additions & 1 deletion ncm-opennebula/src/main/pan/components/opennebula/sudo.pan
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ include 'components/sudo/config';
"/sbin/service libvirtd restart",
"/sbin/service libvirt-guests restart",
'/usr/bin/virsh secret-set-value *',
'/usr/bin/virsh secret-define *'
'/usr/bin/virsh secret-define *',
'/usr/sbin/iptables',
'/usr/sbin/ebtables',
'/usr/bin/ovs-vsctl',
'/usr/bin/ovs-ofctl'
Copy link
Member

Choose a reason for hiding this comment

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

add an , at the end (future modifications will give cleaner diffs)

);
foreach (i; cmd; sudolist){
nl = nlist("host", "ALL",
Expand Down
18 changes: 15 additions & 3 deletions ncm-opennebula/src/main/perl/opennebula.pm
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,22 @@ sub manage_something
sub manage_hosts
{
my ($self, $one, $type, $resources, %protected) = @_;
my $new;
my ($new, $vnm_mad);
my $hosts = $resources->{hosts};
my @existhost = $one->get_hosts();
my %newhosts = map { $_ => 1 } @$hosts;
my (@rmhosts, @failedhost);

if (exists($resources->{host_ovs}) and $resources->{host_ovs}) {
if ($type eq "kvm") {
$vnm_mad = "ovswitch";
} elsif ($type eq "xen") {
$vnm_mad = "ovswitch_brcompat";
}
} else {
$vnm_mad = "dummy";
}

foreach my $t (@existhost) {
# Remove the host only if there are no VMs running on it
if (exists($protected{$t->name})) {
Expand All @@ -389,7 +400,7 @@ sub manage_hosts
'name' => $host,
'im_mad' => $type,
'vmm_mad' => $type,
'vnm_mad' => "dummy"
'vnm_mad' => $vnm_mad
);
# to keep the record of our cloud infrastructure
# we include the host in ONE db even if it fails
Expand Down Expand Up @@ -586,6 +597,8 @@ sub Configure
my $tm_system_ds = $tree->{tm_system_ds};
# untouchables resources
my $untouchables = $tree->{untouchables};
# hypervisor type
my $hypervisor = $tree->{host_hyp};

# We must change oneadmin pass first
if (exists $tree->{rpc}->{password}) {
Expand Down Expand Up @@ -617,7 +630,6 @@ sub Configure
$self->info("Updated system datastore TM_MAD = $tm_system_ds");
}

my $hypervisor = "kvm";
$self->manage_something($one, $hypervisor, $tree, $untouchables->{hosts});

$self->manage_something($one, "user", $tree->{users}, $untouchables->{users});
Expand Down
22 changes: 22 additions & 0 deletions ncm-opennebula/src/main/perl/opennebula.pod
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ be described in this section.

Set ssh multiplex options

=item * host_hyp : string

Set host hypervisor type

=over 5

=item * kvm

Set KVM hypervisor

=item * xen

Set XEN hypervisor

=back

=item * host_ovs : boolean (optional)

Includes the Open vSwitch network drives in your hypervisors. (OVS must be installed in each host)
Open vSwitch replaces Linux bridges, Linux bridges must be disabled.
More info: http://docs.opennebula.org/4.4/administration/networking/openvswitch.html

=item * tm_system_ds : string (optional)

Set system datastore TM_MAD value (shared by default). Valid values:
Expand Down
2 changes: 1 addition & 1 deletion ncm-opennebula/src/main/resources/oned.tt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[%- digits = ['monitoring_interval', 'monitoring_threads',
'port', 'vnc_base_port', 'network_size', 'session_expiration_time',
'default_umask'] -%]
[%- oned_attr_list = ['vm_restricted_attr', 'inherit_datastore_attr'] -%]
[%- oned_attr_list = ['vm_restricted_attr', 'inherit_datastore_attr', 'inherit_vnet_attr'] -%]
[%- FOR pair IN oned.pairs -%]
[%- SWITCH pair.key -%]
[% CASE oned_section -%]
Expand Down
4 changes: 4 additions & 0 deletions ncm-opennebula/src/main/resources/tests/profiles/oned.pan
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ prefix "/metaconfig/contents/oned";
"passwd", "my-fancy-pass",
"db_name", "opennebula",
);
"log" = nlist(
Copy link
Member

Choose a reason for hiding this comment

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

dict(

"system", "syslog",
"debug_level", 3,
);
"default_device_prefix" = "vd";
"onegate_endpoint" = "http://hyp004.cubone.os:5030";
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ bind "/metaconfig/contents/vnet" = opennebula_vnet;

prefix "/metaconfig/contents/vnet";
"name" = "node.cubone.os";
"type" = "FIXED";
"bridge" = "br100";
"gateway" = "10.141.10.250";
"dns" = "10.141.10.250";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ bind "/metaconfig/contents/vnet" = opennebula_vnet;

prefix "/metaconfig/contents/vnet";
"name" = "node2.cubone.os";
"type" = "FIXED";
"bridge" = "br101";
"gateway" = "10.141.10.250";
"dns" = "10.141.10.250";
Expand Down
22 changes: 22 additions & 0 deletions ncm-opennebula/src/main/resources/tests/profiles/vnet_ovsbr0.pan
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
object template vnet_ovsbr0;

include 'components/opennebula/schema';

bind "/metaconfig/contents/vnet" = opennebula_vnet;

"/metaconfig/module" = "vnet";

prefix "/metaconfig/contents/vnet";
"name" = "node3.cubone.os";
"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;
"ar" = nlist(
Copy link
Member

Choose a reason for hiding this comment

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

dict(

"type", "IP4",
"ip", "10.141.14.100",
"size", 29,
);
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ multiline
^INHERIT_DATASTORE_ATTR\s?=\s?"GLUSTER_HOST"$
^INHERIT_DATASTORE_ATTR\s?=\s?"GLUSTER_VOLUME"$
^INHERIT_VNET_ATTR\s?=\s?"VLAN_TAGGED_ID"$
^INHERIT_VNET_ATTR\s?=\s?"BRIDGE_OVS"$
^LOG\s?=\s?\[$
^\s{4}debug_level\s?=\s?3,$
^\s{4}system\s?=\s?"file"$
^\s{4}system\s?=\s?"syslog"$
^\]$
^MAC_PREFIX\s?=\s?"02:00"$
^MONITORING_INTERVAL\s?=\s?60$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ multiline
^DEFAULT_UMASK\s?=\s*\d+\s*$
^IMAGE_RESTRICTED_ATTR\s?=\s?".+"\s*$
^INHERIT_DATASTORE_ATTR\s?=\s?".+"\s*$
^INHERIT_VNET_ATTR\s?=\s?".+"\s*$
^LOG\s?=\s?\[$
^\s*debug_level\s?=\s*\d+,\s*$
^\s*system\s?=\s*".+"\s*$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ multiline
^GATEWAY\s?=\s?".+"\s*$
^NAME\s?=\s?".+"\s*$
^NETWORK_MASK\s?=\s?".+"\s*$
^TYPE\s?=\s?".+"\s*$
^QUATTOR\s?=\s?\d+\s*$
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ multiline
^GATEWAY\s?=\s?".+"\s*$
^NAME\s?=\s?".+"\s*$
^NETWORK_MASK\s?=\s?".+"\s*$
^TYPE\s?=\s?".+"\s*$
^QUATTOR\s?=\s?\d+\s*$
18 changes: 18 additions & 0 deletions ncm-opennebula/src/main/resources/tests/regexps/vnet_ovsbr0/simple
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Opennebular vnet test
---
multiline
---
^AR\s?=\s?\[$
^\s*ip\s?=\s*".+",\s*$
^\s*size\s?=\s*".+",\s*$
^\s*type\s?=\s*".+"\s*$
^\]$
^BRIDGE\s?=\s?".+"\s*$
^BRIDGE_OVS\s?=\s?".+"\s*$
^DNS\s?=\s?".+"\s*$
^GATEWAY\s?=\s?".+"\s*$
^NAME\s?=\s?".+"\s*$
^NETWORK_MASK\s?=\s?".+"\s*$
^VLAN\s?=\s?".+"\s*$
^VLAN_ID\s?=\s?".+"\s*$
^QUATTOR\s?=\s?\d+\s*$
14 changes: 12 additions & 2 deletions ncm-opennebula/src/main/resources/vnet.tt
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
[%- booleans = ['vlan'] -%]
[%- ar_section = ['ar'] -%]
[% FOR pair IN vnet.pairs -%]
[% pair.key.upper %] = "[% pair.value %]"
[% END -%]
[%- SWITCH pair.key -%]
[% CASE booleans -%]
[% pair.key.upper %] = "[% pair.value ? "YES" : "NO" %]"
[% CASE ar_section -%]
[% pair.key.upper %] = [% INCLUDE 'opennebula/oned_level1.tt'
data=vnet.${pair.key} -%]
[% CASE -%]
[% pair.key.upper %] = "[% pair.value %]"
[% END -%]
[%- END -%]
QUATTOR = 1
2 changes: 1 addition & 1 deletion ncm-opennebula/src/test/perl/opennebula.t
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ is($NCM::Component::opennebula::ONED_CONF_FILE, "/etc/one/oned.conf", "expected

my $fh = get_file($NCM::Component::opennebula::ONED_CONF_FILE);
isa_ok($fh, "CAF::FileWriter", "oned.conf CAF::FileWriter instance");
# only test one entry, the remainder is verified with teh TT unittests
# only test one entry, the remainder is verified with the TT unittests
like("$fh", qr{^DB\s?=\s?\[$}m, "oned.conf has expected content");

done_testing();
Loading