How to add a ROW at VM

Hello

I'm doing a script that does the following:

-Stop VM

-disconnects a RAW disk (GUI: remove the drive (from VM))

-create a virtual machine template

-Add the (offline) drive to VM (GUI: Add (existing) hard drive folder/file name)

This is to avoid including the ROUGH disc in model.

Everthings works for records of type "virtual disk", but in the case of a RAW disk, I get an error.

I use a funtion Add - HD that comes with the virtual machine, Datastore, Filename and SCSI controller

The vmdk file name is recovered upon withdrawal of the drive and specify the disk needs to be added.

Someone suggstions what to change in function addHD for adding existing RDM?

Thank you

Frank

Why not do everything in 1 script? This would make it even easier.

The thing is that the "device" you remove, you can add in the last step.

There is therefore no reason to construct the object from scratch.

The only thing that changes in VirtualDeviceConfigSpec is the property of the operation; first of all, it is 'remove' and then 'Add '.

function find-device {
  param($obj, $deviceName)
  $device = $null

  foreach($dev in $obj.config.hardware.device){
    if ($dev.deviceInfo.label -eq $deviceName){
          $device = $dev
     }
  }
  $device
}

$vm = 
# Device name, ex "Hard Disk 4"
$dn = 

$vmObj = Get-View (Get-VM $vm).ID

# Remove the RDM

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.deviceChange = @()
$spec.DeviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec
$targetdev = find-device $vmObj $dn
if($targetdev -eq $null) {return}
$spec.deviceChange[0].device += $targetdev
$spec.deviceChange[0].operation = "remove"

$taskMoRef = $vmObj.ReconfigVM_Task($spec)

$task = Get-View $taskMoRef
while($task.info.state -eq "running" -or $task.info.state -eq "queued"){$task = Get-View $taskMoRef}

# Create the template
New-Template -VM (Get-VM $vm) -Name  -Location (Get-Folder )

# Add the RDM
$spec.deviceChange[0].operation = "add"

$taskMoRef = $vmObj.ReconfigVM_Task($spec)
$task = Get-View $taskMoRef
while($task.info.state -eq "running" -or $task.info.state -eq "queued"){$task = Get-View $taskMoRef}

The problem in your script was the property of support.

A record gross is not a VirtualDiskFlatVer2BackingInfo object, but an object VirtualDiskRawDiskVer2BackingInfo .

Tags: VMware

