Skip to content

Instantly share code, notes, and snippets.

gowatana

  • Japan
View GitHub Profile
@gowatana
gowatana / create_image_from_vm.py
Last active Mar 17, 2019
Nutanix AHV の VM から、イメージサービスに Disk イメージを登録。
View create_image_from_vm.py
import sys
import json
import requests
import datetime
import time
image_create_wait_sec = 2
args = sys.argv
conf_file = args[1]
@gowatana
gowatana / create_image_from_vm.sh
Created Dec 25, 2018
Nutanix AHV の VM からディスク イメージを作成する。
View create_image_from_vm.sh
#!/bin/bash
VM_NAME=$1
[ x == x"$VM_NAME" ] && echo "VM Name wo kudasare."
TS=`date "+%Y%m%d%H%M%S"`
acli vm.disk_list $VM_NAME | grep ^scsi | awk '{print $2}' | while read L
do
DISK_ADDR=`echo 'scsi.'$L`
@gowatana
gowatana / take_ahv_vm_snapshot.yml
Created Dec 24, 2018
Ansible で Nutanix AHV の VM Snapshot を取得する。Nutanix REST API v2
View take_ahv_vm_snapshot.yml
---
- name: Nutnaix AHV Take VM Snapshot
hosts: localhost
connection: local
vars:
prism_address: "Prism のアドレス"
prism_username: "admin"
prism_password: "Prism ユーザのパスワード"
ahv_vm_uuid: "ff156400-4234-4ddf-8d3f-6ac56b9b7a52"
@gowatana
gowatana / nutanix.tf
Created Dec 24, 2018
Terraform Nutanix Provider サンプル。
View nutanix.tf
provider "nutanix" {
username = "admin"
password = "パスワード"
endpoint = "Prism アドレス"
insecure = true
port = 9440
}
resource "nutanix_virtual_machine" "vm01-tf" {
name = "vm01-tf"
@gowatana
gowatana / get_vm-uuid.py
Created Dec 10, 2018
Nutanix CE で、VM 名から VM UUID を取得する。
View get_vm-uuid.py
import sys
import json
import requests
args = sys.argv
conf_file = args[1]
vm_name = args[2]
def main():
with open(conf_file, "r") as file:
@gowatana
gowatana / get_vm-snapshot.py
Created Dec 10, 2018
Nutanix AHV の VM Snapshot 一覧を取得する。(VM 単位)
View get_vm-snapshot.py
import sys
import json
import requests
import datetime
args = sys.argv
conf_file = args[1]
vm_uuid = args[2]
def main():
@gowatana
gowatana / gist:5558fb11e72796a2f283865976e2adb8
Created Dec 9, 2018
Nutanix AHV での UVM の vCPU 定義情報。
View gist:5558fb11e72796a2f283865976e2adb8
<vcpu placement="static" current="1">240</vcpu>
<cpu mode="custom" match="exact">
<model fallback="forbid">kvm64</model>
<topology sockets="240" cores="1" threads="1"/>
<cache level="3" mode="emulate"/>
<feature policy="require" name="smap"/>
<feature policy="require" name="xsaveopt"/>
<feature policy="require" name="rtm"/>
<feature policy="require" name="tsc_adjust"/>
<feature policy="require" name="tsc-deadline"/>
@gowatana
gowatana / gist:27979ef6fe8eb81b9aac66228be5e00a
Last active Dec 9, 2018
Oracle Linux 7 KVM での vCPU 定義。
View gist:27979ef6fe8eb81b9aac66228be5e00a
<vcpu placement="static">1</vcpu>
<cpu mode="custom" match="exact" check="full">
<model fallback="forbid">Broadwell-IBRS</model>
<feature policy="require" name="hypervisor"/>
<feature policy="disable" name="erms"/>
<feature policy="require" name="xsaveopt"/>
</cpu>
@gowatana
gowatana / gist:ee4af1b919d6331373c52f3e56d4cb1c
Created Dec 7, 2018
Nutanix AHV での、ユーザ VM の vDisk 接続。
View gist:ee4af1b919d6331373c52f3e56d4cb1c
<?xml version="1.0"?>
<disk type="network" device="lun">
<driver name="qemu" type="raw" cache="none" error_policy="report" io="native"/>
<source protocol="iscsi" name="iqn.2010-06.com.nutanix:vmdisk-5f37574d-326a-40b0-8824-c14d727f6974/0">
<host name="127.0.0.1" port="3261"/>
</source>
<backingStore/>
<target dev="sda" bus="scsi"/>
<boot order="2"/>
<alias name="scsi0-0-0-0"/>
View gist:3ed5dec20ea550c117211dc03ac26d41
<?xml version="1.0"?>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"/>
<source file="/var/lib/libvirt/images/vm01.qcow2"/>
<backingStore/>
<target dev="vda" bus="virtio"/>
<alias name="virtio-disk0"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x07" function="0x0"/>
</disk>
You can’t perform that action at this time.