This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Add some functions to get consoles, SRs. #7
Open
simonfuhrer
wants to merge
2
commits into
xenserver:master
Choose a base branch
from
simonfuhrer:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package client | ||
|
||
import ( | ||
"github.com/nilshell/xmlrpc" | ||
) | ||
|
||
type Console XenAPIObject | ||
|
||
func (self *Console) GetRecord() (record map[string]interface{}, err error) { | ||
record = make(map[string]interface{}) | ||
result := APIResult{} | ||
err = self.Client.APICall(&result, "console.get_record", self.Ref) | ||
if err != nil { | ||
return record, err | ||
} | ||
for k, v := range result.Value.(xmlrpc.Struct) { | ||
record[k] = v | ||
} | ||
return record, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,28 @@ package client | |
|
||
import ( | ||
"fmt" | ||
"github.com/nilshell/xmlrpc" | ||
"strconv" | ||
|
||
log "github.com/Sirupsen/logrus" | ||
"github.com/nilshell/xmlrpc" | ||
// "time" | ||
) | ||
|
||
type VM XenAPIObject | ||
|
||
func (self *VM) GetRecord() (record map[string]interface{}, err error) { | ||
record = make(map[string]interface{}) | ||
result := APIResult{} | ||
err = self.Client.APICall(&result, "VM.get_record", self.Ref) | ||
if err != nil { | ||
return record, err | ||
} | ||
for k, v := range result.Value.(xmlrpc.Struct) { | ||
record[k] = v | ||
} | ||
return record, nil | ||
} | ||
|
||
func (self *VM) Clone(name_label string) (new_instance *VM, err error) { | ||
new_instance = new(VM) | ||
|
||
|
@@ -275,6 +291,23 @@ func (self *VM) GetVIFs() (vifs []VIF, err error) { | |
return vifs, nil | ||
} | ||
|
||
func (self *VM) GetConsoles() (consoles []Console, err error) { | ||
consoles = make([]Console, 0) | ||
result := APIResult{} | ||
err = self.Client.APICall(&result, "VM.get_consoles", self.Ref) | ||
if err != nil { | ||
return consoles, err | ||
} | ||
for _, elem := range result.Value.([]interface{}) { | ||
console := Console{} | ||
console.Ref = elem.(string) | ||
console.Client = self.Client | ||
consoles = append(consoles, console) | ||
} | ||
|
||
return consoles, nil | ||
} | ||
|
||
func (self *VM) GetAllowedVIFDevices() (devices []string, err error) { | ||
var device string | ||
devices = make([]string, 0) | ||
|
@@ -361,7 +394,7 @@ func (self *VM) ConnectVdi(vdi *VDI, vdiType VDIType, userdevice string) (err er | |
if userdevice == "" { | ||
userdevice = "autodetect" | ||
} | ||
|
||
log.Debugf("RPCCall method=%v params=%v\n", "asdasd", "asdasdasd") | ||
vbd_rec := make(xmlrpc.Struct) | ||
vbd_rec["VM"] = self.Ref | ||
vbd_rec["VDI"] = vdi.Ref | ||
|
@@ -370,7 +403,7 @@ func (self *VM) ConnectVdi(vdi *VDI, vdiType VDIType, userdevice string) (err er | |
vbd_rec["other_config"] = make(xmlrpc.Struct) | ||
vbd_rec["qos_algorithm_type"] = "" | ||
vbd_rec["qos_algorithm_params"] = make(xmlrpc.Struct) | ||
|
||
fmt.Println(vdiType) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove this? |
||
switch vdiType { | ||
case CD: | ||
vbd_rec["mode"] = "RO" | ||
|
@@ -386,20 +419,20 @@ func (self *VM) ConnectVdi(vdi *VDI, vdiType VDIType, userdevice string) (err er | |
vbd_rec["mode"] = "RW" | ||
vbd_rec["bootable"] = false | ||
vbd_rec["unpluggable"] = true | ||
vbd_rec["type"] = "Floppy" | ||
vbd_rec["type"] = "Disk" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand why you've made this change? |
||
} | ||
|
||
result := APIResult{} | ||
err = self.Client.APICall(&result, "VBD.create", vbd_rec) | ||
|
||
return nil | ||
if err != nil { | ||
return err | ||
} | ||
|
||
vbd_ref := result.Value.(string) | ||
//vbd_ref := result.Value.(string) | ||
|
||
result = APIResult{} | ||
err = self.Client.APICall(&result, "VBD.get_uuid", vbd_ref) | ||
//result = APIResult{} | ||
//err = self.Client.APICall(&result, "VBD.get_uuid", vbd_ref) | ||
return nil | ||
|
||
/* | ||
// 2. Plug VBD (Non need - the VM hasn't booted. | ||
|
@@ -411,7 +444,7 @@ func (self *VM) ConnectVdi(vdi *VDI, vdiType VDIType, userdevice string) (err er | |
return err | ||
} | ||
*/ | ||
return | ||
//return | ||
} | ||
|
||
func (self *VM) DisconnectVdi(vdi *VDI) error { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this?