Similar Questions

  • How to add a row in a computer using New-disk virtual hard?

    Hello

    I am running powercli 5.0.1 build 581491 and I'm writing a powercli script for:

    (1) create a RDM

    (2) assign the RDM to VM1

    (3) assign the same RDM to VM2

    I am able to create the ROW and assign it to VM1, but I am unable to use "New drive" assign to VM2.  Using the following command, I am able to create the ROW and assign it to VM1.

    New-disk-hard - VM VM1 DiskType - RawVirtual /vmfs/devices/disks/naa.60000970000192603729533030353531 - DeviceName

    While trying to assign to VM2, I do the following:

    New-harddisk - VM, VM2 - DiskPath ' [san - datastore:1] vm1/vm1_1.vmdk.

    And I get the following error:

    New-hard drive: 06/06/2012 14:13:19 new-support device Incompatible hard disk specified for the device '0'.

    What I realized, is that if I create a regular vmdk file, then use the New drive using the '-DiskPath ' option, then the command works well.  So my question is, what is the command to add a ROW in a virtual machine?

    Thanks in advance.

    No, indeed it seems something wrong with the cmdlet New-disk hard when adding shared RDMs.

    I have the following, which assigns the RDM common to both virtual machines.

    It's more or less the same, what you've seen in Onyx, but it adds the RDM shared for two virtual machines.

    $vm1 = Get-VM -Name VM1 $vm2 = Get-VM -Name VM2
    $DeviceName = "/vmfs/devices/disks/naa.600507680180701ed00000000000124" 
    
    $hd1 = New-HardDisk -VM $vm1 -DeviceName $DeviceName -DiskType RawVirtual $ctrl1 = New-ScsiController -HardDisk $hd -BusSharingMode Virtual -Type VirtualLsiLogicSAS
    $spec = New-Object VMware.Vim.VirtualMachineConfigSpec
    $spec.DeviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec $spec.deviceChange[0].device += $ctrl1.ExtensionData $spec.deviceChange[0].device.Key = -101$spec.deviceChange[0].operation = "add"
    $spec.DeviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec$spec.deviceChange[1].device += $hd1.ExtensionData$spec.deviceChange[1].device.Key = -102$spec.deviceChange[1].device.ControllerKey = -101$spec.deviceChange[1].operation = "add"
    
    $vm2.ExtensionData.ReconfigVM($spec)
    
  • How to add two lines when the second row is not visible, but also gets the first data line too?

    Mr President

    Jdev worm is 12.2.1

    How to add two lines when the second row is not visible, but also gets the first data line too?

    I want to add two lines like below picture, but want the second to remain invisible.

    tworows.png

    I asked this question but my way of asking was wrong, that's why for me once again.

    Concerning

    Try to follow these steps:

    1. in the database table to add the new column "JOIN_COLUMN" and add the new sequence "JOIN_SEQ".

    2. Add this new column in the entity object. (You can add this in entity object by right clicking on the entity object and then select "Synchronize with database" then the new column and press on sync)

    3. in your bookmark create button to create only one line NOT 2 rows.

    4 - Open the object entity--> java--> java class--> on the entity object class generate and Tick tick on the accessors and methods of data manipulation

    5 - Open the generated class to EntityImpl and go to the doDML method and write this code

      protected void doDML(int operation, TransactionEvent e)
      {
        if(operation == DML_INSERT)
        {
          SequenceImpl seq = new SequenceImpl("JOIN_SEQ", getDBTransaction());
          oracle.jbo.domain.Number seqValue = seq.getSequenceNumber();
          setJoinColumn(seqValue);
          insertSecondRowInDatabase(getAttribute1(), getAttribute2(), getAttribute3(), getJoinColumn());
        }
    
        if(operation == DML_UPDATE)
        {
          updateSecondRowInDatabase(getAttribute1(), getAttribute2(), getAttribute3(), getJoinColumn());
        }
    
        super.doDML(operation, e);
      }
    
      private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object joinColumn)
      {
        PreparedStatement stat = null;
        try
        {
          String sql = "Insert into table_name (COLUMN_1,COLUMN_2,COLUMN_3,JOIN_COLUMN, HIDDEN_COLUMN) values ('" + value1 + "','" + value2 + "','" + value3 + "','" + joinColumn + "', 1)";
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
      private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object joinColumn)
      {
        PreparedStatement stat = null;
        try
        {
          String sql = "update table_name set column_1='" + value1 + "', column_2='" + value2 + "', column_3='" + value3 + "' where JOIN_COLUMN='" + joinColumn + "'";
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
  • How to add multiple lines when the button is clicked

    How to add multiple lines when the click on button now is just add a row .plz give me idea how... waiting for answer

    / public final class screen extends MyScreen
    {
    /**
    * Creates a new object of MyScreen
    */
    ObjectChoiceField obj1 obj2, obj3, obj4.
    Table of String() = {'101 ', ' 102'};
    String of shadow [] = {"Shade1", "Shade2"};
    Rolls of string [] = {'101 ', ' 102'};
    String cutting [] = {"100-150", "150-200"};
    Chain of selectedindex1, selectedindex2, selectedindex3, selectedindex4;
    LabelField lbl1 lbl2, lbl3, lbl4;
        
    GFM LinedGridFieldManager;
    HFM HorizontalFieldManager, hfm1, hfm2 hfm3;
    VerticalFieldManager vfmMain;
        
    public MyScreen()
    {
        
    Set the displayed title of the screen
    hfm1 = new HorizontalFieldManager (HorizontalFieldManager.NO_VERTICAL_SCROLL |) HorizontalFieldManager.NO_VERTICAL_SCROLLBAR);
    hfm2 = new HorizontalFieldManager (HorizontalFieldManager.NO_VERTICAL_SCROLL |) HorizontalFieldManager.NO_VERTICAL_SCROLLBAR);
    hfm3 = new HorizontalFieldManager (HorizontalFieldManager.NO_VERTICAL_SCROLL |) HorizontalFieldManager.NO_VERTICAL_SCROLLBAR);
    HFM = new HorizontalFieldManager (HorizontalFieldManager.FIELD_RIGHT);
    vfmMain = new VerticalFieldManager (Manager.NO_VERTICAL_SCROLL |) Manager.NO_HORIZONTAL_SCROLLBAR);
            
    obj1 = new ObjectChoiceField ("", graph, 0, FIELD_LEFT);
    obj2 = new ObjectChoiceField ("", blind, 0, FIELD_LEFT);
    Obj3 = new ObjectChoiceField ("", rolls, 0, FIELD_LEFT);
    Obj4 = new ObjectChoiceField ("", cuts, 0, FIELD_LEFT);
            
    LBL1 = new LabelField("");
    LBL2 = new LabelField("");
    lbl3 = new LabelField("");
    lbl4 = new LabelField("");
            
    ButtonField btnAdd = new ButtonField ("ADD", FIELD_RIGHT);
            
    GFM = new LinedGridFieldManager (4, LinedGridFieldManager.VERTICAL_SCROLL);
            
    hfm1.setMargin (20, 0, 10, 0);
    hfm1. Add (new LabelField ("Chart"));
    hfm1. Add (obj1);
    hfm1. Add (new LabelField ("Shade"));
    hfm1. Add (obj2);
            
    hfm2. Add (new LabelField ("Rolls"));
    hfm2. Add (Obj3);
    hfm2. Add (new LabelField ("Cuts"));
    hfm2. Add (Obj4);
    HFM. Add (btnAdd);
            
    GFM. Add (new LabelField ("Chart"));
    GFM. Add (new LabelField ("Shade"));
    GFM. Add (new LabelField ("Rolls"));
    GFM. Add (new LabelField ("Cuts"));
            
    vfmMain.add (hfm1);
    vfmMain.add (hfm2);
    vfmMain.add (hfm3);
    vfmMain.add (hfm);
    vfmMain.add (new SeparatorField());
    vfmMain.add (gfm);
    Add (vfmMain);
            
    btnAdd.setChangeListener (new FieldChangeListener()
    {
    ' Public Sub fieldChanged (field field, int context) {}
    TODO self-generating method stub
    selectedindex1 = chart [obj1.getSelectedIndex ()];
    selectedindex2 = shade [obj2.getSelectedIndex ()];
    selectedindex3 = rolls [obj3.getSelectedIndex ()];
    selectedindex4 = cuts [obj4.getSelectedIndex ()];
                    
    While (LBL1. GetText(). Equals("") | LBL2. GetText(). Equals("") | lbl3. GetText(). Equals("") | lbl4. GetText(). Equals(""))
    {
    LBL1. SetText (selectedindex1);
    LBL2. SetText (selectedindex2);
    lbl3. SetText (selectedindex3);
    lbl4. SetText (selectedindex4);
                    
    GFM. Add (LBL1);
    GFM. Add (LBL2);
    GFM. Add (lbl3);
    GFM. Add (lbl4);
                    
    }
    }
    });
    }
    }

    Hi Piya,

    I run your code, and according to your logic that it works correctly.

    It's adding that line only once because according to your logic that one line can be added to MDT, if you do not want to add line on each click on the button, follow these steps:

    selectedindex1 = chart [obj1.getSelectedIndex ()];
    selectedindex2 = shade [obj2.getSelectedIndex ()];
    selectedindex3 = rolls [obj3.getSelectedIndex ()];
    selectedindex4 = cuts [obj4.getSelectedIndex ()];

    Lbl1 LabelField = new LabelField("");
    Lbl2 LabelField = new LabelField("");
    LabelField lbl3 = new LabelField("");
    LabelField lbl4 = new LabelField("");
    If (LBL1. GetText(). Equals("") | LBL2. GetText(). Equals("") | lbl3. GetText(). Equals("") | lbl4. GetText(). Equals(""))
    {
    LBL1. SetText (selectedindex1);
    LBL2. SetText (selectedindex2);
    lbl3. SetText (selectedindex3);
    lbl4. SetText (selectedindex4);
                    
    GFM. Add (LBL1);
    GFM. Add (LBL2);
    GFM. Add (lbl3);
    GFM. Add (lbl4);
                    
    }

  • How to add new physical columns in the physical layer

    Hi gurus,

    We had a size and a few new columns are added in these Dimensions, how to define these columns, these columns are available in the database how to add these columns in the tables.

    Thanks in advance

    Vincent

    Make a right-click on the Dimension table-> new item-> physical column-> give the name that you have in DB and data type-> save the RPD and check the number of updated rows.

    It will work.

    Thank you

    prassu

  • How to add several lines to the CreateWithParameters method

    Hello
    can someone tell me how to insert several rows in a table by using the CreateWithParameters method, which I use in a taskflow.

    That's why you get a null pointer...
    Add the iterator in this page or call the method in the second page... both should work... :)

  • How to add the column to the compressed table

    Hi gurus,

    Can someone help me how to add a column to compressed tables


    Thanks in advance

    The only difference is if added column has a default value. In this case:

    SQL> create table tbl(id number,val varchar2(10))
      2  /
    
    Table created.
    
    SQL> insert into tbl
      2  select level,lpad('X',10,'X')
      3  from dual
      4  connect by level <= 100000
      5  /
    
    100000 rows created.
    
    SQL> select bytes
      2  from user_segments
      3  where segment_name = 'TBL'
      4  /
    
         BYTES
    ----------
       3145728
    
    SQL> alter table tbl move compress
      2  /
    
    Table altered.
    
    SQL> select bytes
      2  from user_segments
      3  where segment_name = 'TBL'
      4  /
    
         BYTES
    ----------
       2097152
    
    SQL> alter table tbl add name varchar2(5) default 'NONE'
      2  /
    alter table tbl add name varchar2(5) default 'NONE'
                        *
    ERROR at line 1:
    ORA-39726: unsupported add/drop column operation on compressed tables
    
    SQL> alter table tbl add name varchar2(5)
      2  /
    
    Table altered.
    
    SQL> update tbl set name = 'NONE'
      2  /
    
    100000 rows updated.
    
    SQL> commit
      2  /
    
    Commit complete.
    
    SQL> select bytes
      2  from user_segments
      3  where segment_name = 'TBL'
      4  /
    
         BYTES
    ----------
       7340032
    
    SQL> select compression from user_tables where table_name = 'TBL'
      2  /
    
    COMPRESS
    --------
    ENABLED
    
    SQL> alter table tbl move compress
      2  /
    
    Table altered.
    
    SQL> select bytes
      2  from user_segments
      3  where segment_name = 'TBL'
      4  /
    
         BYTES
    ----------
       2097152
    
    SQL> 
    

    SY.

  • How to add contacts to my Apple Watch?

    Can someone explain how to add contacts to my Apple Watch 2, watch OS 3

    Hello

    Apple Watch is not a Contacts application and it is not possible to create new contacts on your watch.

    When make calls or send new messages, existing between in contact with instead are selectable via the phone and applications or Messages using Siri / the microphone to dictate a phone number:

    Instructions are available here:

  • How to add friends again Apple Watch

    How to add a friend again Apple Watch?

    Hello

    Under watch OS 3, the friends feature (which was available in previous versions) comes over and there is no direct replacement for it.

    When making calls or sending of new messages, contacts instead can be selected via the phone and Messages applications or using Siri:

  • How to add new folders in thunderbird for mac 38.2.0 POP3

    Switch PC to a macbook pro. Downloaded Thunderbird 38.2.0. I am trying to add new folders, under local folders. Trash and Outbox are in local folders, but I don't see how to add folders to organize my mail.

    Right-click

  • How to add podcasts to an existing account?

    I already downloaded 4 to 5 podcasts on my account, but I can't understand how I add another. I can repeat the process, but then I should add these 5 previous podcasts.

    I can't understand how it just add to my account.

    Everyone knows this?

    Thank you!

    Do you mean "podcasts" or do you mean "episodes"? A podcast is, indeed, the 'wrapper' for the episodes and has its own page in the iTunes Store, in which episodes show. The Store and iTunes work stream, which contains the information in a specific format. All what you need to do is add an episode to the food and the re - publish: subscribers in iTunes will see the new episode almost immediately and the store will be updated in 1 or 2 days.

    If you want to add a new podcast, with its own distinct episodes of your existing, just go to http://podcastsconnect.apple.com and click on the icon "+" at the top left to add. This will not affect your existing podcast.

    When you have any questions you should post the URL of your feed and iTunes Store page, because without them, we can give very general answers.

  • How to add another search engine?

    Hi, guys! I have been using your browser for years on my PC and for about half a year on my cell phone. I used to use ie, opera, chrome, but finally I chose your browser for mobile and PC because your application is the best! It is incomparable! I have a simple question on the mobile version - how to add my favorite search yandex.ru for list provider do its default value? I did a tip of the parameters but it doesn't work. And why don't you make also much easier by adding a button like 'Add another search site' in the settings? Apart from please give advise me how to activate the English spelling? Thank you in advance for help.

    You should be able to find it at http://mycroftproject.com/search-engines.html?name=yandex.ru

    Search engines are managed in the settings of Firefox as described in https://support.mozilla.org/en-US/kb/manage-my-default-search-engines-firefox-android

  • How to add Russian keyboard to the phone of flame with the construction of the aurora

    I have Mozilla flame phone.
    I change the stock software for:
    Boot2Gecko 2.1.0.0 - prerelease.
    Version of the platform: 34.0.
    Channel: aurora.

    But has no Russian keyboard. How to add the Russian keyboard on track.
    Thank you!

    p.s. I have tha same problem with 2.0. I build keyboard gaia repo git with included Russian keyboard app and install it. Maybe there is another way?

    The Russian keyboard should be available in these versions, if they are not, please also create a report bug with accurate information, equip and peripheral on the device. The component would be Gaia::System:Window

    In the meantime, here are the instructions on how to build with several locale if the local Russian keyboard is not available:
    https://developer.Mozilla.org/en-us/F.../building#Building_multilocale

    If you need help with this, we are happy to help you.

  • How to add a new printer

    Firefox has several options of the printer, but not the one I need to use at home. I just need to know how to add a printer from the drop-down list. Thank you!

    Nevermind, I figured it. Thanks anyway!

  • How to add an email address to a group in the address book?

    When I look at the ad group, I don't see how to add an address to the group.

    Simply select the contact to add to the list and drag it to the folder from the list and it lay.
    Hard, double click on the folder in the list to open the editing box and type in the info.

Maybe you are looking for