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

How I can do run code in vm, without govc ? #2458

Closed
ahmtxonly opened this issue May 23, 2021 · 7 comments · Fixed by #2464
Closed

How I can do run code in vm, without govc ? #2458

ahmtxonly opened this issue May 23, 2021 · 7 comments · Fixed by #2464

Comments

@ahmtxonly
Copy link

ahmtxonly commented May 23, 2021

How can I run the following code on the virtual machine, without using govc?

echo "linuxpassword" | passwd --stdin linuxuser
or
./runscipt.sh

I'm stuck on this

I'm trying to learn the logic of using govc commands outside.

@github-actions
Copy link
Contributor

Howdy 🖐   ahmtxonly ! Thank you for your interest in this project. We value your feedback and will respond soon.

If you want to contribute to this project, please make yourself familiar with the CONTRIBUTION guidelines.

@embano1
Copy link
Contributor

embano1 commented May 23, 2021

Just to understand: you don't (can't) want to use govc and are looking for a programmatic approach using the govmomi SDK?

@ahmtxonly
Copy link
Author

ahmtxonly commented May 23, 2021

Yes I don't want to use govc, I want make a managed virtual server system with control panel @embano1

Clone vm > change disk capacity > change network settings (ip,netmask, getaway) > change password

@embano1
Copy link
Contributor

embano1 commented May 23, 2021

@ahmtxonly
Copy link
Author

Thank you so much for this;

Any chance to provide a very small code sample for me? in order to progress in a healthy way @embano1
I did a lot of research and couldn't find any helpful resources.

@dougm
Copy link
Member

dougm commented May 23, 2021

@ahmtxonly example of Clone here:

func ExampleVirtualMachine_Clone() {

And changing network settings via Customize here:

func ExampleVirtualMachine_Customize() {

Example of running guest commands in the govc guest.run source:

name := f.Arg(0)
c, err := cmd.Toolbox()
if err != nil {
return err
}
ecmd := &exec.Cmd{
Path: name,
Args: f.Args()[1:],
Env: cmd.vars,
Dir: cmd.dir,
Stdout: os.Stdout,
Stderr: os.Stderr,
}
switch cmd.data {
case "":
case "-":
ecmd.Stdin = os.Stdin
default:
ecmd.Stdin = bytes.NewBuffer([]byte(cmd.data))
}
return c.Run(ctx, ecmd)

@ahmtxonly
Copy link
Author

ahmtxonly commented May 24, 2021

Example of running guest commands in the govc guest.run source:

name := f.Arg(0)
c, err := cmd.Toolbox()
if err != nil {
return err
}
ecmd := &exec.Cmd{
Path: name,
Args: f.Args()[1:],
Env: cmd.vars,
Dir: cmd.dir,
Stdout: os.Stdout,
Stderr: os.Stderr,
}
switch cmd.data {
case "":
case "-":
ecmd.Stdin = os.Stdin
default:
ecmd.Stdin = bytes.NewBuffer([]byte(cmd.data))
}
return c.Run(ctx, ecmd)

image

I could not start it
@dougm

dougm added a commit to dougm/govmomi that referenced this issue May 25, 2021
dougm added a commit to dougm/govmomi that referenced this issue May 26, 2021
protochron pushed a commit to protochron/govmomi that referenced this issue Aug 31, 2021
yuyin002 pushed a commit to yuyin002/govmomi that referenced this issue Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants