Example #1
0
 def execute(self, args):
     iscsi_mgr = SoftLayer.ISCSIManager(self.client)
     iscsi_id = helpers.resolve_id(iscsi_mgr.resolve_ids,
                                   args.get('<identifier>'),
                                   'iSCSI')
     notes = args.get('--notes')
     iscsi_mgr.create_snapshot(iscsi_id, notes)
Example #2
0
    def execute(self, args):
        iscsi_mgr = SoftLayer.ISCSIManager(self.client)
        iscsi_id = helpers.resolve_id(iscsi_mgr.resolve_ids,
                                      args.get('<identifier>'),
                                      'iSCSI')
        iscsi = self.client['Network_Storage_Iscsi']
        snapshots = iscsi.getPartnerships(
            mask='volumeId,partnerVolumeId,createDate,type', id=iscsi_id)
        snapshots = [utils.NestedDict(n) for n in snapshots]

        table = formatting.Table([
            'id',
            'createDate',
            'name',
            'description',
        ])

        for snapshot in snapshots:
            table.add_row([
                snapshot['partnerVolumeId'],
                snapshot['createDate'],
                snapshot['type']['name'],
                snapshot['type']['description'],
            ])
        return table
Example #3
0
 def execute(self, args):
     iscsi_mgr = SoftLayer.ISCSIManager(self.client)
     iscsi_list = iscsi_mgr.list_iscsi()
     iscsi_list = [utils.NestedDict(n) for n in iscsi_list]
     table = formatting.Table([
         'id',
         'datacenter',
         'size',
         'username',
         'password',
         'server'
     ])
     for iscsi in iscsi_list:
         table.add_row([
             iscsi['id'],
             iscsi['serviceResource']['datacenter'].get('name',
                                                        formatting.blank()),
             formatting.FormattedItem(
                 iscsi.get('capacityGb', formatting.blank()),
                 "%dGB" % iscsi.get('capacityGb', 0)),
             iscsi.get('username', formatting.blank()),
             iscsi.get('password', formatting.blank()),
             iscsi.get('serviceResourceBackendIpAddress',
                       formatting.blank())])
     return table
Example #4
0
def cli(env):
    """List iSCSI targets."""

    iscsi_mgr = SoftLayer.ISCSIManager(env.client)
    iscsi_list = iscsi_mgr.list_iscsi()
    iscsi_list = [utils.NestedDict(n) for n in iscsi_list]
    table = formatting.Table([
        'id',
        'datacenter',
        'size',
        'username',
        'password',
        'server'
    ])
    for iscsi in iscsi_list:
        table.add_row([
            iscsi['id'],
            iscsi['serviceResource']['datacenter'].get('name',
                                                       formatting.blank()),
            formatting.FormattedItem(iscsi.get('capacityGb',
                                               formatting.blank()),
                                     "%dGB" % iscsi.get('capacityGb', 0)),
            iscsi.get('username', formatting.blank()),
            iscsi.get('password', formatting.blank()),
            iscsi.get('serviceResourceBackendIpAddress',
                      formatting.blank())])

    env.fout(table)
Example #5
0
    def execute(self, args):
        iscsi_mgr = SoftLayer.ISCSIManager(self.client)
        table = formatting.KeyValueTable(['Name', 'Value'])
        table.align['Name'] = 'r'
        table.align['Value'] = 'l'

        iscsi_id = helpers.resolve_id(
            iscsi_mgr.resolve_ids,
            args.get('<identifier>'),
            'iSCSI')
        result = iscsi_mgr.get_iscsi(iscsi_id)
        result = utils.NestedDict(result)

        table.add_row(['id', result['id']])
        table.add_row(['serviceResourceName', result['serviceResourceName']])
        table.add_row(['createDate', result['createDate']])
        table.add_row(['nasType', result['nasType']])
        table.add_row(['capacityGb', result['capacityGb']])
        if result['snapshotCapacityGb']:
            table.add_row(['snapshotCapacityGb', result['snapshotCapacityGb']])
        table.add_row(['mountableFlag', result['mountableFlag']])
        table.add_row(
            ['serviceResourceBackendIpAddress',
             result['serviceResourceBackendIpAddress']])
        table.add_row(['price', result['billingItem']['recurringFee']])
        table.add_row(['BillingItemId', result['billingItem']['id']])
        if result.get('notes'):
            table.add_row(['notes', result['notes']])

        if args.get('--password'):
            pass_table = formatting.Table(['username', 'password'])
            pass_table.add_row([result['username'], result['password']])
            table.add_row(['users', pass_table])

        return table
