<commit_before>/*
Copyright 2017 Mirantis

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package flexvolume

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
	"path"
	"path/filepath"
	"reflect"
	"strings"
	"testing"

	"github.com/Mirantis/virtlet/pkg/utils"
	testutils "github.com/Mirantis/virtlet/pkg/utils/testing"
)

const (
	cephDisk = `
<disk type="network" device="disk">
  <driver name="qemu" type="raw"/>
  <auth username="libvirt">
    <secret type="ceph" uuid="abb67e3c-71b3-4ddd-5505-8c4215d5c4eb"/>
  </auth>
  <source protocol="rbd" name="libvirt-pool/rbd-test-image">
    <host name="127.0.0.1" port="6789"/>
  </source>
  <target dev="%s" bus="virtio"/>
</disk>
`
	cephSecret = `
<secret ephemeral='no' private='no'>
  <uuid>abb67e3c-71b3-4ddd-5505-8c4215d5c4eb</uuid>
  <usage type='ceph'>
    <name>libvirt</name>
  </usage>
</secret>
`
	noCloudDiskTestTemplate = `
<disk type="file" device="disk">
  <driver name="qemu" type="raw"/>
  <source file='%s'/>
  <readonly/>
  <target dev="%%s" bus="virtio"/>
</disk>
`
	noCloudMetaData = `
instance-id: some-instance-id
local-hostname: foobar
`
	noCloudUserData = `
    #cloud-config<commit_msg>Fix flexvolume tests<commit_after>/*
Copyright 2017 Mirantis

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package flexvolume

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
	"path"
	"path/filepath"
	"reflect"
	"strings"
	"testing"

	"github.com/Mirantis/virtlet/pkg/utils"
	testutils "github.com/Mirantis/virtlet/pkg/utils/testing"
)

const (
	cephDisk = `<DomainDisk type="network" device="disk">
  <driver name="qemu" type="raw"></driver>
  <auth username="libvirt">
    <secret type="ceph" uuid="abb67e3c-71b3-4ddd-5505-8c4215d5c4eb"></secret>
  </auth>
  <source protocol="rbd" name="libvirt-pool/rbd-test-image">
    <host name="127.0.0.1" port="6789"></host>
  </source>
  <target bus="virtio"></target>
</DomainDisk>`
	cephSecret = `<secret ephemeral="no" private="no">
  <uuid>abb67e3c-71b3-4ddd-5505-8c4215d5c4eb</uuid>
  <usage type="ceph">
    <name>libvirt</name>
  </usage>
</secret>`
	noCloudDiskTestTemplate = `<DomainDisk type="file" device="disk">
  <driver name="qemu" type="raw"></driver>
  <source file="%s"></source>
  <target bus="virtio"></target>
  <readonly></readonly>
</DomainDisk>`
	noCloudMetaData = `
instance-id: some-instance-id
local-hostname: foobar
`
	noCloudUserData = `
    #cloud-config
{'fraction_non_alphanumeric': 0.14749702026221692, 'fraction_numerical': 0.03218116805721097, 'mean_word_length': 4.585690515806989, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6592522', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1179, 'n_words': 305}