1
/* ============================================================================
2
Copyright 2014 Hewlett Packard
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
8
http://www.apache.org/licenses/LICENSE-2.0
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
============================================================================ */
17
using System.Collections.Generic;
20
using Openstack.Client.Powershell.Providers.Common;
21
using Openstack.Objects.Domain.Compute;
22
using Openstack.Objects.Domain.Compute.Servers;
23
using Openstack.Objects.Domain.Compute.Servers.Actions;
25
namespace Openstack.Client.Powershell.Providers.Compute
27
public class ServerLogUIContainer : BaseUIContainer
29
public static int CountStringOccurrences(string text, string pattern)
31
// Loop through all instances of the string 'text'.
34
while ((i = text.IndexOf(pattern, i)) != -1)
42
//=========================================================================================================
46
//=========================================================================================================
47
public override void Load()
49
GetServerLogAction action = new GetServerLogAction();
50
action.ServerId = this.Parent.Entity.Id;
51
this.Entity = (Log)this.RepositoryFactory.CreateServerRepository().GetServerLog(action);
53
this.WriteHeader("Log Entries");
55
Log log = (Log)this.Entity;
56
System.Text.RegularExpressions.Regex ex = new System.Text.RegularExpressions.Regex(@"\\n");
57
string[] buffer = ex.Split(log.Content);
60
foreach (string line in buffer)
62
Console.WriteLine(line);
66
//=========================================================================================================
70
//=========================================================================================================
71
public override void WriteEntityDetails()
74
this.WriteHeader("Log Entries");
75
Console.Write(((Log)this.Entity).Content);