Example #6
0
def cli(env, identifier):
    """Cancel/Delete iSCSI snapshot."""

    iscsi_mgr = SoftLayer.ISCSIManager(env.client)
    snapshot_id = helpers.resolve_id(iscsi_mgr.resolve_ids, identifier,
                                     'Snapshot')
    iscsi_mgr.delete_snapshot(snapshot_id)
def cli(env, snapshot_id, volume_id):
    """Restores volume from existing snapshot."""
    iscsi_mgr = SoftLayer.ISCSIManager(env.client)
    volume_id = helpers.resolve_id(iscsi_mgr.resolve_ids, volume_id, 'iSCSI')
    snapshot_id = helpers.resolve_id(iscsi_mgr.resolve_ids, snapshot_id,
                                     'Snapshot')
    iscsi_mgr.restore_from_snapshot(volume_id, snapshot_id)
Example #8
0
 def execute(self, args):
     iscsi_mgr = SoftLayer.ISCSIManager(self.client)
     volume_id = helpers.resolve_id(iscsi_mgr.resolve_ids,
                                    args.get('<volume_identifier>'),
                                    'iSCSI')
     snapshot_id = helpers.resolve_id(iscsi_mgr.resolve_ids,
                                      args.get('<snapshot_identifier>'),
                                      'Snapshot')
     iscsi_mgr.restore_from_snapshot(volume_id, snapshot_id)
Example #9
0
def cli(env, identifier, reason, immediate):
    """Cancel an existing iSCSI account."""

    iscsi_mgr = SoftLayer.ISCSIManager(env.client)
    iscsi_id = helpers.resolve_id(iscsi_mgr.resolve_ids, identifier, 'iSCSI')

    if env.skip_confirmations or formatting.no_going_back(iscsi_id):
        iscsi_mgr.cancel_iscsi(iscsi_id, reason, immediate)
    else:
        raise exceptions.CLIAbort('Aborted')
Example #10
0
 def execute(self, args):
     iscsi_mgr = SoftLayer.ISCSIManager(self.client)
     invalid_args = [k for k in self.required_params if args.get(k) is None]
     if invalid_args:
         raise exceptions.ArgumentError('Missing required options: %s'
                                        % ','.join(invalid_args))
     iscsi_id = helpers.resolve_id(iscsi_mgr.resolve_ids,
                                   args.get('<identifier>'),
                                   'iSCSI')
     capacity = args.get('--capacity')
     iscsi_mgr.create_snapshot_space(iscsi_id, capacity)
Example #11
0
    def execute(self, args):
        iscsi_mgr = SoftLayer.ISCSIManager(self.client)
        iscsi_id = helpers.resolve_id(
            iscsi_mgr.resolve_ids,
            args.get('<identifier>'),
            'iSCSI')

        immediate = args.get('--immediate', False)

        reason = args.get('--reason')
        if args['--really'] or formatting.no_going_back(iscsi_id):
            iscsi_mgr.cancel_iscsi(iscsi_id, reason, immediate)
        else:
            raise exceptions.CLIAbort('Aborted')
Example #12
0
def cli(env, iscsi_identifier):
    """List iSCSI Snapshots."""

    iscsi_mgr = SoftLayer.ISCSIManager(env.client)
    iscsi_id = helpers.resolve_id(iscsi_mgr.resolve_ids, iscsi_identifier,
                                  'iSCSI')
    iscsi = env.client['Network_Storage_Iscsi']
    snapshots = iscsi.getPartnerships(
        mask='volumeId,partnerVolumeId,createDate,type', id=iscsi_id)
    snapshots = [utils.NestedDict(n) for n in snapshots]

    table = formatting.Table(['id', 'createDate', 'name', 'description'])

    for snapshot in snapshots:
        table.add_row([
            snapshot['partnerVolumeId'],
            snapshot['createDate'],
            snapshot['type']['name'],
            snapshot['type']['description'],
        ])
    env.fout(table)
Example #13
0
def cli(env, identifier, password):
    """Get details for an iSCSI target."""

    iscsi_mgr = SoftLayer.ISCSIManager(env.client)

    iscsi_id = helpers.resolve_id(iscsi_mgr.resolve_ids, identifier, 'iSCSI')
    result = iscsi_mgr.get_iscsi(iscsi_id)
    result = utils.NestedDict(result)

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    table.add_row(['id', result['id']])
    table.add_row(['serviceResourceName', result['serviceResourceName']])
    table.add_row(['createDate', result['createDate']])
    table.add_row(['nasType', result['nasType']])
    table.add_row(['capacityGb', result['capacityGb']])

    if result['snapshotCapacityGb']:
        table.add_row(['snapshotCapacityGb', result['snapshotCapacityGb']])

    table.add_row(['mountableFlag', result['mountableFlag']])
    table.add_row([
        'serviceResourceBackendIpAddress',
        result['serviceResourceBackendIpAddress']
    ])
    table.add_row(['price', result['billingItem']['recurringFee']])
    table.add_row(['BillingItemId', result['billingItem']['id']])
    if result.get('notes'):
        table.add_row(['notes', result['notes']])

    if password:
        pass_table = formatting.Table(['username', 'password'])
        pass_table.add_row([result['username'], result['password']])
        table.add_row(['users', pass_table])

    env.fout(table)
Example #14
0
def cli(env, identifier, capacity):
    """Orders snapshot space for given iSCSI."""

    iscsi_mgr = SoftLayer.ISCSIManager(env.client)
    iscsi_id = helpers.resolve_id(iscsi_mgr.resolve_ids, identifier, 'iSCSI')
    iscsi_mgr.create_snapshot_space(iscsi_id, capacity)
Example #15
0
def cli(env, size, datacenter):
    """Creates an iSCSI target."""

    iscsi_mgr = SoftLayer.ISCSIManager(env.client)
    iscsi_mgr.create_iscsi(size=size, location=datacenter)
Example #16
0
 def set_up(self):
     self.iscsi = SoftLayer.ISCSIManager(self.client)
 def set_up(self):
     self.client = testing.FixtureClient()
     self.iscsi = SoftLayer.ISCSIManager(self.client)
Example #18
0
def cli(env, identifier, notes):
    """Create a snapshot of an iSCSI volume."""

    iscsi_mgr = SoftLayer.ISCSIManager(env.client)
    iscsi_id = helpers.resolve_id(iscsi_mgr.resolve_ids, identifier, 'iSCSI')
    iscsi_mgr.create_snapshot(iscsi_id, notes)
Example #19
0
 def execute(self, args):
     iscsi_mgr = SoftLayer.ISCSIManager(self.client)
     self._validate_create_args(args)
     size, location = self._parse_create_args(args)
     iscsi_mgr.create_iscsi(size=size, location=location)
Example #20
0
 def execute(self, args):
     iscsi_mgr = SoftLayer.ISCSIManager(self.client)
     snapshot_id = helpers.resolve_id(iscsi_mgr.resolve_ids,
                                      args.get('<identifier>'),
                                      'Snapshot')
     iscsi_mgr.delete_snapshot(snapshot_id)